import console;
import sqlite;
/*
//合并数据
var db = sqlite("/test1.mbtiles");
var db2 = sqlite("/test2.mbtiles");
for zoom_level, tile_column, tile_row, tile_data in db2.each("SELECT * FROM [tiles]"){
db.prepare("INSERT INTO tiles (zoom_level, tile_column, tile_row, tile_data) values (@v1, @v2, @v3, @v4);").step(
v1 = zoom_level,
v2 = tile_column,
v3 = tile_row,
v4 = tile_data);
}
*/
//修改bounds
var result = db.stepQuery("SELECT * FROM [metadata]");
if (result.name == "bounds"){
var bounds = result.value;
//console.log(bounds);
var boundsArr = string.split(bounds, ",");
bounds = boundsArr[1] ++ "," ++ boundsArr[4] ++ "," ++ boundsArr[3] ++ "," ++ boundsArr[2];
//console.log(bounds);
db.exec("UPDATE metadata SET value = '%s' WHERE name = '%s';"
,bounds, "bounds");
}
//找相同的数据
var db = sqlite("/test1.mbtiles")
var db2 = sqlite("/test2.mbtiles")
var dbtable = {}
for zoom_level, tile_column, tile_row, tile_data in db.each("SELECT * FROM [tiles] WHERE zoom_level=15"){
table.push(dbtable, {zoom_level, tile_column, tile_row, tile_data})
}
var db2table = {}
for zoom_level, tile_column, tile_row, tile_data in db2.each("SELECT * FROM [tiles] WHERE zoom_level=15"){
table.push(db2table, {zoom_level, tile_column, tile_row, tile_data})
}
for (k2, v2 in db2table){
var f = 0
for (k, v in dbtable){
if (v2[1] == v[1] and v2[2] == v[2] and v2[3] == v[3]){
f = 1
break
}
}
if (f != 1){
console.log(v2[1], v2[2], v2[3])
}
}
console.pause();