Search in sources :

Example 26 with PoiUIFilter

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);
}
Also used : Amenity(net.osmand.data.Amenity) ArrayList(java.util.ArrayList) PoiType(net.osmand.osm.PoiType) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap)

Example 27 with PoiUIFilter

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());
}
Also used : PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Example 28 with PoiUIFilter

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);
}
Also used : CustomSearchPoiFilter(net.osmand.search.core.CustomSearchPoiFilter) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter)

Aggregations

PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)28 ArrayList (java.util.ArrayList)12 PoiFiltersHelper (net.osmand.plus.poi.PoiFiltersHelper)8 TextView (android.widget.TextView)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 DialogInterface (android.content.DialogInterface)6 AlertDialog (android.support.v7.app.AlertDialog)6 View (android.view.View)5 AbstractPoiType (net.osmand.osm.AbstractPoiType)5 PoiType (net.osmand.osm.PoiType)5 SearchResult (net.osmand.search.core.SearchResult)5 SpannableString (android.text.SpannableString)4 Button (android.widget.Button)4 LinearLayout (android.widget.LinearLayout)4 Drawable (android.graphics.drawable.Drawable)3 AdapterView (android.widget.AdapterView)3 EditText (android.widget.EditText)3 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)3 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)3