diff --git a/OsmAnd-java/src/net/osmand/IndexConstants.java b/OsmAnd-java/src/net/osmand/IndexConstants.java index 3bc588eb0f..e7134506d5 100644 --- a/OsmAnd-java/src/net/osmand/IndexConstants.java +++ b/OsmAnd-java/src/net/osmand/IndexConstants.java @@ -50,6 +50,7 @@ public class IndexConstants { public static final String LIVE_INDEX_DIR= "live/"; public static final String TOURS_INDEX_DIR= "tours/"; public static final String SRTM_INDEX_DIR = "srtm/"; //$NON-NLS-1$ + public static final String ROADS_INDEX_DIR = "roads/"; //$NON-NLS-1$ public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$ public static final String AV_INDEX_DIR = "avnotes/"; //$NON-NLS-1$ public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$ diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java index a1560fae7f..51c03ed43e 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java @@ -74,7 +74,7 @@ public class BinaryInspector { // "-zoom=15", // "-bbox=1.74,51.17,1.75,51.16", // "-vstats", - "/Users/victorshcherb/osmand/temp/Angola_cuanza-sul_africa_2.srtm.obf" + "/Users/victorshcherb/osmand/temp/Czech-republic_jihovychod_europe_2.road.obf" }); } else { in.inspector(args); diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index 60c1681f83..65a2d144f7 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -88,6 +88,7 @@ public class LocalIndexHelper { List result = new ArrayList(); loadObfData(app.getAppPath(IndexConstants.MAPS_PATH), result, false, loadTask, loadedMaps); + loadObfData(app.getAppPath(IndexConstants.ROADS_INDEX_DIR), result, false, loadTask, loadedMaps); loadObfData(app.getAppPath(IndexConstants.BACKUP_INDEX_DIR), result, true, loadTask, loadedMaps); loadTilesData(app.getAppPath(IndexConstants.TILES_INDEX_DIR), result, false, loadTask); loadSrtmData(app.getAppPath(IndexConstants.SRTM_INDEX_DIR), result, loadTask); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index 0682ada7e1..48a37946ba 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -78,11 +78,12 @@ public class DownloadActivityType { } public boolean isAccepted(String fileName) { - if (ROADS_FILE == this || NORMAL_FILE == this) { - return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP, - IndexConstants.BINARY_MAP_VERSION)) + if(NORMAL_FILE == this) { + return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION)) || fileName.endsWith(IndexConstants.EXTRA_ZIP_EXT) || fileName.endsWith(IndexConstants.SQLITE_EXT); + } else if(ROADS_FILE == this) { + return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION)); } else if (VOICE_FILE == this) { return fileName.endsWith(addVersionToExt(IndexConstants.VOICE_INDEX_EXT_ZIP, IndexConstants.VOICE_VERSION)); } else if (WIKIPEDIA_FILE == this) { @@ -98,13 +99,15 @@ public class DownloadActivityType { } public File getDownloadFolder(OsmandApplication ctx, IndexItem indexItem) { - if (ROADS_FILE == this || NORMAL_FILE == this) { + if (NORMAL_FILE == this) { if(indexItem.fileName.endsWith(IndexConstants.SQLITE_EXT)) { return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR); } return ctx.getAppPath(IndexConstants.MAPS_PATH); } else if (VOICE_FILE == this) { return ctx.getAppPath(IndexConstants.VOICE_INDEX_DIR); + } else if (ROADS_FILE == this) { + return ctx.getAppPath(IndexConstants.ROADS_INDEX_DIR); } else if (SRTM_COUNTRY_FILE == this) { return ctx.getAppPath(IndexConstants.SRTM_INDEX_DIR); } else if (WIKIPEDIA_FILE == this) { @@ -143,7 +146,7 @@ public class DownloadActivityType { return ""; } } else if (ROADS_FILE == this) { - return "-roads" + BINARY_MAP_INDEX_EXT; + return IndexConstants.BINARY_ROAD_MAP_INDEX_EXT; } else if (VOICE_FILE == this) { return ""; } else if (SRTM_COUNTRY_FILE == this) { @@ -292,7 +295,7 @@ public class DownloadActivityType { return baseNameWithoutVersion + IndexConstants.BINARY_WIKI_MAP_INDEX_EXT; } if (this == DownloadActivityType.ROADS_FILE) { - baseNameWithoutVersion += "-roads"; + return baseNameWithoutVersion + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT; } baseNameWithoutVersion += IndexConstants.BINARY_MAP_INDEX_EXT; return baseNameWithoutVersion; diff --git a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java index 0b116da76b..6d9d7a56b8 100644 --- a/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/LocalIndexesFragment.java @@ -344,6 +344,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { File parent = new File(i.getPathToData()).getParentFile(); if(i.getType() == LocalIndexType.SRTM_DATA){ parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR); + } else if(i.getFileName().endsWith(IndexConstants.ROADS_INDEX_DIR)){ + parent = getMyApplication().getAppPath(IndexConstants.ROADS_INDEX_DIR); } else if(i.getType() == LocalIndexType.WIKI_DATA){ parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR); } else if(i.getType() == LocalIndexType.MAP_DATA){ @@ -1112,16 +1114,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment { private String getMapDescription(String fileName){ - int ls = fileName.lastIndexOf("."); - String name = fileName; - if (ls >= 0) { - name = fileName.substring(0, ls); - } - - if (name.endsWith("-roads")) { + if (fileName.endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) { return ctx.getString(R.string.download_roads_only_item); } - return ""; } } diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index 0cf856dbcf..e22dbb0347 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -10,6 +10,7 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -585,18 +586,35 @@ public class ResourceManager { } return files; } + + private void renameRoadsFiles(ArrayList files, File roadsPath) { + Iterator it = files.iterator(); + while(it.hasNext()) { + File f = it.next(); + if (f.getName().endsWith("-roads" + IndexConstants.BINARY_MAP_INDEX_EXT)) { + f.renameTo(new File(roadsPath, f.getName().replace("-roads" + IndexConstants.BINARY_MAP_INDEX_EXT, + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT))); + } + } + } public List indexingMaps(final IProgress progress) { long val = System.currentTimeMillis(); ArrayList files = new ArrayList(); File appPath = context.getAppPath(null); + File roadsPath = context.getAppPath(IndexConstants.ROADS_INDEX_DIR); + roadsPath.mkdirs(); + collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files); + renameRoadsFiles(files, roadsPath); + collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files); if(!Version.isFreeVersion(context)) { collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); } if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) { collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); } + if(context.getSettings().BETA_TESTING_LIVE_UPDATES.get()) { collectFiles(context.getAppPath(IndexConstants.LIVE_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files); } @@ -714,6 +732,8 @@ public class ResourceManager { return warnings; } + + public void initMapBoundariesCacheNative() { File indCache = context.getAppPath(INDEXES_CACHE); if (indCache.exists()) {