{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openeik.org/schemas/0.7/project/plan-limits.schema.json",
  "$comment": "OpenEik 0.7: folded by tools/fold-schemas-0.7.mjs from the proposal planLimits, which 0.7 makes a rule (open questions, 170). Written by hand, not generated.",
  "title": "project/plan-limits.json",
  "description": "A plan's limits on the site (Part II, 2.4: lines and outlines in the model's plan, each with the plan and the provision it comes from.",
  "type": "object",
  "required": [
    "planLimits"
  ],
  "additionalProperties": false,
  "properties": {
    "planLimits": {
      "description": "1 to 1000 limits (Part II, 2.4, rule 1).",
      "type": "array",
      "minItems": 1,
      "maxItems": 1000,
      "items": {
        "type": "object",
        "required": [
          "id",
          "kind",
          "points",
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "description": "The limit's id, once in the file (rule 2): 1 to 80 characters, no /, no white space.",
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "pattern": "^[^/\\s]+$"
          },
          "kind": {
            "description": "facadeLine, a line a building's facade stands on and does not cross; buildingLimit, an outline a building stays inside; noBuild, an outline no building stands on; heightLimit, an outline over which a building reaches no higher than its height (rule 3).",
            "enum": [
              "facadeLine",
              "buildingLimit",
              "noBuild",
              "heightLimit"
            ]
          },
          "name": {
            "description": "What people call it, for a list or a drawing.",
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "points": {
            "description": "Points in plan, mm, in the model's coordinates: a facade line's an open line of two points or more, the side a building may not cross into on its left walked from its first point; an outline's three points or more, closed from its last point back to its first, which it does not repeat (rule 3).",
            "type": "array",
            "minItems": 2,
            "maxItems": 10000,
            "items": {
              "type": "array",
              "minItems": 2,
              "maxItems": 2,
              "items": {
                "type": "number"
              }
            }
          },
          "height": {
            "description": "A height limit's height, mm: the highest a building's top reaches over the outline, a height as a level's elevation is, above the project's zero (rule 4).",
            "type": "number",
            "minimum": -100000,
            "maximum": 1000000
          },
          "source": {
            "description": "Where the limit comes from (rule 5): the authority that adopted the plan, the plan, and the provision, each as the authority writes it.",
            "type": "object",
            "required": [
              "authority",
              "plan"
            ],
            "additionalProperties": false,
            "properties": {
              "authority": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "x-eik-values": "national"
              },
              "plan": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "x-eik-values": "national"
              },
              "provision": {
                "type": "string",
                "minLength": 1,
                "maxLength": 200,
                "x-eik-values": "national"
              }
            }
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "kind": {
                  "const": "heightLimit"
                }
              },
              "required": [
                "kind"
              ]
            },
            "then": {
              "required": [
                "height"
              ]
            },
            "else": {
              "not": {
                "required": [
                  "height"
                ]
              }
            }
          },
          {
            "if": {
              "properties": {
                "kind": {
                  "enum": [
                    "buildingLimit",
                    "noBuild",
                    "heightLimit"
                  ]
                }
              },
              "required": [
                "kind"
              ]
            },
            "then": {
              "properties": {
                "points": {
                  "minItems": 3
                }
              }
            }
          }
        ]
      }
    }
  }
}
