Skip to content

Commit

Permalink
Merge pull request #89 from andrewharvey/zyx
Browse files Browse the repository at this point in the history
include zyx scheme from vips dzsave --google
  • Loading branch information
sgillies authored Oct 4, 2017
2 parents bfcd0d5 + daf299a commit 2fc4161
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mb-util
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 4 additions & 0 deletions mbutil/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand All @@ -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)

Expand Down
Binary file added test/data/tiles/zyx/3/2/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions test/data/tiles/zyx/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "ZYX Tiles",
"type": "baselayer",
"description": "",
"version": "1",
"format": "png"
}
9 changes: 8 additions & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] == ''
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')

0 comments on commit 2fc4161

Please sign in to comment.