Search in sources :

Example 1 with TransportStopType

use of net.osmand.plus.transport.TransportStopType in project Osmand by osmandapp.

the class TransportStopsLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
    List<TransportStop> objects = null;
    if (tb.getZoom() >= startZoomRoute) {
        if (stopRoute != null) {
            objects = stopRoute.route.getForwardStops();
            int color = stopRoute.getColor(mapActivity.getMyApplication(), settings.isNightMode());
            attrs.paint.setColor(color);
            attrs.updatePaints(view, settings, tb);
            try {
                path.reset();
                List<Way> ws = stopRoute.route.getForwardWays();
                if (ws != null) {
                    for (Way w : ws) {
                        TIntArrayList tx = new TIntArrayList();
                        TIntArrayList ty = new TIntArrayList();
                        for (int i = 0; i < w.getNodes().size(); i++) {
                            Node o = w.getNodes().get(i);
                            int x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
                            int y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
                            tx.add(x);
                            ty.add(y);
                        }
                        calculatePath(tb, tx, ty, path);
                    }
                }
                attrs.drawPath(canvas, path);
            } catch (Exception e) {
            // ignore
            }
        }
    }
    if (showTransportStops && tb.getZoom() >= startZoom && objects == null) {
        data.queryNewData(tb);
        objects = data.getResults();
    }
    if (objects != null) {
        float iconSize = stopBus.getWidth() * 3 / 2.5f;
        QuadTree<QuadRect> boundIntersections = initBoundIntersections(tb);
        List<TransportStop> fullObjects = new ArrayList<>();
        for (TransportStop o : objects) {
            float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
            float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
            if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
                canvas.drawBitmap(stopSmall, x - stopSmall.getWidth() / 2, y - stopSmall.getHeight() / 2, paintIcon);
            } else {
                fullObjects.add(o);
            }
        }
        for (TransportStop o : fullObjects) {
            float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
            float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
            if (stopRoute != null) {
                TransportStopType type = TransportStopType.findType(stopRoute.route.getType());
                if (type != null) {
                    Bitmap foregroundIcon = RenderingIcons.getIcon(mapActivity, type.getResName(), false);
                    canvas.drawBitmap(backgroundIcon, x - backgroundIconHalfWidth, y - backgroundIconHalfHeight, paintIcon);
                    canvas.drawBitmap(foregroundIcon, x - foregroundIcon.getWidth() / 2, y - foregroundIcon.getHeight() / 2, paintWhiteIcon);
                }
            } else {
                Bitmap b = stopBus;
                canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
            }
        }
    }
}
Also used : TransportStopType(net.osmand.plus.transport.TransportStopType) Node(net.osmand.osm.edit.Node) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint) Way(net.osmand.osm.edit.Way) TIntArrayList(gnu.trove.list.array.TIntArrayList) Bitmap(android.graphics.Bitmap) TransportStop(net.osmand.data.TransportStop)

Example 2 with TransportStopType

use of net.osmand.plus.transport.TransportStopType in project Osmand by osmandapp.

the class TransportStopController method addRoutes.

private void addRoutes(List<TransportStopRoute> routes, boolean useEnglishNames, TransportIndexRepository t, TransportStop s, TransportStop refStop, int dist) {
    Collection<TransportRoute> rts = t.getRouteForStop(s);
    if (rts != null) {
        for (TransportRoute rs : rts) {
            TransportStopType type = TransportStopType.findType(rs.getType());
            if (topType == null && type != null && type.isTopType()) {
                topType = type;
            }
            if (!containsRef(routes, rs)) {
                TransportStopRoute r = new TransportStopRoute();
                r.type = type;
                r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
                r.route = rs;
                r.refStop = refStop;
                r.stop = s;
                r.distance = dist;
                routes.add(r);
            }
        }
    }
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) TransportStopType(net.osmand.plus.transport.TransportStopType) TransportRoute(net.osmand.data.TransportRoute)

Example 3 with TransportStopType

use of net.osmand.plus.transport.TransportStopType in project Osmand by osmandapp.

the class AmenityMenuController method addRoutes.

private void addRoutes(boolean useEnglishNames, TransportIndexRepository t, TransportStop s, int dist, boolean isSubwayEntrance) {
    Collection<TransportRoute> rts = t.getRouteForStop(s);
    if (rts != null) {
        for (TransportRoute rs : rts) {
            if (!containsRef(rs)) {
                TransportStopType type = TransportStopType.findType(rs.getType());
                if (isSubwayEntrance && type != TransportStopType.SUBWAY && dist > 150) {
                    continue;
                }
                TransportStopRoute r = new TransportStopRoute();
                r.type = type;
                r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();
                r.route = rs;
                r.stop = s;
                r.distance = dist;
                this.routes.add(r);
            }
        }
    }
}
Also used : TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) TransportStopType(net.osmand.plus.transport.TransportStopType) TransportRoute(net.osmand.data.TransportRoute)

Aggregations

TransportStopType (net.osmand.plus.transport.TransportStopType)3 TransportRoute (net.osmand.data.TransportRoute)2 TransportStopRoute (net.osmand.plus.transport.TransportStopRoute)2 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 ArrayList (java.util.ArrayList)1 QuadRect (net.osmand.data.QuadRect)1 TransportStop (net.osmand.data.TransportStop)1 Node (net.osmand.osm.edit.Node)1 Way (net.osmand.osm.edit.Way)1