Skip to content

Instantly share code, notes, and snippets.

@rzymek
rzymek / mbtiles-osmand.sql
Created December 5, 2016 17:58
Extend mbtiles with osmand's .sqllitedb compatibility
-- Unfortunately osmand's .sqlitedb and .mbtiles use the same table name, but with different columns
alter table tiles rename to mbtiles;
-- osmand uses inverted y numbering (compared to mbtiles)
-- The formula to calculate inverted y is: y' = (2^z - 1) - y
-- As sqlite does not support pow() function, here's a table of precalculated (2^z-1) for z from 0 to 25.
create table maxy (y integer, z integer);
CREATE UNIQUE INDEX IF NOT EXISTS maxy_index on maxy (z,y);
insert into maxy(y,z) values(0,0);