Einzelfunktionenexperimentierverzeichnis in git integriert
This commit is contained in:
24
EinzelfunktionenExperimentierbereich/maptiles/maptiles.py
Normal file
24
EinzelfunktionenExperimentierbereich/maptiles/maptiles.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Python
|
||||
# Kachelkoordinaten umrechnen
|
||||
import math
|
||||
|
||||
|
||||
def deg2num(lat_deg, lon_deg, zoom):
|
||||
lat_rad = math.radians(lat_deg)
|
||||
n = 2.0 ** zoom
|
||||
xtile = int((lon_deg + 180.0) / 360.0 * n)
|
||||
ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
|
||||
return xtile, ytile
|
||||
|
||||
|
||||
def num2deg(xtile, ytile, zoom):
|
||||
n = 2.0 ** zoom
|
||||
lon_deg = xtile / n * 360.0 - 180.0
|
||||
lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * ytile / n)))
|
||||
lat_deg = math.degrees(lat_rad)
|
||||
return lat_deg, lon_deg
|
||||
|
||||
|
||||
for i in range(22, 25):
|
||||
x = num2deg(4496422252, 974119798, i)
|
||||
print(i, x)
|
||||
Reference in New Issue
Block a user