use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.
the class MenuBuilder method processNearstWiki.
protected boolean processNearstWiki() {
if (showNearestWiki && latLon != null) {
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
nearestWiki = app.getResourceManager().searchAmenities(new BinaryMapIndexReader.SearchPoiTypeFilter() {
@Override
public boolean accept(PoiCategory type, String subcategory) {
return type.isWiki();
}
@Override
public boolean isEmpty() {
return false;
}
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
Collections.sort(nearestWiki, new Comparator<Amenity>() {
@Override
public int compare(Amenity o1, Amenity o2) {
double d1 = MapUtils.getDistance(latLon, o1.getLocation());
double d2 = MapUtils.getDistance(latLon, o2.getLocation());
return Double.compare(d1, d2);
}
});
Long id = objectId;
List<Amenity> wikiList = new ArrayList<>();
for (Amenity wiki : nearestWiki) {
String lng = wiki.getContentLanguage("content", preferredMapAppLang, "en");
if (wiki.getId().equals(id) || (!lng.equals("en") && !lng.equals(preferredMapAppLang))) {
wikiList.add(wiki);
}
}
nearestWiki.removeAll(wikiList);
return true;
}
return false;
}
use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.
the class OsmAndFormatter 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.PoiCategory in project Osmand by osmandapp.
the class PoiTypeDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MapPoiTypes poiTypes = ((OsmandApplication) getActivity().getApplication()).getPoiTypes();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final List<PoiCategory> categories = new ArrayList<PoiCategory>();
ArrayList<String> vals = new ArrayList<>();
for (PoiCategory category : poiTypes.getCategories(false)) {
if (!category.isNotEditableOsm()) {
vals.add(category.getTranslation());
categories.add(category);
}
}
builder.setItems(vals.toArray(new String[vals.size()]), new Dialog.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
PoiCategory aType = categories.get(which);
onItemSelectListener.select(aType);
dismiss();
}
});
return builder.create();
}
use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.
the class PoiUIFilter method fillPoiAdditionals.
private void fillPoiAdditionals(AbstractPoiType pt, boolean allFromCategory) {
for (PoiType add : pt.getPoiAdditionals()) {
poiAdditionals.put(add.getKeyName().replace('_', ':').replace(' ', ':'), add);
poiAdditionals.put(add.getTranslation().replace(' ', ':').toLowerCase(), add);
}
if (pt instanceof PoiCategory && allFromCategory) {
for (PoiFilter pf : ((PoiCategory) pt).getPoiFilters()) {
fillPoiAdditionals(pf, true);
}
for (PoiType ps : ((PoiCategory) pt).getPoiTypes()) {
fillPoiAdditionals(ps, false);
}
} else if (pt instanceof PoiFilter && !(pt instanceof PoiCategory)) {
for (PoiType ps : ((PoiFilter) pt).getPoiTypes()) {
fillPoiAdditionals(ps, false);
}
}
}
use of net.osmand.osm.PoiCategory in project Osmand by osmandapp.
the class AmenityMenuController method getTypeStr.
public static String getTypeStr(Amenity amenity) {
PoiCategory pc = amenity.getType();
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
String typeStr = amenity.getSubType();
if (pt != null) {
typeStr = pt.getTranslation();
} else if (typeStr != null) {
typeStr = Algorithms.capitalizeFirstLetterAndLowercase(typeStr.replace('_', ' '));
}
return typeStr;
}
Aggregations