[GH-2830] Fix S2 Geography WKB writer to emit OGC-conformant polygon closure#2975
Open
zhangfengcdt wants to merge 4 commits into
Open
[GH-2830] Fix S2 Geography WKB writer to emit OGC-conformant polygon closure#2975zhangfengcdt wants to merge 4 commits into
zhangfengcdt wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Sedona’s S2Geography WKB serialization to emit OGC-conformant polygon rings by explicitly writing the closing vertex (last point equals first) for POLYGON and MULTIPOLYGON rings, and adds byte-level tests to enforce this invariant.
Changes:
- Update
WKBWriter.writePolygonto writenumVertices + 1coordinates per ring and duplicate the first vertex as the closing point. - Update
WKBWriter.writeMultiPolygonto apply the same N+1 ring closure behavior for each polygon/ring. - Add unit tests that parse the emitted WKB byte stream to verify ring point counts and closure for POLYGON and MULTIPOLYGON.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
common/src/main/java/org/apache/sedona/common/S2Geography/WKBWriter.java |
Writes OGC-closed rings by emitting an explicit closing coordinate for polygon rings. |
common/src/test/java/org/apache/sedona/common/S2Geography/WKBWriterTest.java |
Adds byte-level tests to assert ring closure for POLYGON and MULTIPOLYGON WKB output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jiayuasu
reviewed
May 20, 2026
| os.write(buf, 8); | ||
| ByteOrderValues.putDouble(lat, buf, byteOrder); | ||
| os.write(buf, 8); | ||
| if (n == 0) { |
Member
There was a problem hiding this comment.
This code seems to be duplicate of Line 327?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes #<issue_number>What changes were proposed in this PR?
Fix WKBGeography.getWKBBytes() to emit OGC-conformant (closed-ring) WKB.
How was this patch tested?
Did this PR include necessary documentation updates?