use of net.osmand.osm.PoiType 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.PoiType in project Osmand by osmandapp.
the class QuickSearchPoiFilterFragment method initPoiAdditionals.
private void initPoiAdditionals(Collection<PoiType> poiAdditionals, Set<String> excludedPoiAdditionalCategories) {
Set<String> selectedCategories = new LinkedHashSet<>();
Set<String> topTrueOnlyCategories = new LinkedHashSet<>();
Set<String> topFalseOnlyCategories = new LinkedHashSet<>();
for (PoiType poiType : poiAdditionals) {
String category = poiType.getPoiAdditionalCategory();
if (category != null) {
topTrueOnlyCategories.add(category);
topFalseOnlyCategories.add(category);
}
}
for (PoiType poiType : poiAdditionals) {
String category = poiType.getPoiAdditionalCategory();
if (category == null) {
category = "";
}
if (excludedPoiAdditionalCategories != null && excludedPoiAdditionalCategories.contains(category)) {
topTrueOnlyCategories.remove(category);
topFalseOnlyCategories.remove(category);
continue;
}
if (!poiType.isTopVisible()) {
topTrueOnlyCategories.remove(category);
} else {
topFalseOnlyCategories.remove(category);
}
String keyName = poiType.getKeyName().replace('_', ':').replace(' ', ':').toLowerCase();
if (selectedPoiAdditionals.contains(keyName)) {
selectedCategories.add(category);
}
}
for (String category : topTrueOnlyCategories) {
if (!showAllCategories.contains(category)) {
showAllCategories.add(category);
}
}
for (String category : topFalseOnlyCategories) {
if (!collapsedCategories.contains(category) && !showAllCategories.contains(category)) {
if (!selectedCategories.contains(category)) {
collapsedCategories.add(category);
}
showAllCategories.add(category);
}
}
}
use of net.osmand.osm.PoiType in project Osmand by osmandapp.
the class POIMapLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
Set<PoiUIFilter> selectedPoiFilters = app.getPoiFilters().getSelectedPoiFilters();
if (!this.filters.equals(selectedPoiFilters)) {
this.filters = new TreeSet<>(selectedPoiFilters);
data.clearCache();
}
List<Amenity> objects = Collections.emptyList();
List<Amenity> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
if (!filters.isEmpty()) {
if (tileBox.getZoom() >= startZoom) {
data.queryNewData(tileBox);
objects = data.getResults();
if (objects != null) {
float iconSize = poiBackground.getWidth() * 3 / 2;
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
for (Amenity o : objects) {
float x = tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
canvas.drawBitmap(poiBackgroundSmall, x - poiBackgroundSmall.getWidth() / 2, y - poiBackgroundSmall.getHeight() / 2, paintIconBackground);
smallObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()));
} else {
fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude()));
}
}
for (Amenity o : fullObjects) {
int x = (int) tileBox.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
canvas.drawBitmap(poiBackground, x - poiBackground.getWidth() / 2, y - poiBackground.getHeight() / 2, paintIconBackground);
String id = null;
PoiType st = o.getType().getPoiTypeByKeyName(o.getSubType());
if (st != null) {
if (RenderingIcons.containsSmallIcon(st.getIconKeyName())) {
id = st.getIconKeyName();
} else if (RenderingIcons.containsSmallIcon(st.getOsmTag() + "_" + st.getOsmValue())) {
id = st.getOsmTag() + "_" + st.getOsmValue();
}
}
if (id != null) {
Bitmap bmp = RenderingIcons.getIcon(view.getContext(), id, false);
if (bmp != null) {
canvas.drawBitmap(bmp, x - bmp.getWidth() / 2, y - bmp.getHeight() / 2, paintIcon);
}
}
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
}
}
mapTextLayer.putData(this, objects);
}
use of net.osmand.osm.PoiType in project Osmand by osmandapp.
the class AddPOIAction method getCategory.
private PoiCategory getCategory(Map<String, PoiType> allTranslatedNames) {
String tp = getTagsFromParams().get(POI_TYPE_TAG);
if (tp == null)
return null;
PoiType pt = allTranslatedNames.get(tp.toLowerCase());
if (pt != null) {
return pt.getCategory();
} else
return null;
}
Aggregations