Build a CityJSON Coordinate Precision and Transformation Verifier — implementation
Linked challenge: Build a CityJSON Coordinate Precision and Transformation Verifier
Prompt source
implementation107 lines11 sectionsNo variables1 code block
## Build
Inspect CityJSON transform matrices and vertex compression precision to verify spatial fidelity. Detect degenerate surface geometries and scale anomalies before municipal GIS federation.
## User
GIS Spatial Data Coordinator
## Workflow
1. Parse CityJSON root transform object including scale and translate vector arrays.
2. Decompress integer coordinates to real-world world coordinates across vertex arrays.
3. Identify zero-area polygons, inverted normal facets, or out-of-bounds geographic coordinates.
4. Produce transformation fidelity report with recommended quantization tolerance corrections.
## Interface
Diagnostics dashboard showing coordinate transformation histograms and defective vertex listings.
## Data
Generate synthetic CityJSON files with varied transform scales and intentionally corrupted vertices.
Starter examples below are synthetic. They are not downloaded records.
## Source
[CityJSON](https://www.cityjson.org/specs/2.0.1/)
Directly implements the CityJSON Section 1 Transform Object (scale and translate arrays) and Section 3.1 vertex decoding.
## Tools
pydantic-ai, numpy, fastapi.
Pydantic AI validates strict numerical schemas for transform vectors and vertex coordinate triplets.
Local or hosted model supporting schema evaluation and structured JSON output.
## 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
- Properly verifies that scale vectors contain exactly three positive non-zero floats.
- Flags compressed vertices that produce identical real-world coordinates within single polygons.
- Outputs decompressed bounding extents matching metadata ranges.
## Starter Examples
```json
[
{
"input": {
"type": "CityJSON",
"version": "2.0",
"transform": {
"scale": [
0.001,
0.001,
0.001
],
"translate": [
10000,
20000,
0
]
},
"vertices": [
[
0,
0,
0
],
[
1000,
0,
0
],
[
1000,
1000,
0
]
]
},
"expected_output": {
"transform_valid": true,
"vertex_count": 3,
"degenerate_polygons": 0,
"status": "VALID_GEOMETRY"
}
},
{
"input": {
"type": "CityJSON",
"version": "2.0",
"transform": {
"scale": [
0,
0.001,
0.001
],
"translate": [
0,
0,
0
]
},
"vertices": [
[
10,
20,
30
]
]
},
"expected_output": {
"transform_valid": false,
"vertex_count": 1,
"degenerate_polygons": 0,
"status": "INVALID_SCALE_VECTOR"
}
}
]
```
## Safety
Geometric validation processes geospatial metadata only and modifies no external physical municipal databases.
Use mock external writes. Require human review before any real deployment.