Skip to content

Commit 52f268b

Browse files
committed
Refactored the structure of tests
1 parent 819a3ee commit 52f268b

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

python/sedona/spark/geopandas/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ def force_3d(self, z=0.0):
955955
2D geometries will get the provided Z coordinate; 3D geometries
956956
are unchanged (unless their Z coordinate is ``np.nan``).
957957
958+
Note: Sedona's behavior may differ from Geopandas' for M and ZM geometries.
959+
For M geometries, Sedona will replace the M coordinate and add the Z coordinate.
960+
For ZM geometries, Sedona will drop the M coordinate and retain the Z coordinate.
961+
958962
Parameters
959963
----------
960964
z : float | array_like (default 0)

python/tests/geopandas/test_geoseries.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,22 @@ def test_force_3d(self):
15941594
result = s.force_3d(z)
15951595
self.check_sgpd_equals_gpd(result, expected)
15961596

1597+
# 4. Ensure M and ZM geometries are handled correctly
1598+
s = sgpd.GeoSeries(
1599+
[
1600+
shapely.wkt.loads("POINT M (1 2 3)"),
1601+
shapely.wkt.loads("POINT ZM (1 2 3 4)"),
1602+
]
1603+
)
1604+
result = s.force_3d(7.5)
1605+
expected = gpd.GeoSeries(
1606+
[
1607+
shapely.wkt.loads("POINT Z (1 2 7.5)"),
1608+
shapely.wkt.loads("POINT Z (1 2 3)"),
1609+
]
1610+
)
1611+
self.check_sgpd_equals_gpd(result, expected)
1612+
15971613
def test_line_merge(self):
15981614
pass
15991615

python/tests/geopandas/test_match_geopandas_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ def test_force_3d(self):
883883
pytest.skip("geopandas force_3d requires version 1.0.0 or higher")
884884
# 1) Promote 2D to 3D with z = 4
885885
for geom in self.geoms:
886-
if isinstance(geom[0], (LinearRing, GeometryCollection, MultiPolygon)):
886+
if isinstance(geom[0], (LinearRing)):
887887
continue
888888
sgpd_result = GeoSeries(geom).force_3d(4)
889889
gpd_result = gpd.GeoSeries(geom).force_3d(4)

0 commit comments

Comments
 (0)