{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "division",
  "description": "Divisions are recognized official or non-official organizations of people as seen from a given political perspective. Examples include countries, provinces, cities, towns, neighborhoods, etc.",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/id"
    },
    "geometry": {
      "description": "Division geometry MUST be a Point as defined by GeoJSON schema. It represents the approximate location of a position commonly associated with the real-world entity modeled by the division feature.",
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "https://geojson.org/schema/Point.json"
        }
      ]
    },
    "properties": {
      "unevaluatedProperties": false,
      "allOf": [
        {
          "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyContainers/overtureFeaturePropertiesContainer"
        },
        {
          "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyContainers/namesContainer"
        },
        {
          "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyContainers/cartographyContainer"
        },
        {
          "if": {
            "properties": {
              "subtype": {
                "enum": [
                  "country"
                ]
              }
            }
          },
          "then": {
            "required": [
              "names",
              "subtype",
              "country",
              "hierarchies"
            ],
            "not": {
              "required": [
                "parent_division_id"
              ]
            }
          },
          "else": {
            "required": [
              "names",
              "subtype",
              "country",
              "hierarchies",
              "parent_division_id"
            ]
          }
        },
        {
          "required": [
            "theme",
            "type"
          ]
        }
      ],
      "properties": {
        "theme": {
          "const": "divisions"
        },
        "type": {
          "const": "division"
        },
        "subtype": {
          "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/divisions/definitions/schema.json#/$defs/propertyDefinitions/placetype"
        },
        "class": {
          "type": "string",
          "enum": [
            "megacity",
            "city",
            "town",
            "village",
            "hamlet"
          ]
        },
        "local_type": {
          "description": "Local name for the subtype property, optionally localized.\nFor example, the Canadian province of Quebec has the subtype 'region', but in the local administrative hierarchy it is referred to as a 'province'. Similarly, the Canadian Yukon territory also has subtype 'region', but is locally called a 'territory'.\nThis property is localized using a standard Overture names structure. So for example, in Switzerland the top-level administrative subdivision corresponding to subtype 'region' is the canton, which is may be translated in each of Switzerland's official languages as, 'canton' in French, 'kanton' in German, 'cantone' in Italian, and 'chantun' in Romansh.",
          "allOf": [
            {
              "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/commonNames"
            }
          ]
        },
        "country": {
          "description": "ISO 3166-1 alpha-2 country code of the country or country-like entity, that this division represents or belongs to.\nIf the entity this division represents has a country code, the country property contains it. If it does not, the country property contains the country code of the first division encountered by traversing the parent_division_id chain to the root.\nFor example:\n  - The country value for the United States is 'US'\n  - The country value for New York City is 'US'\n  - The country value for Puerto Rico, a dependency of the US,\n    is 'PR'.\n  - The country value for San Juan, Puerto Rico is 'PR'.\n\nIf an entity has an internationally-recognized ISO 3166-1 alpha-2 country code, it should always be used. In cases where the schema requires the code but no internationally-recognized code is available, a synthetic code may be used provided it does not conflict with any internationally-recognized codes.",
          "allOf": [
            {
              "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/iso3166_1Alpha2CountryCode"
            }
          ]
        },
        "region": {
          "description": "ISO 3166-2 principal subdivision code of the subdivision-like entity this division represents or belongs to.\nIf the entity this division represents has a principal subdivision code, the region property contains it. If it does not, the region property contains the principal subdivision code of the first division encountered by traversing the parent_division_id chain to the root.\nFor example:\n  - The region value for the United States is omitted.\n  - The region value for the U.S. state of New York is 'US-NY'.\n  - The region value for New York City is 'US-NY', which it\n    inherits from the state of New York.\n  - The region value for Puerto Rico is 'US-PR'.",
          "allOf": [
            {
              "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/iso3166_2SubdivisionCode"
            }
          ]
        },
        "hierarchies": {
          "description": "Hierarchies in which this division participates.\nEvery division participates in at least one hierarchy. Most participate in only one. Some divisions may participate in more than one hierarchy, for example if they are claimed by different parent divisions from different political perspectives; or if there are other real-world reasons why the division or one of its ancestors has multiple parents.\nThe first hierarchy in the list is the default hierarchy, and the second-to-last entry in the default hierarchy (if there is such an entry) always corresponds to the `parent_division_id' property. The ordering of hierarchies after the first one is arbitrary.",
          "type": "array",
          "items": {
            "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/divisions/definitions/schema.json#/$defs/propertyDefinitions/hierarchy"
          },
          "minItems": 1,
          "uniqueItems": true
        },
        "parent_division_id": {
          "description": "Division ID of this division's parent division.\nNot allowed for top-level divisions (countries) and required for all other divisions.\nThe default parent division is the parent division as seen from the default political perspective, if there is one, and is otherwise chosen somewhat arbitrarily. The hierarchies property can be used to inspect the exhaustive list of parent divisions.",
          "allOf": [
            {
              "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/id"
            }
          ]
        },
        "perspectives": {
          "description": "Political perspectives from which this division is considered to be an accurate representation.\nIf this property is absent, then this division is not known to be disputed from any political perspective. Consequently, there is only one division feature representing the entire real world entity.\nIf this property is present, it means the division represents one of several alternative perspectives on the same real-world entity.\nThere are two modes of perspective:\n\n  1. `accepted_by` means the representation of the division is\n     accepted by the listed entities and would be included on\n     a map drawn from their perspective.\n\n  2. `disputed_by` means the representation of the division is\n     disputed by the listed entities and would be excluded\n     from a map drawn from their perspective.\n    \nWhen drawing a map from the perspective of a given country, one would start by gathering all the undisputed divisions (with no `perspectives` property), and then adding to that first all divisions explicitly accepted by the country, and second all divisions not explicitly disputed by the country.",
          "allOf": [
            {
              "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/divisions/definitions/schema.json#/$defs/propertyDefinitions/perspectives"
            }
          ]
        },
        "norms": {
          "description": "Collects information about local norms and rules within the division that are generally useful for mapping and map-related use cases.\nIf the norms property or a desired sub-property of the norms property is missing on a division, but at least one of its ancestor divisions has the norms property and the desired sub-property, then the value from the nearest ancestor division may be assumed.",
          "$comment": "If we decide to include default language, it will go here. But is it really generally-useful information?",
          "type": "object",
          "unevaluatedProperties": false,
          "properties": {
            "driving_side": {
              "description": "Side of the road on which vehicles drive in the division.",
              "allOf": [
                {
                  "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/side"
                }
              ]
            }
          }
        },
        "population": {
          "description": "Population of the division",
          "type": "integer",
          "minimum": 0
        },
        "capital_division_ids": {
          "description": "Division IDs of this division's capital divisions. If present, this property will refer to the division IDs of the capital cities, county seats, etc. of a division.",
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/id"
          }
        },
        "capital_of_divisions": {
          "description": "Division IDs and subtypes of divisions this division is a capital of.",
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/divisions/definitions/schema.json#/$defs/propertyDefinitions/capitalOfDivisionItem"
          }
        },
        "wikidata": {
          "$ref": "https://ogcincubator.github.io/bblocks-overturemaps/build/annotated/overturemaps/schemas/definitions/schema.json#/$defs/propertyDefinitions/wikidata"
        }
      }
    }
  }
}