Open slazav opened 3 weeks ago
Is anything stopping you from having a tiles
table that has zoom_level, tile_column, tile_row, tile_data, x, y, z, image, and time columns?
Thanks for the answer! I tested it with OruxMaps:
tiles
it still works, but it's not sharing information, each tile is recorded twice: CREATE TABLE tiles (tile_column int, tile_row int, zoom_level int, tile_data blob, x int, y int, z int, image blob, PRIMARY KEY (tile_column, tile_row, zoom_level));
CREATE TABLE tiles (tile_column int, tile_row int, zoom_level int, tile_data blob, x int as (tile_column), y int as (tile_row), z int as (zoom_level), image blob as (tile_data), PRIMARY KEY (tile_column, tile_row, zoom_level));'
I'm not familiar with mbtiles and was not sure what is allowed there. The standartd says: it must contain 3+1 columns. Probably now it's just my misunderstanding of sqlite (why the autogenerated columns are different) or a question to OruxMaps (what do they expect in the file).
Sorry, I wish I knew anything about OruxMaps and its requirements.
The reason the autogenerated columns don't work is probably that the Y axis in mbtiles is backwards, so y is 2**zoom_level - 1 - tile_row
, not just tile_row
.
Fortunately, Osmand allows different directions (inverted_y
setting in info
table). In this test I'm just adding additional fields to a working mbtiles file keeping the original structure intact.
I would like to publish a single set of tiles which can be used in different programs. Structure of mbtiles database is very similar to osmand (https://osmand.net/docs/technical/osmand-file-formats/osmand-sqlite/). I believe I can provide both mbtiles
metadata
and osmandinfo
tables in the single database. Providingtiles
table looks more difficult: unfortunately it has same name in both formats (not possible to create an sql view), but different names of fields. Having extra fields in this table breaks the mbtiles specification (I can see that it does not work in Orux app). It would be nice to have a solution for this problem.