projects
/
pyrungps.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9b3eba0
)
Искусственное ограничение количества плиток при автоматической генерации ("сколько...
author
Roman Bazalevsky
<rvb@rvb.name>
Fri, 29 Jan 2016 21:15:22 +0000
(
00:15
+0300)
committer
Roman Bazalevsky
<rvb@rvb.name>
Fri, 29 Jan 2016 21:15:22 +0000
(
00:15
+0300)
render_tiles.py
patch
|
blob
|
history
diff --git
a/render_tiles.py
b/render_tiles.py
index 3d95a8570c06738361ca04fd7cfb96239343ce7e..18432d31077110641bf6ed63155cce7864be59df 100644
(file)
--- 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)
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):
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
# определяем примерный стартовый зум
minzoom=8
+
if forced_max_zoom:
maxzoom=forced_max_zoom
else:
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
ins = conn.cursor()
print minlat,maxlat,minlon,maxlon,minzoom,maxzoom