{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "const": "arbin-cloud-trace-v1"
    },
    "source": {
      "type": "object",
      "properties": {
        "width": {
          "type": "integer",
          "minimum": 50,
          "maximum": 20000
        },
        "height": {
          "type": "integer",
          "minimum": 50,
          "maximum": 20000
        }
      },
      "required": [
        "width",
        "height"
      ],
      "additionalProperties": false
    },
    "calibration": {
      "type": "object",
      "properties": {
        "a": {
          "type": "object",
          "properties": {
            "x": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "y": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          },
          "required": [
            "x",
            "y"
          ],
          "additionalProperties": false
        },
        "b": {
          "type": "object",
          "properties": {
            "x": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            },
            "y": {
              "type": "number",
              "minimum": 0,
              "maximum": 1
            }
          },
          "required": [
            "x",
            "y"
          ],
          "additionalProperties": false
        },
        "cm": {
          "type": "number",
          "minimum": 1,
          "maximum": 100000
        }
      },
      "required": [
        "a",
        "b",
        "cm"
      ],
      "additionalProperties": false
    },
    "trace": {
      "type": "object",
      "properties": {
        "readable": {
          "type": "boolean"
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "notes": {
          "maxItems": 30,
          "type": "array",
          "items": {
            "type": "string",
            "maxLength": 300
          }
        },
        "walls": {
          "maxItems": 250,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "a": {
                "type": "object",
                "properties": {
                  "x": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "y": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "x",
                  "y"
                ],
                "additionalProperties": false
              },
              "b": {
                "type": "object",
                "properties": {
                  "x": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "y": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "x",
                  "y"
                ],
                "additionalProperties": false
              },
              "thickness": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 0.1
              },
              "parapet": {
                "type": "boolean"
              }
            },
            "required": [
              "a",
              "b",
              "thickness",
              "parapet"
            ],
            "additionalProperties": false
          }
        },
        "rooms": {
          "maxItems": 40,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 60
              },
              "points": {
                "minItems": 3,
                "maxItems": 60,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "x": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "y": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    }
                  },
                  "required": [
                    "x",
                    "y"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "name",
              "points"
            ],
            "additionalProperties": false
          }
        },
        "openings": {
          "maxItems": 120,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "door",
                  "window",
                  "sliding-door",
                  "double-door",
                  "casement-window",
                  "fixed-window",
                  "full-window"
                ]
              },
              "wall": {
                "type": "integer",
                "minimum": 0,
                "maximum": 249
              },
              "t": {
                "type": "number",
                "minimum": 0,
                "maximum": 1
              },
              "width": {
                "type": "number",
                "minimum": 0.005,
                "maximum": 1
              },
              "flipped": {
                "type": "boolean"
              },
              "mirroredY": {
                "type": "boolean"
              }
            },
            "required": [
              "kind",
              "wall",
              "t",
              "width",
              "flipped",
              "mirroredY"
            ],
            "additionalProperties": false
          }
        },
        "structures": {
          "maxItems": 100,
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "column",
                  "beam",
                  "shaft"
                ]
              },
              "center": {
                "type": "object",
                "properties": {
                  "x": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  },
                  "y": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1
                  }
                },
                "required": [
                  "x",
                  "y"
                ],
                "additionalProperties": false
              },
              "width": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 0.8
              },
              "depth": {
                "type": "number",
                "minimum": 0.001,
                "maximum": 0.8
              },
              "rotation": {
                "type": "number",
                "minimum": -180,
                "maximum": 180
              }
            },
            "required": [
              "kind",
              "center",
              "width",
              "depth",
              "rotation"
            ],
            "additionalProperties": false
          }
        }
      },
      "required": [
        "readable",
        "confidence",
        "notes",
        "walls",
        "rooms",
        "openings",
        "structures"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "format",
    "source",
    "calibration",
    "trace"
  ],
  "additionalProperties": false
}
