Copilot commented on code in PR #2221:
URL: https://github.com/apache/sedona/pull/2221#discussion_r2252785058
##########
common/src/main/java/org/apache/sedona/common/S2Geography/S2Geography.java:
##########
@@ -24,6 +24,7 @@
import java.io.*;
import java.util.ArrayList;
import java.util.List;
+import org.locationtech.jts.geom.PrecisionModel;
Review Comment:
The PrecisionModel import is only used in the new toString methods but
WKTWriter is not imported. This suggests either missing imports or the
WKTWriter class needs to be properly imported.
```suggestion
import org.locationtech.jts.geom.PrecisionModel;
import org.locationtech.jts.io.WKTWriter;
```
##########
common/src/main/java/org/apache/sedona/common/S2Geography/PolylineGeography.java:
##########
@@ -58,6 +58,12 @@ public PolylineGeography(List<S2Polyline> polylines) {
this.polylines = new ArrayList<>(polylines);
}
+ public PolylineGeography(GeographyKind kind, S2Polyline polyline) {
+ super(kind);
Review Comment:
The new constructor accepts any GeographyKind but should validate that the
kind is appropriate for polyline geography (e.g., POLYLINE or SINGLEPOLYLINE)
to prevent misuse.
```suggestion
super(kind);
if (kind != GeographyKind.POLYLINE && kind !=
GeographyKind.SINGLEPOLYLINE) {
throw new IllegalArgumentException("Invalid GeographyKind for
PolylineGeography: " + kind);
}
```
##########
common/src/main/java/org/apache/sedona/common/S2Geography/PolylineGeography.java:
##########
@@ -137,6 +143,10 @@ public static PolylineGeography decode(UnsafeInput in,
EncodeTag tag) throws IOE
// 5) Read the number of polylines (4-byte)
int count = in.readInt();
+ if (tag.getKind() == GeographyKind.SINGLEPOLYLINE) {
+ return new SinglePolylineGeography(S2Polyline.decode(in));
+ }
+
Review Comment:
The SINGLEPOLYLINE decoding logic creates a SinglePolylineGeography but then
continues to read the count variable, which may be wasteful. Consider
restructuring to handle single polyline cases before reading the count.
```suggestion
```
--
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]