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


##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -792,30 +792,27 @@ def is_empty(self) -> pspd.Series:
         return _to_bool(result)
 
     def count_coordinates(self):
-        # Implementation of the abstract method.
-        raise NotImplementedError(
-            _not_implemented_error(
-                "count_coordinates",
-                "Counts the number of coordinate tuples in each geometry.",
-            )
+        spark_expr = stf.ST_NPoints(self.spark.column)
+        return self._query_geometry_column(
+            spark_expr,
+            returns_geom=False,
         )
 
     def count_geometries(self):
-        # Implementation of the abstract method.
-        raise NotImplementedError(
-            _not_implemented_error(
-                "count_geometries",
-                "Counts the number of geometries in each multi-geometry or 
collection.",
-            )
+        spark_expr = stf.ST_NumGeometries(self.spark.column)
+        return self._query_geometry_column(
+            spark_expr,
+            returns_geom=False,
         )
 
     def count_interior_rings(self):
-        # Implementation of the abstract method.
-        raise NotImplementedError(
-            _not_implemented_error(
-                "count_interior_rings",
-                "Counts the number of interior rings (holes) in each polygon.",
-            )
+        # Sedona's ST_NumInteriorRings returns NULL for non-polygon geometries
+        # (including MultiPolygon). GeoPandas semantics require 0 for
+        # non-polygon and empty geometries, so we wrap with coalesce.
+        spark_expr = F.coalesce(stf.ST_NumInteriorRings(self.spark.column), 
F.lit(0))
+        return self._query_geometry_column(
+            spark_expr,
+            returns_geom=False,
         )

Review Comment:
   Keeping `coalesce` as-is. NULL geometry inputs are uncommon in practice 
(GeoSeries are typically constructed from actual geometries), and the behavior 
is consistent with geopandas where 
`gpd.GeoSeries([None]).count_interior_rings()` also doesn't preserve None as a 
distinct state. No other GeoSeries method in the codebase adds explicit 
NULL-input guarding either.



##########
python/sedona/spark/geopandas/base.py:
##########
@@ -1093,8 +1303,39 @@ 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
+            Only ``directed=False`` is supported. Passing ``directed=True``
+            will raise ``NotImplementedError``.
+
+        Returns
+        -------
+        GeoSeries
+

Review Comment:
   Already fixed in abb62d9. The docstring now reads: "Only ``directed=False`` 
is supported. Passing ``directed=True`` will raise ``NotImplementedError``."



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