6 from pprint import pprint
8 def queue_render(db,filename):
10 conn = sqlite3.connect(db)
13 cur.execute("select minlat,minlon,maxlat,maxlon from tracks where filename=?" , (filename.decode('UTF-8'),))
14 minlat,minlon,maxlat,maxlon=cur.fetchone()
15 queue_tiles(db,minlat,minlon,maxlat,maxlon)
17 def queue_tiles(db,minlat,minlon,maxlat,maxlon):
19 conn = sqlite3.connect(db)
21 # определяем примерный стартовый зум
23 minlatrad = math.radians(minlat)
24 maxlatrad = math.radians(maxlat)
26 minx = (minlon + 180.0)/360.0
27 maxx = (maxlon + 180.0)/360.0
29 miny = (1.0 - math.log(math.tan(minlatrad) + (1 / math.cos(minlatrad))) / math.pi) / 2.0
30 maxy = (1.0 - math.log(math.tan(maxlatrad) + (1 / math.cos(maxlatrad))) / math.pi) / 2.0
38 for zoom in range(9,16):
48 print zoom,minxt,maxxt,minyt,maxyt
49 ins.execute('insert into render_queue(zoom,minx,maxx,miny,maxy) values(?,?,?,?,?)',(zoom,minxt,maxxt,minyt,maxyt))
51 if (maxxt-minxt>16) or (maxyt-minyt>12):
57 def process_queue(db,map):
61 conn = sqlite3.connect(db)
63 cur.execute('select id,zoom,minx,maxx,miny,maxy from render_queue')
68 id,zoom,minx,maxx,miny,maxy=rec
70 command = 'render_list -a -m '+map+ \
71 ' -z '+str(zoom)+' -Z '+str(zoom)+ \
72 ' -x '+str(minx)+' -X '+str(maxx)+ \
73 ' -y '+str(miny)+' -Y '+str(maxy)
74 if system(command)==0:
76 dcur.execute('delete from render_queue where id=?',(id,))
81 from optparse import OptionParser
83 parser = OptionParser()
84 parser.add_option("-d", "--data", dest="directory",
85 help="Data directory", metavar="DIR")
86 parser.add_option("-m", "--map", dest="map",
87 help="Map name", metavar="MAP")
88 (options, args) = parser.parse_args()
90 db=options.directory+'/gpx.db'
95 if __name__ == "__main__":