{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://postflight.co/aeronautiql/planning/v1_1/results/draw-projection.schema.json",
  "title": "Planning draw projection 1.1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "projectionId",
    "snapshotId",
    "documentId",
    "commitId",
    "createdAt",
    "context",
    "legStates",
    "verticalBases",
    "edges",
    "layers",
    "generation",
    "editMappings",
    "displayProfiles"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.1"
    },
    "projectionId": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
    },
    "snapshotId": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
    },
    "documentId": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
    },
    "commitId": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
    },
    "createdAt": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/utc"
    },
    "context": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1_1/edits/mapping.schema.json#/$defs/context"
    },
    "legStates": {
      "type": "array",
      "minItems": 0,
      "items": {
        "$ref": "#/$defs/legState"
      }
    },
    "verticalBases": {
      "type": "array",
      "items": {
        "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/verticalBasis"
      }
    },
    "edges": {
      "type": "array",
      "maxItems": 20000,
      "items": {
        "$ref": "#/$defs/edge"
      }
    },
    "layers": {
      "type": "array",
      "minItems": 0,
      "maxItems": 1000,
      "items": {
        "$ref": "#/$defs/layer"
      }
    },
    "extensions": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/extensions"
    },
    "generation": {
      "$ref": "https://postflight.co/aeronautiql/planning/v1_1/results/planning-snapshot.schema.json#/properties/generation"
    },
    "editMappings": {
      "type": "object",
      "additionalProperties": {
        "$ref": "https://postflight.co/aeronautiql/planning/v1_1/edits/mapping.schema.json"
      }
    },
    "displayProfiles": {
      "type": "object",
      "additionalProperties": {
        "$ref": "display-profile.schema.json"
      }
    }
  },
  "$defs": {
    "legState": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "legId",
        "resolutionState",
        "evaluationState",
        "vertical",
        "metrics"
      ],
      "properties": {
        "legId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
        },
        "resolutionState": {
          "enum": [
            "pending",
            "usable",
            "unusable"
          ]
        },
        "routeIdentity": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "resolutionMappingId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/mappingId"
        },
        "editMappingId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/mappingId"
        },
        "evaluationState": {
          "enum": [
            "pending",
            "usable",
            "unavailable"
          ]
        },
        "vertical": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1_1/results/planning-snapshot.schema.json#/$defs/leg/properties/vertical"
        },
        "metrics": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1_1/results/planning-snapshot.schema.json#/$defs/leg/properties/metrics"
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "resolutionState": {
                "const": "usable"
              }
            }
          },
          "then": {
            "required": [
              "routeIdentity"
            ]
          }
        }
      ]
    },
    "edge": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "edgeId",
        "legId",
        "fromOccurrenceId",
        "toOccurrenceId",
        "ownerElementIds",
        "editable",
        "routeIdentity",
        "fromPointIndex",
        "toPointIndex"
      ],
      "properties": {
        "edgeId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "legId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
        },
        "fromOccurrenceId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "toOccurrenceId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "ownerElementIds": {
          "type": "array",
          "minItems": 0,
          "uniqueItems": true,
          "items": {
            "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
          }
        },
        "editable": {
          "type": "boolean"
        },
        "routeIdentity": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "fromPointIndex": {
          "type": "integer",
          "minimum": 0
        },
        "toPointIndex": {
          "type": "integer",
          "minimum": 1
        },
        "admission": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1_1/edits/mapping.schema.json#/properties/edges/items"
        }
      },
      "dependentRequired": {
        "fromPointIndex": [
          "toPointIndex"
        ],
        "toPointIndex": [
          "fromPointIndex"
        ]
      }
    },
    "layer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "layerId",
        "role",
        "sourceSnapshotId",
        "features"
      ],
      "properties": {
        "layerId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "role": {
          "enum": [
            "route",
            "fixes",
            "vertical",
            "issues",
            "directTo",
            "selection"
          ]
        },
        "sourceSnapshotId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "features": {
          "type": "array",
          "maxItems": 50000,
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/lineFeature"
              },
              {
                "$ref": "#/$defs/fixFeature"
              },
              {
                "$ref": "#/$defs/breakFeature"
              }
            ]
          }
        }
      }
    },
    "lineFeature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "featureId",
        "legId",
        "edgeIds",
        "coordinates"
      ],
      "properties": {
        "kind": {
          "const": "line"
        },
        "featureId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "legId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
        },
        "edgeIds": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
          }
        },
        "coordinates": {
          "type": "array",
          "minItems": 2,
          "maxItems": 20000,
          "items": {
            "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/coordinate"
          }
        },
        "verticalBasisId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "altitudes": {
          "type": "array",
          "minItems": 2,
          "maxItems": 20000,
          "items": {
            "type": "number"
          }
        }
      },
      "dependentRequired": {
        "altitudes": [
          "verticalBasisId"
        ],
        "verticalBasisId": [
          "altitudes"
        ]
      }
    },
    "fixFeature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "featureId",
        "legId",
        "occurrenceId",
        "ownerElementIds",
        "position",
        "pointIndex",
        "label"
      ],
      "properties": {
        "kind": {
          "const": "fix"
        },
        "featureId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "legId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
        },
        "occurrenceId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "ownerElementIds": {
          "type": "array",
          "minItems": 0,
          "uniqueItems": true,
          "items": {
            "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
          }
        },
        "position": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/coordinate"
        },
        "verticalBasisId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "altitude": {
          "type": "number"
        },
        "pointIndex": {
          "type": "integer",
          "minimum": 0
        },
        "admission": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1_1/edits/mapping.schema.json#/properties/vertices/items"
        },
        "label": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512
        }
      },
      "dependentRequired": {
        "altitude": [
          "verticalBasisId"
        ],
        "verticalBasisId": [
          "altitude"
        ]
      }
    },
    "breakFeature": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "kind",
        "featureId",
        "legId",
        "reason"
      ],
      "properties": {
        "kind": {
          "const": "break"
        },
        "featureId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/id"
        },
        "legId": {
          "$ref": "https://postflight.co/aeronautiql/planning/v1/results/common.schema.json#/$defs/intentId"
        },
        "reason": {
          "enum": [
            "pending",
            "unusable",
            "discontinuity",
            "notInNavigationContext"
          ]
        }
      }
    }
  }
}
