mirror of
https://github.com/alfanhui/mbtilesToPngs.git
synced 2025-05-16 23:10:10 -07:00
Merged ok
This commit is contained in:
parent
84015fe0b8
commit
bb26341ebd
@ -23,55 +23,44 @@ def create_connection(db_file):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def select_all_images(conn, tms):
|
def select_all_tiles(conn, tms):
|
||||||
"""
|
|
||||||
Query all rows in the tasks table
|
|
||||||
:param conn: the Connection object
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute("SELECT * FROM images")
|
cur.execute("SELECT * FROM map")
|
||||||
|
|
||||||
rows = cur.fetchall()
|
rows = cur.fetchall()
|
||||||
assets = {}
|
assets = {}
|
||||||
print("Imamge count: " + str(len(rows)))
|
print("Map count: " + str(len(rows)))
|
||||||
print("TMS: " + str(tms))
|
print("TMS: " + str(tms))
|
||||||
for row in rows:
|
for row in rows:
|
||||||
result = get_Metadata(conn, row[1])
|
image = get_Image(conn, row[3])
|
||||||
|
|
||||||
# for printing
|
# for printing
|
||||||
dir = str(result['zoom']) + "/" + str(result['column'])
|
dir = str(row[0]) + "/" + str(row[1])
|
||||||
assets[dir] = dir
|
assets[dir] = dir
|
||||||
|
|
||||||
# tsm check
|
# tsm check
|
||||||
xValue = result['row']
|
xValue = row[2]
|
||||||
if(tms):
|
if(tms):
|
||||||
ymax = 1 << result['zoom']
|
ymax = 1 << row[0]
|
||||||
xValue = ymax - result['row'] - 1
|
xValue = ymax - row[2] - 1
|
||||||
|
|
||||||
# generate png
|
# generate png
|
||||||
blobToFile(
|
blobToFile(
|
||||||
str(result['zoom']), # {z}
|
str(row[0]), # {z}
|
||||||
str(result['column']), # {x}
|
str(row[1]), # {x}
|
||||||
str(xValue), # {y}
|
str(xValue), # {y}
|
||||||
row[0], # data
|
image, # data
|
||||||
)
|
)
|
||||||
for asset in assets:
|
for asset in assets:
|
||||||
print ('- assets/map/' + assets[asset] + "/")
|
print ('- assets/map/' + assets[asset] + "/")
|
||||||
|
|
||||||
|
|
||||||
def get_Metadata(conn, id):
|
def get_Image(conn, id):
|
||||||
"""
|
|
||||||
Query all rows in the tasks table
|
|
||||||
:param conn: the Connection object
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
cur.execute("SELECT * FROM map WHERE tile_id = ?", [id])
|
cur.execute("SELECT * FROM images WHERE tile_id = ?", [id])
|
||||||
|
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
return({'zoom': row[0], 'column': row[1], 'row': row[2]})
|
return(row[0])
|
||||||
|
|
||||||
|
|
||||||
def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
@ -99,7 +88,7 @@ def beginConvertion(database, tms):
|
|||||||
conn = create_connection(database)
|
conn = create_connection(database)
|
||||||
with conn:
|
with conn:
|
||||||
print("Processing mbtiles..\n***********\nIf you find your y coordinates (filename.png) are incorrect, use the -tsm option\n***********\n")
|
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):
|
def main(argv):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user