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

Fixes units in Python writer default bounds #311

Merged
merged 1 commit into from
Dec 15, 2023

Conversation

daniel-j-h
Copy link
Contributor

When there are no user-provided bounds provided in the writer (as in: min/max_lat/lng_e7 properties) the writer mistakenly defaults to -180,-90,180,90 for these properties.

min_lon_e7 = h.get("min_lon_e7",-180)
write_int32(min_lon_e7)
min_lat_e7 = h.get("min_lat_e7",-90)
write_int32(min_lat_e7)
max_lon_e7 = h.get("max_lon_e7",180)
write_int32(max_lon_e7)
max_lat_e7 = h.get("max_lat_e7",90)

But these properties need to be multiplied by 10000000 as seen e.g. in this examples and as indicated by the "_e7" postfix

"min_lon_e7": int(-180.0 * 10000000),
"min_lat_e7": int(-85.0 * 10000000),
"max_lon_e7": int(180.0 * 10000000),
"max_lat_e7": int(85.0 * 10000000),

Without this fix we were seeing pmtiles with bounds around null island, because the order of magnitude was wrong.

When there are no user-provided bounds provided in the writer
(as in: min/max_lat/lng_e7 properties) the writer mistakenly
defaults to -180,-90,180,90 for these properties.

https://github.com/protomaps/PMTiles/blob/e1228f5df1a4ac852e0117dc08c8813089a5c8af/python/pmtiles/tile.py#L277-L283

But these properties need to be multiplied by 10000000 as
seen e.g. in this examples and as indicated by the "_e7"

https://github.com/protomaps/PMTiles/blob/e1228f5df1a4ac852e0117dc08c8813089a5c8af/python/examples/create_raster_example.py#L29-L32

Without this fix we were seeing pmtiles with bounds around null
island, because the order of magnitude was wrong.
@bdon bdon merged commit dd76720 into protomaps:main Dec 15, 2023
2 checks passed
@bdon
Copy link
Member

bdon commented Dec 15, 2023

Good catch, thanks!

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 this pull request may close these issues.

2 participants