zhangfengcdt commented on code in PR #2088:
URL: https://github.com/apache/sedona/pull/2088#discussion_r2201066692


##########
python/sedona/geopandas/sindex.py:
##########
@@ -196,7 +196,38 @@ def intersection(self, bounds):
         list
             List of indices of matching geometries.
         """
-        raise NotImplementedError("This method is not implemented yet.")
+        log_advice(
+            "`intersection` returns local list of indices of matching 
geometries onto driver's memory. "
+            "It should only be used if the resulting collection is expected to 
be small."
+        )
+
+        if self.is_empty:
+            return []
+
+        # Create a polygon from the bounds
+        from shapely.geometry import box
+
+        bbox = box(*bounds)
+
+        if self._is_spark:
+            # For Spark-based spatial index
+            from sedona.spark.core.spatialOperator import RangeQuery
+
+            # Execute the spatial range query with the bounding box
+            result_rdd = RangeQuery.SpatialRangeQuery(
+                self._indexed_rdd, bbox, True, True
+            )
+
+            results = result_rdd.collect()

Review Comment:
   The query(), intersection(), and nearest() all returns list in geopandas. 
This is different than the operators on GeoSeries / GeoDataframe for which it 
could return a new GeoSeries / GeoDataframe and chain another operators. 
   
   The sindex is basically an efficient way to "search" the spatial data 
instead of transform the data. So mostly of the cases, it should return to 
driver for the end users. 
   
   I might be misunderstanding the use of sindex though.
   



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