jiayuasu commented on code in PR #2088:
URL: https://github.com/apache/sedona/pull/2088#discussion_r2201089257
##########
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:
make sense!
--
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]