Permalink
Browse files

fix for issue #37

  • Loading branch information...
1 parent 4f857cb commit 8e5b7d5aab7bd8feaa8fa54f9d20ff45d97cf246 @csomerlot csomerlot committed Dec 19, 2012
Showing with 10 additions and 4 deletions.
  1. +6 −1 mb-util
  2. +4 −3 mbutil/util.py
View
7 mb-util
@@ -31,11 +31,16 @@ if __name__ == '__main__':
but uses a flipped y coordinate''',
type='string',
default='xyz')
+
+ parser.add_option('--image_format', dest='format',
+ help='''The format of the image tiles, either png or jpg''',
+ type='string',
+ default='png')
(options, args) = parser.parse_args()
# Transfer operations
- if len(args) != 2:
+ if 4 < len(args) < 2:
parser.print_help()
sys.exit(1)
View
7 mbutil/util.py
@@ -133,11 +133,12 @@ def disk_to_mbtiles(directory_path, mbtiles_file, **kwargs):
cur = con.cursor()
optimize_connection(cur)
mbtiles_setup(cur)
- image_format = 'png'
+ #~ image_format = 'png'
+ image_format = kwargs.get('format')
grid_warning = True
try:
metadata = json.load(open(os.path.join(directory_path, 'metadata.json'), 'r'))
- image_format = metadata.get('format', 'png')
+ image_format = kwargs.get('format')
for name, value in metadata.items():
cur.execute('insert into metadata (name, value) values (?, ?)',
(name, value))
@@ -210,7 +211,7 @@ def mbtiles_to_disk(mbtiles_file, directory_path, **kwargs):
tile_dir = os.path.join(base_path, str(z), str(x))
if not os.path.isdir(tile_dir):
os.makedirs(tile_dir)
- tile = os.path.join(tile_dir,'%s.%s' % (y,metadata.get('format', 'png')))
+ tile = os.path.join(tile_dir,'%s.%s' % (y,kwargs.get('format')))
f = open(tile, 'wb')
f.write(t[3])
f.close()

0 comments on commit 8e5b7d5

Please sign in to comment.