-
Notifications
You must be signed in to change notification settings - Fork 765
[GH-3017] Implement rotate #3018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1847,6 +1847,44 @@ def test_segmentize(self): | |
| def test_transform(self): | ||
| pass | ||
|
|
||
| def test_rotate(self): | ||
| geoms = [ | ||
| Point(1, 1), | ||
| LineString([(1, -1), (1, 0)]), | ||
| Polygon([(3, -1), (4, 0), (3, 1)]), | ||
| None, | ||
| ] | ||
| s = GeoSeries(geoms) | ||
| gpd_s = gpd.GeoSeries(geoms) | ||
|
|
||
| # Test default (degrees, origin='center') | ||
| self.check_sgpd_equals_gpd(s.rotate(90), gpd_s.rotate(90)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # Test with explicit origin tuple | ||
| self.check_sgpd_equals_gpd( | ||
| s.rotate(90, origin=(0, 0)), gpd_s.rotate(90, origin=(0, 0)) | ||
| ) | ||
|
|
||
| # Test use_radians | ||
| import math | ||
|
|
||
| self.check_sgpd_equals_gpd( | ||
| s.rotate(math.pi / 2, use_radians=True), | ||
| gpd_s.rotate(math.pi / 2, use_radians=True), | ||
| ) | ||
|
|
||
| # Test origin='centroid' | ||
| self.check_sgpd_equals_gpd( | ||
| s.rotate(45, origin="centroid"), gpd_s.rotate(45, origin="centroid") | ||
| ) | ||
|
|
||
| # Test GeoDataFrame works too | ||
| self.check_sgpd_equals_gpd(s.to_geoframe().rotate(90), gpd_s.rotate(90)) | ||
|
|
||
| # Test invalid origin | ||
| with pytest.raises((ValueError, TypeError)): | ||
| s.rotate(90, origin="invalid") | ||
|
|
||
| def test_force_2d(self): | ||
| s = sgpd.GeoSeries( | ||
| [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -956,6 +956,17 @@ def test_segmentize(self): | |
| def test_transform(self): | ||
| pass | ||
|
|
||
| def test_rotate(self): | ||
| for geom in self.geoms: | ||
| # Sedona converts empty geometries to None, skip them | ||
| if not gpd.GeoSeries(geom).is_empty.any(): | ||
| sgpd_result = GeoSeries(geom).rotate(45) | ||
| gpd_result = gpd.GeoSeries(geom).rotate(45) | ||
| self.check_sgpd_equals_gpd(sgpd_result, gpd_result) | ||
| sgpd_result = GeoSeries(geom).rotate(45, origin=(0, 0)) | ||
| gpd_result = gpd.GeoSeries(geom).rotate(45, origin=(0, 0)) | ||
|
Comment on lines
+966
to
+967
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we update these to an origin other than can we also add add a case for testing |
||
| self.check_sgpd_equals_gpd(sgpd_result, gpd_result) | ||
|
|
||
| def test_force_2d(self): | ||
| # force_2d was added from geopandas 1.0.0 | ||
| if parse_version(gpd.__version__) < parse_version("1.0.0"): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should update the import for sedona instead of geopandas