{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "description": "Discrete Global Grid System Reference System (DGGRS) Definition. This provisional schema is provided as informative guidance until a normative OGC Topic 21 - Part 5: DGGRS Definition Schema is finalized. DGGRS descriptions for OGC API - DGGS must link to such a definition using the link relation type http://www.opengis.net/def/rel/ogc/1.0/dggrs-definition. A JSON DGGRS definition is intended to provide a complete and unambiguous definition of a DGGRS, including the topology of the grids hierarchy, the mapping to a particular underlying Earth model, the zone identifier reference system and the deterministic sub-zone order, allowing to implement the OGC API - DGGS functionality for that DGGRS in interoperable clients and servers. At least until a normative schema is published as a Topic 21 part, clients should rely on matching URIs associated with specific DGGRS definitions they recognize rather than attempt to parse the definition's content. This is intentionally included in the OGC API - DGGS example OpenAPI definition for reference, but unused in resource paths, since the API is only required to provide a link, but not necessarily host the definition itself at any partiular resource path.",
  "type": "object",
  "required": [
    "dggh",
    "zirs",
    "subZoneOrder"
  ],
  "properties": {
    "title": {
      "type": "string",
      "description": "A short human readable title or name for this DGGRS"
    },
    "description": {
      "type": "string",
      "description": "A summary textual description of this DGGRS"
    },
    "uri": {
      "type": "string",
      "format": "uri",
      "description": "The authoritative URI associated with this DGGRS definition"
    },
    "dggh": {
      "type": "object",
      "description": "The hierarchical series of Discrete Global Grid upon which this DGGRS is based, including any parameters.",
      "properties": {
        "definition": {
          "description": "The base definition of the hierarchical series of Discrete Global Grid, which may be parameterized.",
          "type": "object",
          "required": [
            "spatialDimensions",
            "temporalDimensions"
          ],
          "properties": {
            "crs": {
              "allOf": [
                {
                  "description": "The native Coordinate Reference System (CRS) in which the geometry of the zones for this DGG hierarchy is defined."
                },
                {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "uri",
                      "example": "EPSG:7789"
                    },
                    {
                      "type": "object"
                    }
                  ]
                }
              ]
            },
            "basePolyhedron": {
              "type": "string",
              "description": "The Type/Class of Polyhedron used to construct the Discrete Global Grid System - if it is constructued using a Base Polyhedron.",
              "example": "icosahedron"
            },
            "refinementRatio": {
              "description": "The ratio of the area of zones between two consecutive hierarchy level (the ratio of child zones to parent zones, also called the aperture).",
              "example": 9,
              "type": "integer"
            },
            "constraints": {
              "type": "object",
              "properties": {
                "cellAxisAligned": {
                  "description": "Set to true if all edges of the geometry of all zones are aligned with one of the axis of the `crs`.",
                  "type": "boolean",
                  "default": false
                },
                "cellConformal": {
                  "type": "boolean",
                  "default": false
                },
                "cellEquiAngular": {
                  "type": "boolean",
                  "default": false
                },
                "cellEquiDistant": {
                  "type": "boolean",
                  "default": false
                },
                "cellEqualSized": {
                  "description": "Set to true if the area of all zones is the same for a particular zone geometry type of any specifc discrete global grid of the DGG hierarchy.",
                  "type": "boolean",
                  "default": false
                }
              }
            },
            "spatialDimensions": {
              "description": "Number of Spatial Dimensions defined by the Discrete Global Grid System.",
              "example": 2,
              "type": "integer"
            },
            "temporalDimensions": {
              "description": "Number of Temporal Dimensions defined by the Discrete Global Grid System.",
              "example": 0,
              "type": "integer"
            },
            "zoneTypes": {
              "type": "array",
              "items": {
                "anyOf": [
                   { "type": "string" },
                   {
                      "type": "string",
                      "enum": [
                        "triangle",
                        "square",
                        "hexagon",
                        "pentagon",
                        "rhombus"
                      ]
                   }
                ]
              },
              "example": [
                "hexagon",
                "pentagon"
              ]
            },
            "refinementStrategy": {
              "description": "The refinement strategy used by the Discrete Global Grid System",
              "type": "array",
              "items": {
                 "type": "string",
                 "enum": [
                    "centredChildCell",
                    "nestedChildCell",
                    "nodeCentredChildCell",
                    "nodeSharingChildCell",
                    "edgeCentredChildCell",
                    "faceCentredChildCell",
                    "solidCentredChildCell"
                 ]
              },
              "example": [ "nestedChildCell" ]
            }
          }
        },
        "parameters": {
          "description": "The optional parameters establishing a very specific Discrete Global Grid System, where each zone has a well-defined geometry.",
          "type": "object",
          "properties": {
            "ellipsoid": {
              "type": "string",
              "format": "uri",
              "description": "Globe Reference System Identifier/Specification",
              "example": [
                "EPGS:7019"
              ]
            },
            "orientation": {
              "type": "object",
              "properties": {
                "latitude": {
                  "description": "Reference geodetic Latitude in decimal degrees to fix the orientation of the polyhedron.",
                  "example": 58.397145907431,
                  "type": "number"
                },
                "longitude": {
                  "description": "Reference Longitude in decimal degrees to fix the orientation of the polyhedron.",
                  "example": 11.20,
                  "type": "number"
                },
                "azimuth": {
                  "description": "Azimuth in decimal degrees of second vertex relative to the first vertex.",
                  "example": 0.0,
                  "type": "number",
                  "default": 0.0
                },
                "description": {
                  "type": "string"
                }
              },
              "required": [
                "longitude",
                "latitude"
              ]
            }
          }
        }
      }
    },
    "zirs": {
      "description": "The Zone Identifier Reference System used for this Discrete Global Grid System Reference System.",
      "type": "object",
      "required": [
        "textZIRS"
      ],
      "properties": {
        "textZIRS": {
          "description": "textual zone identifier indexing scheme",
          "type": "object",
          "required": [
            "description"
          ],
          "properties": {
            "description": {
              "type": "string",
              "examples": [
                "Topological Morton Code (Space Filling Curve) Identifier. With a Level 0 alphabetical identifier from 'A' to 'S' followed by a numeric reference from 1 to 9 for all subsequent levels representing the arrangement of child zones following a Morton (Z-code) subdivision of the parent zone. The length of the identifier represents the level of refinement.",
                "Universal Morton Code (Space Filling Curve) Identifier. An ellipsoidal bitwise concatenation of longitude and latitude direct position to form a direct Morton code. This can be used across multiple DGGS infrastructures to provide a common index structure that is fixed in nature regardless of the topological zone index used by each DGGS.",
                "An identifier comprised of three separate level, row and column components corresponding to an OGC 2D Tile Matrix Set tile identifier, where the individual component are represented by uppercase hexadecimal numbers separated by a hyphen.",
                "An identifier comprised of an uppercase letter representing a level (A for level 0, B for level 1...), followed by a number from 0 to 9 representing the root rhombus corresponding to the faces of an icosahedron, in a staircase order from the top-left to the bottom right of an ISEA planar projection after a 60 degrees clockwise rotation, followed by a hyphen, then by an uppercase hexadecimal number identifying a sub-zone starting to count from 0 in row-major order.",
                "An identifier comprised of an uppercase letter representing the ISEA9R level corresponding to the current even or immediate lower odd ISEA3H level (A for level 0, B for level 1...), followed by a number from 0 to 9 representing the root rhombus corresponding to the faces of an icosahedron, in a staircase order from the top-left to the bottom right of an ISEA planar projection after a 60 degrees clockwise rotation, followed by a hyphen, then by an uppercase hexadecimal number identifying a sub-zone starting to count from 0 in row-major order, followed by a second hyphen, then by a letter identifying a hexagonal or pentagonal zone intersecting the sub-rhombus: A: even level regular zone B: even level North pole zone C: even level South pole zone D: odd level zone centered on rhombus vertex E: odd level zone top-right of rhombus vertex F: odd level zone bottom-right of rhombus vertex G: odd level North pole zone H: odd level South pole zone\n"
              ]
            },
            "type": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "string",
                  "enum": [
                    "hierarchicalConcatenation",
                    "ogc2DTMSHexLevelRowCol",
                    "levelRootFaceHexRowMajorSubZone"
                  ]
                }
              ]
            }
          }
        },
        "uint64ZIRS": {
          "description": "64-bit unsigned integer zone indexing scheme",
          "type": "object",
          "required": [
            "description"
          ],
          "properties": {
            "description": {
              "type": "string",
              "examples": [
                "A 64-bit integer with the 30 least significant bits corresponds to a column, the next 29 bits corresponding to a row, and the 5 most significant bits correspond to a level of an OGC 2D Tile Matrix Set identifier, with individual components using little endian.",
                "A 64-bit integer with the 3 least significant bits corresponding to a hexagonal or pentagonal zone intersecting a sub-rhombus: 0: even level regular zone 1: even level North pole zone 2: even level South pole zone 3: odd level zone centered on rhombus vertex 4: odd level zone top-right of rhombus vertex 5: odd level zone bottom-right of rhombus vertex 6: odd level North pole zone 7: odd level South pole zone, the next 51 bits corresponding to a sub-rhombus index, the next 4 bits corresponding to a root rhombus, the next 5 bits corresponding to an associated ISEA9R level, and the last most significant bit always 0 for a valid zone identifier.\n"
              ]
            },
            "type": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "string",
                  "enum": [
                    "ogc2DTMSHexLevelRowCol"
                  ]
                }
              ]
            }
          }
        }
      }
    },
    "subZoneOrder": {
      "description": "The ordering used for this Discrete Global Grid System Reference System when encoding the values associated with sub-zones at any given depth relative to a parent zone.",
      "type": "object",
      "required": [
        "description"
      ],
      "properties": {
        "description": {
          "type": "string",
          "examples": [
            "The zones are ordered in tightly packed scanlines. For an odd relative depth, scanlines start along a hexagon edge, whereas for even relative depths, scanlines start on a hexagon vertex. Scanlines run in a clockwise direction. For sub-zones at an even refinement level, zones are ordered left to right along a scanline and scanlines are ordered from top to bottom (considering the ISEA planar projection). For sub-zones at an odd refinement level, zones are ordered top to bottom along a scanline and scanlines are ordered from left to right. Sub-zones are at an even refinement level when the parity (even/odd) of the parent zone level corresponds to the parity of the relative depth, and at an odd refinement level when the parity of the parent zone level and relative depth do not match. For polar pentagons, the orientation of the scanlines varies in the ISEA planar projection but is always clockwise, the vertex/edge of the first sub-zone is on the left side of the planar ISEA projection for the north pole (in root rhombus 0), and on the right side for the south pole (in root rhombus 9)."
          ]
        },
        "type": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "string",
              "enum": [
                "scanline",
                "spiralFromCenter",
                "mortonCurve",
                "hilbertCurve"
              ]
            }
          ]
        }
      }
    }
  }
}
