geopandas / contextily

Context geo-tiles in Python
https://contextily.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
504 stars 81 forks source link

OSM Tiles should rely on round-robin load balancer, not hardcode subdomains #116

Open kannes opened 4 years ago

kannes commented 4 years ago

https://github.com/darribas/contextily/blob/master/contextily/tile_providers.py#L19-L22 specifies OSM_Ato OSM_Cwith a to b as (sub-)subdomains. Please always just use the tile.openstreetmap.org as any request to it will automatically be shared between the sub-hosts.

jorisvandenbossche commented 4 years ago

@kannes thanks for the report!

You are linking to the "old" provider definitions. The ones in https://github.com/darribas/contextily/blob/master/contextily/_providers.py should eventually replace that. However, also there, we are using a hardcoded subdomain:

https://github.com/darribas/contextily/blob/013307da68742bfc0e54dd3bdff3f120e4fc7188/contextily/_providers.py#L44

(the {s} gets later filled with "a" if not provided by the user)

Ideally it would be changed there, but if needed, we can also patch the url in contextily (the linked _providers.py file is auto-generated based on https://github.com/leaflet-extras/leaflet-providers source, but can add some patches to the conversion code).

It seems that leaflet "divides" over the different domains using a calculation based on the coordinates for a given tile:

https://github.com/Leaflet/Leaflet/blob/37d2fd15ad6518c254fae3e033177e96c48b5012/src/layer/tile/TileLayer.js#L222-L225

kannes commented 4 years ago

Ah, I was just following the code from the example notebook :)

It seems that leaflet "divides" over the different domains using a calculation based on the coordinates for a given tile:

That sounds wild!

The docs https://leafletjs.com/reference-1.6.0.html#tilelayer imply that {s} is replaced by "a", "b", or "c" unless the user sets different options. That's how I always understood it too, with those three subdomains being available. Sounds like it would be safe to simply randomly use a, b or c if there is a {s} in a URL.