use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class QuickSearchPoiFilterFragment method processFilterFields.
private void processFilterFields() {
OsmandApplication app = getMyApplication();
String filterByName = filter.getFilterByName();
if (!Algorithms.isEmpty(filterByName)) {
int index;
MapPoiTypes poiTypes = app.getPoiTypes();
Map<String, PoiType> poiAdditionals = filter.getPoiAdditionals();
Set<String> excludedPoiAdditionalCategories = getExcludedPoiAdditionalCategories();
List<PoiType> otherAdditionalCategories = poiTypes.getOtherMapCategory().getPoiAdditionalsCategorized();
if (!excludedPoiAdditionalCategories.contains("opening_hours")) {
String keyNameOpen = app.getString(R.string.shared_string_is_open).replace(' ', '_').toLowerCase();
String keyNameOpen24 = app.getString(R.string.shared_string_is_open_24_7).replace(' ', '_').toLowerCase();
index = filterByName.indexOf(keyNameOpen24);
if (index != -1) {
selectedPoiAdditionals.add(keyNameOpen24);
filterByName = filterByName.replaceAll(keyNameOpen24, "");
}
index = filterByName.indexOf(keyNameOpen);
if (index != -1) {
selectedPoiAdditionals.add(keyNameOpen);
filterByName = filterByName.replaceAll(keyNameOpen, "");
}
}
if (poiAdditionals != null) {
Map<String, List<PoiType>> additionalsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
extractPoiAdditionals(poiAdditionals.values(), additionalsMap, excludedPoiAdditionalCategories, true);
extractPoiAdditionals(otherAdditionalCategories, additionalsMap, excludedPoiAdditionalCategories, true);
if (additionalsMap.size() > 0) {
List<String> filters = new ArrayList<>(Arrays.asList(filterByName.split(" ")));
for (Entry<String, List<PoiType>> entry : additionalsMap.entrySet()) {
for (PoiType poiType : entry.getValue()) {
String keyName = poiType.getKeyName().replace('_', ':').toLowerCase();
index = filters.indexOf(keyName);
if (index != -1) {
selectedPoiAdditionals.add(keyName);
filters.remove(index);
}
}
}
filterByName = TextUtils.join(" ", filters);
}
}
if (filterByName.trim().length() > 0 && Algorithms.isEmpty(nameFilterText)) {
nameFilterText = filterByName.trim();
}
}
}
use of net.osmand.osm.MapPoiTypes in project Osmand by osmandapp.
the class QuickSearchHelper method findAmenity.
public Amenity findAmenity(String name, double lat, double lon, String lang, boolean transliterate) {
QuadRect rect = MapUtils.calculateLatLonBbox(lat, lon, 15);
List<Amenity> amenities = app.getResourceManager().searchAmenities(new SearchPoiTypeFilter() {
@Override
public boolean accept(PoiCategory type, String subcategory) {
return true;
}
@Override
public boolean isEmpty() {
return false;
}
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
MapPoiTypes types = app.getPoiTypes();
for (Amenity amenity : amenities) {
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, lang, transliterate);
if (poiSimpleFormat.equals(name)) {
return amenity;
}
}
for (Amenity amenity : amenities) {
String amenityName = amenity.getName(lang, transliterate);
if (Algorithms.isEmpty(amenityName)) {
AbstractPoiType st = types.getAnyPoiTypeByKey(amenity.getSubType());
if (st != null) {
amenityName = st.getTranslation();
} else {
amenityName = amenity.getSubType();
}
}
if (name.contains(amenityName)) {
return amenity;
}
}
return null;
}
Aggregations