1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| MAP_URLS = { "Google": "http://mts0.googleapis.com/vt?lyrs={style}&x={x}&y={y}&z={z}", "Google China": "http://mt2.google.cn/vt/lyrs={style}&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}"}
def get_url(source, x, y, z, style): if source == 'Google China': url = MAP_URLS["Google China"].format(x=x, y=y, z=z, style=style) elif source == 'Google': url = MAP_URLS["Google"].format(x=x, y=y, z=z, style=style) else: raise Exception("Unknown Map Source ! ") return url def get_urls(x1, y1, x2, y2, z, source='google', style='s'): pos1x, pos1y = wgs_to_tile(x1, y1, z) pos2x, pos2y = wgs_to_tile(x2, y2, z) lenx = pos2x - pos1x + 1 leny = pos2y - pos1y + 1 print("Total tiles number:{x} X {y}".format(x=lenx, y=leny)) urls = [get_url(source, i, j, z, style) for j in range(pos1y, pos1y + leny) for i in range(pos1x, pos1x + lenx)] return urls
|