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

Misleading tiles() iterator #76

Closed
sbquinlan opened this issue Jan 22, 2022 · 0 comments · Fixed by #79
Closed

Misleading tiles() iterator #76

sbquinlan opened this issue Jan 22, 2022 · 0 comments · Fixed by #79

Comments

@sbquinlan
Copy link

The tiles() iterator for 'WebMercatorQuad' can return incorrect tile coordinates. The 'truncate' option in this case is misleading. The truncate_lnglat method it uses in utils.py is hard coded to bound coordinates to [-180, 180] and [-90, 90] irrespective of the TMS's bounds (in this case, correctly described in the warning).

I believe a less misleading interface would be to bound the coordinates by self.bbox in tiles().

Expected Result:

>>> import morecantile
>>> tms = morecantile.tms.get('WebMercatorQuad')
>>> tiles = list(tms.tiles(-180., -90., 180., 90., range(1), truncate=True))
<redacted>/.venv/lib/python3.8/site-packages/morecantile/models.py:450: PointOutsideTMSBounds: Point (-179.99999999999, 89.99999999999) is outside TMS bounds [-179.9999999999996, -85.05112877980656, 179.9999999999996, 85.05112877980656].
  warnings.warn(
<redacted>/.venv/lib/python3.8/site-packages/morecantile/models.py:450: PointOutsideTMSBounds: Point (179.99999999999, -89.99999999999) is outside TMS bounds [-179.9999999999996, -85.05112877980656, 179.9999999999996, 85.05112877980656].
  warnings.warn(
>>> tiles
[Tile(x=0, y=0, z=0)]

Actual Result:

>>> import morecantile
>>> tms = morecantile.tms.get('WebMercatorQuad')
>>> tiles = list(tms.tiles(-180., -90., 180., 90., range(1), truncate=True))
<redacted>/.venv/lib/python3.8/site-packages/morecantile/models.py:450: PointOutsideTMSBounds: Point (-179.99999999999, 89.99999999999) is outside TMS bounds [-179.9999999999996, -85.05112877980656, 179.9999999999996, 85.05112877980656].
  warnings.warn(
<redacted>/.venv/lib/python3.8/site-packages/morecantile/models.py:450: PointOutsideTMSBounds: Point (179.99999999999, -89.99999999999) is outside TMS bounds [-179.9999999999996, -85.05112877980656, 179.9999999999996, 85.05112877980656].
  warnings.warn(
>>> tiles
[Tile(x=0, y=0, z=0), Tile(x=0, y=1, z=0)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant