Skip to content

Commit

Permalink
Merge pull request #2083 from greglucas/qulogic-delete-proj-geos
Browse files Browse the repository at this point in the history
Remove GEOS dependency in favor of Shapely
  • Loading branch information
greglucas authored Jul 14, 2023
2 parents b1e7252 + 2dcd21d commit 9006591
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 198 deletions.
4 changes: 0 additions & 4 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ Further information about the required dependencies can be found here:
Python package for 2D plotting. Python package required for any
graphical capabilities.

**GEOS** 3.7.2 or later (https://trac.osgeo.org/geos/)
GEOS is an API of spatial predicates and functions for processing geometry
written in C++.

**Shapely** 1.7.1 or later (https://github.com/Toblerity/Shapely)
Python package for the manipulation and analysis of planar geometric
objects.
Expand Down
24 changes: 10 additions & 14 deletions lib/cartopy/tests/test_linear_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,21 @@ def test_cuts(self):
assert len(multi_line_string.geoms) > 1
assert not rings

def assert_intersection_with_boundary(segment_coords):
# Double the length of the segment.
start = segment_coords[0]
end = segment_coords[1]
end = [end[i] + 2 * (end[i] - start[i]) for i in (0, 1)]
extended_segment = sgeom.LineString([start, end])
# And see if it crosses the boundary.
intersection = extended_segment.intersection(projection.boundary)
assert not intersection.is_empty, 'Bad topology near boundary'

# Each line resulting from the split should start and end with a
# segment that crosses the boundary when extended to double length.
def assert_close_to_boundary(xy):
# Are we close to the boundary, which we are considering within
# a fraction of the x domain limits
limit = (projection.x_limits[1] - projection.x_limits[0]) / 1e4
assert sgeom.Point(*xy).distance(projection.boundary) < limit, \
'Bad topology near boundary'

# Each line resulting from the split should be close to the boundary.
# (This is important when considering polygon rings which need to be
# attached to the boundary.)
for line_string in multi_line_string.geoms:
coords = list(line_string.coords)
assert len(coords) >= 2
assert_intersection_with_boundary(coords[1::-1])
assert_intersection_with_boundary(coords[-2:])
assert_close_to_boundary(coords[0])
assert_close_to_boundary(coords[-1])

def test_out_of_bounds(self):
# Check that a ring that is completely out of the map boundary
Expand Down
Loading

0 comments on commit 9006591

Please sign in to comment.