Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new failing test case for a bug in tiles(), update requirements.txt #152

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ package-lock.json
node_modules
.hypothesis
.mailmap
.venv
31 changes: 24 additions & 7 deletions mercantile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,10 @@ def quadkey_to_tile(qk):


def tiles(west, south, east, north, zooms, truncate=False):
"""Get the tiles overlapped by a geographic bounding box
"""Get the tiles overlapped by a geographic bounding box.

NOTE: Web Mercator tiles cannot latitudes beyond ±85.051129.
This region is not represented in the returned tile set even if you request it.

Parameters
----------
Expand All @@ -521,12 +524,26 @@ def tiles(west, south, east, north, zooms, truncate=False):
if truncate:
west, south = truncate_lnglat(west, south)
east, north = truncate_lnglat(east, north)
if west > east:
bbox_west = (-180.0, south, east, north)
bbox_east = (west, south, 180.0, north)
bboxes = [bbox_west, bbox_east]
else:
bboxes = [(west, south, east, north)]

# Create our bbox.
bboxes = [(west, south, east, north)]
# If the bbox straddles a pole (north-south), split it in half.
new_bboxes = []
for w, s, e, n in bboxes:
if s > n:
new_bboxes += [(w, s, e, 90.0), (w, -90.0, e, n)]
else:
new_bboxes += [(w,s,e,n)]
bboxes = new_bboxes

# If the bboxes straddle the antimeridian (east-west), split them in half.
new_bboxes = []
for w, s, e, n in bboxes:
if w > e:
new_bboxes += [(-180.0, s, e, n), (w, s, 180.0, n)]
else:
new_bboxes += [(w,s,e,n)]
bboxes = new_bboxes

for w, s, e, n in bboxes:
# Clamp bounding values.
Expand Down
26 changes: 26 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
attrs
certifi
chardet
click
coverage>=7.6.8
coveralls>=4.0.1
docopt
hypothesis
idna
importlib-metadata
iniconfig
packaging
pluggy
py
pydocstyle
pyparsing
pytest
pytest-cov
requests
snowballstemmer
sortedcontainers
toml
typing-extensions
urllib3
zipp
setuptools==7.
Loading