Repository navigation
Fix GeoJSON polygon coordinates dropping the exterior ring with holes - #10345
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The fix is minimal, aligns with the GeoJSON spec/field contract, and is backed by a targeted regression test and snapshot.
Pull request overview
This pull request fixes a long-standing GeoJSON serialization bug in GeoJSONPolygonType.coordinates where polygons with interior rings (holes) would overwrite the exterior ring and leave the final ring slot null, violating the field description and RFC 7946. It updates the resolver to emit the exterior ring first (index 0) followed by interior rings, and adds a regression test with snapshot coverage for a polygon with holes.
Changes:
- Fix
GeoJsonPolygonType.Resolvers.GetCoordinatesto write interior rings starting at index 1 (coordinates[i + 1]). - Add a new test case covering polygons with multiple interior rings to prevent regressions.
- Add a new snapshot capturing
type,coordinates,bbox, andcrsfor the new test.
File summaries
| File | Description |
|---|---|
| src/HotChocolate/Spatial/src/Types/GeoJsonPolygonType.cs | Corrects ring indexing so the exterior ring remains at coordinates[0] and holes follow. |
| src/HotChocolate/Spatial/test/Types.Tests/GeoJsonPolygonTypeTests.cs | Adds a regression test for polygons with holes to validate ring ordering. |
| src/HotChocolate/Spatial/test/Types.Tests/snapshots/GeoJsonPolygonTypeTests.GetCoordinates_Should_ReturnExteriorRingFirst_When_PolygonHasHoles.snap | Records expected execution output for the new holes scenario (including coordinates and metadata). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Patch coverage100.0% of changed lines covered (1/1)
Project coverage: 57.8% (287226/497237 lines) |
Summary
GeoJSONPolygonType.coordinatesnow emits the exterior ring at index 0 followed by the interior rings, as the field's description and RFC 7946 require.null. TheGeometryscalar and the input types were not affected.Test plan
GeoJsonPolygonTypeTestscase with a polygon that has two interior rings snapshotstype,coordinates,bbox, andcrs. It fails without the resolver change.HotChocolate.Types.Spatial.Testspasses on net10.0.Closes #10341