-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from SpatioTemporal/antimeridian
Fix for CCW detection
- Loading branch information
Showing
5 changed files
with
975 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import starepandas | ||
import shapely | ||
|
||
|
||
def test_antimeridan_crossing(): | ||
# Polygon crossing antimeridian in the pacific | ||
# This polygon IS CCW, however shapely will tell us it is not CCW | ||
lons = [-100, 160, 165, -160, 170, -100] | ||
lats = [25, 20, -25, -20, 0, 25] | ||
polygon = shapely.geometry.Polygon(zip(lons, lats)) | ||
ring = polygon.exterior | ||
assert ring.is_ccw == False | ||
assert starepandas.spatial_conversions.ring_is_ccw(ring) == True | ||
|
||
|
||
def test_northpole(): | ||
# Polygon around the northpole | ||
# This polygon IS CCW, however shapely will tell us it is not CCW | ||
lons = [0, 90, 180, -90] | ||
lats = [50, 50, 50, 50] | ||
polygon = shapely.geometry.Polygon(zip(lons, lats)) | ||
ring = polygon.exterior | ||
assert ring.is_ccw == False | ||
assert starepandas.spatial_conversions.ring_is_ccw(ring) == True | ||
|
||
|
||
def test_southpole(): | ||
# Polygon around the northpole | ||
# This polygon IS not CCW, and shapely will tell us it is not CCW | ||
lons = [0, 90, 180, -90] | ||
lats = [-50, -50, -50, -50] | ||
polygon = shapely.geometry.Polygon(zip(lons, lats)) | ||
ring = polygon.exterior | ||
assert ring.is_ccw == False | ||
assert starepandas.spatial_conversions.ring_is_ccw(ring) == False |