Display alternative names for streets

This commit is contained in:
Alexey Kulish 2017-03-25 20:13:44 +03:00
parent f6d4b62555
commit 51d9605cde

View file

@ -41,6 +41,7 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@ -356,6 +357,15 @@ public class SearchCoreFactory {
if (!phrase.getNameStringMatcher().matches(stripBraces(sr.localeName))) {
sr.priorityDistance = 5;
}
String searchTextLower = phrase.getUnknownSearchWord().toLowerCase();
if (!Algorithms.isEmpty(searchTextLower) && !sr.localeName.toLowerCase().contains(searchTextLower)) {
for (String otherName : sr.otherNames) {
if (otherName.toLowerCase().contains(searchTextLower)) {
sr.localeName = sr.localeName + " (" + otherName + ")";
break;
}
}
}
sr.objectType = ObjectType.STREET;
sr.localeRelatedObjectName = ((Street)object).getCity().getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
sr.relatedObject = ((Street)object).getCity();
@ -866,6 +876,15 @@ public class SearchCoreFactory {
&& !(nm.matches(res.localeName) || nm.matches(res.otherNames))) {
continue;
}
String searchTextLower = phrase.getUnknownSearchWord().toLowerCase();
if (!Algorithms.isEmpty(searchTextLower) && !res.localeName.toLowerCase().contains(searchTextLower)) {
for (String otherName : res.otherNames) {
if (otherName.toLowerCase().contains(searchTextLower)) {
res.localeName = res.localeName + " (" + otherName + ")";
break;
}
}
}
res.localeRelatedObjectName = c.getName(phrase.getSettings().getLang(), phrase.getSettings().isTransliterate());
res.object = object;
res.preferredZoom = 17;