1
0
mirror of https://github.com/alfanhui/mbtilesToPngs.git synced 2025-05-16 06:50:10 -07:00

Merged ok

This commit is contained in:
Alfanhui 2018-06-08 00:19:34 +01:00
parent 84015fe0b8
commit bb26341ebd

View File

@ -23,55 +23,44 @@ def create_connection(db_file):
return None
def select_all_images(conn, tms):
"""
Query all rows in the tasks table
:param conn: the Connection object
:return:
"""
def select_all_tiles(conn, tms):
cur = conn.cursor()
cur.execute("SELECT * FROM images")
cur.execute("SELECT * FROM map")
rows = cur.fetchall()
assets = {}
print("Imamge count: " + str(len(rows)))
print("Map count: " + str(len(rows)))
print("TMS: " + str(tms))
for row in rows:
result = get_Metadata(conn, row[1])
image = get_Image(conn, row[3])
# for printing
dir = str(result['zoom']) + "/" + str(result['column'])
dir = str(row[0]) + "/" + str(row[1])
assets[dir] = dir
# tsm check
xValue = result['row']
xValue = row[2]
if(tms):
ymax = 1 << result['zoom']
xValue = ymax - result['row'] - 1
ymax = 1 << row[0]
xValue = ymax - row[2] - 1
# generate png
blobToFile(
str(result['zoom']), # {z}
str(result['column']), # {x}
str(row[0]), # {z}
str(row[1]), # {x}
str(xValue), # {y}
row[0], # data
image, # data
)
for asset in assets:
print ('- assets/map/' + assets[asset] + "/")
def get_Metadata(conn, id):
"""
Query all rows in the tasks table
:param conn: the Connection object
:return:
"""
def get_Image(conn, id):
cur = conn.cursor()
cur.execute("SELECT * FROM map WHERE tile_id = ?", [id])
cur.execute("SELECT * FROM images WHERE tile_id = ?", [id])
row = cur.fetchone()
return({'zoom': row[0], 'column': row[1], 'row': row[2]})
return(row[0])
def mkdir_p(path):
@ -99,7 +88,7 @@ def beginConvertion(database, tms):
conn = create_connection(database)
with conn:
print("Processing mbtiles..\n***********\nIf you find your y coordinates (filename.png) are incorrect, use the -tsm option\n***********\n")
select_all_images(conn, tms)
select_all_tiles(conn, tms)
def main(argv):