use of net.osmand.osm.PoiFilter in project Osmand by osmandapp.
the class ContextMenuLayer method getPublicTransportTypes.
private List<String> getPublicTransportTypes() {
if (publicTransportTypes == null) {
publicTransportTypes = new ArrayList<>();
List<PoiFilter> filters = activity.getMyApplication().getPoiTypes().getPoiCategoryByName("transportation").getPoiFilters();
for (PoiFilter poiFilter : filters) {
if (poiFilter.getKeyName().equals("public_transport")) {
for (PoiType poiType : poiFilter.getPoiTypes()) {
publicTransportTypes.add(poiType.getKeyName());
for (PoiType poiAdditionalType : poiType.getPoiAdditionals()) {
publicTransportTypes.add(poiAdditionalType.getKeyName());
}
}
}
}
}
return publicTransportTypes;
}
use of net.osmand.osm.PoiFilter in project Osmand by osmandapp.
the class QuickSearchListItem method getTypeName.
public static String getTypeName(OsmandApplication app, SearchResult searchResult) {
switch(searchResult.objectType) {
case CITY:
City city = (City) searchResult.object;
return getCityTypeStr(app, city.getType());
case POSTCODE:
return app.getString(R.string.postcode);
case VILLAGE:
city = (City) searchResult.object;
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
if (searchResult.distRelatedObjectName > 0) {
return getCityTypeStr(app, city.getType()) + " • " + OsmAndFormatter.getFormattedDistance((float) searchResult.distRelatedObjectName, app) + " " + app.getString(R.string.shared_string_from) + " " + searchResult.localeRelatedObjectName;
} else {
return getCityTypeStr(app, city.getType()) + ", " + searchResult.localeRelatedObjectName;
}
} else {
return getCityTypeStr(app, city.getType());
}
case STREET:
StringBuilder streetBuilder = new StringBuilder();
if (searchResult.localeName.endsWith(")")) {
int i = searchResult.localeName.indexOf('(');
if (i > 0) {
streetBuilder.append(searchResult.localeName.substring(i + 1, searchResult.localeName.length() - 1));
}
}
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
if (streetBuilder.length() > 0) {
streetBuilder.append(", ");
}
streetBuilder.append(searchResult.localeRelatedObjectName);
}
return streetBuilder.toString();
case HOUSE:
if (searchResult.relatedObject != null) {
Street relatedStreet = (Street) searchResult.relatedObject;
if (relatedStreet.getCity() != null) {
return searchResult.localeRelatedObjectName + ", " + relatedStreet.getCity().getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
} else {
return searchResult.localeRelatedObjectName;
}
}
return "";
case STREET_INTERSECTION:
Street street = (Street) searchResult.object;
if (street.getCity() != null) {
return street.getCity().getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
}
return "";
case POI_TYPE:
String res = "";
if (searchResult.object instanceof AbstractPoiType) {
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
if (abstractPoiType instanceof PoiCategory) {
res = "";
} else if (abstractPoiType instanceof PoiFilter) {
PoiFilter poiFilter = (PoiFilter) abstractPoiType;
res = poiFilter.getPoiCategory() != null ? poiFilter.getPoiCategory().getTranslation() : "";
} else if (abstractPoiType instanceof PoiType) {
PoiType poiType = (PoiType) abstractPoiType;
res = poiType.getParentType() != null ? poiType.getParentType().getTranslation() : null;
if (res == null) {
res = poiType.getCategory() != null ? poiType.getCategory().getTranslation() : null;
}
if (res == null) {
res = "";
}
} else {
res = "";
}
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
res = ((CustomSearchPoiFilter) searchResult.object).getName();
}
return res;
case POI:
Amenity amenity = (Amenity) searchResult.object;
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;
case LOCATION:
LatLon latLon = searchResult.location;
if (latLon != null && searchResult.localeRelatedObjectName == null) {
String locationCountry = app.getRegions().getCountryName(latLon);
searchResult.localeRelatedObjectName = locationCountry == null ? "" : locationCountry;
}
return searchResult.localeRelatedObjectName;
case FAVORITE:
FavouritePoint fav = (FavouritePoint) searchResult.object;
return fav.getCategory().length() == 0 ? app.getString(R.string.shared_string_favorites) : fav.getCategory();
case FAVORITE_GROUP:
return app.getString(R.string.shared_string_my_favorites);
case REGION:
BinaryMapIndexReader binaryMapIndexReader = (BinaryMapIndexReader) searchResult.object;
System.out.println(binaryMapIndexReader.getFile().getAbsolutePath() + " " + binaryMapIndexReader.getCountryName());
break;
case RECENT_OBJ:
HistoryEntry entry = (HistoryEntry) searchResult.object;
boolean hasTypeInDescription = !Algorithms.isEmpty(entry.getName().getTypeName());
if (hasTypeInDescription) {
return entry.getName().getTypeName();
} else {
return "";
}
case WPT:
StringBuilder sb = new StringBuilder();
GPXFile gpx = (GPXFile) searchResult.relatedObject;
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
sb.append(searchResult.localeRelatedObjectName);
}
if (gpx != null && !Algorithms.isEmpty(gpx.path)) {
if (sb.length() > 0) {
sb.append(", ");
}
sb.append(new File(gpx.path).getName());
}
return sb.toString();
case UNKNOWN_NAME_FILTER:
break;
}
return searchResult.objectType.name();
}
use of net.osmand.osm.PoiFilter in project Osmand by osmandapp.
the class PoiFiltersHelper method getTopDefinedPoiFilters.
public List<PoiUIFilter> getTopDefinedPoiFilters() {
if (cacheTopStandardFilters == null) {
List<PoiUIFilter> top = new ArrayList<PoiUIFilter>();
// user defined
top.addAll(getUserDefinedPoiFilters());
if (getLocalWikiPOIFilter() != null) {
top.add(getLocalWikiPOIFilter());
}
// default
MapPoiTypes poiTypes = application.getPoiTypes();
for (PoiFilter t : poiTypes.getTopVisibleFilters()) {
PoiUIFilter f = new PoiUIFilter(t, application, "");
top.add(f);
}
Collections.sort(top);
cacheTopStandardFilters = top;
}
List<PoiUIFilter> result = new ArrayList<PoiUIFilter>();
result.addAll(cacheTopStandardFilters);
result.add(getShowAllPOIFilter());
return result;
}
use of net.osmand.osm.PoiFilter 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.PoiFilter in project Osmand by osmandapp.
the class QuickSearchListItem method getTypeName.
public static String getTypeName(SampleApplication app, SearchResult searchResult) {
switch(searchResult.objectType) {
case CITY:
City city = (City) searchResult.object;
return getCityTypeStr(app, city.getType());
case POSTCODE:
return app.getString("postcode");
case VILLAGE:
city = (City) searchResult.object;
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
if (searchResult.distRelatedObjectName > 0) {
return getCityTypeStr(app, city.getType()) + " • " + SampleFormatter.getFormattedDistance((float) searchResult.distRelatedObjectName, app) + " " + app.getString("shared_string_from") + " " + searchResult.localeRelatedObjectName;
} else {
return getCityTypeStr(app, city.getType()) + ", " + searchResult.localeRelatedObjectName;
}
} else {
return getCityTypeStr(app, city.getType());
}
case STREET:
StringBuilder streetBuilder = new StringBuilder();
if (searchResult.localeName.endsWith(")")) {
int i = searchResult.localeName.indexOf('(');
if (i > 0) {
streetBuilder.append(searchResult.localeName.substring(i + 1, searchResult.localeName.length() - 1));
}
}
if (!Algorithms.isEmpty(searchResult.localeRelatedObjectName)) {
if (streetBuilder.length() > 0) {
streetBuilder.append(", ");
}
streetBuilder.append(searchResult.localeRelatedObjectName);
}
return streetBuilder.toString();
case HOUSE:
if (searchResult.relatedObject != null) {
Street relatedStreet = (Street) searchResult.relatedObject;
if (relatedStreet.getCity() != null) {
return searchResult.localeRelatedObjectName + ", " + relatedStreet.getCity().getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
} else {
return searchResult.localeRelatedObjectName;
}
}
return "";
case STREET_INTERSECTION:
Street street = (Street) searchResult.object;
if (street.getCity() != null) {
return street.getCity().getName(searchResult.requiredSearchPhrase.getSettings().getLang(), true);
}
return "";
case POI_TYPE:
String res = "";
if (searchResult.object instanceof AbstractPoiType) {
AbstractPoiType abstractPoiType = (AbstractPoiType) searchResult.object;
if (abstractPoiType instanceof PoiCategory) {
res = "";
} else if (abstractPoiType instanceof PoiFilter) {
PoiFilter poiFilter = (PoiFilter) abstractPoiType;
res = poiFilter.getPoiCategory() != null ? poiFilter.getPoiCategory().getTranslation() : "";
} else if (abstractPoiType instanceof PoiType) {
PoiType poiType = (PoiType) abstractPoiType;
res = poiType.getParentType() != null ? poiType.getParentType().getTranslation() : null;
if (res == null) {
res = poiType.getCategory() != null ? poiType.getCategory().getTranslation() : null;
}
if (res == null) {
res = "";
}
} else {
res = "";
}
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
res = ((CustomSearchPoiFilter) searchResult.object).getName();
}
return res;
case POI:
Amenity amenity = (Amenity) searchResult.object;
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;
case LOCATION:
LatLon latLon = searchResult.location;
if (searchResult.localeRelatedObjectName == null) {
String locationCountry = app.getRegions().getCountryName(latLon);
searchResult.localeRelatedObjectName = locationCountry == null ? "" : locationCountry;
}
return searchResult.localeRelatedObjectName;
case REGION:
BinaryMapIndexReader binaryMapIndexReader = (BinaryMapIndexReader) searchResult.object;
System.out.println(binaryMapIndexReader.getFile().getAbsolutePath() + " " + binaryMapIndexReader.getCountryName());
break;
case UNKNOWN_NAME_FILTER:
break;
}
return searchResult.objectType.name();
}
Aggregations