{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.badgerhomeowner.com/data/madison-exterior-restrictions.schema.json",
  "title": "Madison exterior restrictions by area",
  "description": "Areas of Madison where exterior work on a house is restricted beyond ordinary zoning (local historic districts, local landmarks, the Capitol height limit), the rules that apply in them, and the neighborhood names people search for. Every rule and every neighborhood match carries an official source. Written by scripts/make-historic.mjs from research/historic-districts-madison.json and research/capitol-view-madison.json.",
  "type": "object",
  "required": ["checked", "areas", "rules", "neighborhoods", "contact"],
  "additionalProperties": false,
  "properties": {
    "checked": { "type": "string", "format": "date", "description": "When the facts were last verified." },
    "contact": {
      "type": "object",
      "required": ["office", "phone", "email", "source"],
      "properties": {
        "office": { "type": "string" },
        "phone": { "type": "string" },
        "email": { "type": "string" },
        "source": { "$ref": "#/$defs/source" }
      }
    },
    "areas": { "type": "array", "items": { "$ref": "#/$defs/area" }, "minItems": 1 },
    "rules": { "type": "array", "items": { "$ref": "#/$defs/rule" }, "minItems": 1 },
    "neighborhoods": { "type": "array", "items": { "$ref": "#/$defs/neighborhood" } }
  },
  "$defs": {
    "source": {
      "type": "object",
      "description": "An official or primary source: the page or document, the ordinance section if any, and a short verbatim quote.",
      "required": ["url", "quote"],
      "additionalProperties": false,
      "properties": {
        "url": { "type": "string", "pattern": "^https://" },
        "section": { "type": "string", "description": "Ordinance or statute section, e.g. 'MGO 41.25(5)(c)2'." },
        "quote": { "type": "string", "minLength": 10 }
      }
    },
    "area": {
      "type": "object",
      "required": ["id", "name", "kind", "summary", "source"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "name": { "type": "string" },
        "kind": {
          "enum": ["local-historic-district", "landmark", "height-limit"],
          "description": "local-historic-district: one of Madison's districts under MGO ch. 41. landmark: an individually designated property (matched by address). height-limit: the Capitol height and view rules."
        },
        "designated": { "type": "integer", "description": "Year the Common Council designated it." },
        "period": { "type": "string", "description": "Period of significance, e.g. '1850-1930'." },
        "acres": { "type": "number" },
        "boundary": { "type": "string", "description": "Where it is, in the city's words or from city parcel data." },
        "summary": { "type": "string", "description": "One line for the alert card header." },
        "gisValue": { "type": "string", "description": "Value of LocalHistoricalDist in the city parcel layer, for the address check." },
        "page": { "type": "string", "pattern": "^https://" },
        "source": { "$ref": "#/$defs/source" }
      }
    },
    "rule": {
      "type": "object",
      "description": "One restriction on exterior work.",
      "required": ["id", "element", "level", "text", "appliesTo", "source"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "element": {
          "enum": ["windows", "doors", "siding-trim", "masonry", "chimneys", "roofing", "skylights-dormers", "vents", "porches-decks", "mechanical", "solar", "fences", "additions", "garages-sheds", "demolition", "paint", "height", "any-exterior", "maintenance"]
        },
        "level": {
          "enum": ["prohibited", "commission", "conditions", "staff", "none"],
          "description": "prohibited: not allowed (only a variance under MGO 41.19 can change it). commission: needs a Certificate of Approval from the full Landmarks Commission. conditions: allowed with a Certificate of Approval only if the stated conditions are met. staff: needs a Certificate of Approval, which staff can issue. none: no approval needed."
        },
        "text": { "type": "string", "description": "Plain-English rule, second person." },
        "appliesTo": {
          "type": "array",
          "minItems": 1,
          "items": { "type": "string" },
          "description": "Area ids, or 'districts' for all five local historic districts."
        },
        "visibleOnly": { "type": "boolean", "description": "True when the rule only covers parts visible from the street." },
        "source": { "$ref": "#/$defs/source" }
      }
    },
    "neighborhood": {
      "type": "object",
      "description": "A neighborhood name a person might type, and how much of it each restricted area covers.",
      "required": ["name", "matches"],
      "additionalProperties": false,
      "properties": {
        "name": { "type": "string" },
        "aliases": { "type": "array", "items": { "type": "string" } },
        "matches": {
          "type": "array",
          "description": "Empty means no restricted area found in this neighborhood.",
          "items": {
            "type": "object",
            "required": ["area", "coverage", "note", "source"],
            "additionalProperties": false,
            "properties": {
              "area": { "type": "string" },
              "coverage": { "enum": ["all", "part", "edge"], "description": "all: the whole neighborhood is in the area. part: some blocks are. edge: the area only touches it." },
              "note": { "type": "string" },
              "source": { "$ref": "#/$defs/source" }
            }
          }
        },
        "note": { "type": "string" },
        "source": { "$ref": "#/$defs/source" }
      }
    }
  }
}
