Skip to content

Commit

Permalink
deps: Make shapely a mandatory dependency
Browse files Browse the repository at this point in the history
Resolves pyproj4#1470
  • Loading branch information
pmav99 committed Jan 29, 2025
1 parent 42aa92f commit acbf53a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 41 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ classifiers = [
requires-python = ">=3.10"
dependencies = [
"certifi",
"shapely",
]

[project.urls]
Expand Down
51 changes: 10 additions & 41 deletions test/test_geod.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,20 @@
import numpy
import pytest
from numpy.testing import assert_almost_equal, assert_array_equal
from shapely.geometry import (
LinearRing,
LineString,
MultiLineString,
MultiPoint,
MultiPolygon,
Point,
Polygon,
)
from shapely.geometry.polygon import orient

from pyproj import Geod
from pyproj.geod import GeodIntermediateFlag, reverse_azimuth

try:
from shapely.geometry import (
LinearRing,
LineString,
MultiLineString,
MultiPoint,
MultiPolygon,
Point,
Polygon,
)
from shapely.geometry.polygon import orient

SHAPELY_LOADED = True
except (ImportError, OSError):
SHAPELY_LOADED = False


skip_shapely = pytest.mark.skipif(not SHAPELY_LOADED, reason="Missing shapely")


# BOSTON
_BOSTON_LAT = 42.0 + (15.0 / 60.0)
_BOSTON_LON = -71.0 - (7.0 / 60.0)
Expand Down Expand Up @@ -551,13 +541,11 @@ def test_polygon_area_perimeter__single_point():
assert perimeter == 0


@skip_shapely
def test_geometry_length__point():
geod = Geod(ellps="WGS84")
assert geod.geometry_length(Point(1, 2)) == 0


@skip_shapely
def test_geometry_length__linestring():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -567,7 +555,6 @@ def test_geometry_length__linestring():
)


@skip_shapely
def test_geometry_length__linestring__radians():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -585,7 +572,6 @@ def test_geometry_length__linestring__radians():
)


@skip_shapely
def test_geometry_length__linearring():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -597,7 +583,6 @@ def test_geometry_length__linearring():
)


@skip_shapely
def test_geometry_length__polygon():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -609,7 +594,6 @@ def test_geometry_length__polygon():
)


@skip_shapely
def test_geometry_length__polygon__radians():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -630,7 +614,6 @@ def test_geometry_length__polygon__radians():
)


@skip_shapely
def test_geometry_length__multipolygon():
geod = Geod(ellps="WGS84")
polygon = Polygon(LineString([Point(1, 2), Point(3, 4), Point(5, 2)]))
Expand All @@ -641,7 +624,6 @@ def test_geometry_length__multipolygon():
)


@skip_shapely
def test_geometry_length__multipolygon__radians():
geod = Geod(ellps="WGS84")
polygon = Polygon(
Expand All @@ -660,7 +642,6 @@ def test_geometry_length__multipolygon__radians():
)


@skip_shapely
def test_geometry_length__multilinestring():
geod = Geod(ellps="WGS84")
line_string = LineString([Point(1, 2), Point(3, 4), Point(5, 2)])
Expand All @@ -671,21 +652,18 @@ def test_geometry_length__multilinestring():
)


@skip_shapely
def test_geometry_length__multipoint():
geod = Geod(ellps="WGS84")
assert (
geod.geometry_length(MultiPoint([Point(1, 2), Point(3, 4), Point(5, 2)])) == 0
)


@skip_shapely
def test_geometry_area_perimeter__point():
geod = Geod(ellps="WGS84")
assert geod.geometry_area_perimeter(Point(1, 2)) == (0, 0)


@skip_shapely
def test_geometry_area_perimeter__linestring():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -695,7 +673,6 @@ def test_geometry_area_perimeter__linestring():
)


@skip_shapely
def test_geometry_area_perimeter__linestring__radians():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -713,7 +690,6 @@ def test_geometry_area_perimeter__linestring__radians():
)


@skip_shapely
def test_geometry_area_perimeter__linearring():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -725,7 +701,6 @@ def test_geometry_area_perimeter__linearring():
)


@skip_shapely
def test_geometry_area_perimeter__polygon():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -737,7 +712,6 @@ def test_geometry_area_perimeter__polygon():
)


@skip_shapely
def test_geometry_area_perimeter__polygon__radians():
geod = Geod(ellps="WGS84")
assert_almost_equal(
Expand All @@ -758,7 +732,6 @@ def test_geometry_area_perimeter__polygon__radians():
)


@skip_shapely
def test_geometry_area_perimeter__polygon__holes():
geod = Geod(ellps="WGS84")

Expand All @@ -780,7 +753,6 @@ def test_geometry_area_perimeter__polygon__holes():
)


@skip_shapely
def test_geometry_area_perimeter__multipolygon():
geod = Geod(ellps="WGS84")
polygon = Polygon(LineString([Point(1, 2), Point(3, 4), Point(5, 2)]))
Expand All @@ -791,7 +763,6 @@ def test_geometry_area_perimeter__multipolygon():
)


@skip_shapely
def test_geometry_area_perimeter__multipolygon__radians():
geod = Geod(ellps="WGS84")
polygon = Polygon(
Expand All @@ -810,7 +781,6 @@ def test_geometry_area_perimeter__multipolygon__radians():
)


@skip_shapely
def test_geometry_area_perimeter__multilinestring():
geod = Geod(ellps="WGS84")
line_string = LineString([Point(1, 2), Point(3, 4), Point(5, 2)])
Expand All @@ -821,7 +791,6 @@ def test_geometry_area_perimeter__multilinestring():
)


@skip_shapely
def test_geometry_area_perimeter__multipoint():
geod = Geod(ellps="WGS84")
assert geod.geometry_area_perimeter(
Expand Down

0 comments on commit acbf53a

Please sign in to comment.