Search in sources :

Example 6 with PoiFilter

use of net.osmand.osm.PoiFilter in project Osmand by osmandapp.

the class QuickSearchPoiFilterFragment method getExcludedPoiAdditionalCategories.

@NonNull
private Set<String> getExcludedPoiAdditionalCategories() {
    Set<String> excludedPoiAdditionalCategories = new LinkedHashSet<>();
    if (filter.getAcceptedTypes().size() == 0) {
        return excludedPoiAdditionalCategories;
    }
    MapPoiTypes poiTypes = getMyApplication().getPoiTypes();
    PoiCategory topCategory = null;
    for (Entry<PoiCategory, LinkedHashSet<String>> entry : filter.getAcceptedTypes().entrySet()) {
        if (topCategory == null) {
            topCategory = entry.getKey();
        }
        if (entry.getValue() != null) {
            Set<String> excluded = new LinkedHashSet<>();
            for (String keyName : entry.getValue()) {
                PoiType poiType = poiTypes.getPoiTypeByKeyInCategory(topCategory, keyName);
                if (poiType != null) {
                    collectExcludedPoiAdditionalCategories(poiType, excluded);
                    if (!poiType.isReference()) {
                        PoiFilter poiFilter = poiType.getFilter();
                        if (poiFilter != null) {
                            collectExcludedPoiAdditionalCategories(poiFilter, excluded);
                        }
                        PoiCategory poiCategory = poiType.getCategory();
                        if (poiCategory != null) {
                            collectExcludedPoiAdditionalCategories(poiCategory, excluded);
                        }
                    }
                }
                if (excludedPoiAdditionalCategories.size() == 0) {
                    excludedPoiAdditionalCategories.addAll(excluded);
                } else {
                    excludedPoiAdditionalCategories.retainAll(excluded);
                }
                excluded.clear();
            }
        }
    }
    if (topCategory != null && topCategory.getExcludedPoiAdditionalCategories() != null) {
        excludedPoiAdditionalCategories.addAll(topCategory.getExcludedPoiAdditionalCategories());
    }
    return excludedPoiAdditionalCategories;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PoiFilter(net.osmand.osm.PoiFilter) PoiCategory(net.osmand.osm.PoiCategory) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) MapPoiTypes(net.osmand.osm.MapPoiTypes) NonNull(android.support.annotation.NonNull)

Aggregations

PoiFilter (net.osmand.osm.PoiFilter)6 PoiType (net.osmand.osm.PoiType)5 AbstractPoiType (net.osmand.osm.AbstractPoiType)4 PoiCategory (net.osmand.osm.PoiCategory)4 CustomSearchPoiFilter (net.osmand.search.core.CustomSearchPoiFilter)3 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)2 Amenity (net.osmand.data.Amenity)2 City (net.osmand.data.City)2 LatLon (net.osmand.data.LatLon)2 Street (net.osmand.data.Street)2 MapPoiTypes (net.osmand.osm.MapPoiTypes)2 NonNull (android.support.annotation.NonNull)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 FavouritePoint (net.osmand.data.FavouritePoint)1 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)1 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)1