Merge pull request #9154 from osmandapp/minor_fixes

Fix possible terrain db error
This commit is contained in:
vshcherb 2020-06-05 16:52:13 +02:00 committed by GitHub
commit 79b5b9bf08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,28 +1,5 @@
package net.osmand.plus.srtmplugin;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;
@ -31,6 +8,29 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.AsyncTask;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox;
import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.settings.backend.OsmandSettings.TerrainMode;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static net.osmand.plus.settings.backend.OsmandSettings.TerrainMode.HILLSHADE;
public class TerrainLayer extends MapTileLayer {
@ -86,11 +86,11 @@ public class TerrainLayer extends MapTileLayer {
new File(cacheDir, mode == HILLSHADE ? HILLSHADE_CACHE : SLOPE_CACHE).getPath(),
null, SQLiteDatabase.ENABLE_WRITE_AHEAD_LOGGING
| SQLiteDatabase.CREATE_IF_NECESSARY );
if(sqliteDb.getVersion() == 0) {
if (sqliteDb.getVersion() == 0) {
sqliteDb.setVersion(1);
sqliteDb.execSQL("CREATE TABLE TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)");
}
sqliteDb.execSQL("CREATE TABLE IF NOT EXISTS TILE_SOURCES(filename varchar2(256), date_modified int, left int, right int, top int, bottom int)");
Map<String, Long> fileModified = new HashMap<String, Long>();
Map<String, SQLiteTileSource> rs = readFiles(app, tilesDir, fileModified);
indexCachedResources(fileModified, rs);