{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/engrate/json-schema/engrate-geo-json-feature-collection-schema.json",
  "title": "GeoJsonFeatureCollection",
  "description": "Standard [GeoJSON FeatureCollection](https://datatracker.ietf.org/doc/html/rfc7946) with typed properties.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/engrate-geo-api-openapi.yml#/components/schemas/GeoJsonFeatureCollection",
  "properties": {
    "features": {
      "items": {
        "$ref": "#/$defs/GeoJsonFeature"
      },
      "title": "Features",
      "type": "array"
    },
    "type": {
      "const": "FeatureCollection",
      "default": "FeatureCollection",
      "title": "Type",
      "type": "string"
    }
  },
  "required": [
    "features"
  ],
  "type": "object",
  "$defs": {
    "ExtraIdentifier": {
      "description": "Extra identifiers are used to attach things like EIC ids, VAT numbers, jurisdiction-specific identifiers, etc.\n\nFor example, Metering Grid Area's in parts of Europe are assigned an local jurisdiction EIC code; for those MGAs, the Engrate system will store the EIC as an extra identifier. However some jurisdictions have not yet switched to EIC codes, instead they rely on older local identification schemes. Swedish MGAs, as an example, use a local code assigned by the Swedish TSO.\n\nBecause the local schemes are subject to collisions - two TSOs assigning the same numerical code to different things, as they do not coordinate id assignment - we also track an identifier \"kind\".",
      "properties": {
        "kind": {
          "$ref": "#/$defs/IdentifierKind",
          "description": "The kind of identifier"
        },
        "value": {
          "description": "The identifier value",
          "title": "Value",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "value"
      ],
      "title": "ExtraIdentifier",
      "type": "object"
    },
    "GeoJsonFeature": {
      "description": "A single [GeoJSON Feature](https://datatracker.ietf.org/doc/html/rfc7946).",
      "properties": {
        "geometry": {
          "oneOf": [
            {
              "$ref": "#/$defs/GeoJsonPolygon"
            },
            {
              "$ref": "#/$defs/GeoJsonMultiPolygon"
            }
          ],
          "title": "Geometry"
        },
        "id": {
          "description": "Id for the underlying entity this geometry represents",
          "title": "Id",
          "type": "string"
        },
        "properties": {
          "description": "Properties for the entity type this geometry represents, currently always [MeteringGridArea](/api-reference/core/models/metering-grid-area), but this may change in the future, use the 'type' discriminator field to check the entity type.",
          "oneOf": [
            {
              "$ref": "#/$defs/MeteringGridAreaUnionEntry"
            }
          ],
          "title": "Properties"
        },
        "type": {
          "const": "Feature",
          "default": "Feature",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "geometry",
        "id",
        "properties"
      ],
      "title": "GeoJsonFeature",
      "type": "object"
    },
    "GeoJsonMultiPolygon": {
      "description": "A [GeoJSON MultiPolygon](https://datatracker.ietf.org/doc/html/rfc7946).",
      "properties": {
        "coordinates": {
          "description": "Array of polygons, each containing an array of linear rings.",
          "items": {
            "items": {
              "items": {
                "items": {
                  "type": "number"
                },
                "type": "array"
              },
              "type": "array"
            },
            "type": "array"
          },
          "title": "Coordinates",
          "type": "array"
        },
        "type": {
          "const": "MultiPolygon",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "coordinates",
        "type"
      ],
      "title": "GeoJsonMultiPolygon",
      "type": "object"
    },
    "GeoJsonPolygon": {
      "description": "A [GeoJSON Polygon](https://datatracker.ietf.org/doc/html/rfc7946).",
      "properties": {
        "coordinates": {
          "description": "Array of linear rings. Each ring is an array of [longitude, latitude] positions.",
          "items": {
            "items": {
              "items": {
                "type": "number"
              },
              "type": "array"
            },
            "type": "array"
          },
          "title": "Coordinates",
          "type": "array"
        },
        "type": {
          "const": "Polygon",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "coordinates",
        "type"
      ],
      "title": "GeoJsonPolygon",
      "type": "object"
    },
    "Identifier": {
      "properties": {
        "extra_ids": {
          "description": "[Extra Identifiers](/api-reference/core/models/extra-identifier) used to reference this same entity",
          "items": {
            "$ref": "#/$defs/ExtraIdentifier"
          },
          "title": "Extra Ids",
          "type": "array"
        },
        "id": {
          "description": "Unique identifier assigned by Engrate",
          "format": "uuid",
          "title": "Id",
          "type": "string"
        }
      },
      "required": [
        "extra_ids",
        "id"
      ],
      "title": "Identifier",
      "type": "object"
    },
    "IdentifierKind": {
      "enum": [
        "eic",
        "vat",
        "gln",
        "se.ediel",
        "se.mga_code",
        "no.mga_code",
        "esett.mga_type"
      ],
      "title": "IdentifierKind",
      "type": "string"
    },
    "MeteringGridAreaUnionEntry": {
      "description": "[MeteringGridArea](/api-reference/core/models/metering-grid-area) with an extra 'type' field, used in tagged unions",
      "properties": {
        "extra_ids": {
          "description": "[Extra Identifiers](/api-reference/core/models/extra-identifier) for this MGA",
          "items": {
            "$ref": "#/$defs/ExtraIdentifier"
          },
          "title": "Extra Ids",
          "type": "array"
        },
        "geometry_granularity": {
          "default": "mga",
          "description": "Whether the accompanying geometry is the true MGA boundary ('mga') or the shared DSO concession territory standing in for it ('dso', used where a DSO operates several MGAs but only a single concession-area polygon is published).",
          "enum": [
            "mga",
            "dso"
          ],
          "title": "Geometry Granularity",
          "type": "string"
        },
        "id": {
          "description": "Unique identifier for the MGA",
          "format": "uuid",
          "title": "Id",
          "type": "string"
        },
        "name": {
          "description": "Name of the metering grid area",
          "title": "Name",
          "type": "string"
        },
        "scheduling_area_eic": {
          "description": "EIC code for the Scheduling Area this Metering Grid Area belongs to",
          "title": "Scheduling Area Eic",
          "type": "string"
        },
        "system_operator": {
          "$ref": "#/$defs/Identifier",
          "description": "The [Party](/api-reference/core/models/party) that operates this MGA"
        },
        "type": {
          "const": "metering-grid-area",
          "default": "metering-grid-area",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "extra_ids",
        "id",
        "name",
        "scheduling_area_eic",
        "system_operator"
      ],
      "title": "MeteringGridAreaUnionEntry",
      "type": "object"
    }
  }
}