You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@sedona.apache.org by "petern48 (via GitHub)" <gi...@apache.org> on 2026/06/01 22:41:57 UTC
Re: [PR] [GH-3017] Implement rotate [sedona]
petern48 commented on code in PR #3018:
URL: https://github.com/apache/sedona/pull/3018#discussion_r3330946989
##########
python/tests/geopandas/test_match_geopandas_series.py:
##########
@@ -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))
Review Comment:
can we update these to an origin other than `(0, 0)`, just to make sure it works? maybe something like `(1, 2)`.
can we also add add a case for testing `"centroid"` and a `Point()` object as input for origin field to make sure they work?
##########
python/sedona/spark/geopandas/base.py:
##########
@@ -1362,6 +1362,56 @@ def segmentize(self, max_segment_length):
# def transform(self, transformation, include_z=False):
# raise NotImplementedError("This method is not implemented yet.")
+ def rotate(self, angle, origin="center", use_radians=False):
+ """Return a ``GeoSeries`` with rotated geometries.
+
+ See http://shapely.readthedocs.io/en/latest/manual.html#shapely.affinity.rotate
+ for details.
+
+ Parameters
+ ----------
+ angle : float
+ The angle of rotation can be specified in either degrees (default)
+ or radians by setting use_radians=True. Positive angles are
+ counter-clockwise and negative are clockwise rotations.
+ origin : string, Point, or tuple (x, y)
+ The point of origin can be a keyword 'center' for the bounding box
+ center (default), 'centroid' for the geometry's centroid, a Point
+ object or a coordinate tuple (x, y).
+ use_radians : boolean
+ Whether to interpret the angle of rotation as degrees or radians
+
+ Examples
+ --------
+ >>> from shapely.geometry import Point, LineString, Polygon
+ >>> s = geopandas.GeoSeries(
Review Comment:
```suggestion
>>> from sedona.spark.geopandas import GeoSeries
>>> s = GeoSeries(
```
we should update the import for sedona instead of geopandas
##########
python/tests/geopandas/test_geoseries.py:
##########
@@ -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))
Review Comment:
`test_geoseries.py` should be testing the hard-coded expected outputs instead of comparing it directly to the result of what geopandas returns (that's what test_match_geopandas_series.py` is for. Could you update all of these examples to compare to the hard-coded expected output geometries?
--
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: issues-unsubscribe@sedona.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org