{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/normatia-com/json-schema/normatia-com-parcel-schema.json",
  "title": "Parcel",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/normatia-com-openapi.json#/components/schemas/Parcel",
  "properties": {
    "object": {
      "type": "string",
      "const": "parcel",
      "title": "Object",
      "default": "parcel"
    },
    "ref": {
      "type": "string",
      "title": "Ref",
      "description": "La referencia catastral de 14 caracteres"
    },
    "place": {
      "$ref": "#/$defs/src__api__v1__parcelas__Place"
    },
    "cadastral_class": {
      "anyOf": [
        {
          "$ref": "#/$defs/CodeLabel"
        },
        {
          "type": "null"
        }
      ]
    },
    "main_use": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Main Use",
      "description": "Uso principal de lo edificado (residencial, industrial...)"
    },
    "area_m2": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Area M2",
      "description": "Superficie oficial del Catastro, o medida en su huso UTM"
    },
    "centroid": {
      "anyOf": [
        {
          "$ref": "#/$defs/Point"
        },
        {
          "type": "null"
        }
      ]
    },
    "bbox": {
      "anyOf": [
        {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Bbox",
      "description": "[oeste, sur, este, norte], en grados"
    },
    "addresses": {
      "items": {
        "$ref": "#/$defs/Address"
      },
      "type": "array",
      "title": "Addresses",
      "description": "Los portales, el más cercano a su punto primero"
    },
    "constraints": {
      "anyOf": [
        {
          "$ref": "#/$defs/Constraints"
        },
        {
          "type": "null"
        }
      ],
      "description": "Con include=constraints"
    },
    "zoning": {
      "anyOf": [
        {
          "$ref": "#/$defs/Zoning"
        },
        {
          "type": "null"
        }
      ],
      "description": "Con include=zoning. Vacío si el planeamiento de su municipio no está cargado"
    },
    "buildings": {
      "anyOf": [
        {
          "$ref": "#/$defs/Buildings"
        },
        {
          "type": "null"
        }
      ],
      "description": "Con include=buildings. null si el Catastro de edificios no está cargado en su municipio"
    },
    "units": {
      "anyOf": [
        {
          "$ref": "#/$defs/Units"
        },
        {
          "type": "null"
        }
      ],
      "description": "Con include=units. null si los datos del Catastro no están cargados en su municipio"
    },
    "geometry": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Geometry",
      "description": "Con include=geometry: GeoJSON (MultiPolygon, WGS84)"
    },
    "disclaimer": {
      "type": "string",
      "title": "Disclaimer"
    }
  },
  "type": "object",
  "required": [
    "ref",
    "place",
    "disclaimer"
  ],
  "$defs": {
    "Address": {
      "properties": {
        "street": {
          "type": "string",
          "title": "Street",
          "description": "Como la escribe el Catastro: «PS NUESTRA SEÑORA DE LA O»"
        },
        "number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Number"
        },
        "postal_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Postal Code"
        }
      },
      "type": "object",
      "required": [
        "street"
      ],
      "title": "Address"
    },
    "Buildings": {
      "properties": {
        "built": {
          "type": "boolean",
          "title": "Built",
          "description": "false: el Catastro está cargado y no hay nada edificado"
        },
        "condition": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Condition",
          "description": "funcional | deteriorado | ruina"
        },
        "year_built": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Year Built"
        },
        "built_area_m2": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Built Area M2"
        },
        "dwellings": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Dwellings"
        },
        "units": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Units",
          "description": "Inmuebles catastrales"
        },
        "floors_above": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Floors Above"
        },
        "floors_below": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Floors Below"
        },
        "source": {
          "type": "string",
          "title": "Source",
          "default": "Dirección General del Catastro (INSPIRE, edificios)"
        }
      },
      "type": "object",
      "required": [
        "built"
      ],
      "title": "Buildings"
    },
    "CodeLabel": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code"
        },
        "label": {
          "type": "string",
          "title": "Label"
        }
      },
      "type": "object",
      "required": [
        "code",
        "label"
      ],
      "title": "CodeLabel"
    },
    "ConstraintLayer": {
      "properties": {
        "layer": {
          "type": "string",
          "title": "Layer",
          "description": "El código de la capa: `carreteras`, `costas`, `dph`..."
        },
        "affected": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Affected",
          "description": "true afectada, false no afectada, null sin dato: null NUNCA quiere decir «no afectada»"
        },
        "status": {
          "type": "string",
          "enum": [
            "affected",
            "partially_affected",
            "context",
            "not_affected",
            "no_data"
          ],
          "title": "Status"
        },
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Label",
          "description": "Afecta, Exige trámite, Riesgo técnico, A verificar o Informativa (contexto)"
        },
        "summary": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Summary",
          "description": "El hecho en una frase, con sus magnitudes"
        },
        "distance_m": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Distance M"
        },
        "warnings": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Warnings"
        },
        "reason": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reason",
          "description": "Por qué no hay dato (`no_coverage`) o por qué es dudoso"
        },
        "source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source"
        }
      },
      "type": "object",
      "required": [
        "layer",
        "affected",
        "status"
      ],
      "title": "ConstraintLayer"
    },
    "Constraints": {
      "properties": {
        "summary": {
          "$ref": "#/$defs/ConstraintsSummary"
        },
        "layers": {
          "items": {
            "$ref": "#/$defs/ConstraintLayer"
          },
          "type": "array",
          "title": "Layers"
        }
      },
      "type": "object",
      "required": [
        "summary",
        "layers"
      ],
      "title": "Constraints"
    },
    "ConstraintsSummary": {
      "properties": {
        "affected": {
          "type": "integer",
          "title": "Affected"
        },
        "context": {
          "type": "integer",
          "title": "Context"
        },
        "not_affected": {
          "type": "integer",
          "title": "Not Affected"
        },
        "no_data": {
          "type": "integer",
          "title": "No Data"
        }
      },
      "type": "object",
      "required": [
        "affected",
        "context",
        "not_affected",
        "no_data"
      ],
      "title": "ConstraintsSummary"
    },
    "LandClass": {
      "properties": {
        "source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source"
        },
        "date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Date"
        },
        "instrument": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Instrument"
        },
        "label": {
          "type": "string",
          "title": "Label"
        }
      },
      "type": "object",
      "required": [
        "label"
      ],
      "title": "LandClass"
    },
    "OtherZone": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        },
        "percent": {
          "type": "number",
          "title": "Percent"
        }
      },
      "type": "object",
      "required": [
        "code",
        "percent"
      ],
      "title": "OtherZone"
    },
    "PlanningArea": {
      "properties": {
        "code": {
          "type": "string",
          "title": "Code"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        },
        "instrument": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Instrument"
        },
        "percent": {
          "type": "number",
          "title": "Percent"
        }
      },
      "type": "object",
      "required": [
        "code",
        "percent"
      ],
      "title": "PlanningArea"
    },
    "Point": {
      "properties": {
        "lat": {
          "type": "number",
          "title": "Lat"
        },
        "lon": {
          "type": "number",
          "title": "Lon"
        }
      },
      "type": "object",
      "required": [
        "lat",
        "lon"
      ],
      "title": "Point"
    },
    "Unit": {
      "properties": {
        "ref": {
          "type": "string",
          "title": "Ref",
          "description": "La referencia catastral del inmueble, de 20 caracteres"
        },
        "use": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Use",
          "description": "residencial, comercial, oficinas, almacen_estacionamiento..."
        },
        "area_m2": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Area M2"
        },
        "year_built": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Year Built"
        },
        "address": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Address",
          "description": "La vía y el número del inmueble: «CL VIRGEN DEL CORO 20»"
        },
        "postal_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Postal Code"
        }
      },
      "type": "object",
      "required": [
        "ref"
      ],
      "title": "Unit"
    },
    "Units": {
      "properties": {
        "total": {
          "type": "integer",
          "title": "Total"
        },
        "by_use": {
          "additionalProperties": {
            "type": "integer"
          },
          "type": "object",
          "title": "By Use",
          "description": "Cuántos hay de cada uso (`sin_uso` sin él)"
        },
        "data": {
          "items": {
            "$ref": "#/$defs/Unit"
          },
          "type": "array",
          "title": "Data",
          "description": "Como mucho 200 de cada uso; `total` y `by_use` cuentan todos"
        },
        "has_more": {
          "type": "boolean",
          "title": "Has More",
          "description": "Si hay más inmuebles que los de `data`"
        },
        "source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source",
          "description": "La Dirección General del Catastro o la Diputación foral"
        },
        "date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Date",
          "description": "La de los datos del Catastro de su municipio"
        },
        "note": {
          "type": "string",
          "title": "Note",
          "default": "Elaborado a partir de datos del Catastro. No es información catastral."
        }
      },
      "type": "object",
      "required": [
        "total",
        "has_more"
      ],
      "title": "Units"
    },
    "ZoneParameter": {
      "properties": {
        "value": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Value"
        },
        "unit": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Unit"
        },
        "text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Text"
        }
      },
      "type": "object",
      "title": "ZoneParameter"
    },
    "Zoning": {
      "properties": {
        "land_class": {
          "anyOf": [
            {
              "$ref": "#/$defs/LandClass"
            },
            {
              "type": "null"
            }
          ]
        },
        "zone": {
          "anyOf": [
            {
              "$ref": "#/$defs/src__api__v1__parcelas__Zone"
            },
            {
              "type": "null"
            }
          ]
        },
        "other_zones": {
          "items": {
            "$ref": "#/$defs/OtherZone"
          },
          "type": "array",
          "title": "Other Zones"
        },
        "areas": {
          "items": {
            "$ref": "#/$defs/PlanningArea"
          },
          "type": "array",
          "title": "Areas",
          "description": "Ámbitos de planeamiento que la tocan"
        },
        "zone_from_other_municipality": {
          "type": "boolean",
          "title": "Zone From Other Municipality",
          "description": "Una zona del municipio vecino la toca: el límite municipal no casa con la parcela",
          "default": false
        },
        "contrast_land_class": {
          "anyOf": [
            {
              "$ref": "#/$defs/LandClass"
            },
            {
              "type": "null"
            }
          ],
          "description": "La clase de suelo de las fuentes de contraste (el SIU), aparte"
        }
      },
      "type": "object",
      "title": "Zoning"
    },
    "src__api__v1__parcelas__Place": {
      "properties": {
        "geo_id": {
          "type": "string",
          "title": "Geo Id",
          "description": "El identificador de lugar de la API: `ES-` y el código INE"
        },
        "ine": {
          "type": "string",
          "title": "Ine"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "geo_id",
        "ine"
      ],
      "title": "Place"
    },
    "src__api__v1__parcelas__Zone": {
      "properties": {
        "source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source"
        },
        "date": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Date"
        },
        "instrument": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Instrument"
        },
        "code": {
          "type": "string",
          "title": "Code"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Name"
        },
        "percent": {
          "type": "number",
          "title": "Percent",
          "description": "Qué parte de la parcela cae en la zona"
        },
        "global_use": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Global Use"
        },
        "typology": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Typology"
        },
        "parameters": {
          "additionalProperties": {
            "$ref": "#/$defs/ZoneParameter"
          },
          "type": "object",
          "title": "Parameters",
          "description": "Los parámetros validados: edificabilidad, altura, plantas, ocupación, parcela mínima, usos..."
        }
      },
      "type": "object",
      "required": [
        "code",
        "percent"
      ],
      "title": "Zone"
    }
  }
}