X-Git-Url: https://git.rvb.name/pyrungps.git/blobdiff_plain/b8e66f213d0df36cb584685a34276d8c45882e71..5c18c71d0182aeb1424dba1dcc54fb23929ef85c:/render_tiles.py diff --git a/render_tiles.py b/render_tiles.py index 1c57b0b..f181cbe 100644 --- a/render_tiles.py +++ b/render_tiles.py @@ -2,17 +2,21 @@ # coding: UTF-8 import sqlite3 - import math +from pprint import pprint def queue_render(db,filename): 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() + minlat,minlon,maxlat,maxlon=cur.fetchone() + queue_tiles(db,minlat,minlon,maxlat,maxlon) + +def queue_tiles(db,minlat,minlon,maxlat,maxlon): + + conn = sqlite3.connect(db) # определяем примерный стартовый зум @@ -49,4 +53,46 @@ def queue_render(db,filename): break conn.commit() + +def process_queue(db,map): + + from os import system + + conn = sqlite3.connect(db) + cur = conn.cursor() + cur.execute('select id,zoom,minx,maxx,miny,maxy from render_queue') + list=cur.fetchall() + + for rec in list: + + 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) + if system(command)==0: + dcur=conn.cursor() + dcur.execute('delete from render_queue where id=?',(id,)) + conn.commit() + +def main(): + + from optparse import OptionParser + + parser = OptionParser() + parser.add_option("-d", "--data", dest="directory", + help="Data directory", metavar="DIR") + parser.add_option("-m", "--map", dest="map", + help="Map name", metavar="MAP") + (options, args) = parser.parse_args() + + db=options.directory+'/gpx.db' + map=options.map + + process_queue(db,map) + +if __name__ == "__main__": + + main() \ No newline at end of file