def setUp(self): # the bbox is not really important self.backend = map_utils.MBTilesBackend('TestMBTiles', [10, 20, 30, 40]) session = sqlite3.connect('TestMBTiles.mbt') self.session.set_trace_callback(print) self.db = session.cursor()
def main(): maps = sys.argv[1:] atlas = {} # splitext() returns the leading dot mbt_exts = re.compile(r'\.(mbt|mbtiles|sqlite|sqlitedb)') for map in maps: basename, ext = os.path.splitext(map) if mbt_exts.match(ext) is not None: atlas[basename] = map_utils.MBTilesBackend(map, None, ro=True) elif stat.S_ISDIR(os.stat(map).st_mode): atlas[basename] = map_utils.DiskBackend(map) # TODO: use aio server = HTTPServer(('', 4847), lambda *a: TileServer(*a, atlas)) server.serve_forever()
#! /usr/bin/env python3 import sys import os.path import map_utils sector = sys.argv[1] a = map_utils.Atlas([sector]) m = a.maps[sector] be = map_utils.MBTilesBackend(sector, m.bbox) print('INSERTING TILES') for z in range(m.max_z + 1): for x in m.iterate_x(z): for y in m.iterate_y(z): try: data = open(os.path.join('Elevation', str(z), str(x), "%d.png" % y), 'rb').read() except FileNotFoundError: pass else: be.store_raw(z, x, y, data) be.commit()
#! /usr/bin/env python3 import sys import os.path import map_utils sector = sys.argv[1] a = map_utils.Atlas([sector]) m = a.maps[sector] be = map_utils.MBTilesBackend("%s.mbt" % sector, m.bbox) for z in range(m.max_z + 1): for x in m.iterate_x(z): for y in m.iterate_y(z): try: data = open( os.path.join('Elevation', str(z), str(x), "%d.png" % y), 'rb').read() except FileNotFoundError: pass else: be.store(z, x, y, data) be.commit()