Copilot commented on code in PR #2828:
URL: https://github.com/apache/sedona/pull/2828#discussion_r3045865432


##########
python/sedona/spark/geopandas/base.py:
##########
@@ -994,8 +994,50 @@ def extract_unique_points(self):
         """
         return _delegate_to_geometry_column("extract_unique_points", self)
 
-    # def offset_curve(self, distance, quad_segs=8, join_style="round", 
mitre_limit=5.0):
-    #     raise NotImplementedError("This method is not implemented yet.")
+    def offset_curve(self, distance, quad_segs=8, join_style="round", 
mitre_limit=5.0):
+        """Returns a line at a given offset distance from each linear geometry.
+
+        Positive distance offsets to the left, negative to the right.
+

Review Comment:
   The PR description says this change "does not affect any public API", but 
this diff adds new public `GeoSeries`/`GeoDataFrame`-level methods 
(`offset_curve`, `shortest_line`). Please either update the PR description to 
reflect that this is a public API addition, or add any required user-facing 
docs/release-note entry per project expectations for new GeoPandas-compat APIs.



##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -1058,8 +1058,13 @@ def extract_unique_points(self):
         )
 
     def offset_curve(self, distance, quad_segs=8, join_style="round", 
mitre_limit=5.0):
-        # Implementation of the abstract method.
-        raise NotImplementedError("This method is not implemented yet.")
+        # ST_OffsetCurve returns null for empty geometries, but GeoPandas 
returns LINESTRING EMPTY
+        empty_line = stc.ST_GeomFromText(F.lit("LINESTRING EMPTY"))
+        spark_col = F.when(
+            stf.ST_IsEmpty(self.spark.column),
+            empty_line,
+        ).otherwise(stf.ST_OffsetCurve(self.spark.column, distance, quad_segs))

Review Comment:
   `offset_curve` replaces empty input geometries with 
`ST_GeomFromText('LINESTRING EMPTY')`, which will have SRID=0. If the input 
GeoSeries has CRS set (via SRID), this can silently drop CRS for results (e.g., 
if the first non-null row is empty, `GeoSeries.crs` will become `None`). 
Consider constructing the empty geometry with the input SRID (e.g., pass 
`ST_SRID(self.spark.column)` as the `srid` arg to `ST_GeomFromText`, or 
`ST_SetSRID` on the empty geometry) so CRS/SRID is preserved even for empty 
rows.



-- 
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