[Git][debian-gis-team/mercantile][upstream] New upstream version 1.1.5
Joachim Langenbach
gitlab at salsa.debian.org
Sat Jul 11 14:57:58 BST 2020
Joachim Langenbach pushed to branch upstream at Debian GIS Project / mercantile
Commits:
93ca82e3 by Joachim Langenbach at 2020-07-11T13:50:07+00:00
New upstream version 1.1.5
- - - - -
3 changed files:
- CHANGES.txt
- mercantile/__init__.py
- tests/test_funcs.py
Changes:
=====================================
CHANGES.txt
=====================================
@@ -1,6 +1,13 @@
Changes
=======
+1.1.5 (2020-06-16)
+------------------
+
+- A bug in ``simplify()`` has been fixed and the algorithm has been improved
+ (#111).
+- Implementation of ``tile()`` has been simplified and corrected (#114).
+
1.1.4 (2020-04-28)
------------------
=====================================
mercantile/__init__.py
=====================================
@@ -4,6 +4,7 @@ from collections import namedtuple
import math
import sys
import warnings
+import operator
if sys.version_info < (3,):
warnings.warn(
@@ -15,7 +16,7 @@ else:
from collections.abc import Sequence
-__version__ = "1.1.4"
+__version__ = "1.1.5"
__all__ = [
"Bbox",
@@ -336,26 +337,17 @@ def tile(lng, lat, zoom, truncate=False):
elif x >= 1:
xtile = int(Z2 - 1)
else:
- # Heuristic to find points straddling tiles.
- xtile_a = math.floor((x - EPSILON) * Z2)
- xtile_b = math.floor((x + EPSILON) * Z2)
- if xtile_a != xtile_b:
- xtile = int(xtile_b)
- else:
- xtile = int(xtile_a)
+ # To address loss of precision in round-tripping between tile
+ # and lng/lat, points within EPSILON of the right side of a tile
+ # are counted in the next tile over.
+ xtile = math.floor((x + EPSILON) * Z2)
if y <= 0:
ytile = 0
elif y >= 1:
ytile = int(Z2 - 1)
else:
- # Heuristic to find points straddling tiles.
- ytile_a = math.floor((y + EPSILON) * Z2)
- ytile_b = math.floor((y - EPSILON) * Z2)
- if ytile_a != ytile_b:
- ytile = int(ytile_a)
- else:
- ytile = int(ytile_b)
+ ytile = math.floor((y + EPSILON) * Z2)
return Tile(xtile, ytile, zoom)
@@ -620,14 +612,18 @@ def simplify(tiles):
return current_tileset, changed
# Check to see if a tile and its parent both already exist.
+ # Ensure that tiles are sorted by zoom so parents are encountered first.
# If so, discard the child (it's covered in the parent)
root_set = set()
- for tile in tiles:
+ for tile in sorted(tiles, key=operator.itemgetter(2)):
x, y, z = tile
+ is_new_tile = True
for supertile in (parent(tile, zoom=i) for i in range(z + 1)):
if supertile in root_set:
+ is_new_tile = False
continue
- root_set |= {tile}
+ if is_new_tile:
+ root_set |= {tile}
# Repeatedly run merge until no further simplification is possible.
is_merging = True
=====================================
tests/test_funcs.py
=====================================
@@ -327,6 +327,20 @@ def test_simplify():
assert target in simplified
+def test_simplify_removal():
+ ''' Verify that tiles are being removed by simplify()
+ '''
+ tiles = [
+ (1298, 3129, 13),
+ (649, 1564, 12),
+ (650, 1564, 12),
+ ]
+ simplified = mercantile.simplify(tiles)
+ assert (1298, 3129, 13) not in simplified, 'Tile covered by a parent'
+ assert (650, 1564, 12) in simplified, 'Highest-level tile'
+ assert (649, 1564, 12) in simplified, 'Also highest-level tile'
+
+
@pytest.mark.parametrize(
"bounds,tile",
[
View it on GitLab: https://salsa.debian.org/debian-gis-team/mercantile/-/commit/93ca82e358478a6a66a316cd2bfb7ec129f85d79
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/mercantile/-/commit/93ca82e358478a6a66a316cd2bfb7ec129f85d79
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/20200711/a0cdfe64/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list