simonw / download-tiles

Download map tiles and store them in an MBTiles database
https://datasette.io/tools/download-tiles
Apache License 2.0
29 stars 6 forks source link

--city and --country options as alternatives to --bbox #1

Closed simonw closed 3 years ago

simonw commented 3 years ago

Looking up bounding boxes is a hassle. Nominatim provides an API, documented at https://nominatim.org/release-docs/latest/api/Search/ which can be used to look up the bounding boxes of specific addresses, cities and countries.

The city= and country= APIs are particularly relevant here:

simonw commented 3 years ago

Output for that San Francisco one:

[
  {
    "place_id": 257346022,
    "licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
    "osm_type": "relation",
    "osm_id": 111968,
    "boundingbox": [
      "37.6403143",
      "37.929811",
      "-123.173825",
      "-122.281479"
    ],
    "lat": "37.7790262",
    "lon": "-122.4199061",
    "display_name": "San Francisco, California, United States",
    "class": "boundary",
    "type": "administrative",
    "importance": 0.9251309463713038,
    "icon": "https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png"
  }
]

Note that the boundingbox array doesn't come back in the min-lon,min-lat,max-lon,max-lat format that we need to pass to Landez. It looks like it's lat1,lat2,lon1,lon2.

simonw commented 3 years ago

Landez already uses requests so I'll use that.