{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://postflight.co/aeronautiql/planning/v1_1/results/terminal-ownership.schema.json",
  "title": "Terminal ownership and captured effective inputs v1.1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "bindings",
    "basePointIndices",
    "pointTerminals",
    "edgeTerminals"
  ],
  "properties": {
    "bindings": {
      "type": "array",
      "maxItems": 2,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "role",
          "stopId",
          "airport",
          "runway"
        ],
        "properties": {
          "role": {
            "enum": [
              "departure",
              "arrival"
            ]
          },
          "stopId": {
            "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
          },
          "airport": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          },
          "runway": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512
          }
        }
      }
    },
    "basePointIndices": {
      "type": "array",
      "minItems": 2,
      "maxItems": 20000,
      "uniqueItems": true,
      "items": {
        "type": "integer",
        "minimum": 0
      }
    },
    "pointTerminals": {
      "type": "array",
      "minItems": 2,
      "maxItems": 20000,
      "items": {
        "oneOf": [
          {
            "type": "integer",
            "minimum": 0,
            "maximum": 1
          },
          {
            "type": "null"
          }
        ]
      }
    },
    "edgeTerminals": {
      "type": "array",
      "minItems": 1,
      "maxItems": 19999,
      "items": {
        "oneOf": [
          {
            "type": "integer",
            "minimum": 0,
            "maximum": 1
          },
          {
            "type": "null"
          }
        ]
      }
    }
  },
  "$defs": {
    "inputs": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "departure",
        "arrival"
      ],
      "properties": {
        "departure": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "stopId",
                "selection",
                "selectionRevision",
                "catalogRevision",
                "windRevision",
                "runway"
              ],
              "properties": {
                "stopId": {
                  "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
                },
                "selection": {
                  "enum": [
                    "automatic",
                    "pilot"
                  ]
                },
                "selectionRevision": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512
                },
                "catalogRevision": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512
                },
                "windRevision": {
                  "oneOf": [
                    {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "runway": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "airport",
                    "designator",
                    "threshold",
                    "far_end"
                  ],
                  "properties": {
                    "airport": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512
                    },
                    "designator": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512
                    },
                    "threshold": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "latitude",
                        "longitude"
                      ],
                      "properties": {
                        "latitude": {
                          "type": "number",
                          "minimum": -90,
                          "maximum": 90
                        },
                        "longitude": {
                          "type": "number",
                          "minimum": -180,
                          "maximum": 180
                        }
                      }
                    },
                    "far_end": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "latitude",
                        "longitude"
                      ],
                      "properties": {
                        "latitude": {
                          "type": "number",
                          "minimum": -90,
                          "maximum": 90
                        },
                        "longitude": {
                          "type": "number",
                          "minimum": -180,
                          "maximum": 180
                        }
                      }
                    }
                  }
                }
              }
            },
            {
              "type": "null"
            }
          ]
        },
        "arrival": {
          "oneOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "stopId",
                "selection",
                "selectionRevision",
                "catalogRevision",
                "windRevision",
                "runway"
              ],
              "properties": {
                "stopId": {
                  "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
                },
                "selection": {
                  "enum": [
                    "automatic",
                    "pilot"
                  ]
                },
                "selectionRevision": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512
                },
                "catalogRevision": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512
                },
                "windRevision": {
                  "oneOf": [
                    {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "runway": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "airport",
                    "designator",
                    "threshold",
                    "far_end"
                  ],
                  "properties": {
                    "airport": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512
                    },
                    "designator": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 512
                    },
                    "threshold": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "latitude",
                        "longitude"
                      ],
                      "properties": {
                        "latitude": {
                          "type": "number",
                          "minimum": -90,
                          "maximum": 90
                        },
                        "longitude": {
                          "type": "number",
                          "minimum": -180,
                          "maximum": 180
                        }
                      }
                    },
                    "far_end": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "latitude",
                        "longitude"
                      ],
                      "properties": {
                        "latitude": {
                          "type": "number",
                          "minimum": -90,
                          "maximum": 90
                        },
                        "longitude": {
                          "type": "number",
                          "minimum": -180,
                          "maximum": 180
                        }
                      }
                    }
                  }
                }
              }
            },
            {
              "type": "null"
            }
          ]
        }
      }
    }
  }
}
