[Git][debian-gis-team/mercantile][upstream] 2 commits: Raise InvalidLatitudeError at 90.0 north (#107)
Joachim Langenbach
gitlab at salsa.debian.org
Sun May 3 16:35:22 BST 2020
Joachim Langenbach pushed to branch upstream at Debian GIS Project / mercantile
Commits:
635f37e8 by Sean Gillies at 2020-04-28T17:05:23-06:00
Raise InvalidLatitudeError at 90.0 north (#107)
Resolves #106
- - - - -
4cd0c36d by Sean Gillies at 2020-04-28T17:13:27-06:00
Change a list comprehension to a generator expression
- - - - -
3 changed files:
- CHANGES.txt
- mercantile/__init__.py
- tests/test_funcs.py
Changes:
=====================================
CHANGES.txt
=====================================
@@ -1,6 +1,14 @@
Changes
=======
+1.1.4 (2020-04-28)
+------------------
+
+- Change a list comprehension to a generator expression in simplify().
+- Change DeprecationWarning introduced in 1.1.3 to a UserWarning to increase
+ visibility.
+- Ensure symmetric InvalidLatitudeErrors at both poles (#106).
+
1.1.3 (2020-04-13)
------------------
=====================================
mercantile/__init__.py
=====================================
@@ -8,14 +8,14 @@ import warnings
if sys.version_info < (3,):
warnings.warn(
"Python versions < 3 will not be supported by mercantile 2.0.",
- DeprecationWarning,
+ UserWarning,
)
from collections import Sequence
else:
from collections.abc import Sequence
-__version__ = "1.1.3"
+__version__ = "1.1.4"
__all__ = [
"Bbox",
@@ -305,7 +305,7 @@ def _xy(lng, lat, truncate=False):
try:
y = 0.5 - 0.25 * math.log((1.0 + sinlat) / (1.0 - sinlat)) / math.pi
- except ValueError:
+ except (ValueError, ZeroDivisionError):
raise InvalidLatitudeError("Y can not be computed: lat={!r}".format(lat))
else:
return x, y
@@ -624,8 +624,7 @@ def simplify(tiles):
root_set = set()
for tile in tiles:
x, y, z = tile
- supers = [parent(tile, zoom=i) for i in range(z + 1)]
- for supertile in supers:
+ for supertile in (parent(tile, zoom=i) for i in range(z + 1)):
if supertile in root_set:
continue
root_set |= {tile}
=====================================
tests/test_funcs.py
=====================================
@@ -438,3 +438,36 @@ def test_ul_xy_bounds(t):
def test_lower_left_tile():
assert mercantile.tile(180.0, -85, 1) == mercantile.Tile(1, 1, 1)
+
+
+ at pytest.mark.parametrize("lat", [-90.0, 90.0])
+def test_tile_poles(lat):
+ with pytest.raises(mercantile.InvalidLatitudeError):
+ mercantile.tile(0.0, lat, zoom=17)
+
+
+ at pytest.mark.parametrize("lat", [-90.0, 90.0])
+def test__xy_poles(lat):
+ with pytest.raises(mercantile.InvalidLatitudeError):
+ mercantile._xy(0.0, lat)
+
+
+ at pytest.mark.parametrize("lat,fy", [(85.0511287798066, 0.0), (-85.0511287798066, 1.0)])
+def test__xy_limits(lat, fy):
+ x, y = mercantile._xy(0.0, lat)
+ assert x == 0.5
+ assert y == pytest.approx(fy)
+
+
+ at pytest.mark.parametrize("lat", [86.0])
+def test__xy_north_of_limit(lat):
+ x, y = mercantile._xy(0.0, lat)
+ assert x == 0.5
+ assert y < 0
+
+
+ at pytest.mark.parametrize("lat", [-86.0])
+def test__xy_south_of_limit(lat):
+ x, y = mercantile._xy(0.0, lat)
+ assert x == 0.5
+ assert y > 1
View it on GitLab: https://salsa.debian.org/debian-gis-team/mercantile/-/compare/478e7e1c2291c828e52c381052f108ecec89989b...4cd0c36df219496a897224242ad4d46ce2815c11
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/mercantile/-/compare/478e7e1c2291c828e52c381052f108ecec89989b...4cd0c36df219496a897224242ad4d46ce2815c11
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200503/9d3cb8fe/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list