jiayuasu commented on code in PR #2975:
URL: https://github.com/apache/sedona/pull/2975#discussion_r3276153520
##########
common/src/main/java/org/apache/sedona/common/S2Geography/WKBWriter.java:
##########
@@ -358,20 +373,21 @@ private void writeMultiPolygon(int geometryType,
MultiPolygonGeography multiPoly
List<S2Loop> loops = s2poly.polygon.getLoops();
writeInt(loops.size(), os);
- // 4c) For each ring, write vertex count + coords
+ // 4c) For each ring, write vertex count + coords.
+ // Emit N+1 vertices with last == first for OGC WKB compliance; see the
+ // explanatory comment in writePolygon(). Degenerate empty rings
+ // (n == 0) keep the prior behavior of writing a 0-point ring.
for (S2Loop loop : loops) {
int n = loop.numVertices();
- writeInt(n, os);
- for (int i = 0; i < n; i++) {
- S2LatLng ll = new S2LatLng(loop.vertex(i));
- double lon = ll.lngDegrees();
- double lat = ll.latDegrees();
-
- // X (lon) then Y (lat)—matches Point/LineString ordering
- ByteOrderValues.putDouble(lon, buf, byteOrder);
- os.write(buf, 8);
- ByteOrderValues.putDouble(lat, buf, byteOrder);
- os.write(buf, 8);
+ if (n == 0) {
Review Comment:
This code seems to be duplicate of Line 327?
--
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]