jiayuasu commented on code in PR #2701:
URL: https://github.com/apache/sedona/pull/2701#discussion_r2910163693


##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -1105,8 +1114,11 @@ def force_3d(self, z=0.0) -> "GeoSeries":
         )
 
     def line_merge(self, directed=False):
-        # Implementation of the abstract method.
-        raise NotImplementedError("This method is not implemented yet.")
+        spark_expr = stf.ST_LineMerge(self.spark.column)
+        return self._query_geometry_column(
+            spark_expr,
+            returns_geom=True,
+        )

Review Comment:
   Resolved — `line_merge` has been removed from this PR entirely. It's 
deferred to a follow-up PR pending the fix for the underlying Sedona bug 
(#2702).



##########
python/sedona/spark/geopandas/base.py:
##########
@@ -1015,8 +1093,40 @@ def force_3d(self, z=0.0):
         """
         return _delegate_to_geometry_column("force_3d", self, z)
 
-    # def line_merge(self, directed=False):
-    #     raise NotImplementedError("This method is not implemented yet.")
+    def line_merge(self, directed=False):
+        """Return merged LineStrings.
+
+        Returns a ``GeoSeries`` of (Multi)LineStrings, where connected
+        LineStrings are merged together into single LineStrings.
+
+        Parameters
+        ----------
+        directed : bool, default False
+            Currently not supported by Sedona.
+
+        Returns
+        -------
+        GeoSeries
+
+        Examples
+        --------
+        >>> from sedona.spark.geopandas import GeoSeries
+        >>> from shapely.geometry import MultiLineString, LineString
+        >>> s = GeoSeries(
+        ...     [
+        ...         MultiLineString([[(0, 0), (1, 1)], [(1, 1), (2, 2)]]),
+        ...         MultiLineString([[(0, 0), (1, 1)], [(2, 2), (3, 3)]]),
+        ...         LineString([(0, 0), (1, 1)]),
+        ...     ]
+        ... )
+        >>> s.line_merge()
+        0                     LINESTRING (0 0, 1 1, 2 2)
+        1    MULTILINESTRING ((0 0, 1 1), (2 2, 3 3))
+        2                         LINESTRING (0 0, 1 1)

Review Comment:
   Resolved — `line_merge` has been removed from this PR entirely (including 
the docstring). It's deferred to a follow-up PR pending the fix for #2702.



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