Skip to content

GeoJSON Position Arrays: Enforce 2D Coordinates (maxItems: 2) for Cadastral Data#2769

Merged
simonredfern merged 4 commits intoOpenBankProject:developfrom
hongwei1:obp-develop
Apr 28, 2026
Merged

GeoJSON Position Arrays: Enforce 2D Coordinates (maxItems: 2) for Cadastral Data#2769
simonredfern merged 4 commits intoOpenBankProject:developfrom
hongwei1:obp-develop

Conversation

@hongwei1
Copy link
Copy Markdown
Contributor

Summary

This PR enforces 2D-only coordinates for GeoJSON position arrays in cadastral data by setting maxItems: 2 instead of the RFC 7946 recommended maxItems: 3.

Changes

Modified Files

  • obp-api/src/main/scala/code/api/v1_4_0/JSONFactory1_4_0.scala
  • obp-api/src/test/scala/code/api/v1_4_0/JSONFactory1_4_0NestedArrayTest.scala
  • obp-api/src/main/scala/code/api/ResourceDocs1_4_0/OpenAPI31JSONFactory.scala

Key Changes

  • Updated addGeoJSONConstraints() to generate minItems: 2, maxItems: 2
  • Updated test expectations to verify 2D-only constraints
  • Added comprehensive comments explaining the business rationale

Rationale

Why maxItems: 2 instead of RFC 7946's optional 3rd element?

  1. Cadastral datasets don't provide elevation - Land registry data focuses on 2D boundaries
  2. Vertical CRS complexity - Allowing elevation requires defining a vertical coordinate reference system
  3. Coordinate consistency - RFC 7946 requires all positions in a geometry to have the same number of coordinates, but JSON Schema cannot enforce this cross-element constraint
  4. API simplification - Restricting to 2D simplifies API mocking and client implementation

Generated Schema

{
  "type": "array",
  "items": {"type": "number"},
  "minItems": 2,
  "maxItems": 2
}

Testing

All unit tests pass (4/4):

  • ✅ 2-level nested array
  • ✅ 3-level nested array
  • ✅ 4-level GeoJSON MultiPolygon with minItems: 2, maxItems: 2
  • ✅ Empty nested array

Trade-offs

  • ❌ Deviates from RFC 7946's recommendation to allow optional elevation
  • ✅ Matches real-world cadastral data usage patterns
  • ✅ Prevents coordinate dimension inconsistency issues
  • ✅ Simplifies validation and testing

Related Commits

  • a3bf6c3 - test/remove maxItems constraint from GeoJSON position arrays per RFC 7946
  • ff8bbef - enhancement/add maxItems 3 constraint to GeoJSON position arrays per RFC 7946
  • c8690d0 - enhancement/extract minItems and maxItems from JSON schema for OpenAPI conversion
  • 7051629 - refactor/change GeoJSON position arrays to 2D only (maxItems: 2) for cadastral data

Documentation

Full specification and rationale documented in: .kiro/specs/geojson-rfc7946-compliance/

@sonarqubecloud
Copy link
Copy Markdown

@simonredfern simonredfern merged commit 5eff59f into OpenBankProject:develop Apr 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants