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


##########
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.
+
+        Parameters
+        ----------
+        distance : float or array-like
+            The offset distance. Positive offsets to the left, negative to the
+            right.
+        quad_segs : int, default 8
+            Number of segments to approximate a quarter circle.
+        join_style : str, default "round"
+            Accepted values are "round", "mitre", and "bevel".
+
+            .. note::
+               ``join_style`` and ``mitre_limit`` are accepted for API
+               compatibility but are currently ignored by Sedona's
+               ``ST_OffsetCurve``.

Review Comment:
   The docstring states `join_style` accepts only "round", "mitre", and 
"bevel", but the implementation currently ignores `join_style` and does not 
validate it. Either validate and raise a clear error on unsupported values (to 
match the documented contract), or update the docstring to note that any value 
is accepted/ignored for compatibility.
   ```suggestion
               Join style parameter accepted for API compatibility.
   
               .. note::
                  ``join_style`` and ``mitre_limit`` are accepted for API
                  compatibility but are currently ignored by Sedona's
                  ``ST_OffsetCurve``. Any value is therefore accepted and has
                  no effect at present.
   ```



##########
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),

Review Comment:
   `GeoSeries.offset_curve` forwards `distance` directly into 
`stf.ST_OffsetCurve`, so array-like / per-row distances (e.g., a Series) are 
not supported even though the public docstring advertises them. Consider either 
implementing per-row distances via `_make_series_of_val(distance)` + 
`_row_wise_operation(...)` (like `segmentize`), or explicitly rejecting 
non-scalar `distance` with a clear `NotImplementedError` (and aligning the 
docstring accordingly) to avoid confusing type-validation errors from 
`stf.ST_OffsetCurve`.



##########
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.
+
+        Parameters
+        ----------
+        distance : float or array-like
+            The offset distance. Positive offsets to the left, negative to the
+            right.

Review Comment:
   The docstring says `distance` can be "float or array-like", but the current 
GeoSeries implementation only supports scalar distances. Please either adjust 
this docstring to reflect the actual supported inputs, or extend the 
implementation to handle per-row distances.
   ```suggestion
           distance : float
               The scalar offset distance. Positive offsets to the left,
               negative to the right.
   ```



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