{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://stac-extensions.github.io/projection/v1.0.0/schema.json",
  "title": "Projection Extension",
  "description": "STAC Projection Extension for STAC Items.",
  "oneOf": [
    {
      "$comment": "This is the schema for STAC Items.",
      "allOf": [
        {
          "type": "object",
          "required": [
            "type",
            "properties",
            "assets"
          ],
          "properties": {
            "type": {
              "const": "Feature"
            },
            "properties": {
              "allOf": [
                {
                  "$comment": "Require fields here for item properties.",
                  "required": [
                    "proj:epsg"
                  ]
                },
                {
                  "$ref": "#/definitions/fields"
                }
              ]
            },
            "assets": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/fields"
              }
            }
          }
        },
        {
          "$ref": "#/definitions/stac_extensions"
        }
      ]
    },
    {
      "$comment": "This is the schema for STAC Collections.",
      "allOf": [
        {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "const": "Collection"
            },
            "assets": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/fields"
              }
            },
            "item_assets": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/fields"
              }
            }
          }
        },
        {
          "$ref": "#/definitions/stac_extensions"
        }
      ]
    }
  ],
  "definitions": {
    "stac_extensions": {
      "type": "object",
      "required": [
        "stac_extensions"
      ],
      "properties": {
        "stac_extensions": {
          "type": "array",
          "contains": {
            "const": "https://stac-extensions.github.io/projection/v1.0.0/schema.json"
          }
        }
      }
    },
    "fields": {
      "$comment": "Add your new fields here. Don't require them here, do that above in the item schema.",
      "type": "object",
      "properties": {
        "proj:epsg":{
          "title":"EPSG code",
          "type":[
            "integer",
            "null"
          ]
        },
        "proj:wkt2":{
          "title":"Coordinate Reference System in WKT2 format",
          "type":[
            "string",
            "null"
          ]
        },
        "proj:projjson": {
          "title":"Coordinate Reference System in PROJJSON format",
          "oneOf": [
            {
              "$ref": "https://proj.org/schemas/v0.2/projjson.schema.json"
            },
            {
              "type": "null"
            }
          ]
        },
        "proj:geometry":{
          "$ref": "https://geojson.org/schema/Geometry.json"
        },
        "proj:bbox":{
          "title":"Extent",
          "type":"array",
          "oneOf": [
            {
              "minItems":4,
              "maxItems":4
            },
            {
              "minItems":6,
              "maxItems":6
            }
          ],
          "items":{
            "type":"number"
          }
        },
        "proj:centroid":{
          "title":"Centroid",
          "type":"object",
          "required": [
            "lat",
            "lon"
          ],
          "properties": {
            "lat": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "lon": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            }
          }
        },
        "proj:shape":{
          "title":"Shape",
          "type":"array",
          "minItems":2,
          "maxItems":2,
          "items":{
            "type":"integer"
          }
        },
        "proj:transform":{
          "title":"Transform",
          "type":"array",
          "oneOf": [
            {
              "minItems":6,
              "maxItems":6
            },
            {
              "minItems":9,
              "maxItems":9
            }
          ],
          "items":{
            "type":"number"
          }
        }
      },
      "patternProperties": {
        "^(?!proj:)": {}
      },
      "additionalProperties": false
    }
  }
}