def test_export_mbtiles_add_suffix(tmpdir): tpk = TPK("tests/data/states_filled.tpk") mbtiles_filename = str(tmpdir.join("test")) tpk.to_mbtiles(mbtiles_filename) tpk.close() assert os.path.exists("{0}.mbtiles".format(mbtiles_filename))
def test_export_mbtiles_int_zoom(tmpdir): tpk = TPK("tests/data/states_filled.tpk") mbtiles_filename = str(tmpdir.join("test.mbtiles")) tpk.to_mbtiles(mbtiles_filename, zoom=1) tpk.close() assert os.path.exists(mbtiles_filename)
def test_alt_root_name(tmpdir): tpk = TPK("tests/data/alt_root_name.tpk") mbtiles_filename = str(tmpdir.join("test")) tpk.to_mbtiles(mbtiles_filename) tpk.close() assert os.path.exists("{0}.mbtiles".format(mbtiles_filename))
def test_alt_root_name(tmpdir): tpk = TPK('tests/data/alt_root_name.tpk') mbtiles_filename = str(tmpdir.join('test')) tpk.to_mbtiles(mbtiles_filename) tpk.close() assert os.path.exists('{0}.mbtiles'.format(mbtiles_filename))
def test_export_mbtiles_mixed_format(tmpdir): tpk = TPK("tests/data/states_filled.tpk") tpk.format = "mixed" # this is a hack to make test fail, need a test file for this mbtiles_filename = str(tmpdir.join("test.mbtiles")) with pytest.raises(ValueError): tpk.to_mbtiles(mbtiles_filename) tpk.close()
def mbtiles(tpk_filename, mbtiles_filename, zoom, overwrite, verbose): """Export the tile package to mbtiles format""" configure_logging(verbose) if os.path.exists(mbtiles_filename) and not overwrite: raise click.ClickException('Output exists and overwrite is false. ' 'Use --overwrite option to overwrite') start = time.time() if zoom is not None: zoom = [int(v) for v in zoom.split(',')] tpk = TPK(tpk_filename) tpk.to_mbtiles(mbtiles_filename, zoom) tpk.close() print('Exported tiles in {0:2f} seconds'.format(time.time() - start))
def mbtiles(tpk_filename, mbtiles_filename, zoom, overwrite, drop_empty, tile_bounds, verbose): """Export the tile package to mbtiles format""" configure_logging(verbose) if os.path.exists(mbtiles_filename) and not overwrite: raise click.ClickException("Output exists and overwrite is false. " "Use --overwrite option to overwrite") start = time.time() if zoom is not None: zoom = [int(v) for v in zoom.split(",")] tpk = TPK(tpk_filename) tpk.to_mbtiles(mbtiles_filename, zoom=zoom, tile_bounds=tile_bounds, drop_empty=drop_empty) tpk.close() print("Exported tiles in {0:2f} seconds".format(time.time() - start))