From 148e6a2b1ee13ce59df467888baf0ca1037d51a5 Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Mon, 10 Feb 2020 12:08:29 +0200 Subject: [PATCH] sqlite map sources with urls --- .../src/net/osmand/plus/SQLiteTileSource.java | 23 +++++-------------- .../src/net/osmand/plus/SettingsHelper.java | 4 ++-- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java index c3b84f35f3..3771b2c1b0 100644 --- a/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java +++ b/OsmAnd/src/net/osmand/plus/SQLiteTileSource.java @@ -56,14 +56,7 @@ public class SQLiteTileSource implements ITileSource { private OsmandApplication ctx; private boolean onlyReadonlyAvailable = false; - private static final String TILES_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS tiles (" + - "x, " + - "y, " + - "z, " + - "s, " + - "image, " + - "time" + - ")"; + private static final String TILES_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS \"tiles\" (\"x\" INTEGER NOT NULL, \"y\" INTEGER NOT NULL, \"z\" INTEGER NOT NULL, \"s\" INTEGER, \"image\" BLOB, \"time\" INTEGER, PRIMARY KEY (\"x\", \"y\", \"z\"))"; public SQLiteTileSource(OsmandApplication ctx, File f, List toFindUrl){ this.ctx = ctx; @@ -106,18 +99,14 @@ public class SQLiteTileSource implements ITileSource { public void createDataBase() { db = ctx.getSQLiteAPI().getOrCreateDatabase( ctx.getAppPath(TILES_INDEX_DIR).getAbsolutePath() + "/" + name + SQLITE_EXT, true); + db.execSQL("CREATE TABLE IF NOT EXISTS info (" + - "url " + + "minzoom, " + + "maxzoom " + ");"); - db.execSQL("INSERT INTO info (url) VALUES ('" + urlTemplate + "');"); + db.execSQL("INSERT INTO info (minzoom,maxzoom) VALUES ('" + minZoom + "','" + maxZoom + "');"); -// db.execSQL("INSERT INTO info VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", -// new Object[]{minZoom, maxZoom, urlTemplate, randoms, isEllipsoid ? 1 : 0, -// invertedY ? 1 : 0, referer, timeSupported ? "yes" : "no", timeSupported ? "yes" : "no", -// getExpirationTimeMinutes(), inversiveZoom ? "BigPlanet" : ""}); - - addInfoColumn("minzoom", String.valueOf(minZoom)); - addInfoColumn("maxzoom", String.valueOf(maxZoom)); + addInfoColumn("url", urlTemplate); addInfoColumn("randoms", randoms); addInfoColumn("ellipsoid", isEllipsoid ? "1" : "0"); addInfoColumn("inverted_y", invertedY ? "1" : "0"); diff --git a/OsmAnd/src/net/osmand/plus/SettingsHelper.java b/OsmAnd/src/net/osmand/plus/SettingsHelper.java index 2ebb252685..f7b4fd492e 100644 --- a/OsmAnd/src/net/osmand/plus/SettingsHelper.java +++ b/OsmAnd/src/net/osmand/plus/SettingsHelper.java @@ -1091,8 +1091,8 @@ public class SettingsHelper { JSONObject object = items.getJSONObject(i); boolean sql = object.optBoolean("sql"); String name = object.optString("name"); - int minZoom = object.optInt("minZoom", 1); - int maxZoom = object.optInt("maxZoom", 17); + int minZoom = object.optInt("minZoom"); + int maxZoom = object.optInt("maxZoom"); String url = object.optString("url"); String randoms = object.optString("randoms"); boolean ellipsoid = object.optBoolean("ellipsoid", false);