diff --git a/README.md b/README.md index c8345dd..743847b 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Python installation (requires easy_install) other options are "tms" which is also z/x/y but uses a flipped y coordinate, and "wms" which replicates the MapServer WMS TileCache directory structure "z/000/000/x/000/000/y.png"''', + and "zyx" which is the format vips dzsave --layout google uses. --image_format=FORMAT The format of the image tiles, either png, jpg, webp or pbf --grid_callback=CALLBACK diff --git a/mb-util b/mb-util index f238f25..7854264 100755 --- a/mb-util +++ b/mb-util @@ -35,7 +35,7 @@ if __name__ == '__main__': + '''which replicates the MapServer WMS TileCache directory structure ''' + '''"z/000/000/x/000/000/y.png"''', type='choice', - choices=['wms', 'tms', 'xyz', 'gwc','ags'], + choices=['wms', 'tms', 'xyz', 'zyx', 'gwc','ags'], default='xyz') parser.add_option('--image_format', dest='format', diff --git a/mbutil/util.py b/mbutil/util.py index 55e3362..50f581c 100755 --- a/mbutil/util.py +++ b/mbutil/util.py @@ -213,6 +213,8 @@ def disk_to_mbtiles(directory_path, mbtiles_file, **kwargs): y = flip_y(z, int(row_dir.replace("R", ""), 16)) elif kwargs.get("scheme") == 'gwc': pass + elif kwargs.get("scheme") == 'zyx': + y = flip_y(int(z), int(row_dir)) else: x = int(row_dir) for current_file in os.listdir(os.path.join(directory_path, zoom_dir, row_dir)): @@ -231,6 +233,8 @@ def disk_to_mbtiles(directory_path, mbtiles_file, **kwargs): x, y = file_name.split('_') x = int(x) y = int(y) + elif kwargs.get("scheme") == 'zyx': + x = int(file_name) else: y = int(file_name) diff --git a/test/data/tiles/zyx/3/2/1.png b/test/data/tiles/zyx/3/2/1.png new file mode 100644 index 0000000..f607ae0 Binary files /dev/null and b/test/data/tiles/zyx/3/2/1.png differ diff --git a/test/data/tiles/zyx/metadata.json b/test/data/tiles/zyx/metadata.json new file mode 100644 index 0000000..eefc2f1 --- /dev/null +++ b/test/data/tiles/zyx/metadata.json @@ -0,0 +1,7 @@ +{ + "name": "ZYX Tiles", + "type": "baselayer", + "description": "", + "version": "1", + "format": "png" +} diff --git a/test/test.py b/test/test.py index d6d96b2..e02e259 100644 --- a/test/test.py +++ b/test/test.py @@ -49,4 +49,11 @@ def test_mbtiles_to_disk_utfgrid_callback(): callback[c] = f.read().split('{')[0] f.close() assert callback['foo'] == 'foo(' - assert callback['null'] == '' \ No newline at end of file + assert callback['null'] == '' + +@with_setup(clear_data, clear_data) +def test_disk_to_mbtiles_zyx(): + os.mkdir('test/output') + disk_to_mbtiles('test/data/tiles/zyx', 'test/output/zyx.mbtiles', scheme='zyx', format='png') + mbtiles_to_disk('test/output/zyx.mbtiles', 'test/output/tiles', callback=None) + assert os.path.exists('test/output/tiles/3/1/5.png')