{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://stac-extensions.github.io/sat/v1.2.0/schema.json",
  "title": "Satellite Extension",
  "description": "STAC Sat Extension to a STAC Item.",
  "type": "object",
  "required": [
    "stac_extensions"
  ],
  "properties": {
    "stac_extensions": {
      "type": "array",
      "contains": {
        "const": "https://stac-extensions.github.io/sat/v1.2.0/schema.json"
      }
    }
  },
  "oneOf": [
    {
      "$comment": "This is the schema for STAC Items.",
      "type": "object",
      "required": [
        "type",
        "properties",
        "assets"
      ],
      "properties": {
        "type": {
          "const": "Feature"
        },
        "properties": {
          "allOf": [
            {
              "anyOf": [
                {
                  "required": [
                    "sat:platform_international_designator"
                  ]
                },
                {
                  "required": [
                    "sat:orbit_state"
                  ]
                },
                {
                  "required": [
                    "sat:absolute_orbit"
                  ]
                },
                {
                  "required": [
                    "sat:relative_orbit"
                  ]
                },
                {
                  "required": [
                    "sat:anx_datetime"
                  ]
                },
                {
                  "required": [
                    "sat:orbit_cycle"
                  ]
                },
                {
                  "required": [
                    "sat:orbit_state_vectors"
                  ]
                },
                {
                  "required": [
                    "sat:acquisition_station"
                  ]
                }
              ]
            },
            {
              "$ref": "#/definitions/fields"
            }
          ]
        },
        "assets": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/fields"
          }
        }
      }
    },
    {
      "$comment": "This is the schema for STAC Collections.",
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "const": "Collection"
        },
        "assets": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/fields"
          }
        },
        "item_assets": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/definitions/fields"
          }
        }
      }
    }
  ],
  "definitions": {
    "fields": {
      "type": "object",
      "properties": {
        "sat:platform_international_designator": {
          "type": "string"
        },
        "sat:orbit_state": {
          "title": "Orbit State",
          "type": "string",
          "enum": [
            "ascending",
            "descending",
            "geostationary",
            "crossing"
          ]
        },
        "sat:absolute_orbit": {
          "title": "Absolute Orbit",
          "description": "The absolute orbit number at the start of acquisition. When the orbit changes during data acquisition (i.e., the acquisition spans multiple orbits), use the absolute orbit number at the start of the acquisition.",
          "type": "integer",
          "minimum": 1
        },
        "sat:relative_orbit": {
          "title": "Relative Orbit",
          "description": "The relative orbit number at the start of acquisition. When the orbit changes during data acquisition (i.e., the acquisition spans multiple orbits), use the relative orbit number at the start of the acquisition.",
          "type": "integer",
          "minimum": 1
        },
        "sat:anx_datetime": {
          "type": "string",
          "format": "date-time"
        },
        "sat:orbit_cycle": {
          "type": "integer",
          "minimum": 1
        },
        "sat:orbit_state_vectors": {
          "type": "object",
          "$comment": "The key is a date-time string, and the value is an array of numbers.",
          "patternProperties": {
            "^(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d\\.\\d+([+-][0-2]\\d:[0-5]\\d|Z))|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z))|(\\d{4}-[01]\\d-[0-3]\\dT[0-2]\\d:[0-5]\\d([+-][0-2]\\d:[0-5]\\d|Z))$": {
              "type": "array",
              "items": {
                "type": "number"
              },
              "minItems": 6,
              "maxItems": 9
            }
          },
          "additionalProperties": false
        },
        "sat:acquisition_station": {
          "type": "string"
        }
      },
      "patternProperties": {
        "^(?!sat:)": {
          "$comment": "Do not allow unspecified fields prefixed with sat:"
        }
      },
      "additionalProperties": false
    }
  }
}