From 7b110d16b72ee2c5ce13a2a45de656390526ce81 Mon Sep 17 00:00:00 2001 From: Roman Bazalevskiy Date: Fri, 28 Apr 2017 21:02:21 +0300 Subject: [PATCH] =?utf8?q?=D0=A0=D0=B0=D0=B7=D0=BB=D0=BE=D0=B6=D0=B8=D0=BB?= =?utf8?q?=D0=B8=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D0=BE=20=D0=B3?= =?utf8?q?=D0=BE=D0=B4=D0=B0=D0=BC=20=D0=B8=20=D0=BC=D0=B5=D1=81=D1=8F?= =?utf8?q?=D1=86=D0=B0=D0=BC.=20=D0=9C=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BD?= =?utf8?q?=D0=B0=D0=BA=D0=BE=D0=BF=D0=B8=D0=BB=D0=BE=D1=81=D1=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- pyrungps.py | 2 +- render_tiles.py | 86 +++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 70 insertions(+), 18 deletions(-) mode change 100644 => 100755 render_tiles.py diff --git a/pyrungps.py b/pyrungps.py index 5290430..58dd344 100644 --- a/pyrungps.py +++ b/pyrungps.py @@ -42,7 +42,7 @@ def sync_folder(username,year,month,dir=".",verbose=False,force=False): training_list = get_page(username,year,month) for tr in training_list: - filename = "%s/%s_%s.gpx" % (dir,tr[0],tr[1]) + filename = "%s/%04d/%02d/%s_%s.gpx" % (dir,year,(month+1),tr[0],tr[1]) if os.path.exists(filename) and not force: diff --git a/render_tiles.py b/render_tiles.py old mode 100644 new mode 100755 index e229ead..1116287 --- a/render_tiles.py +++ b/render_tiles.py @@ -26,7 +26,7 @@ def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): conn = sqlite3.connect(db) # определяем примерный стартовый зум - + minzoom=8 if forced_max_zoom: @@ -36,19 +36,23 @@ def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None): while True: minx,miny=deg2num(minlat,minlon,maxzoom) maxx,maxy=deg2num(maxlat,maxlon,maxzoom) + print maxzoom,':',minx,'-',maxx,'/',miny,'-',maxy if (maxx-minx>16) or (maxy-miny>12) or (maxzoom==16): break else: maxzoom=maxzoom+1 + if maxzoommaxx: + tx=minx + maxx=minx + minx=tx + + if miny>maxy: + ty=miny + maxy=miny + miny=ty + + print zoom,minx,miny,maxx,maxy - if force: - command = 'tirex-batch -n 0 '+command - else: - command = 'tirex-batch -n 0 '+command+' -f not-exists' + maps = map.split(',') + + for map_name in maps: + + command = 'render_list -a -m '+map+ \ + ' -z '+str(zoom)+' -Z '+str(zoom)+ \ + ' -x '+str(minx)+' -X '+str(maxx)+ \ + ' -y '+str(miny)+' -Y '+str(maxy) + if force: + command = command+ ' --force' - print command + print command - if system(command)==0: + if system(command)<>0: + return + dcur=conn.cursor() dcur.execute('delete from render_queue where id=?',(id,)) conn.commit() @@ -91,10 +137,10 @@ def main(): 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") + parser.add_option("-r", "--renderer", dest="renderer", + help="Rendering backend: tirex or renderd") (options, args) = parser.parse_args() - print options,args - db=options.directory+'/gpx.db' map=options.map zoom=options.zoom @@ -102,6 +148,12 @@ def main(): zoom=12 force=(options.force=='on') + if options.renderer: + renderer=options.renderer + else: + print "Using default rendering backend..." + renderer="default" + if len(args)==1: filename,=args print "Rendering file: "+filename+"\n" @@ -112,8 +164,8 @@ def main(): queue_tiles(db,float(minlat),float(minlon),float(maxlat),float(maxlon),int(zoom)) if map: - print "Processing map "+map+"\n" - process_queue(db,map,force) + print "Processing map(s) "+map+"\n" + process_queue(db,map,force,renderer) if __name__ == "__main__": -- 2.34.1