diff --git a/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java b/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java index 77988f04ae..8616808eeb 100644 --- a/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java +++ b/OsmAnd-java/src/net/osmand/osm/AbstractPoiType.java @@ -17,7 +17,10 @@ public abstract class AbstractPoiType { private AbstractPoiType baseLangType; private boolean notEditableOsm; private String poiAdditionalCategory; - private List excludedPoiAdditionalCategoies; + private List excludedPoiAdditionalCategories; + private String synonyms; + private String enTranslation; + private String translation; public AbstractPoiType(String keyName, MapPoiTypes registry) { this.keyName = keyName; @@ -66,12 +69,26 @@ public abstract class AbstractPoiType { public String getTranslation() { - return registry.getTranslation(this); + + if(translation == null) { + translation = registry.getTranslation(this); + } + return translation; } + public String getSynonyms() { + if(synonyms == null) { + synonyms = registry.getSynonyms(this); + } + return synonyms; + } public String getEnTranslation() { - return registry.getEnTranslation(this); + + if(enTranslation == null) { + enTranslation = registry.getEnTranslation(this); + } + return enTranslation; } public String getPoiAdditionalCategoryTranslation() { @@ -137,14 +154,14 @@ public abstract class AbstractPoiType { } public List getExcludedPoiAdditionalCategories() { - return excludedPoiAdditionalCategoies; + return excludedPoiAdditionalCategories; } public void addExcludedPoiAdditionalCategories(String[] excludedPoiAdditionalCategories) { - if (excludedPoiAdditionalCategoies == null) { - excludedPoiAdditionalCategoies = new ArrayList<>(); + if (this.excludedPoiAdditionalCategories == null) { + this.excludedPoiAdditionalCategories = new ArrayList<>(); } - Collections.addAll(excludedPoiAdditionalCategoies, excludedPoiAdditionalCategories); + Collections.addAll(this.excludedPoiAdditionalCategories, excludedPoiAdditionalCategories); } public abstract Map> putTypes(Map> acceptedTypes); diff --git a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java index d82b6ae350..86fd57b6a7 100644 --- a/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java +++ b/OsmAnd-java/src/net/osmand/osm/MapPoiTypes.java @@ -55,8 +55,10 @@ public class MapPoiTypes { String getTranslation(String keyName); String getEnTranslation(AbstractPoiType type); - String getEnTranslation(String keyName); + + String getSynonyms(AbstractPoiType type); + String getSynonyms(String keyName); } public static MapPoiTypes getDefaultNoInit() { @@ -699,6 +701,15 @@ public class MapPoiTypes { } + public String getSynonyms(AbstractPoiType abstractPoiType) { + if (poiTranslator != null) { + String translation = poiTranslator.getSynonyms(abstractPoiType); + if (!Algorithms.isEmpty(translation)) { + return translation; + } + } + return ""; + } public String getEnTranslation(AbstractPoiType abstractPoiType) { if (poiTranslator != null) { String translation = poiTranslator.getEnTranslation(abstractPoiType); diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java index 6d8d227193..cd6092a23a 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java @@ -1,6 +1,5 @@ package net.osmand.search.core; -import com.google.openlocationcode.OpenLocationCode; import com.jwetherell.openmap.common.LatLonPoint; import com.jwetherell.openmap.common.UTMPoint; @@ -50,7 +49,6 @@ import java.util.Set; import java.util.TreeSet; import gnu.trove.list.array.TIntArrayList; -import gnu.trove.set.hash.TLongHashSet; public class SearchCoreFactory { @@ -616,13 +614,17 @@ public class SearchCoreFactory { List results = new ArrayList() ; NameStringMatcher nm = phrase.getNameStringMatcher(); for (PoiFilter pf : topVisibleFilters) { - if (!phrase.isUnknownSearchWordPresent() || nm.matches(pf.getTranslation()) || nm.matches(pf.getEnTranslation())) { + if (!phrase.isUnknownSearchWordPresent() || + nm.matches(pf.getTranslation()) || nm.matches(pf.getEnTranslation()) || + nm.matches(pf.getSynonyms())) { results.add(pf); } } if (phrase.isUnknownSearchWordPresent()) { for (PoiCategory c : categories) { - if (!results.contains(c) && (nm.matches(c.getTranslation()) || nm.matches(c.getEnTranslation()) ) ) { + if (!results.contains(c) && + (nm.matches(c.getTranslation()) || nm.matches(c.getEnTranslation()) + || nm.matches(c.getSynonyms())) ) { results.add(c); } } @@ -631,14 +633,17 @@ public class SearchCoreFactory { Entry e = it.next(); PoiType pt = e.getValue(); if (pt.getCategory() != types.getOtherMapCategory()) { - if (!results.contains(pt) && ( nm.matches(pt.getEnTranslation()) || nm.matches(pt.getTranslation()) )) { + if (!results.contains(pt) && ( + nm.matches(pt.getEnTranslation()) || nm.matches(pt.getTranslation()) + || nm.matches(pt.getSynonyms()) )) { results.add(pt); } List additionals = pt.getPoiAdditionals(); if (additionals != null) { for (PoiType a : additionals) { if (!a.isReference() && !results.contains(a) && - ( nm.matches(a.getEnTranslation()) || nm.matches(a.getTranslation()) )) { + ( nm.matches(a.getEnTranslation()) || nm.matches(a.getTranslation()) + || nm.matches(a.getSynonyms()) )) { results.add(a); } } diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 3cfba9db6f..18c099d7b6 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -357,6 +357,29 @@ public class AppInitializer implements IProgress { return null; } + @Override + public String getSynonyms(AbstractPoiType type) { + if(type.getBaseLangType() != null) { + return getSynonyms(type.getBaseLangType()); + } + return getSynonyms(type.getIconKeyName()); + } + + + @Override + public String getSynonyms(String keyName) { + try { + Field f = R.string.class.getField("synonyms_poi_" + keyName); + if (f != null) { + Integer in = (Integer) f.get(null); + return app.getString(in); + } + } catch (Exception e) { + // LOG.debug("No translation for "+ keyName + " " + e.getMessage()); + } + return ""; + } + @Override public String getEnTranslation(AbstractPoiType type) { if(type.getBaseLangType() != null) {