use of net.osmand.binary.BinaryMapIndexReader.SearchPoiTypeFilter 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