Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert False
if options.bounds:
bounds = BoundingPyramid.from_string(options.bounds)
tilestream = BoundingPyramidTileStore(bounds).list()
tilestream = store.get(tilestream)
else:
tilestream = store.get_all()
connection = sqlite3.connect(options.output)
kwargs = {}
mbtiles_tile_store = MBTilesTileStore(connection, commit=False)
for key in 'name type version description format'.split():
value = getattr(options, key)
if value is not None:
mbtiles_tile_store.metadata[key] = getattr(options, key)
tilestream = mbtiles_tile_store.put(tilestream)
consume(tilestream, options.limit)
connection.commit()
def main(argv):
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(module)s:%(message)s', level=logging.INFO)
bounding_pyramid = BoundingPyramid.from_string('19/269628/181744:278856/187776')
bounding_pyramid_tile_store = BoundingPyramidTileStore(bounding_pyramid)
tilestream = bounding_pyramid_tile_store.list()
shutil.copyfile('map3d.done.mbtiles', 'map3d.done.mbtiles.tmp')
tmp_done_tile_store = MBTilesTileStore(sqlite3.connect('map3d.done.mbtiles.tmp', check_same_thread=False))
tilestream = (tile for tile in tilestream if tile not in tmp_done_tile_store)
pool = multiprocessing.Pool(6)
tilestream = pool.imap_unordered(convert_to_jpeg_and_put_if_not_transparent, tilestream)
tilestream = imap(Logger(logger, logging.INFO, 'wrote %(tilecoord)s'), tilestream)
done_tile_store = MBTilesTileStore(sqlite3.connect('map3d.done.mbtiles'))
tilestream = done_tile_store.put(tilestream)
consume(tilestream, None)
# 1. Generate a list of tiles to download from a BoundingPyramid
# 4/8/5 is the root tile, corresponding to Central Europe
# +3/+1/+1 specifies up to zoom level 4 + 3 = 7 and an extent of one tile in the X and Y directions
bounding_pyramid = BoundingPyramid.from_string("4/8/5:+3/+1/+1")
bounding_pyramid_tilestore = BoundingPyramidTileStore(bounding_pyramid)
tilestream = bounding_pyramid_tilestore.list()
# 2. Filter out tiles that already downloaded
tilestream = (tile for tile in tilestream if tile not in output_tilestore)
# 3. Get the tile from openstreetmap.org
tilestream = input_tilestore.get(tilestream)
# 4. Save the tile to local.mbtiles
tilestream = output_tilestore.put(tilestream)
# 5. Log the fact that the tile was downloaded
tilestream = imap(Logger(logger, logging.INFO, "downloaded %(tilecoord)s"), tilestream)
# Go!
consume(tilestream, None)
def main(argv):
option_parser = OptionParser()
option_parser.add_option('--limit', metavar='LIMIT', type=int)
option_parser.add_option('--output', metavar='FILENAME')
option_parser.add_option('-z', metavar='Z', type=int)
options, args = option_parser.parse_args(argv[1:])
assert options.output
assert options.z
mbtiles_tile_stores = [MBTilesTileStore(sqlite3.connect(arg)) for arg in args]
bounding_pyramid_tile_store = BoundingPyramidTileStore()
tilestream = chain.from_iterable(mbtiles_tile_store.list() for mbtiles_tile_store in mbtiles_tile_stores)
tilestream = bounding_pyramid_tile_store.put(tilestream)
consume(tilestream, options.limit)
mask_tile_store = MaskTileStore(options.z, bounding_pyramid_tile_store.bounding_pyramid.bounds[options.z])
tilestream = chain.from_iterable(mbtiles_tile_store.list() for mbtiles_tile_store in mbtiles_tile_stores)
tilestream = mask_tile_store.put(tilestream)
consume(tilestream, options.limit)
mask_tile_store.save(options.output, 'PNG')
tile_matrix_set="EPSG:900913",
tile_matrix=lambda z: "EPSG:900913:{0:d}".format(z),
)
tilestream = generate_tilestore.get(tilestream)
tilestream = imap(Logger(logger, logging.INFO, "got %(tilecoord)s, error=%(error)s"), tilestream)
# Put the tile back into the RenderingTheWorld tile store. This check whether the tile should be
# subdivided, and, if so, adds the tile's children to the list of tiles to be generated.
tilestream = rendering_the_world_tilestore.put(tilestream)
# Get rid of tiles that returned an error (i.e. where there was no data).
tilestream = imap(DropErrors(), tilestream)
# Store the generated tiles in the output tile store, in our case a local MBTiles file.
output_tilestore = MBTilesTileStore(sqlite3.connect("medford_buildings.mbtiles"))
tilestream = output_tilestore.put(tilestream)
tilestream = imap(Logger(logger, logging.INFO, "saved %(tilecoord)s"), tilestream)
# Go!
consume(tilestream, None)
gene.tilestream = MetaTileSplitter().get(gene.tilestream)
# Only keep tiles that intersect geometry
gene.add_geom_filter(layer)
def count_tile(tile):
if tile:
if tile.tilecoord.z in nb_tiles:
nb_tiles[tile.tilecoord.z] += 1
else:
print("Calculate zoom {}.".format(tile.tilecoord.z))
nb_tiles[tile.tilecoord.z] = 1
return tile
gene.imap(count_tile)
consume(gene.tilestream, None)
times = {}
print('')
for z in nb_metatiles:
print("{} meta tiles in zoom {}.".format(nb_metatiles[z], z))
times[z] = layer['cost']['metatile_generation_time'] * nb_metatiles[z]
price = 0
all_size = 0
all_time = 0
all_tiles = 0
for z in nb_tiles:
print('')
print("{} tiles in zoom {}.".format(nb_tiles[z], z))
all_tiles += nb_tiles[z]
if meta:
def run(self):
consume(self._generator._gene.tilestream, n=None)
option_parser = OptionParser()
option_parser.add_option('--limit', metavar='LIMIT', type=int)
option_parser.add_option('--output', metavar='FILENAME')
option_parser.add_option('-z', metavar='Z', type=int)
options, args = option_parser.parse_args(argv[1:])
assert options.output
assert options.z
mbtiles_tile_stores = [MBTilesTileStore(sqlite3.connect(arg)) for arg in args]
bounding_pyramid_tile_store = BoundingPyramidTileStore()
tilestream = chain.from_iterable(mbtiles_tile_store.list() for mbtiles_tile_store in mbtiles_tile_stores)
tilestream = bounding_pyramid_tile_store.put(tilestream)
consume(tilestream, options.limit)
mask_tile_store = MaskTileStore(options.z, bounding_pyramid_tile_store.bounding_pyramid.bounds[options.z])
tilestream = chain.from_iterable(mbtiles_tile_store.list() for mbtiles_tile_store in mbtiles_tile_stores)
tilestream = mask_tile_store.put(tilestream)
consume(tilestream, options.limit)
mask_tile_store.save(options.output, 'PNG')