use of net.osmand.plus.poi.PoiUIFilter 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.plus.poi.PoiUIFilter in project Osmand by osmandapp.
the class ShowHidePoiAction method execute.
@Override
public void execute(MapActivity activity) {
PoiFiltersHelper pf = activity.getMyApplication().getPoiFilters();
List<PoiUIFilter> poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
if (!isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters)) {
pf.clearSelectedPoiFilters();
for (PoiUIFilter filter : poiFilters) {
pf.addSelectedPoiFilter(filter);
}
} else
pf.clearSelectedPoiFilters();
activity.getMapLayers().updateLayers(activity.getMapView());
}
use of net.osmand.plus.poi.PoiUIFilter in project Osmand by osmandapp.
the class QuickSearchHelper method refreshCustomPoiFilters.
public void refreshCustomPoiFilters() {
core.clearCustomSearchPoiFilters();
PoiFiltersHelper poiFilters = app.getPoiFilters();
for (CustomSearchPoiFilter udf : poiFilters.getUserDefinedPoiFilters()) {
core.addCustomSearchPoiFilter(udf, 0);
}
PoiUIFilter localWikiPoiFilter = poiFilters.getLocalWikiPOIFilter();
if (localWikiPoiFilter != null) {
core.addCustomSearchPoiFilter(localWikiPoiFilter, 1);
}
core.addCustomSearchPoiFilter(poiFilters.getShowAllPOIFilter(), 1);
}
Aggregations