Copilot commented on code in PR #2766:
URL: https://github.com/apache/sedona/pull/2766#discussion_r2958173329
##########
python/tests/geopandas/test_geoseries.py:
##########
@@ -1919,6 +1919,60 @@ def test_line_merge(self):
df_result = s.to_geoframe().line_merge()
self.check_sgpd_equals_gpd(df_result, expected)
+ def test_build_area(self):
+ # build_area is an aggregate operation: all linework is combined,
+ # then areas are built from the combined noded linework.
+ s = GeoSeries(
+ [
+ LineString([(0, 0), (1, 0)]),
+ LineString([(1, 0), (0.5, 1)]),
+ LineString([(0.5, 1), (0, 0)]),
+ ]
+ )
+ result = s.build_area()
+ assert result.name == "polygons"
+ assert len(result) == 1
+ expected_poly = Polygon([(1, 0), (0, 0), (0.5, 1), (1, 0)])
+ self.check_geom_equals(result.iloc[0], expected_poly)
+
+ # Check that GeoDataFrame works too
+ df_result = s.to_geoframe().build_area()
+ assert df_result.name == "polygons"
+ assert len(df_result) == 1
+ self.check_geom_equals(df_result.iloc[0], expected_poly)
+
+ # Test empty GeoSeries
+ result_empty = GeoSeries([]).build_area()
+ assert len(result_empty) == 0
+ assert result_empty.name == "polygons"
+
+ def test_polygonize(self):
+ # polygonize is an aggregate operation: all linework is combined,
+ # then polygons are formed from the combined noded linework.
+ s = GeoSeries(
+ [
+ LineString([(0, 0), (1, 0), (1, 1), (0, 1), (0, 0)]),
+ LineString([(1, 0), (2, 0), (2, 1), (1, 1)]),
+ ]
+ )
+ result = s.polygonize()
+ assert result.name == "polygons"
+ assert len(result) == 2
+
+ # Check that GeoDataFrame works too
+ df_result = s.to_geoframe().polygonize()
+ assert df_result.name == "polygons"
+ assert len(df_result) == 2
Review Comment:
The `test_polygonize` unit test only asserts the output name and length.
Since polygonize can return multiple polygons and ordering/contents can vary,
this test should also assert the actual polygon geometries match the expected
shapes (e.g., two adjacent polygons produced by the provided linework), to
catch regressions where the count is correct but the polygons are wrong/empty.
##########
python/tests/geopandas/test_geoseries.py:
##########
@@ -2635,6 +2716,42 @@ def test_relate(self):
expected = pd.Series(["FF2F11212", "212101212"])
self.check_pd_series_equal(result, expected)
+ def test_relate_pattern(self):
+ s = GeoSeries(
+ [
+ Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]),
+ Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]),
+ Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]),
+ ]
+ )
+ s2 = GeoSeries(
+ [
+ Point(1, 1), # interior → contains pattern matches
+ Point(0, 0), # boundary → contains pattern fails
+ Point(3, 3), # exterior → contains pattern fails
+ ]
+ )
+
+ # Test contains_properly pattern: T**FF*FF*
+ result = s.relate_pattern(s2, "T**FF*FF*", align=False)
+ expected = pd.Series([True, False, False])
+ self.check_pd_series_equal(result, expected)
+
+ # Test intersects pattern: T********
Review Comment:
The comment labels `"T********"` as an "intersects" pattern, but that
pattern specifically requires a non-empty interior–interior intersection and
will be False for boundary-only contacts (as reflected by the expected values
here). Consider updating the comment to describe what the pattern actually
tests to avoid confusing it with the `intersects` predicate.
##########
python/sedona/spark/geopandas/base.py:
##########
@@ -3399,7 +3472,64 @@ def contains(self, other, align=None):
return _delegate_to_geometry_column("contains", self, other, align)
def contains_properly(self, other, align=None):
- raise NotImplementedError("This method is not implemented yet.")
+ """Returns a ``Series`` of ``dtype('bool')`` with value ``True`` for
+ each aligned geometry that properly contains `other`.
+
+ An object is said to properly contain `other` if the `other` object
+ lies entirely within the `interior` of the object (no shared boundary
+ points).
+
+ The operation works on a 1-to-1 row-wise manner.
Review Comment:
Minor grammar: "works on a 1-to-1 row-wise manner" reads awkwardly. Consider
changing to "works in a 1-to-1 row-wise manner" (or "works in a 1-to-1,
row-wise manner") for clarity.
##########
python/sedona/spark/geopandas/base.py:
##########
@@ -3472,6 +3602,66 @@ def relate(self, other, align=None):
"""
return _delegate_to_geometry_column("relate", self, other, align)
+ def relate_pattern(self, other, pattern, align=None):
+ """Returns a ``Series`` of ``dtype('bool')`` with value ``True`` if the
+ DE-9IM relationship between each geometry and `other` matches the
+ specified `pattern`.
+
+ The operation works on a 1-to-1 row-wise manner.
Review Comment:
Minor grammar: "works on a 1-to-1 row-wise manner" should be "works in a
1-to-1 row-wise manner" for readability.
--
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]