Packaged at last...
[pyrungps.git] / render_tiles.py
diff --git a/render_tiles.py b/render_tiles.py
deleted file mode 100644 (file)
index bef03c1..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env python
-# 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()
-  queue_tiles(db,minlat,minlon,maxlat,maxlon)
-            
-def queue_tiles(db,minlat,minlon,maxlat,maxlon,forced_max_zoom=None):
-
-  conn = sqlite3.connect(db)
-  
-  # определяем примерный стартовый зум
-  
-  minlatrad = math.radians(minlat)
-  maxlatrad = math.radians(maxlat)
-  
-  minx = (minlon + 180.0)/360.0
-  maxx = (maxlon + 180.0)/360.0
-  
-  miny = (1.0 - math.log(math.tan(minlatrad) + (1 / math.cos(minlatrad))) / math.pi) / 2.0
-  maxy = (1.0 - math.log(math.tan(maxlatrad) + (1 / math.cos(maxlatrad))) / math.pi) / 2.0
-
-  if minx>maxx:
-    minx,maxx = maxx,minx
-    
-  if miny>maxy:
-    miny,maxy = maxy,miny
-  
-  minzoom=9
-  if forced_max_zoom:
-    maxzoom=forced_max_zoom
-  else:
-    maxzoom=16  
-  
-  for zoom in range(minzoom,maxzoom+1):
-    
-    n = 2 ** zoom
-    
-    minxt = int(minx * n)
-    minyt = int(miny * n)
-    maxxt = int(maxx * n)
-    maxyt = int(maxy * n)
-    
-    ins = conn.cursor()
-    print zoom,minxt,maxxt,minyt,maxyt
-    ins.execute('insert into render_queue(zoom,minx,maxx,miny,maxy) values(?,?,?,?,?)',(zoom,minxt,maxxt,minyt,maxyt))
-
-    if not forced_max_zoom:
-      if (maxxt-minxt>16) or (maxyt-minyt>12):
-        conn.commit()
-        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")
-  parser.add_option("-z", "--zoom", dest="zoom",
-    help="Maximal zoom (forced), used with coordinates pairs (minlat minlon maxlat maxlon) in arguments", metavar="MAP")
-  (options, args) = parser.parse_args()  
-
-  db=options.directory+'/gpx.db'
-  map=options.map  
-  zoom=options.zoom
-
-  if zoom:
-    minlat,minlon,maxlat,maxlon=args
-    queue_tiles(db,float(minlat),float(minlon),float(maxlat),float(maxlon),int(zoom))
-
-  if map:
-    process_queue(db,map)
-  
-if __name__ == "__main__":
-
-  main()          
-  
\ No newline at end of file