Fix custom poi filters

This commit is contained in:
Victor Shcherb 2016-08-03 23:44:52 +02:00
parent 1a79aa6088
commit e360335dbf
8 changed files with 267 additions and 156 deletions

View file

@ -1,5 +1,6 @@
package net.osmand.search;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -22,8 +23,11 @@ import net.osmand.osm.MapPoiTypes;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreAPI;
import net.osmand.search.core.SearchCoreFactory;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityByTypeAPI;
import net.osmand.search.core.SearchCoreFactory.SearchAmenityTypesAPI;
import net.osmand.search.core.SearchCoreFactory.SearchBuildingAndIntersectionsByStreetAPI;
import net.osmand.search.core.SearchCoreFactory.SearchStreetByCityAPI;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.SearchPhrase;
import net.osmand.search.core.SearchResult;
import net.osmand.search.core.SearchSettings;
@ -97,6 +101,38 @@ public class SearchUICore {
this.totalLimit = totalLimit;
}
@SuppressWarnings("unchecked")
public <T> T getApiByClass(Class<T> cl) {
for(SearchCoreAPI a : apis) {
if(cl.isInstance(a)) {
return (T) a;
}
}
return null;
}
public <T extends SearchCoreAPI> SearchResultCollection shallowSearch(Class<T> cl,
String text, final ResultMatcher<SearchResult> matcher) throws IOException {
SearchResultCollection quickRes = new SearchResultCollection();
T api = getApiByClass(cl);
if(api != null) {
SearchPhrase sphrase = this.phrase.generateNewPhrase(text, searchSettings);
preparePhrase(sphrase);
AtomicInteger ai = new AtomicInteger();
SearchResultMatcher rm = new SearchResultMatcher(matcher, ai.get(), ai, totalLimit);
api.search(sphrase, rm);
sortSearchResults(sphrase, rm.getRequestResults());
filterSearchDuplicateResults(sphrase, rm.getRequestResults());
LOG.info(">> Shallow Search phrase " + phrase + " " + rm.getRequestResults().size());
SearchResultCollection collection = new SearchResultCollection(rm.getRequestResults(),
sphrase);
return collection;
}
return quickRes;
}
public void init() {
apis.add(new SearchCoreFactory.SearchLocationAndUrlAPI());
apis.add(new SearchCoreFactory.SearchAmenityTypesAPI(poiTypes));
@ -110,6 +146,14 @@ public class SearchUICore {
apis.add(new SearchCoreFactory.SearchAddressByNameAPI(streetsApi, cityApi));
}
public void addCustomSearchPoiFilter(CustomSearchPoiFilter poiFilter, int priority) {
for(SearchCoreAPI capi : apis) {
if(capi instanceof SearchAmenityTypesAPI) {
((SearchAmenityTypesAPI) capi).addCustomFilter(poiFilter, priority);
}
}
}
public void registerAPI(SearchCoreAPI api) {
apis.add(api);
}
@ -207,12 +251,7 @@ public class SearchUICore {
private void searchInBackground(final SearchPhrase phrase, SearchResultMatcher matcher) {
for (SearchWord sw : phrase.getWords()) {
if(sw.getResult() != null && sw.getResult().file != null) {
phrase.selectFile(sw.getResult().file);
}
}
phrase.sortFiles();
preparePhrase(phrase);
ArrayList<SearchCoreAPI> lst = new ArrayList<>(apis);
Collections.sort(lst, new Comparator<SearchCoreAPI>() {
@ -238,6 +277,15 @@ public class SearchUICore {
}
}
}
private void preparePhrase(final SearchPhrase phrase) {
for (SearchWord sw : phrase.getWords()) {
if(sw.getResult() != null && sw.getResult().file != null) {
phrase.selectFile(sw.getResult().file);
}
}
phrase.sortFiles();
}
public boolean sameSearchResult(SearchResult r1, SearchResult r2) {
if(r1.location != null && r2.location != null) {

View file

@ -0,0 +1,15 @@
package net.osmand.search.core;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter;
import net.osmand.data.Amenity;
public interface CustomSearchPoiFilter extends SearchPoiTypeFilter {
public String getName();
public Object getIconResource();
public ResultMatcher<Amenity> wrapResultMatcher(final ResultMatcher<Amenity> matcher);
}

View file

@ -1,5 +1,7 @@
package net.osmand.search.core;
import gnu.trove.list.array.TIntArrayList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@ -11,6 +13,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.TreeSet;
import net.osmand.CollatorStringMatcher.StringMatcherMode;
@ -465,12 +468,19 @@ public class SearchCoreFactory {
private Map<String, PoiType> translatedNames = new LinkedHashMap<>();
private List<PoiFilter> topVisibleFilters;
private List<CustomSearchPoiFilter> customPoiFilters = new ArrayList<>();
private TIntArrayList customPoiFiltersPriorites = new TIntArrayList();
private MapPoiTypes types;
public SearchAmenityTypesAPI(MapPoiTypes types) {
this.types = types;
}
public void addCustomFilter(CustomSearchPoiFilter poiFilter, int priority) {
this.customPoiFilters.add(poiFilter);
this.customPoiFiltersPriorites.add(priority);
}
@Override
public boolean search(SearchPhrase phrase, SearchResultMatcher resultMatcher) throws IOException {
if(translatedNames.isEmpty()) {
@ -478,17 +488,11 @@ public class SearchCoreFactory {
topVisibleFilters = types.getTopVisibleFilters();
}
// results.clear();
TreeSet<AbstractPoiType> results = new TreeSet<>(new Comparator<AbstractPoiType>() {
@Override
public int compare(AbstractPoiType o1, AbstractPoiType o2) {
return o1.getKeyName().compareTo(o2.getKeyName());
}
});
TreeMap<String, AbstractPoiType> results = new TreeMap<String, AbstractPoiType>() ;
NameStringMatcher nm = phrase.getNameStringMatcher();
for (PoiFilter pf : topVisibleFilters) {
if (!phrase.isUnknownSearchWordPresent() || nm.matches(pf.getTranslation())) {
results.add(pf);
results.put(pf.getTranslation(), pf);
}
}
if (phrase.isUnknownSearchWordPresent()) {
@ -496,19 +500,34 @@ public class SearchCoreFactory {
while (it.hasNext()) {
Entry<String, PoiType> e = it.next();
if (nm.matches(e.getKey()) || nm.matches(e.getValue().getTranslation())) {
results.add(e.getValue());
results.put(e.getValue().getTranslation(), e.getValue());
}
}
}
for (AbstractPoiType p : results) {
Iterator<Entry<String, AbstractPoiType>> it = results.entrySet().iterator();
while(it.hasNext()) {
Entry<String, AbstractPoiType> p = it.next();
SearchResult res = new SearchResult(phrase);
res.localeName = p.getTranslation();
res.object = p;
res.localeName = p.getKey();
res.object = p.getValue();
res.priority = SEARCH_AMENITY_TYPE_PRIORITY;
res.priorityDistance = 0;
res.objectType = ObjectType.POI_TYPE;
resultMatcher.publish(res);
}
for(int i =0 ; i< customPoiFilters.size(); i++) {
CustomSearchPoiFilter csf = customPoiFilters.get(i);
int p = customPoiFiltersPriorites.get(i);
if (!phrase.isUnknownSearchWordPresent() || nm.matches(csf.getName())) {
SearchResult res = new SearchResult(phrase);
res.localeName = csf.getName();
res.object = csf;
res.priority = SEARCH_AMENITY_TYPE_PRIORITY + p;
res.objectType = ObjectType.POI_TYPE;
resultMatcher.publish(res);
}
}
return true;
}
@ -531,9 +550,6 @@ public class SearchCoreFactory {
public SearchAmenityByTypeAPI(MapPoiTypes types) {
this.types = types;
}
public boolean isLastWordPoi(SearchPhrase p ) {
return p.isLastWord(ObjectType.POI_TYPE);
}
private Map<PoiCategory, LinkedHashSet<String>> acceptedTypes = new LinkedHashMap<PoiCategory,
@ -563,87 +579,106 @@ public class SearchCoreFactory {
@Override
public boolean search(final SearchPhrase phrase, final SearchResultMatcher resultMatcher) throws IOException {
if(phrase.isLastWord(ObjectType.POI_TYPE)) {
final AbstractPoiType pt = (AbstractPoiType) phrase.getLastSelectedWord().getResult().object;
acceptedTypes.clear();
poiAdditionals.clear();
updateTypesToAccept(pt);
Object obj = phrase.getLastSelectedWord().getResult().object;
SearchPoiTypeFilter ptf;
if(obj instanceof AbstractPoiType) {
ptf = getPoiTypeFilter((AbstractPoiType) obj);
} else if (obj instanceof SearchPoiTypeFilter) {
ptf = (SearchPoiTypeFilter) obj;
} else {
throw new UnsupportedOperationException();
}
QuadRect bbox = phrase.getRadiusBBoxToSearch(10000);
List<BinaryMapIndexReader> oo = phrase.getOfflineIndexes();
final BinaryMapIndexReader[] selected = new BinaryMapIndexReader[1];
final NameStringMatcher ns = phrase.getNameStringMatcher();
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
(int)bbox.left, (int)bbox.right,
(int)bbox.top, (int)bbox.bottom, -1,
new SearchPoiTypeFilter() {
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean accept(PoiCategory type, String subtype) {
if (type == null) {
return true;
}
if (!types.isRegisteredType(type)) {
type = types.getOtherPoiCategory();
}
if (!acceptedTypes.containsKey(type)) {
return false;
}
LinkedHashSet<String> set = acceptedTypes.get(type);
if (set == null) {
return true;
}
return set.contains(subtype);
}
}, new ResultMatcher<Amenity>() {
@Override
public boolean publish(Amenity object) {
SearchResult res = new SearchResult(phrase);
res.localeName = object.getName(phrase.getSettings().getLang(), true);
res.otherNames = object.getAllNames(true);
if (Algorithms.isEmpty(res.localeName)) {
AbstractPoiType st = types.getAnyPoiTypeByKey(object.getSubType());
if (st != null) {
res.localeName = st.getTranslation();
} else {
res.localeName = object.getSubType();
}
}
if (phrase.isUnknownSearchWordPresent()
&& !(ns.matches(res.localeName) || ns.matches(res.otherNames))) {
return false;
}
res.object = object;
res.preferredZoom = 17;
res.file = selected[0];
res.location = object.getLocation();
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
res.priorityDistance = 1;
res.objectType = ObjectType.POI;
resultMatcher.publish(res);
return false;
}
@Override
public boolean isCancelled() {
return resultMatcher.isCancelled();
}
});
for (BinaryMapIndexReader o : oo) {
selected[0] = o;
ResultMatcher<Amenity> rm = getResultMatcher(phrase, resultMatcher, o);
if(obj instanceof CustomSearchPoiFilter) {
rm = ((CustomSearchPoiFilter) obj).wrapResultMatcher(rm);
}
SearchRequest<Amenity> req = BinaryMapIndexReader.buildSearchPoiRequest(
(int)bbox.left, (int)bbox.right,
(int)bbox.top, (int)bbox.bottom, -1, ptf,
rm);
o.searchPoi(req);
resultMatcher.apiSearchRegionFinished(this, o, phrase);
}
}
return true;
}
private ResultMatcher<Amenity> getResultMatcher(final SearchPhrase phrase, final SearchResultMatcher resultMatcher,
final BinaryMapIndexReader selected) {
final NameStringMatcher ns = phrase.getNameStringMatcher();
return new ResultMatcher<Amenity>() {
@Override
public boolean publish(Amenity object) {
SearchResult res = new SearchResult(phrase);
res.localeName = object.getName(phrase.getSettings().getLang(), true);
res.otherNames = object.getAllNames(true);
if (Algorithms.isEmpty(res.localeName)) {
AbstractPoiType st = types.getAnyPoiTypeByKey(object.getSubType());
if (st != null) {
res.localeName = st.getTranslation();
} else {
res.localeName = object.getSubType();
}
}
if (phrase.isUnknownSearchWordPresent()
&& !(ns.matches(res.localeName) || ns.matches(res.otherNames))) {
return false;
}
res.object = object;
res.preferredZoom = 17;
res.file = selected;
res.location = object.getLocation();
res.priority = SEARCH_AMENITY_BY_TYPE_PRIORITY;
res.priorityDistance = 1;
res.objectType = ObjectType.POI;
resultMatcher.publish(res);
return false;
}
@Override
public boolean isCancelled() {
return resultMatcher.isCancelled();
}
};
}
private SearchPoiTypeFilter getPoiTypeFilter(AbstractPoiType pt) {
acceptedTypes.clear();
poiAdditionals.clear();
updateTypesToAccept(pt);
return new SearchPoiTypeFilter() {
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean accept(PoiCategory type, String subtype) {
if (type == null) {
return true;
}
if (!types.isRegisteredType(type)) {
type = types.getOtherPoiCategory();
}
if (!acceptedTypes.containsKey(type)) {
return false;
}
LinkedHashSet<String> set = acceptedTypes.get(type);
if (set == null) {
return true;
}
return set.contains(subtype);
}
};
}
@Override
public int getSearchPriority(SearchPhrase p) {
@ -653,6 +688,7 @@ public class SearchCoreFactory {
}
return -1;
}
}

View file

@ -174,7 +174,7 @@ public class PoiFiltersHelper {
getTopDefinedPoiFilters();
}
private List<PoiUIFilter> getUserDefinedPoiFilters() {
public List<PoiUIFilter> getUserDefinedPoiFilters() {
ArrayList<PoiUIFilter> userDefinedFilters = new ArrayList<PoiUIFilter>();
PoiFilterDbHelper helper = openDbHelper();
if (helper != null) {

View file

@ -11,7 +11,6 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
@ -30,6 +29,7 @@ import net.osmand.osm.PoiType;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser;
@ -37,7 +37,7 @@ import net.osmand.util.OpeningHoursParser.OpeningHours;
import android.content.Context;
import android.support.annotation.NonNull;
public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter> {
public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>, CustomSearchPoiFilter {
public final static String STD_PREFIX = "std_"; //$NON-NLS-1$
public final static String USER_PREFIX = "user_"; //$NON-NLS-1$
@ -363,7 +363,13 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
return app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase();
}
private ResultMatcher<Amenity> wrapResultMatcher(final ResultMatcher<Amenity> matcher) {
@Override
public Object getIconResource() {
return getIconId();
}
@Override
public ResultMatcher<Amenity> wrapResultMatcher(final ResultMatcher<Amenity> matcher) {
final AmenityNameFilter nm = getNameFilter(filterByName);
return new ResultMatcher<Amenity>() {
@ -384,6 +390,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
};
}
@Override
public String getName() {
return name;
}
@ -593,7 +600,7 @@ public class PoiUIFilter implements SearchPoiTypeFilter, Comparable<PoiUIFilter>
}
return set.contains(subtype);
}
@Override
public boolean isEmpty() {
return acceptedTypes.isEmpty() &&

View file

@ -183,14 +183,19 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
QuickSearchCoordinatesFragment.showDialog(QuickSearchDialogFragment.this, searchPhrase.getUnknownSearchWord());
} else if (searchPhrase.isNoSelectedType() || searchPhrase.isLastWord(ObjectType.POI_TYPE)) {
PoiUIFilter filter;
if (searchPhrase.isNoSelectedType()) {
filter = new PoiUIFilter(null, app, "");
if (searchPhrase.getLastSelectedWord().getResult().object instanceof AbstractPoiType) {
if (searchPhrase.isNoSelectedType()) {
filter = new PoiUIFilter(null, app, "");
} else {
AbstractPoiType abstractPoiType = (AbstractPoiType) searchPhrase.getLastSelectedWord()
.getResult().object;
filter = new PoiUIFilter(abstractPoiType, app, "");
}
if (!Algorithms.isEmpty(searchPhrase.getUnknownSearchWord())) {
filter.setFilterByName(searchPhrase.getUnknownSearchWord());
}
} else {
AbstractPoiType abstractPoiType = (AbstractPoiType) searchPhrase.getLastSelectedWord().getResult().object;
filter = new PoiUIFilter(abstractPoiType, app, "");
}
if (!Algorithms.isEmpty(searchPhrase.getUnknownSearchWord())) {
filter.setFilterByName(searchPhrase.getUnknownSearchWord());
filter = (PoiUIFilter) searchPhrase.getLastSelectedWord().getResult().object;
}
app.getPoiFilters().clearSelectedPoiFilters();
app.getPoiFilters().addSelectedPoiFilter(filter);
@ -631,61 +636,38 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
}
public void reloadCategories() {
SearchAmenityTypesAPI amenityTypesAPI =
new SearchAmenityTypesAPI(app.getPoiTypes());
final List<SearchResult> amenityTypes = new ArrayList<>();
SearchPhrase sp = new SearchPhrase(null).generateNewPhrase("", searchUICore.getSearchSettings());
try {
amenityTypesAPI.search(sp, new SearchResultMatcher(
new ResultMatcher<SearchResult>() {
@Override
public boolean publish(SearchResult object) {
amenityTypes.add(object);
return true;
}
@Override
public boolean isCancelled() {
return false;
}
}, 0, new AtomicInteger(0), -1));
SearchResultCollection res = searchUICore.shallowSearch(SearchAmenityTypesAPI.class,
"", null);
if (res != null) {
List<QuickSearchListItem> rows = new ArrayList<>();
for (SearchResult sr : res.getCurrentSearchResults()) {
rows.add(new QuickSearchListItem(app, sr));
}
categoriesSearchFragment.updateListAdapter(rows, false);
}
} catch (IOException e) {
e.printStackTrace();
app.showToastMessage(e.getMessage());
}
if (amenityTypes.size() > 0) {
searchUICore.sortSearchResults(sp, amenityTypes);
List<QuickSearchListItem> rows = new ArrayList<>();
for (SearchResult sr : amenityTypes) {
rows.add(new QuickSearchListItem(app, sr));
}
categoriesSearchFragment.updateListAdapter(rows, false);
}
}
public void reloadHistory() {
SearchHistoryAPI historyAPI = new SearchHistoryAPI(app);
final List<SearchResult> history = new ArrayList<>();
SearchPhrase sp = new SearchPhrase(null).generateNewPhrase("", searchUICore.getSearchSettings());
historyAPI.search(sp, new SearchResultMatcher(
new ResultMatcher<SearchResult>() {
@Override
public boolean publish(SearchResult object) {
history.add(object);
return true;
}
@Override
public boolean isCancelled() {
return false;
}
}, 0, new AtomicInteger(0), -1));
List<QuickSearchListItem> rows = new ArrayList<>();
if (history.size() > 0) {
for (SearchResult sr : history) {
rows.add(new QuickSearchListItem(app, sr));
try {
SearchResultCollection res = searchUICore.shallowSearch(SearchHistoryAPI.class,
"", null);
if (res != null) {
List<QuickSearchListItem> rows = new ArrayList<>();
for (SearchResult sr : res.getCurrentSearchResults()) {
rows.add(new QuickSearchListItem(app, sr));
}
historySearchFragment.updateListAdapter(rows, false);
}
} catch (IOException e) {
e.printStackTrace();
app.showToastMessage(e.getMessage());
}
historySearchFragment.updateListAdapter(rows, false);
}
private void runSearch() {

View file

@ -7,10 +7,12 @@ import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.plus.resources.ResourceManager.ResourceListener;
import net.osmand.search.SearchUICore;
import net.osmand.search.SearchUICore.SearchResultCollection;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreFactory;
import net.osmand.search.core.SearchPhrase;
@ -124,6 +126,14 @@ public class QuickSearchHelper implements ResourceListener {
// Register WptPt search api
core.registerAPI(new SearchWptAPI(app));
core.registerAPI(new SearchHistoryAPI(app));
PoiFiltersHelper poiFilters = app.getPoiFilters();
for(CustomSearchPoiFilter udf : poiFilters.getUserDefinedPoiFilters()) {
core.addCustomSearchPoiFilter(udf, 0);
}
core.addCustomSearchPoiFilter(poiFilters.getLocalWikiPOIFilter(), 1);
core.addCustomSearchPoiFilter(poiFilters.getShowAllPOIFilter(), 1);
}
public void setRepositoriesForSearchUICore(final OsmandApplication app) {
@ -215,9 +225,9 @@ public class QuickSearchHelper implements ResourceListener {
@Override
public int getSearchPriority(SearchPhrase p) {
if (!p.isNoSelectedType()) {
if (!p.isEmpty()) {
return -1;
}
}
return SEARCH_HISTORY_API_PRIORITY;
}
}

View file

@ -2,7 +2,6 @@ package net.osmand.plus.search;
import android.content.Context;
import android.graphics.drawable.Drawable;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.City;
@ -24,6 +23,7 @@ import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.search.core.CustomSearchPoiFilter;
import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms;
@ -155,8 +155,9 @@ public class QuickSearchListItem {
}
return "";
case POI_TYPE:
String res= "";
if (searchResult.object instanceof AbstractPoiType) {
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
String res;
if (abstractPoiType instanceof PoiCategory) {
res = "";
} else if (abstractPoiType instanceof PoiFilter) {
@ -175,6 +176,9 @@ public class QuickSearchListItem {
} else {
res = "";
}
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
res = ((CustomSearchPoiFilter) searchResult.object).getName();
}
return res;
case POI:
Amenity amenity = (Amenity) searchResult.object;
@ -272,16 +276,25 @@ public class QuickSearchListItem {
return app.getIconsCache().getIcon(R.drawable.ic_action_intersection,
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
case POI_TYPE:
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
int iconId = -1;
if (searchResult.object instanceof AbstractPoiType) {
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
if (RenderingIcons.containsBigIcon(abstractPoiType.getIconKeyName())) {
iconId = RenderingIcons.getBigIconResourceId(abstractPoiType.getIconKeyName());
} else if (abstractPoiType instanceof PoiType
&& RenderingIcons.containsBigIcon(((PoiType) abstractPoiType).getOsmTag() + "_"
+ ((PoiType) abstractPoiType).getOsmValue())) {
+ ((PoiType) abstractPoiType).getOsmValue())) {
iconId = RenderingIcons.getBigIconResourceId(((PoiType) abstractPoiType).getOsmTag() + "_"
+ ((PoiType) abstractPoiType).getOsmValue());
}
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
Object res = ((CustomSearchPoiFilter) searchResult.object).getIconResource();
if (res instanceof String && RenderingIcons.containsBigIcon(res.toString())) {
iconId = RenderingIcons.getBigIconResourceId(res.toString());
} else {
iconId = R.drawable.mx_user_defined;
}
}
if (iconId != -1) {
return app.getIconsCache().getIcon(iconId,
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);