Skip to content

Fix GeoJSON polygon coordinates dropping the exterior ring with holes - #10345

Merged
glen-84 merged 1 commit into
mainfrom
gai/polygon-exterior-ring-coordinates
Sep 3, 2026
Merged

glen-84 merged 1 commit into
mainfrom
gai/polygon-exterior-ring-coordinates

Conversation

@glen-84

@glen-84 glen-84 commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • GeoJSONPolygonType.coordinates now emits the exterior ring at index 0 followed by the interior rings, as the field's description and RFC 7946 require.
  • Previously each interior ring was written one slot too early, so for any polygon with holes the first hole overwrote the exterior ring and the last slot stayed null. The Geometry scalar and the input types were not affected.

Test plan

  • New GeoJsonPolygonTypeTests case with a polygon that has two interior rings snapshots type, coordinates, bbox, and crs. It fails without the resolver change.
  • HotChocolate.Types.Spatial.Tests passes on net10.0.

Closes #10341

Copilot AI lite review requested due to automatic review settings September 3, 2026 13:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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.GetCoordinates to 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, and crs for 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.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (1/1)

File Covered Changed Patch %
src/HotChocolate/Spatial/src/Types/GeoJsonPolygonType.cs 1 1 100.0% 🟢

Project coverage: 57.8% (287226/497237 lines)

@glen-84
glen-84 merged commit e5a437f into main Sep 3, 2026
152 checks passed
@glen-84
glen-84 deleted the gai/polygon-exterior-ring-coordinates branch September 3, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoJSONPolygonType.coordinates omits the exterior ring when the polygon has holes

2 participants