petern48 commented on code in PR #2512:
URL: https://github.com/apache/sedona/pull/2512#discussion_r2548354107
##########
python/tests/geopandas/test_geoseries.py:
##########
@@ -1520,7 +1520,79 @@ def test_force_2d(self):
self.check_sgpd_equals_gpd(df_result, expected)
def test_force_3d(self):
- pass
+ # 1. 2D geometries promoted to 3D with default z=0.0
+ s = sgpd.GeoSeries(
+ [
+ Point(1, 2),
+ Point(0.5, 2.5, 2),
+ Point(1, 1, np.nan),
+ LineString([(1, 1), (0, 1), (1, 0)]),
+ Polygon([(0, 0), (0, 10), (10, 10)]),
+ GeometryCollection(
+ [
+ Point(1, 1),
+ LineString([(1, 1), (0, 1), (1, 0)]),
+ ]
+ ),
+ ]
+ )
+ # Promote 2D to 3D with z=0, keep 3D as is
+ expected = gpd.GeoSeries(
+ [
+ Point(1, 2, 0),
+ Point(0.5, 2.5, 2),
+ Point(1, 1, 0),
+ LineString([(1, 1, 0), (0, 1, 0), (1, 0, 0)]),
+ Polygon([(0, 0, 0), (0, 10, 0), (10, 10, 0), (0, 0, 0)]),
+ GeometryCollection(
+ [
+ Point(1, 1, 0),
+ LineString([(1, 1, 0), (0, 1, 0), (1, 0, 0)]),
+ ]
+ ),
+ ]
+ )
+ result = s.force_3d()
+ self.check_sgpd_equals_gpd(result, expected)
+
+ # 2. 2D geometries promoted to 3D with scalar z
+ expected = gpd.GeoSeries(
+ [
+ Point(1, 2, 4),
+ Point(0.5, 2.5, 2),
+ Point(1, 1, 4),
+ LineString([(1, 1, 4), (0, 1, 4), (1, 0, 4)]),
+ Polygon([(0, 0, 4), (0, 10, 4), (10, 10, 4), (0, 0, 4)]),
+ GeometryCollection(
+ [
+ Point(1, 1, 4),
+ LineString([(1, 1, 4), (0, 1, 4), (1, 0, 4)]),
+ ]
+ ),
+ ]
+ )
+ result = s.force_3d(4)
+ self.check_sgpd_equals_gpd(result, expected)
+
+ # 3. Array-like z: use ps.Series
+ z = [0, 2, 2, 3, 4, 5]
+ expected = gpd.GeoSeries(
+ [
+ Point(1, 2, 0),
+ Point(0.5, 2.5, 2),
+ Point(1, 1, 2),
+ LineString([(1, 1, 2), (0, 1, 2), (1, 0, 2)]),
+ Polygon([(0, 0, 3), (0, 10, 3), (10, 10, 3), (0, 0, 3)]),
Review Comment:
```suggestion
LineString([(1, 1, 3), (0, 1, 3), (1, 0, 3)]),
Polygon([(0, 0, 4), (0, 10, 4), (10, 10, 4), (0, 0, 4)]),
```
I noticed our tests here were slightly buggy. Here's what the expected
results should look like. These geoms correspond to the 3 and 4 in `z = [0, 2,
2, 3, 4, 5]`. What's concerning is that the tests pass anyway. Experimenting
locally, I noticed we can change the z-coordinate however we like, and the
tests still pass. I think what's happening is that the
`check_sgpd_equals_gpd()` doesn't yet check anything past the x and y
dimensions...
(sigh) Unfortunately, what this means is that we'll need to modify the test
code to test this properly before we can merge this PR. I filed an issue for
this: https://github.com/apache/sedona/issues/2513. You're welcome to try
taking a stab at it or just move on to something else (while keeping this PR
open). My time is limited, so I wouldn't be able to investigate it for at least
a few days. I don't love having to put a hold on merging your great work here,
but this is just how it is sometimes. Sorry about this :(
--
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]