+
+def process_queue(db,map,force=False):
+
+ 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 = '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+' -f not-exists'
+
+ print command
+
+ 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")
+ parser.add_option("-z", "--zoom", dest="zoom",
+ 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:
+ 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,force)
+
+if __name__ == "__main__":
+
+ main()