jiayuasu opened a new pull request, #3268:
URL: https://github.com/apache/sedona/pull/3268

   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor 
Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor 
Development Guide](https://sedona.apache.org/latest/community/develop/).
   
   ## Is this PR related to a ticket?
   
   - Yes, and the PR name follows the format `[GH-XXX] my subject`.
   
   Closes #3267.
   
   ## What changes were proposed in this PR?
   
   Sedona's compact Java geometry format already supports XY, XYZ, XYM, and 
XYZM coordinate-layout tags. However, `GeometrySerializer` selected one of 
those tags by inspecting only a geometry's first coordinate and checking 
whether its Z and M values were finite. This could silently discard recoverable 
ordinates before a geometry crossed a Spark `GeometryUDT` or Flink serializer 
boundary. For example, `LINESTRING Z (0 0 NaN, 1 1 3)` was encoded as XY 
because its first Z value is NaN, so the later finite Z value was lost.
   
   This PR makes dimensional inference and empty reconstruction loss-aware:
   
   - Inspect every coordinate sequence, including all polygon rings and 
multipart members, instead of only the first coordinate.
   - Use `CoordinateSequence` measure metadata to preserve XYM and XYZM layouts 
even when measure values are NaN.
   - Scan ambiguous three-spatial-dimension sequences for a finite Z beyond the 
first coordinate.
   - Preserve recoverable M and ZM metadata when empty Point and Polygon 
values, and their multipart children, are deserialized.
   - Reject recoverably heterogeneous layouts inside one Polygon or multipart 
geometry. The compact format has one coordinate-layout header for the entire 
value, so silently selecting or promoting a layout cannot preserve every 
component's identity. Heterogeneous layouts remain representable with a 
`GeometryCollection`.
   - Reject coordinate-sequence layouts wider than the format's existing XYZM 
model instead of silently truncating them.
   
   The wire format and its four existing coordinate-layout tag values do not 
change, so previously serialized data remains readable.
   
   There is one deliberate JTS boundary. JTS 1.20's default sequence factory 
represents both ordinary XY coordinates and declared XYZ coordinates whose Z 
values are all NaN as `dimension=3, measures=0`. Once JTS has made those 
representations identical, the serializer cannot recover the original 
declaration. This PR keeps the existing XY normalization for that ambiguous 
case instead of promoting ordinary XY payloads to XYZ. Zero-member multipart 
and geometry-collection values similarly expose no child sequence from which to 
recover a declared dimension.
   
   This is a pre-existing GeometrySerde issue identified while reviewing #3266, 
and is intentionally separate from the new equality predicate.
   
   ## How was this patch tested?
   
   - `mvn -pl common test`: 1,298 tests passed.
   - Focused `GeometryDimensionSerdeTest`: 6 tests passed.
   - All geometry-serde pattern tests: 51 tests passed.
   - Spotless, repository commit hooks, and `git diff --check` passed.
   
   The new regression suite covers leading-NaN XYZ/XYM/XYZM values, later 
multipart members establishing a layout, all-NaN measure metadata, recoverable 
typed empty values and children, heterogeneous GeometryCollection children, 
mixed-layout rejection, and ordinary default-JTS XY normalization.
   
   ## Did this PR include necessary documentation updates?
   
   - No, this PR does not affect any public API, so no documentation update is 
required. The representation boundary and compatibility behavior are documented 
in #3267 and in the serializer comments and tests.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to