petern48 commented on code in PR #2071:
URL: https://github.com/apache/sedona/pull/2071#discussion_r2199003816


##########
python/sedona/geopandas/geoseries.py:
##########
@@ -829,9 +829,78 @@ def get_precision(self):
         # Implementation of the abstract method
         raise NotImplementedError("This method is not implemented yet.")
 
-    def get_geometry(self, index):
-        # Implementation of the abstract method
-        raise NotImplementedError("This method is not implemented yet.")
+    def get_geometry(self, index) -> "GeoSeries":
+        """Returns the n-th geometry from a collection of geometries.
+
+        Parameters
+        ----------
+        index : int or array_like
+            Position of a geometry to be retrieved within its collection
+
+        Returns
+        -------
+        GeoSeries
+
+        Notes
+        -----
+        Simple geometries act as collections of length 1. Any out-of-range 
index value
+        returns None.
+
+        Examples
+        --------
+        >>> from shapely.geometry import Point, MultiPoint, GeometryCollection
+        >>> s = geopandas.GeoSeries(
+        ...     [

Review Comment:
   Polygon Empty isn't special, but MultiPolygon Empty is interesting, since 
it's a collection. Our `ST_GeometryN` errors when we use a negative index out 
of scope of the length of the Multi geometry object.
   
   e.g
   ```sql
   SELECT ST_GeometryN(MultiPolygon(Point(1, 1)), -2);  -- errors
   
   SELECT ST_GeometryN(MultiPolygon(), -1);  -- errors
   ```
   
   Geopandas returns null in this case. PostGIS also returns null in this case 
(the PostGIS implementation is already very different than ours since they use 
1-indexing).
   
   We can either fix this on the java Sedona level, Python dataframe level or 
just the geopandas level (case statement). Which do you think @jiayuasu ?



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