Skip to main content
Loading navigation

Build a CityJSON Metadata Extent Coordinate Validator — implementation

Prompt source

implementation93 lines11 sectionsNo variables1 code block
## Build
Parse CityJSON 2.0 metadata objects to verify geographical extent bounding coordinates. Calculate actual dataset bounds from decompressed vertices and flag metadata discrepancies.

## User
Municipal Tax Assessor

## Workflow
1. Ingest CityJSON 2.0 models and extract the root metadata geographicalExtent array.
2. Decompress integer coordinates from the vertices array using the transform object.
3. Calculate the true min/max spatial bounding box enclosing all decompressed vertices.
4. Generate a metadata discrepancy report comparing declared extents versus calculated bounding boxes.

## Interface
Browser validation portal showing calculated vs declared extents and bounding box error warnings.

## Data
Author synthetic CityJSON 2.0 documents with '+' prefix extension object types and custom attributes.
Starter examples below are synthetic. They are not downloaded records.

## Source
[CityJSON](https://www.cityjson.org/specs/2.0.1/)
Applies CityJSON Section 5 Metadata object specifications to validate geographicalExtent arrays.

## Tools
mastra-ai, typescript, zod.
Mastra AI orchestrates schema loading, regex pattern verification, and diagnostic error explanation.
Instruction-tuned LLM capable of schema parsing and concise error reporting via API.

## Deliverables
Submit runnable source, pinned dependencies, setup commands, a working interface, example outputs, and a recorded end-to-end demo. Include tests and an action log.

## Acceptance
- Calculates true bounds accurately from integer decompressed vertices.
- Identifies files where metadata extent deviates from actual geometry.
- Validation report returns status and calculated geographical boundary mismatch distances.

## Starter Examples
```json
[
  {
    "input": {
      "type": "CityJSON",
      "metadata": {
        "geographicalExtent": [
          0,
          0,
          0,
          100,
          100,
          50
        ]
      },
      "calculated_bounds": [
        0,
        0,
        0,
        100,
        100,
        50
      ]
    },
    "expected_output": {
      "extent_declared": true,
      "mismatch": false,
      "max_deviation": 0,
      "mapping_valid": true
    }
  },
  {
    "input": {
      "type": "CityJSON",
      "metadata": {
        "geographicalExtent": [
          0,
          0,
          0,
          50,
          50,
          20
        ]
      },
      "calculated_bounds": [
        0,
        0,
        0,
        100,
        100,
        50
      ]
    },
    "expected_output": {
      "extent_declared": true,
      "mismatch": true,
      "max_deviation": 50,
      "mapping_valid": false
    }
  }
]
```

## Safety
Validator checks syntax and schema metadata only; it does not alter statutory property tax records.
Use mock external writes. Require human review before any real deployment.