From 0f58e0f39a33de394b4792feb55701a3c13d6e5b Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Sat, 30 Jan 2016 00:15:22 +0300 Subject: [PATCH 1/1] =?utf8?q?=D0=98=D1=81=D0=BA=D1=83=D1=81=D1=81=D1=82?= =?utf8?q?=D0=B2=D0=B5=D0=BD=D0=BD=D0=BE=D0=B5=20=D0=BE=D0=B3=D1=80=D0=B0?= =?utf8?q?=D0=BD=D0=B8=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BB?= =?utf8?q?=D0=B8=D1=87=D0=B5=D1=81=D1=82=D0=B2=D0=B0=20=D0=BF=D0=BB=D0=B8?= =?utf8?q?=D1=82=D0=BE=D0=BA=20=D0=BF=D1=80=D0=B8=20=D0=B0=D0=B2=D1=82?= =?utf8?q?=D0=BE=D0=BC=D0=B0=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE?= =?utf8?q?=D0=B9=20=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D0=B8?= =?utf8?q?=20("=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BD=D0=B0?= =?utf8?q?=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=20+=201=20=D1=83=D1=80=D0=BE?= =?utf8?q?=D0=B2=D0=B5=D0=BD=D1=8C")?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- render_tiles.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/render_tiles.py b/render_tiles.py index 3d95a85..18432d3 100644 --- a/render_tiles.py +++ b/render_tiles.py @@ -13,6 +13,13 @@ def queue_render(db,filename,forced_max_zoom=None): cur.execute("select minlat,minlon,maxlat,maxlon from tracks where filename=?" , (filename.decode('UTF-8'),)) minlat,minlon,maxlat,maxlon=cur.fetchone() queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom) + +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 queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): @@ -21,10 +28,19 @@ def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): # определяем примерный стартовый зум minzoom=8 + if forced_max_zoom: maxzoom=forced_max_zoom else: - maxzoom=16 + maxzoom=minzoom + while True: + minx,miny=deg2num(minlat,minlon,maxzoom) + maxx,maxy=deg2num(maxlat,maxlon,maxzoom) + print maxzoom,':',minx,'-',maxx,'/',miny,'-',maxy + if (maxx-minx>32) or (maxy-miny>24) or (maxzoom==16): + break + else: + maxzoom=maxzoom+1 ins = conn.cursor() print minlat,maxlat,minlon,maxlon,minzoom,maxzoom -- 2.34.1