Search in sources :

Example 41 with PoiType

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

the class AmenityMenuController method getLeftIconId.

public static int getLeftIconId(Amenity amenity) {
    int id = 0;
    PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
    if (st != null) {
        id = OsmandResources.getBigDrawableId(st.getIconKeyName());
        if (id == 0) {
            id = OsmandResources.getBigDrawableId(st.getOsmTag() + "_" + st.getOsmValue());
        }
    }
    return id;
}
Also used : PoiType(net.osmand.osm.PoiType)

Example 42 with PoiType

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

the class QuickSearchListItem method getAmenityIconId.

public static int getAmenityIconId(Amenity amenity) {
    int res = 0;
    PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
    if (st != null) {
        res = OsmandResources.getBigDrawableId(st.getIconKeyName());
        if (res == 0) {
            res = OsmandResources.getBigDrawableId(st.getOsmTag() + "_" + st.getOsmValue());
        }
    }
    return res;
}
Also used : AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType)

Example 43 with PoiType

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

the class SampleFormatter method getAmenityDescriptionContent.

public static String getAmenityDescriptionContent(SampleApplication ctx, Amenity amenity, boolean shortDescription) {
    StringBuilder d = new StringBuilder();
    if (amenity.getType().isWiki()) {
        return "";
    }
    MapPoiTypes poiTypes = ctx.getPoiTypes();
    for (Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
        String key = e.getKey();
        String vl = e.getValue();
        if (key.startsWith("name:")) {
            continue;
        } else if (vl.length() >= 150) {
            if (shortDescription) {
                continue;
            }
        } else if (Amenity.OPENING_HOURS.equals(key)) {
            d.append(ctx.getString("opening_hours") + ": ");
        } else if (Amenity.PHONE.equals(key)) {
            d.append(ctx.getString("phone") + ": ");
        } else if (Amenity.WEBSITE.equals(key)) {
            d.append(ctx.getString("website") + ": ");
        } else {
            AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(e.getKey());
            if (pt != null) {
                if (pt instanceof PoiType && !((PoiType) pt).isText()) {
                    vl = pt.getTranslation();
                } else {
                    vl = pt.getTranslation() + ": " + amenity.unzipContent(e.getValue());
                }
            } else {
                vl = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()) + ": " + amenity.unzipContent(e.getValue());
            }
        }
        d.append(vl).append('\n');
    }
    return d.toString().trim();
}
Also used : AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType) AbstractPoiType(net.osmand.osm.AbstractPoiType) MapPoiTypes(net.osmand.osm.MapPoiTypes)

Example 44 with PoiType

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

the class SampleFormatter method getPoiStringWithoutType.

public static String getPoiStringWithoutType(Amenity amenity, String locale, boolean transliterate) {
    PoiCategory pc = amenity.getType();
    PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
    String nm = amenity.getSubType();
    if (pt != null) {
        nm = pt.getTranslation();
    } else if (nm != null) {
        nm = Algorithms.capitalizeFirstLetterAndLowercase(nm.replace('_', ' '));
    }
    String n = amenity.getName(locale, transliterate);
    if (n.indexOf(nm) != -1) {
        // no need to repeat this
        return n;
    }
    if (n.length() == 0) {
        return nm;
    }
    // $NON-NLS-1$
    return nm + " " + n;
}
Also used : PoiCategory(net.osmand.osm.PoiCategory) AbstractPoiType(net.osmand.osm.AbstractPoiType) PoiType(net.osmand.osm.PoiType)

Example 45 with PoiType

use of net.osmand.osm.PoiType 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

PoiType (net.osmand.osm.PoiType)49 AbstractPoiType (net.osmand.osm.AbstractPoiType)30 PoiCategory (net.osmand.osm.PoiCategory)11 MapPoiTypes (net.osmand.osm.MapPoiTypes)10 View (android.view.View)8 TextView (android.widget.TextView)8 Map (java.util.Map)8 Amenity (net.osmand.data.Amenity)8 ArrayList (java.util.ArrayList)7 LinkedHashMap (java.util.LinkedHashMap)7 AdapterView (android.widget.AdapterView)5 HashMap (java.util.HashMap)5 List (java.util.List)5 OsmandApplication (net.osmand.plus.OsmandApplication)5 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)5 AutoCompleteTextView (android.widget.AutoCompleteTextView)4 LinkedHashSet (java.util.LinkedHashSet)4 LatLon (net.osmand.data.LatLon)4 PoiFilter (net.osmand.osm.PoiFilter)4 Node (net.osmand.osm.edit.Node)4