joining together two mbtiles files

后端 未结 2 1210
轻奢々
轻奢々 2021-02-06 15:46

I haven\'t managed to find a way to join two *.mbtiles files together (first one contains zoom level from 0-16 and second one zoom level 17). I was working with different sqlite

2条回答
  •  心在旅途
    2021-02-06 16:17

    In my case I have an error with the @CL. solution:

    Error: cannot modify tiles because it is a view
    

    So the schema of my database is different:

    > .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);
    

    So you can adapt the solution this way:

    First update the metadata the way you want, for example:

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

    Then insert the tiles:

    sqlite> INSERT OR REPLACE INTO images SELECT * from db2.images;
    sqlite> INSERT OR REPLACE INTO map SELECT * from db2.map;
    

提交回复
热议问题