Repository navigation
[GH-2385] Implement is_ccw - #2386
yunchipang wants to merge 3 commits into
Conversation
petern48
left a comment
There was a problem hiding this comment.
Thanks again! I have some more feedback this time. But the PR looks great aside from a few more cases I'd like us to test.
| s = GeoSeries( | ||
| [ | ||
| LinearRing([(0, 0), (0, 1), (1, 1), (0, 0)]), | ||
| LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)]), |
There was a problem hiding this comment.
| LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)]), | |
| LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)]), | |
| LineString([(0, 0), (1, 1), (0, 1), (-1, -1)]), |
Let's add a line that isn't a full ring that should return True.
| LinearRing([(0, 0), (0, 1), (1, 1), (0, 0)]), | ||
| LinearRing([(0, 0), (1, 1), (0, 1), (0, 0)]), | ||
| LineString([(0, 0), (1, 1), (0, 1)]), | ||
| Point(3, 3), |
There was a problem hiding this comment.
| Point(3, 3), | |
| Point(3, 3), | |
| LineString(), | |
| MultiLineString([LineString([(0, 0), (1, 1), (0, 1), (-1, -1)])]), | |
| GeometryCollection([LineString([(0, 0), (1, 1), (0, 1), (-1, -1)])]), |
A few more cases, I'd like to test. The first is LINESTRING EMPTY. The other two are all collections of a single linestring that would return True. Make sure to validate that the expected result is the same as geopandas.
|
|
||
| def test_is_ccw(self): | ||
| pass | ||
| for geom in self.linestrings: |
There was a problem hiding this comment.
| for geom in self.linestrings: | |
| for geom in self.geoms: |
Since the docs explicitly specify the expected result for non-linear geometries is False, then we should test that they do correctly return that result.
There was a problem hiding this comment.
I didn't catch it originally (totally my bad), but the same goes for your other PR for is_closed since the docstring mentions the result should be False. Could you try updating it to self.geoms there too? I think it would pass, but it fails, we can instead leave alone and file a new (bug) issue to fix the implementation in a separate PR.
There was a problem hiding this comment.
Sure! I think in general, most should be pretty easy. As I just mentioned in the issue, I updated the list with corresponding Sedona functions. I'd recommend any of those, since I expect them to be straightforward. It's possible that some are not, but the only way to be sure is to try it out. I think most cases will be as simple as your is_closed PR.
| "is_ccw", | ||
| "Tests if LinearRing geometries are oriented counter-clockwise.", | ||
| ) | ||
| spark_expr = stf.ST_IsPolygonCCW(self.spark.column) |
There was a problem hiding this comment.
After seeing the test failures, I took a look at the documentation and implementation of ST_IsPolygonCCW function. Unfortunately, it doesn't look like ST_IsPolygonCCW will not work for us, since it only handles Polygons and returns False for all linestrings. Looking at the shapely implementation (which geopandas uses) is_ccw is a function with some custom logic, so there doesn't seem to be a direct function equivalent in Sedona currently.
This doesn't seem very easy to implement, so I think it's better to skip this one for now. Sorry about that @yunchipang
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes Geopandas: Implementis_ccw#2385What changes were proposed in this PR?
Implements
is_ccwHow was this patch tested?
Tests added
Did this PR include necessary documentation updates?