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

Update neighbors function across International Date Line #150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 8 additions & 3 deletions mercantile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,18 @@ def neighbors(*tile, **kwargs):

for i in [-1, 0, 1]:
for j in [-1, 0, 1]:
n_xtile, n_ytile = xtile + i, ytile + j
if i == 0 and j == 0:
continue
elif xtile + i < 0 or ytile + j < 0:
elif n_ytile < 0:
continue
elif xtile + i > hi or ytile + j > hi:
elif n_ytile > hi:
continue
tiles.append(Tile(x=xtile + i, y=ytile + j, z=ztile))
elif n_xtile < 0:
n_xtile = hi
elif n_xtile > hi:
n_xtile = 0
tiles.append(Tile(x=n_xtile, y=n_ytile, z=ztile))

# Make sure to not generate invalid tiles for valid input
# https://github.com/mapbox/mercantile/issues/122
Expand Down