Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
28b0845d10
4 changed files with 60 additions and 52 deletions
|
@ -25,6 +25,7 @@ import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.QuadTree;
|
import net.osmand.data.QuadTree;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapAlgorithms;
|
import net.osmand.util.MapAlgorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
@ -37,14 +38,18 @@ public class OsmandRegions {
|
||||||
QuadTree<String> quadTree = null ;
|
QuadTree<String> quadTree = null ;
|
||||||
|
|
||||||
|
|
||||||
Integer prefixType = null;
|
Integer parentFullName = null;
|
||||||
|
Integer fullNameType = null;
|
||||||
Integer downloadNameType = null;
|
Integer downloadNameType = null;
|
||||||
Integer nameEnType = null;
|
Integer nameEnType = null;
|
||||||
Integer nameType = null;
|
Integer nameType = null;
|
||||||
Integer nameLocaleType = null;
|
Integer nameLocaleType = null;
|
||||||
String locale = "en";
|
String locale = "en";
|
||||||
Integer suffixType;
|
Integer regionSrtm;
|
||||||
Integer keyNameType;
|
Integer regionWiki;
|
||||||
|
Integer regionMap;
|
||||||
|
Integer regionRoads;
|
||||||
|
Integer regionHillshade;
|
||||||
|
|
||||||
|
|
||||||
public void prepareFile(String fileName) throws IOException {
|
public void prepareFile(String fileName) throws IOException {
|
||||||
|
@ -106,25 +111,20 @@ public class OsmandRegions {
|
||||||
return locName;
|
return locName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPrefix(BinaryMapDataObject o) {
|
public String getParentFullName(BinaryMapDataObject o) {
|
||||||
if(prefixType == null) {
|
if(parentFullName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return o.getNameByType(prefixType);
|
return o.getNameByType(parentFullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuffix(BinaryMapDataObject o) {
|
|
||||||
if(suffixType == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return o.getNameByType(suffixType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyName(BinaryMapDataObject o) {
|
|
||||||
if(keyNameType == null) {
|
public String getFullName(BinaryMapDataObject o) {
|
||||||
|
if(fullNameType == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return o.getNameByType(keyNameType);
|
return o.getNameByType(fullNameType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInitialized(){
|
public boolean isInitialized(){
|
||||||
|
@ -253,34 +253,31 @@ public class OsmandRegions {
|
||||||
|
|
||||||
public void initLocaleNames() throws IOException {
|
public void initLocaleNames() throws IOException {
|
||||||
// final Collator clt = OsmAndCollator.primaryCollator();
|
// final Collator clt = OsmAndCollator.primaryCollator();
|
||||||
final Map<String, BinaryMapDataObject> downloadNamesPrefix = new LinkedHashMap<String, BinaryMapDataObject>();
|
final Map<String, String> downloadNames = new LinkedHashMap<String, String>();
|
||||||
|
final Map<String, String> parentRelations = new LinkedHashMap<String, String>();
|
||||||
final ResultMatcher<BinaryMapDataObject> resultMatcher = new ResultMatcher<BinaryMapDataObject>() {
|
final ResultMatcher<BinaryMapDataObject> resultMatcher = new ResultMatcher<BinaryMapDataObject>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(BinaryMapDataObject object) {
|
public boolean publish(BinaryMapDataObject object) {
|
||||||
initTypes(object);
|
initTypes(object);
|
||||||
String downloadName = object.getNameByType(downloadNameType).toLowerCase();
|
String downloadName = getDownloadName(object);
|
||||||
String prefix = getPrefix(object);
|
if(downloadName == null) {
|
||||||
String keyName = getKeyName(object);
|
return false;
|
||||||
if(prefix == null) {
|
|
||||||
prefix = "";
|
|
||||||
}
|
}
|
||||||
|
downloadName = downloadName.toLowerCase();
|
||||||
|
String parentFullName = getParentFullName(object);
|
||||||
|
String fullName = getFullName(object);
|
||||||
|
if(!Algorithms.isEmpty(parentFullName)) {
|
||||||
|
parentRelations.put(fullName, parentFullName);
|
||||||
|
}
|
||||||
|
downloadNames.put(fullName, downloadName);
|
||||||
String locName = getLocaleName(object);
|
String locName = getLocaleName(object);
|
||||||
if(locName != null && locName.length() > 0){
|
if(locName != null && locName.length() > 0){
|
||||||
String kn = keyName.toLowerCase();
|
|
||||||
if(prefix.length() > 0) {
|
|
||||||
downloadNamesPrefix.put(downloadName, object);
|
|
||||||
kn = prefix.toLowerCase() +"_" + keyName;
|
|
||||||
}
|
|
||||||
downloadNamesToLocaleNames.put(downloadName, locName);
|
downloadNamesToLocaleNames.put(downloadName, locName);
|
||||||
downloadNamesToLocaleNames.put(kn, locName);
|
|
||||||
}
|
}
|
||||||
MapIndex mi = object.getMapIndex();
|
MapIndex mi = object.getMapIndex();
|
||||||
TIntObjectIterator<String> it = object.getObjectNames().iterator();
|
TIntObjectIterator<String> it = object.getObjectNames().iterator();
|
||||||
|
|
||||||
StringBuilder ind = new StringBuilder();
|
StringBuilder ind = new StringBuilder();
|
||||||
String pr = getDownloadNameIndexLowercase(prefix);
|
|
||||||
ind.append(pr == null ? prefix.toLowerCase() : pr.toLowerCase()).append(" ");
|
|
||||||
while(it.hasNext()) {
|
while(it.hasNext()) {
|
||||||
it.advance();
|
it.advance();
|
||||||
TagValuePair tp = mi.decodeType(it.key());
|
TagValuePair tp = mi.decodeType(it.key());
|
||||||
|
@ -303,18 +300,23 @@ public class OsmandRegions {
|
||||||
};
|
};
|
||||||
iterateOverAllObjects(resultMatcher);
|
iterateOverAllObjects(resultMatcher);
|
||||||
// post process download names
|
// post process download names
|
||||||
for(Map.Entry<String, BinaryMapDataObject> e : downloadNamesPrefix.entrySet()) {
|
for(Map.Entry<String, String> e : downloadNames.entrySet()) {
|
||||||
String downloadName = e.getKey();
|
String fullName = e.getKey();
|
||||||
BinaryMapDataObject o = e.getValue();
|
String downloadName = e.getValue();
|
||||||
String prefix = getPrefix(o).toLowerCase();
|
String parentFullName = parentRelations.get(fullName);
|
||||||
String locPrefix = downloadNamesToLocaleNames.get(prefix);
|
if(!Algorithms.isEmpty(parentFullName) &&
|
||||||
String locName = downloadNamesToLocaleNames.get(downloadName);
|
!Algorithms.isEmpty(parentRelations.get(parentFullName))) {
|
||||||
if(locPrefix == null || locName == null) {
|
String parentDW = downloadNames.get(parentFullName);
|
||||||
throw new IllegalStateException("There is no prefix registered for " + downloadName + " (" + prefix + ") ");
|
String locPrefix = downloadNamesToLocaleNames.get(parentDW);
|
||||||
|
String locName = downloadNamesToLocaleNames.get(downloadName);
|
||||||
|
if(locPrefix == null || locName == null) {
|
||||||
|
throw new IllegalStateException("There is no prefix registered for " + downloadName + " (" + parentFullName + ") ");
|
||||||
|
}
|
||||||
|
downloadNamesToLocaleNames.put(downloadName, locPrefix + " " + locName);
|
||||||
|
String index = downloadNamesToLowercaseIndex.get(downloadName);
|
||||||
|
String prindex = downloadNamesToLowercaseIndex.get(parentDW);
|
||||||
|
downloadNamesToLowercaseIndex.put(downloadName, index + " " + prindex);
|
||||||
}
|
}
|
||||||
downloadNamesToLocaleNames.put(downloadName, locPrefix + " " + locName);
|
|
||||||
String index = downloadNamesToLowercaseIndex.get(downloadName);
|
|
||||||
downloadNamesToLowercaseIndex.put(downloadName, index + " " + prefix + " " + locPrefix.toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -388,9 +390,13 @@ public class OsmandRegions {
|
||||||
nameType = object.getMapIndex().getRule("name", null);
|
nameType = object.getMapIndex().getRule("name", null);
|
||||||
nameEnType = object.getMapIndex().getRule("name:en", null);
|
nameEnType = object.getMapIndex().getRule("name:en", null);
|
||||||
nameLocaleType = object.getMapIndex().getRule("name:" + locale, null);
|
nameLocaleType = object.getMapIndex().getRule("name:" + locale, null);
|
||||||
prefixType = object.getMapIndex().getRule("region_prefix", null);
|
parentFullName = object.getMapIndex().getRule("region_parent_name", null);
|
||||||
suffixType = object.getMapIndex().getRule("region_suffix", null);
|
fullNameType = object.getMapIndex().getRule("region_full_name", null);
|
||||||
keyNameType = object.getMapIndex().getRule("key_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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1014,8 +1014,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
||||||
((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(),
|
((OsmandApplication) getDownloadActivity().getApplication()).getResourceManager().getOsmandRegions(),
|
||||||
child.getFileName());
|
child.getFileName());
|
||||||
if (mapDescr.length() > 0){
|
if (mapDescr.length() > 0) {
|
||||||
return mapDescr + " - " + mapName;
|
return mapName + " - " + mapDescr;
|
||||||
} else {
|
} else {
|
||||||
return mapName;
|
return mapName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,9 +68,9 @@ public class FileNameTranslationHelper {
|
||||||
int index = wikiWord.indexOf("(");
|
int index = wikiWord.indexOf("(");
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
//removing word in "()" from recourse file
|
//removing word in "()" from recourse file
|
||||||
return wikiWord.substring(0, index) + wikiName;
|
return wikiName + wikiWord.substring(0, index);
|
||||||
}
|
}
|
||||||
return ctx.getString(R.string.amenity_type_osmwiki) + " " + wikiName;
|
return wikiName + " " + ctx.getString(R.string.amenity_type_osmwiki);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVoiceName(Context ctx, String basename) {
|
public static String getVoiceName(Context ctx, String basename) {
|
||||||
|
|
|
@ -241,6 +241,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
int cy = queriedBox.getCenter31Y();
|
int cy = queriedBox.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;
|
||||||
|
@ -259,10 +260,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
btnName.append(" ");
|
btnName.append(" ");
|
||||||
}
|
}
|
||||||
filter.append(name);
|
filter.append(name);
|
||||||
if (osmandRegions.getPrefix(o) != null) {
|
// String parent = osmandRegions.getParentFullName(o);
|
||||||
name = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getPrefix(o)) + " "
|
// if (osmandRegions.getParentFullName(o) != null) {
|
||||||
+ name;
|
// name = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getPrefix(o)) + " "
|
||||||
}
|
// + name;
|
||||||
|
// }
|
||||||
btnName.append(name);
|
btnName.append(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue