Joachim Langenbach pushed to branch master at Debian GIS Project / mercantile
Commits: 93ca82e3 by Joachim Langenbach at 2020-07-11T13:50:07+00:00 New upstream version 1.1.5 - - - - - 64583186 by Joachim Langenbach at 2020-07-11T13:50:07+00:00 Update upstream source from tag '1.1.5' Update to upstream version '1.1.5' with Debian dir 396f0e452858c3105b1cbc366b30a582caf1d583 - - - - - f8293113 by Joachim Langenbach at 2020-07-11T13:51:57+00:00 New upstream release. - - - - - 4 changed files: - CHANGES.txt - debian/changelog - 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) ------------------ ===================================== debian/changelog ===================================== @@ -1,3 +1,9 @@ +mercantile (1.1.5-1~exp1) experimental; urgency=medium + + * New upstream release. + + -- Joachim Langenbach <[email protected]> Sat, 11 Jul 2020 13:51:10 +0000 + mercantile (1.1.4-1~exp1) experimental; urgency=medium * Initial release (Closes: #956911) ===================================== 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/-/compare/5d7dce5d9506c1adbd71cd409fe67a7fdbbcf1cb...f829311388e31b3865b5cbd7335b65740ccc9d3f -- View it on GitLab: https://salsa.debian.org/debian-gis-team/mercantile/-/compare/5d7dce5d9506c1adbd71cd409fe67a7fdbbcf1cb...f829311388e31b3865b5cbd7335b65740ccc9d3f You're receiving this email because of your account on salsa.debian.org.
_______________________________________________ Pkg-grass-devel mailing list [email protected] https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-grass-devel
