{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.landscapefederation.org.au/schema/built-environment/tla-gis-geojson.schema.json",
  "title": "TLA civic GIS GeoJSON export profile",
  "description": "GeoJSON FeatureCollection profile for civic and urban landscape registries — flat 2D canopy footprint, taxonomic identity, and maintenance fields mapped from TLA-185.",
  "type": "object",
  "required": ["type", "features"],
  "properties": {
    "type": { "const": "FeatureCollection" },
    "name": { "type": "string" },
    "$schema": { "type": "string", "format": "uri" },
    "crs": {
      "type": "object",
      "properties": {
        "type": { "const": "name" },
        "properties": {
          "type": "object",
          "required": ["name"],
          "properties": {
            "name": { "type": "string" }
          }
        }
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "exporter": { "type": "string" },
        "tlaStandardId": { "type": "string" },
        "federationSchemaVersion": { "type": "string" },
        "generatedAt": { "type": "string", "format": "date-time" }
      }
    },
    "features": {
      "type": "array",
      "items": { "$ref": "#/$defs/feature" },
      "minItems": 1
    }
  },
  "$defs": {
    "feature": {
      "type": "object",
      "required": ["type", "geometry", "properties"],
      "properties": {
        "type": { "const": "Feature" },
        "id": { "type": "string" },
        "geometry": {
          "oneOf": [
            { "$ref": "#/$defs/pointGeometry" },
            { "$ref": "#/$defs/polygonGeometry" }
          ]
        },
        "properties": { "$ref": "#/$defs/plantProperties" }
      }
    },
    "pointGeometry": {
      "type": "object",
      "required": ["type", "coordinates"],
      "properties": {
        "type": { "const": "Point" },
        "coordinates": {
          "type": "array",
          "items": { "type": "number" },
          "minItems": 2,
          "maxItems": 3
        }
      }
    },
    "polygonGeometry": {
      "type": "object",
      "required": ["type", "coordinates"],
      "properties": {
        "type": { "const": "Polygon" },
        "coordinates": {
          "type": "array",
          "items": {
            "type": "array",
            "items": {
              "type": "array",
              "items": { "type": "number" },
              "minItems": 2,
              "maxItems": 3
            }
          }
        }
      }
    },
    "plantProperties": {
      "type": "object",
      "required": ["assetId", "scientificName", "canopyRadius_m"],
      "properties": {
        "assetId": { "type": "string", "description": "TLA-185 field 185-110" },
        "scientificName": { "type": "string", "description": "TLA-185 taxonomy module" },
        "acceptedScientificName": { "type": "string" },
        "vernacularName": { "type": "string", "description": "TLA-185 field 185-127" },
        "family": { "type": "string" },
        "genus": { "type": "string" },
        "taxonID": { "type": "string", "description": "Darwin Core / GBIF — TLA-185 field 185-002" },
        "speciesKey": { "type": "string", "description": "TLA-185 field 185-001" },
        "growthForm": { "type": "string" },
        "nativeStatus": { "type": "string" },
        "matureHeight_m": { "type": "number", "minimum": 0 },
        "matureSpread_m": { "type": "number", "minimum": 0 },
        "canopyRadius_m": {
          "type": "number",
          "minimum": 0,
          "description": "Derived from matureSpread_m / 2 for 2D civic canopy registry."
        },
        "canopyFootprint": {
          "$ref": "#/$defs/polygonGeometry",
          "description": "Optional WGS84 polygon approximation of canopy circle for Shapefile/GIS import."
        },
        "waterRequirementClass": {
          "type": "string",
          "enum": ["very-low", "low", "moderate", "high", "riparian", "unknown"]
        },
        "quantity": { "type": "number", "minimum": 0 },
        "unit": { "type": "string" },
        "maintenance": {
          "type": "object",
          "properties": {
            "inspectionCycleMonths": { "type": "integer", "minimum": 1 },
            "irrigationZone": { "type": "string" },
            "lastPruned": { "type": "string", "format": "date" },
            "establishmentYear": { "type": "integer" },
            "notes": { "type": "string" }
          },
          "additionalProperties": true
        },
        "tlaStandardId": { "type": "string" },
        "tlaFieldRefs": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
