# $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
                     - $ref: '../../../openapi/schemas/dggs-core/crs.yaml'
               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, nodeCentredChildCell ]
         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 on reference globe of first vertex to fix the orientation of the polyhedron.
                        example: 58.397145907431
                        type: number
                     longitude:
                        description: Reference longitude in decimal degrees on reference globe of first vertex 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
                  example: >
                    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.
               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
                  example: >
                    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.
               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
            example: >
              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
