Skip to content

[GH-2028] Implementations of GeographyCollection & ShapeIndexGeography on S2Geography Apache Sedona#2027

Merged
jiayuasu merged 25 commits into
apache:masterfrom
ZhuochengShang:zshang-v2
Jul 9, 2025
Merged

[GH-2028] Implementations of GeographyCollection & ShapeIndexGeography on S2Geography Apache Sedona#2027
jiayuasu merged 25 commits into
apache:masterfrom
ZhuochengShang:zshang-v2

Conversation

@ZhuochengShang
Copy link
Copy Markdown
Collaborator

@ZhuochengShang ZhuochengShang commented Jun 30, 2025

What changes were proposed in this PR?

  1. GeographyCollection class, which takes List
  2. Encode / decode functions of GeographyCollection object
  3. ShapeIndexGeography class, which creates by taking empty, S2Geography or maxEdgesPerCell;
  4. ShapeIndexGeography supports addIndex which assigns input S2Geography with index based on S2ShapeIndex add function.
  5. ShapeIndexGeography only contains encode function, using VectorCoder encoding.
  6. EncodedShapeIndexGeography class supports only decode function, using VectorCoder decoding. It automatically decode EncodedShapeIndexGeography based on corresponding geography type. This class also supports addIndex same as ShapeIndexGeography.

@ZhuochengShang ZhuochengShang requested a review from jiayuasu as a code owner June 30, 2025 16:44
@ZhuochengShang ZhuochengShang requested review from Kontinuation and removed request for jiayuasu June 30, 2025 16:44
@ZhuochengShang ZhuochengShang changed the title [GH-] Implementations of GeographyCollection & ShapeIndexGeography on S2Geography Apache Sedona [GH-2028] Implementations of GeographyCollection & ShapeIndexGeography on S2Geography Apache Sedona Jun 30, 2025
@jiayuasu
Copy link
Copy Markdown
Member

jiayuasu commented Jul 2, 2025

@ZhuochengShang please resolve the conflicts

Comment thread common/src/main/java/org/apache/sedona/common/S2Geography/GeographyIndex.java Outdated
@jiayuasu jiayuasu requested a review from Kontinuation July 9, 2025 01:32
Copy link
Copy Markdown
Member

@Kontinuation Kontinuation left a comment

Choose a reason for hiding this comment

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

It looks good to me. Can you update the description of this PR and remove unnecessary contents came from the PR template?

@jiayuasu jiayuasu requested a review from Copilot July 9, 2025 18:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for serializing collections of geographies and indexed geometries using S2ShapeIndex, along with tests to verify round-trip encoding/decoding.

  • Introduce GeographyCollection for wrapping multiple S2Geography with full encode/decode support
  • Implement ShapeIndexGeography and EncodedShapeIndexGeography classes to build and serialize shape indexes
  • Update S2Geography.decode to route new GEOGRAPHY_COLLECTION and SHAPE_INDEX kinds properly
  • Add GeographyIndex utility for mapping shapes to user values
  • Provide unit tests covering collection behavior and shape-index serialization

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
common/src/test/java/org/apache/sedona/common/S2Geography/ShapeIndexGeographyTest.java New tests for encode/decode round trip of shape-index geography
common/src/test/java/org/apache/sedona/common/S2Geography/GeographyCollectionTest.java New tests for empty, mixed, and round-trip behaviors of GeographyCollection
common/src/main/java/org/apache/sedona/common/S2Geography/ShapeIndexGeography.java Adds ShapeIndexGeography implementation and encode logic, stub decode
common/src/main/java/org/apache/sedona/common/S2Geography/EncodedShapeIndexGeography.java Implements decode for encoded shape-index geography
common/src/main/java/org/apache/sedona/common/S2Geography/GeographyCollection.java Implements GeographyCollection wrapping, encode/decode, and shape dispatch
common/src/main/java/org/apache/sedona/common/S2Geography/S2Geography.java Updates static decode switch to handle GEOGRAPHY_COLLECTION and SHAPE_INDEX cases
common/src/main/java/org/apache/sedona/common/S2Geography/GeographyIndex.java Introduces GeographyIndex for associating shapes with integer values
common/src/main/java/org/apache/sedona/common/S2Geography/PolygonGeography.java Removes redundant commented line in encode override

@jiayuasu
Copy link
Copy Markdown
Member

jiayuasu commented Jul 9, 2025

@ZhuochengShang Please check if the copilot comments make sense or not

@jiayuasu jiayuasu added this to the sedona-1.8.0 milestone Jul 9, 2025
@jiayuasu jiayuasu merged commit 29bfc99 into apache:master Jul 9, 2025
34 checks passed
Kontinuation pushed a commit to Kontinuation/sedona that referenced this pull request Jan 21, 2026
…ography on S2Geography (apache#2027)

* Create object of S2Geography, and implement PoinGeography with its encoder/decoder

* Add POLYLINE implementation on S2Geography

* Add POLYGON implements on S2Geography

* Match coding style

* "Apply Spotless formatting to PolylineGeographyTest"

* Redesign of S2Geography

- Import org.datasyslab s2-geometry-library
- Clean up S2Geography abstract design
- Update Encode/Decode inside each kind of geography

* clean up unnecessary files in current branch

* Refine design of EncodeTagged in S2Geography

- Adding back EncodeTagged in S2Geography
- Let each geography type calls its own encode / decode function
- Change to use Kyro UnsafeInput and UnsafeOutput

* Modify encoder() and add new test cases

* clean up code of encode and clarify comments

* Update POLYGON to only take one polygon

* Remove S2Regionwrapper & S2Shapewrapper

* clean up minor issue

* GeographyCollection and ShapeIndexGeography implementation

* comcomment geography kind in S2Geography

* format violation

* Adjust Shapeindexgeography encode/decode and shapeID

* Clean up format

* change addIndex return type to void

* minor changes for GeographyCollection encode

* clear format
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.

[GH-2028] Implementations of GeographyCollection & ShapeIndexGeography on S2Geography Apache Sedona

5 participants