Skip to content

Tilesets native zoom #792

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

Merged
merged 7 commits into from
Dec 16, 2017

Conversation

Conengmo
Copy link
Member

@Conengmo Conengmo commented Dec 8, 2017

I worked a bit on adding a parameter for the maximum native zoom levels of a tileset, based on #789.

The simplest implementation is just accepting the keyword and adding it to the options of a TileLayer. Since we don't know a reasonable default value, it shouldn't be added if it's None. I think up to here this is an uncontroversial addition.

Then I worked on finding and adding the maximum native zoom level of the tilesets mentioned in the TileLayer docstring. If these are used automatically we prevent users from encountering grayed out tiles.

For most of these tilesets you can check the maximum native zoom level automatically. So I wrote a test that verifies the stored maximum native zoom levels. The tileservers will return a HTTP 403 or 404 when requesting a tile with an unsupported zoom level. Except for the Stamen ones, I didn't find any logic there. It will return tiles for zoom levels up to 30, but will randomly return a HTTP 503 for some reason.

I'm not sure if these values should be hard-coded in raster_layers.py. But the tiles templates also didn't seem to fit right. What I was thinking now was to make the tiles folder into a single JSON file, where each tileset is an entry with an url template, attribution and maximum native zoom level.

I'm also not sure about the test. If the test fails because a tileserver changed, it may confuse a contributor who doesn't know about it.

  • Should folium fill in the maximum native zoom value for known tilesets?
  • Where should these values be stored?
  • Where should the script to find/verify these values be located, or should it be dismissed?

- "Cloudmade" (Must pass API key)
- "Mapbox" (Must pass API key)
- "CartoDB" (positron and dark_matter)


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W293 blank line contains whitespace

@ocefpaf
Copy link
Member

ocefpaf commented Dec 8, 2017

Should folium fill in the maximum native zoom value for known tilesets?

I don't think we should hardcode known values. The grey tiles are "expected" in the slippy mapping world when you go over the max zoom. People who want a "nice" zoom should do that explicitly.

Where should these values be stored?

We can consolidate the tile templates, this is a good idea, but I don't think we should provide the maz values.

Where should the script to find/verify these values be located, or should it be dismissed?

Dismissed. Having the option to add the value manually is good enough IMO.

@Conengmo
Copy link
Member Author

Conengmo commented Dec 8, 2017

Thanks for the quick feedback! I can agree with sticking to manually adding a value. The whole storing and verifying of the values is a bit messy, though interesting to investigate. I'll revert the changes past the keyword part.

@Conengmo Conengmo changed the title WIP: Tilesets native zoom Tilesets native zoom Dec 9, 2017
'attribution': attr, 'subdomains': subdomains,
'detectRetina': detect_retina}
if max_native_zoom:
options['maxNativeZoom'] = max_native_zoom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but I am 99% sure you can just pass the option and, if None, the json.dumps will convert to null and everything will work as expected on the JS side. Then we'll have 1 new line in the options instead of the if clause.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the map won't load with "maxNativeZoom": null. I understand you don't want the extra if clause. I solved it by using 'maxNativeZoom': max_native_zoom or max_zoom.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the map won't load with "maxNativeZoom": null.

Ah! I did not test that. Thanks!

I understand you don't want the extra if clause.

Actually the if-clause was OK in that case.

I solved it by using 'maxNativeZoom': max_native_zoom or max_zoom.

That is fine too. Thanks!

}
options = {'minZoom': min_zoom, 'maxZoom': max_zoom, 'noWrap': no_wrap,
'attribution': attr, 'subdomains': subdomains,
'detectRetina': detect_retina}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 1 option per line is by design, for readability. Do you mind reverting that change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure no problem

@Conengmo
Copy link
Member Author

Thanks for the review @ocefpaf. I corrected the two things you pointed out.

@ocefpaf
Copy link
Member

ocefpaf commented Dec 16, 2017

Thanks @Conengmo! The failure is b/c of our flaky tests that compare templates and results. We need to add the extra option there. But you did a lot already and I can solve this while reviewing the other PRs. Thanks!

@ocefpaf ocefpaf merged commit b03b81e into python-visualization:master Dec 16, 2017
@Conengmo Conengmo deleted the tilesets-native-zoom branch December 16, 2017 12:25
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.

3 participants