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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations