Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
0a21d4e841
2 changed files with 60 additions and 36 deletions
|
@ -31,9 +31,16 @@ import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
public class OsmandRegions {
|
public class OsmandRegions {
|
||||||
|
|
||||||
|
private static final String MAP_TYPE = "region_map";
|
||||||
|
// regionSrtm = object.getMapIndex().getRule("region_srtm", null);
|
||||||
|
// regionWiki = object.getMapIndex().getRule("region_wiki", null);
|
||||||
|
// regionRoads = object.getMapIndex().getRule("region_roads", null);
|
||||||
|
// regionHillshade = object.getMapIndex().getRule("region_hillshade", null);
|
||||||
|
|
||||||
private BinaryMapIndexReader reader;
|
private BinaryMapIndexReader reader;
|
||||||
Map<String, LinkedList<BinaryMapDataObject>> countriesByDownloadName = new HashMap<String, LinkedList<BinaryMapDataObject>>();
|
Map<String, LinkedList<BinaryMapDataObject>> countriesByDownloadName = new HashMap<String, LinkedList<BinaryMapDataObject>>();
|
||||||
Map<String, String> fullNamesToLocaleNames = new HashMap<String, String>();
|
Map<String, String> fullNamesToLocaleNames = new HashMap<String, String>();
|
||||||
|
Map<String, String> fullMapNamesToDownloadNames = new HashMap<String, String>();
|
||||||
Map<String, String> downloadNamesToFullNames = new HashMap<String, String>();
|
Map<String, String> downloadNamesToFullNames = new HashMap<String, String>();
|
||||||
Map<String, String> fullNamesToLowercaseIndex = new HashMap<String, String>();
|
Map<String, String> fullNamesToLowercaseIndex = new HashMap<String, String>();
|
||||||
QuadTree<String> quadTree = null ;
|
QuadTree<String> quadTree = null ;
|
||||||
|
@ -46,11 +53,6 @@ public class OsmandRegions {
|
||||||
Integer nameType = null;
|
Integer nameType = null;
|
||||||
Integer nameLocaleType = null;
|
Integer nameLocaleType = null;
|
||||||
String locale = "en";
|
String locale = "en";
|
||||||
Integer regionSrtm;
|
|
||||||
Integer regionWiki;
|
|
||||||
Integer regionMap;
|
|
||||||
Integer regionRoads;
|
|
||||||
Integer regionHillshade;
|
|
||||||
|
|
||||||
|
|
||||||
public void prepareFile(String fileName) throws IOException {
|
public void prepareFile(String fileName) throws IOException {
|
||||||
|
@ -258,6 +260,10 @@ public class OsmandRegions {
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMapDownloadType(String fullname) {
|
||||||
|
return fullMapNamesToDownloadNames.get(fullname);
|
||||||
|
}
|
||||||
|
|
||||||
public void initLocaleNames() throws IOException {
|
public void initLocaleNames() throws IOException {
|
||||||
// final Collator clt = OsmAndCollator.primaryCollator();
|
// final Collator clt = OsmAndCollator.primaryCollator();
|
||||||
final Map<String, String> parentRelations = new LinkedHashMap<String, String>();
|
final Map<String, String> parentRelations = new LinkedHashMap<String, String>();
|
||||||
|
@ -266,6 +272,13 @@ public class OsmandRegions {
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(BinaryMapDataObject object) {
|
public boolean publish(BinaryMapDataObject object) {
|
||||||
initTypes(object);
|
initTypes(object);
|
||||||
|
int[] types = object.getTypes();
|
||||||
|
for(int i = 0; i < types.length; i++ ) {
|
||||||
|
TagValuePair tp = object.getMapIndex().decodeType(types[i]);
|
||||||
|
if("boundary".equals(tp.value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
String parentFullName = getParentFullName(object);
|
String parentFullName = getParentFullName(object);
|
||||||
String fullName = getFullName(object);
|
String fullName = getFullName(object);
|
||||||
if(!Algorithms.isEmpty(parentFullName)) {
|
if(!Algorithms.isEmpty(parentFullName)) {
|
||||||
|
@ -297,10 +310,14 @@ public class OsmandRegions {
|
||||||
String downloadName = getDownloadName(object);
|
String downloadName = getDownloadName(object);
|
||||||
if(downloadName != null) {
|
if(downloadName != null) {
|
||||||
downloadNamesToFullNames.put(downloadName, fullName);
|
downloadNamesToFullNames.put(downloadName, fullName);
|
||||||
|
if(isDownloadOfType(object, MAP_TYPE)) {
|
||||||
|
fullMapNamesToDownloadNames.put(fullName, downloadName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -331,6 +348,17 @@ public class OsmandRegions {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isDownloadOfType(BinaryMapDataObject object, String type) {
|
||||||
|
int[] addtypes = object.getAdditionalTypes();
|
||||||
|
for(int i = 0; i < addtypes.length; i++) {
|
||||||
|
TagValuePair tp = object.getMapIndex().decodeType(addtypes[i]);
|
||||||
|
if(type.equals(tp.tag) && "yes".equals(tp.value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void cacheAllCountries() throws IOException {
|
public void cacheAllCountries() throws IOException {
|
||||||
quadTree = new QuadTree<String>(new QuadRect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE),
|
quadTree = new QuadTree<String>(new QuadRect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE),
|
||||||
|
@ -402,11 +430,7 @@ public class OsmandRegions {
|
||||||
nameLocaleType = object.getMapIndex().getRule("name:" + locale, null);
|
nameLocaleType = object.getMapIndex().getRule("name:" + locale, null);
|
||||||
parentFullName = object.getMapIndex().getRule("region_parent_name", null);
|
parentFullName = object.getMapIndex().getRule("region_parent_name", null);
|
||||||
fullNameType = object.getMapIndex().getRule("region_full_name", null);
|
fullNameType = object.getMapIndex().getRule("region_full_name", null);
|
||||||
regionSrtm = object.getMapIndex().getRule("region_srtm", null);
|
|
||||||
regionWiki = object.getMapIndex().getRule("region_wiki", null);
|
|
||||||
regionMap = object.getMapIndex().getRule("region_map", null);
|
|
||||||
regionRoads = object.getMapIndex().getRule("region_roads", null);
|
|
||||||
regionHillshade = object.getMapIndex().getRule("region_hillshade", null);
|
|
||||||
if (downloadNameType == null || nameType == null) {
|
if (downloadNameType == null || nameType == null) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,8 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
currentObjects != null) {
|
currentObjects != null) {
|
||||||
path.reset();
|
path.reset();
|
||||||
for (BinaryMapDataObject o : currentObjects) {
|
for (BinaryMapDataObject o : currentObjects) {
|
||||||
boolean downloaded = checkIfObjectDownloaded(o);
|
String downloadName = osmandRegions.getDownloadName(o);
|
||||||
|
boolean downloaded = checkIfObjectDownloaded(downloadName);
|
||||||
if (!downloaded) {
|
if (!downloaded) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -136,10 +137,10 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private boolean checkIfObjectDownloaded(BinaryMapDataObject o) {
|
private boolean checkIfObjectDownloaded(String downloadName) {
|
||||||
final String regionName = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getDownloadName(o))
|
final String regionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName)
|
||||||
+ IndexConstants.BINARY_MAP_INDEX_EXT;
|
+ IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||||
final String roadsRegionName = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getDownloadName(o)) + "-roads"
|
final String roadsRegionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName) + "-roads"
|
||||||
+ IndexConstants.BINARY_MAP_INDEX_EXT;
|
+ IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||||
return rm.getIndexFileNames().containsKey(regionName) || rm.getIndexFileNames().containsKey(roadsRegionName);
|
return rm.getIndexFileNames().containsKey(regionName) || rm.getIndexFileNames().containsKey(roadsRegionName);
|
||||||
}
|
}
|
||||||
|
@ -237,35 +238,34 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
btnName.append(view.getResources().getString(R.string.shared_string_download));
|
btnName.append(view.getResources().getString(R.string.shared_string_download));
|
||||||
filter.setLength(0);
|
filter.setLength(0);
|
||||||
Set<String> set = new TreeSet<String>();
|
Set<String> set = new TreeSet<String>();
|
||||||
int cx = queriedBox.getCenter31X();
|
int cx = view.getCurrentRotatedTileBox().getCenter31X();
|
||||||
int cy = queriedBox.getCenter31Y();
|
int cy = view.getCurrentRotatedTileBox().getCenter31Y();
|
||||||
if ((currentObjects != null && currentObjects.size() > 0)) {
|
if ((currentObjects != null && currentObjects.size() > 0)) {
|
||||||
for (int i = 0; i < currentObjects.size(); i++) {
|
for (int i = 0; i < currentObjects.size(); i++) {
|
||||||
// TODO regions=boundary
|
|
||||||
final BinaryMapDataObject o = currentObjects.get(i);
|
final BinaryMapDataObject o = currentObjects.get(i);
|
||||||
if (!osmandRegions.contain(o, cx, cy)) {
|
if (!osmandRegions.contain(o, cx, cy)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(checkIfObjectDownloaded(o)) {
|
String fullName = osmandRegions.getFullName(o);
|
||||||
return null;
|
String downloadName = osmandRegions.getMapDownloadType(fullName);
|
||||||
|
if (!Algorithms.isEmpty(downloadName)) {
|
||||||
|
String name = osmandRegions.getLocaleName(downloadName); // Algorithms.capitalizeFirstLetterAndLowercase(o.getName());
|
||||||
|
if (checkIfObjectDownloaded(downloadName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!set.add(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (set.size() > 1) {
|
||||||
|
btnName.append(" ").append(view.getResources().getString(R.string.shared_string_or))
|
||||||
|
.append(" ");
|
||||||
|
filter.append(", ");
|
||||||
|
} else {
|
||||||
|
btnName.append(" ");
|
||||||
|
}
|
||||||
|
filter.append(name);
|
||||||
|
btnName.append(name);
|
||||||
}
|
}
|
||||||
String name = osmandRegions.getLocaleName(o); //Algorithms.capitalizeFirstLetterAndLowercase(o.getName());
|
|
||||||
if (!set.add(name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (set.size() > 1) {
|
|
||||||
btnName.append(" ").append(view.getResources().getString(R.string.shared_string_or)).append(" ");
|
|
||||||
filter.append(", ");
|
|
||||||
} else {
|
|
||||||
btnName.append(" ");
|
|
||||||
}
|
|
||||||
filter.append(name);
|
|
||||||
// String parent = osmandRegions.getParentFullName(o);
|
|
||||||
// if (osmandRegions.getParentFullName(o) != null) {
|
|
||||||
// name = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getPrefix(o)) + " "
|
|
||||||
// + name;
|
|
||||||
// }
|
|
||||||
btnName.append(name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue