From 25744d389626199ef947e80ce680f43ead41917d Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Fri, 22 Jan 2016 23:40:35 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=B5=D1=80=D0=B5=D1=85=D0=BE=D0=B4=20?= =?utf8?q?=D0=BD=D0=B0=20tirex=20-=20renderd=20=D0=BD=D0=B5=D1=81=D1=82?= =?utf8?q?=D0=B0=D0=B1=D0=B8=D0=BB=D0=B5=D0=BD=20=D0=BF=D0=BE=D0=B4=20Ubun?= =?utf8?q?tu=2015.10?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- render_tiles.py | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/render_tiles.py b/render_tiles.py index bef03c1..f399f36 100644 --- a/render_tiles.py +++ b/render_tiles.py @@ -5,14 +5,14 @@ import sqlite3 import math from pprint import pprint -def queue_render(db,filename): +def queue_render(db,filename,forced_max_zoom=None): conn = sqlite3.connect(db) cur = conn.cursor() 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) + queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom) def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): @@ -35,7 +35,7 @@ def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): if miny>maxy: miny,maxy = maxy,miny - minzoom=9 + minzoom=8 if forced_max_zoom: maxzoom=forced_max_zoom else: @@ -54,14 +54,15 @@ def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): print zoom,minxt,maxxt,minyt,maxyt ins.execute('insert into render_queue(zoom,minx,maxx,miny,maxy) values(?,?,?,?,?)',(zoom,minxt,maxxt,minyt,maxyt)) - if not forced_max_zoom: - if (maxxt-minxt>16) or (maxyt-minyt>12): + if forced_max_zoom is None: + if (maxxt-minxt>32) or (maxyt-minyt>24): + print "Breaking..." conn.commit() break conn.commit() -def process_queue(db,map): +def process_queue(db,map,force=False): from os import system @@ -74,10 +75,18 @@ def process_queue(db,map): id,zoom,minx,maxx,miny,maxy=rec - command = 'render_list -a -m '+map+ \ - ' -z '+str(zoom)+' -Z '+str(zoom)+ \ - ' -x '+str(minx)+' -X '+str(maxx)+ \ - ' -y '+str(miny)+' -Y '+str(maxy) + command = 'map='+map+ \ + ' z='+str(zoom)+ \ + ' x='+str(minx)+'-'+str(maxx)+ \ + ' y='+str(miny)+'-'+str(maxy) + + if force: + command = 'tirex-batch '+command + else: + command = 'tirex-batch '+command+' not-exists' + + print command + if system(command)==0: dcur=conn.cursor() dcur.execute('delete from render_queue where id=?',(id,)) @@ -93,19 +102,29 @@ def main(): parser.add_option("-m", "--map", dest="map", help="Map name", metavar="MAP") parser.add_option("-z", "--zoom", dest="zoom", - help="Maximal zoom (forced), used with coordinates pairs (minlat minlon maxlat maxlon) in arguments", metavar="MAP") + help="Maximal zoom (forced), used with coordinates pairs (minlat minlon maxlat maxlon) or filename in arguments", metavar="MAP") + parser.add_option("-f", "--force", dest="force", + help="Force tile regeneration (on/off), default off") (options, args) = parser.parse_args() + print options,args + db=options.directory+'/gpx.db' map=options.map zoom=options.zoom + force=(options.force=='on') if zoom: - minlat,minlon,maxlat,maxlon=args - queue_tiles(db,float(minlat),float(minlon),float(maxlat),float(maxlon),int(zoom)) + if len(args)==1: + filename,=args + print "Rendering file: "+filename+"\n" + queue_render(db,filename) + else: + minlat,minlon,maxlat,maxlon=args + queue_tiles(db,float(minlat),float(minlon),float(maxlat),float(maxlon),int(zoom)) if map: - process_queue(db,map) + process_queue(db,map,force) if __name__ == "__main__": -- 2.34.1