From 8953c1b73ec2d259881088f172757bfb3eb2b743 Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Thu, 31 Jul 2014 15:10:31 +0400 Subject: [PATCH 1/1] Render queue processing implemented --- pyrungps.py | 6 ++++++ render_tiles.py | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/pyrungps.py b/pyrungps.py index 76d52f1..5290430 100644 --- a/pyrungps.py +++ b/pyrungps.py @@ -10,6 +10,8 @@ from datetime import date from parsegpx import write_parsed_to_db import pygpx +import render_tiles + def get_page(uname,year,month): trainings = [] @@ -65,6 +67,10 @@ def sync_folder(username,year,month,dir=".",verbose=False,force=False): f.write(etree.tostring(xml,encoding='UTF-8',pretty_print=True)) f.close write_parsed_to_db(db,gpx,filename) + try: + render_tiles.queue_render(db,filename) + except: + None def main(): diff --git a/render_tiles.py b/render_tiles.py index 1c57b0b..a23b136 100644 --- a/render_tiles.py +++ b/render_tiles.py @@ -2,8 +2,8 @@ # coding: UTF-8 import sqlite3 - import math +from pprint import pprint def queue_render(db,filename): @@ -49,4 +49,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 -- 2.34.1