{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://boston-energy-atlas.org/schema/site.schema.json",
  "title": "Site entry",
  "description": "A place where a load or a supply sat. Sites are the atlas's anchors in the ground: an entry exists for a place that carries an argument, not for every point in a layer — the points live in their dataset. A site is the thing you can stand in front of.",
  "type": "object",
  "required": ["type", "id", "name", "kind", "eras", "tier", "location", "sources"],
  "properties": {
    "type": { "const": "site" },
    "id": { "$ref": "common.schema.json#/$defs/id" },
    "name": { "type": "string" },
    "also_known_as": { "type": "array", "items": { "type": "string" } },
    "status": { "$ref": "common.schema.json#/$defs/status" },

    "kind": {
      "type": "string",
      "enum": [
        "generating-station",
        "substation",
        "gas-works",
        "traction-power-station",
        "data-centre",
        "charging-site",
        "storage",
        "distribution-network",
        "other"
      ]
    },
    "operator": { "type": "string", "description": "Who ran it, at the period described." },
    "built": { "type": "string" },
    "retired": { "type": "string" },
    "state": {
      "type": "string",
      "enum": ["operating", "retired", "demolished", "repurposed", "proposed", "unknown"]
    },

    "eras": { "$ref": "common.schema.json#/$defs/eras" },
    "tier": { "$ref": "common.schema.json#/$defs/tier" },

    "location": {
      "type": "object",
      "required": ["lon", "lat", "precision"],
      "properties": {
        "lon": { "type": "number" },
        "lat": { "type": "number" },
        "address": { "type": "string" },
        "municipality": { "type": "string" },
        "precision": {
          "type": "string",
          "enum": [
            "building footprint",
            "street address",
            "block",
            "approximate",
            "atlas-plate located",
            "unlocated"
          ],
          "description": "How well the coordinate is known. A marker on a map implies a precision it rarely has; stating it is the fix."
        },
        "precision_note": { "type": "string" }
      },
      "additionalProperties": false
    },

    "connects_to": {
      "type": "object",
      "description": "How the site meets the grid. The feeder is the atlas's spine, so a modern site that cannot name one is telling you something.",
      "properties": {
        "feeder": { "type": "string" },
        "feeder_kv": { "type": "number" },
        "substation": { "type": "string" },
        "bulk_substation": { "type": "string" },
        "distance_m": { "type": "number" },
        "method": { "type": "string", "description": "How the link was established. Nearest-geometry is a guess with an error bar, not a service record." }
      },
      "additionalProperties": false
    },

    "capacity": {
      "type": "object",
      "properties": {
        "value": { "type": "number" },
        "unit": { "type": "string", "enum": ["MW", "kW", "MVA", "sqft", "kWh"] },
        "basis": { "type": "string", "description": "What the figure measures — nameplate, IT load, winter capability, gross floor area." },
        "tier": { "$ref": "common.schema.json#/$defs/tier" },
        "published": { "type": "boolean", "description": "False where the operator publishes no figure. The atlas records the silence." }
      },
      "additionalProperties": false
    },

    "description": { "type": "string" },
    "atlas_plate": {
      "type": "string",
      "description": "ARK or barcode of the historical atlas volume on which the site can be seen, where one exists."
    },

    "sources": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "common.schema.json#/$defs/source" }
    },
    "open_items": { "type": "array", "items": { "type": "string" } },
    "related": { "type": "array", "items": { "$ref": "common.schema.json#/$defs/entry_ref" } },
    "reading": { "type": "string" }
  },
  "additionalProperties": false
}
