5

我还没有找到将两个 *.mbtiles 文件连接在一起的方法(第一个包含 0-16 的缩放级别,第二个包含 17 的缩放级别)。我正在使用不同的 sqlite 管理器,但不知道如何将 database2 导出和导入到 database1 中,我没有成功 - 二进制字段总是严重损坏,无法恢复 image.png。

有谁知道将两个 mbtiles 文件连接在一起的简单程序?

4

2 回答 2

6

如果这两个文件具有相同的元数据,并且tiles表实际上是表而不是视图,则可以简单地将其中一个的数据附加到另一个表:

/* open database1 as main database, then: */
ATTACH 'database2' AS db2;
INSERT INTO tiles SELECT * FROM db2.tiles;
于 2013-07-19T12:55:53.763 回答
5

就我而言,@CL 有错误。解决方案:

Error: cannot modify tiles because it is a view

所以我的数据库的架构是不同的:

> .schema

CREATE TABLE grid_key (
    grid_id TEXT,
    key_name TEXT
);
CREATE TABLE grid_utfgrid (
    grid_id TEXT,
    grid_utfgrid BLOB
);
CREATE TABLE images (
    tile_data blob,
    tile_id text
);
CREATE TABLE keymap (
    key_name TEXT,
    key_json TEXT
);
CREATE TABLE map (
   zoom_level INTEGER,
   tile_column INTEGER,
   tile_row INTEGER,
   tile_id TEXT,
   grid_id TEXT
);
CREATE TABLE metadata (
    name text,
    value text
);
CREATE VIEW tiles AS
    SELECT
        map.zoom_level AS zoom_level,
        map.tile_column AS tile_column,
        map.tile_row AS tile_row,
        images.tile_data AS tile_data
    FROM map
    JOIN images ON images.tile_id = map.tile_id;
CREATE VIEW grids AS
    SELECT
        map.zoom_level AS zoom_level,
        map.tile_column AS tile_column,
        map.tile_row AS tile_row,
        grid_utfgrid.grid_utfgrid AS grid
    FROM map
    JOIN grid_utfgrid ON grid_utfgrid.grid_id = map.grid_id;
CREATE VIEW grid_data AS
    SELECT
        map.zoom_level AS zoom_level,
        map.tile_column AS tile_column,
        map.tile_row AS tile_row,
        keymap.key_name AS key_name,
        keymap.key_json AS key_json
    FROM map
    JOIN grid_key ON map.grid_id = grid_key.grid_id
    JOIN keymap ON grid_key.key_name = keymap.key_name;
CREATE UNIQUE INDEX grid_key_lookup ON grid_key (grid_id, key_name);
CREATE UNIQUE INDEX grid_utfgrid_lookup ON grid_utfgrid (grid_id);
CREATE UNIQUE INDEX images_id ON images (tile_id);
CREATE UNIQUE INDEX keymap_lookup ON keymap (key_name);
CREATE UNIQUE INDEX map_index ON map (zoom_level, tile_column, tile_row);
CREATE UNIQUE INDEX name ON metadata (name);

因此,您可以通过以下方式调整解决方案:

首先以您想要的方式更新元数据,例如:

sqlite> UPDATE metadata SET value = '7' WHERE name = 'minzoom';

然后插入瓷砖:

sqlite> INSERT OR REPLACE INTO images SELECT * from db2.images;
sqlite> INSERT OR REPLACE INTO map SELECT * from db2.map;
于 2014-06-11T13:25:44.470 回答