November 2018
Intermediate to advanced
360 pages
9h 36m
English
Let's take a look at the following steps:
import mathimport requestsdef get_osm_tile(x, y, z): url = 'http://tile.openstreetmap.org/%d/%d/%d.png' % (z, x, y) req = requests.get(url) if not req.ok: req.raise_for_status() return reqdef deg_xy(lat, lon, zoom): lat_rad = math.radians(lat) n = 2 ** zoom x = int((lon + 180) / 360 * n) y = int((1 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2 * n) return x, y
This code is responsible for getting a tile from the OpenStreetMap server, which ...