Skip to content

Fix GeoJSON MultiPolygon coordinates flattening each polygon's rings - #10347

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

glen-84 merged 1 commit into
mainfrom
gai/multipolygon-nested-ring-coordinates

Conversation

@glen-84

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

Copy link
Copy Markdown
Member

Summary

  • GeoJSONMultiPolygonType.coordinates now emits one ring array per polygon, exterior ring first, so a MultiPolygon's holes survive and the nesting matches the field's description and RFC 7946. The field keeps its Coordinates scalar type, so the schema does not change.
  • Previously each polygon contributed its flat coordinate list, which concatenated the exterior ring and every hole into a single ring and left the output one nesting level short even for polygons without holes.
  • Every MultiPolygon result gains a nesting level, so this is a breaking output change for clients that consumed the old three-level shape.

Follow-up to #10345, covering the MultiPolygon part of #10341.

Test plan

  • New GeoJsonMultiPolygonTypeTests case with one holed and one plain polygon snapshots type, coordinates, bbox, and crs. It fails without the resolver change.
  • The existing MultiPolygon_Execution_Output snapshot is updated to the per-polygon ring shape.
  • HotChocolate.Types.Spatial.Tests passes on net10.0.

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

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 resolver change aligns output with the spec and is backed by new and updated snapshot tests that cover the previously incorrect nesting behavior.

Pull request overview

This PR fixes GeoJSONMultiPolygonType.coordinates output so each polygon emits its own array of linear rings (exterior ring first, followed by interior rings), preserving holes and matching the field description / RFC 7946 shape ([[[Position]]]) while keeping the Coordinates scalar type unchanged.

Changes:

  • Added a dedicated GetMultiPolygonCoordinates resolver that returns rings-per-polygon (Coordinate[][][]) instead of flattening each polygon’s rings into a single coordinate list.
  • Updated GeoJsonMultiPolygonType to use the new resolver for the coordinates field.
  • Added/updated snapshot tests to cover a MultiPolygon containing both a holed polygon and a polygon without holes, and updated the existing MultiPolygon snapshot to reflect the corrected nesting.
File summaries
File Description
src/HotChocolate/Spatial/src/Types/GeoJsonResolvers.cs Adds MultiPolygon-specific coordinate shaping (rings per polygon) and a shared helper to extract polygon rings.
src/HotChocolate/Spatial/src/Types/GeoJsonMultiPolygonType.cs Switches coordinates field resolver from geometry-collection flattening to the new MultiPolygon-specific resolver.
src/HotChocolate/Spatial/test/Types.Tests/GeoJsonMultiPolygonTypeTests.cs Adds a new execution test covering polygons with and without holes to prevent regression.
src/HotChocolate/Spatial/test/Types.Tests/snapshots/GeoJsonMultiPolygonTypeTests.*.snap Updates and adds snapshots to assert the corrected per-polygon ring nesting.
Review details
  • Files reviewed: 5/5 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 (18/18)

File Covered Changed Patch %
…/HotChocolate/Spatial/src/Types/GeoJsonMultiPolygonType.cs 1 1 100.0% 🟢
src/HotChocolate/Spatial/src/Types/GeoJsonResolvers.cs 17 17 100.0% 🟢

Project coverage: 57.8% (287244/497254 lines)

@glen-84
glen-84 merged commit 298ba05 into main Sep 3, 2026
151 checks passed
@glen-84
glen-84 deleted the gai/multipolygon-nested-ring-coordinates branch September 3, 2026 14:07
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.

2 participants