Search in sources :

Example 21 with TransportStop

use of net.osmand.data.TransportStop in project Osmand by osmandapp.

the class TransportStopsLayer method getFromPoint.

public void getFromPoint(RotatedTileBox tb, PointF point, List<? super TransportStop> res, List<TransportStop> objects) {
    int ex = (int) point.x;
    int ey = (int) point.y;
    final int rp = getRadiusPoi(tb);
    int radius = rp * 3 / 2;
    try {
        TreeSet<String> ms = new TreeSet<>();
        for (int i = 0; i < objects.size(); i++) {
            TransportStop n = objects.get(i);
            if (n.getLocation() == null) {
                continue;
            }
            int x = (int) tb.getPixXFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
            int y = (int) tb.getPixYFromLatLon(n.getLocation().getLatitude(), n.getLocation().getLongitude());
            if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
                if (!ms.add(n.getName())) {
                    // only unique names
                    continue;
                }
                radius = rp;
                res.add(n);
            }
        }
    } catch (IndexOutOfBoundsException e) {
    // that's really rare case, but is much efficient than introduce synchronized block
    }
}
Also used : TreeSet(java.util.TreeSet) TransportStop(net.osmand.data.TransportStop) Paint(android.graphics.Paint)

Example 22 with TransportStop

use of net.osmand.data.TransportStop in project Osmand by osmandapp.

the class TransportStopRoute method calculateZoom.

public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
    RotatedTileBox cp = currentRotatedTileBox.copy();
    boolean notContains = true;
    while (cp.getZoom() > 12 && notContains) {
        notContains = false;
        List<TransportStop> sts = route.getForwardStops();
        for (int i = startPosition; i < sts.size(); i++) {
            TransportStop st = sts.get(startPosition);
            if (!cp.containsLatLon(st.getLocation())) {
                notContains = true;
                break;
            }
        }
        cp.setZoom(cp.getZoom() - 1);
    }
    return cp.getZoom();
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) TransportStop(net.osmand.data.TransportStop)

Aggregations

TransportStop (net.osmand.data.TransportStop)22 ArrayList (java.util.ArrayList)8 QuadRect (net.osmand.data.QuadRect)5 Way (net.osmand.osm.edit.Way)5 LinkedHashMap (java.util.LinkedHashMap)4 Paint (android.graphics.Paint)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)3 Node (net.osmand.osm.edit.Node)3 TransportStopRoute (net.osmand.plus.transport.TransportStopRoute)3 TransportIndex (net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex)2 RotatedTileBox (net.osmand.data.RotatedTileBox)2 TransportRoute (net.osmand.data.TransportRoute)2 Relation (net.osmand.osm.edit.Relation)2 RelationMember (net.osmand.osm.edit.Relation.RelationMember)2 Rect (rtree.Rect)2 Bitmap (android.graphics.Bitmap)1 Path (android.graphics.Path)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1