Search in sources :

Example 11 with TransportRouteResultSegment

use of net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment in project Osmand by osmandapp.

the class PublicTransportCard method getIntervalDescr.

private String getIntervalDescr(List<TransportRouteResultSegment> segments) {
    String interval = Algorithms.capitalizeFirstLetter(app.getString(R.string.shared_string_interval));
    Iterator<TransportRouteResultSegment> iterator = segments.iterator();
    boolean firstInterval = true;
    while (iterator.hasNext()) {
        TransportRouteResultSegment segment = iterator.next();
        if (segment.route.hasInterval()) {
            if (firstInterval) {
                interval = app.getString(R.string.ltr_or_rtl_combine_via_space, interval, app.getString(R.string.ltr_or_rtl_combine_via_dash, segment.route.getRef(), segment.route.getInterval()));
                firstInterval = false;
            } else {
                interval = app.getString(R.string.ltr_or_rtl_combine_via_comma, interval, app.getString(R.string.ltr_or_rtl_combine_via_dash, segment.route.getRef(), segment.route.getInterval()));
            }
        }
    }
    return interval;
}
Also used : TransportRouteResultSegment(net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment) SpannableString(android.text.SpannableString)

Example 12 with TransportRouteResultSegment

use of net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment in project Osmand by osmandapp.

the class TransportRoutingHelper method getWalkingTime.

public int getWalkingTime(@NonNull List<TransportRouteResultSegment> segments) {
    int res = 0;
    Map<Pair<TransportRouteResultSegment, TransportRouteResultSegment>, RouteCalculationResult> walkingRouteSegments = this.walkingRouteSegments;
    if (walkingRouteSegments != null) {
        TransportRouteResultSegment prevSegment = null;
        for (TransportRouteResultSegment segment : segments) {
            RouteCalculationResult walkingRouteSegment = getWalkingRouteSegment(prevSegment, segment);
            if (walkingRouteSegment != null) {
                res += walkingRouteSegment.getRoutingTime();
            }
            prevSegment = segment;
        }
        if (segments.size() > 0) {
            RouteCalculationResult walkingRouteSegment = getWalkingRouteSegment(segments.get(segments.size() - 1), null);
            if (walkingRouteSegment != null) {
                res += walkingRouteSegment.getRoutingTime();
            }
        }
    }
    return res;
}
Also used : TransportRouteResultSegment(net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment) Pair(android.util.Pair)

Example 13 with TransportRouteResultSegment

use of net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment in project Osmand by osmandapp.

the class TransportRoutingHelper method getTransportRouteRect.

@Nullable
public QuadRect getTransportRouteRect(@NonNull TransportRouteResult result) {
    TransportRoutingHelper transportRoutingHelper = app.getTransportRoutingHelper();
    QuadRect r = new QuadRect(0, 0, 0, 0);
    TransportRouteResultSegment s1;
    TransportRouteResultSegment s2 = null;
    for (TransportRouteResultSegment segment : result.getSegments()) {
        s1 = segment;
        for (Node n : segment.getNodes()) {
            MapUtils.insetLatLonRect(r, n.getLatitude(), n.getLongitude());
        }
        RouteCalculationResult wrs = s2 == null ? transportRoutingHelper.getWalkingRouteSegment(null, s1) : transportRoutingHelper.getWalkingRouteSegment(s1, s2);
        if (wrs != null) {
            for (Location p : wrs.getRouteLocations()) {
                MapUtils.insetLatLonRect(r, p.getLatitude(), p.getLongitude());
            }
        }
        s2 = s1;
    }
    RouteCalculationResult wrs = transportRoutingHelper.getWalkingRouteSegment(s2, null);
    if (wrs != null) {
        for (Location p : wrs.getRouteLocations()) {
            MapUtils.insetLatLonRect(r, p.getLatitude(), p.getLongitude());
        }
    }
    return r.left == 0 && r.right == 0 ? null : r;
}
Also used : TransportRouteResultSegment(net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment) Node(net.osmand.osm.edit.Node) QuadRect(net.osmand.data.QuadRect) Location(net.osmand.Location) Nullable(androidx.annotation.Nullable)

Aggregations

TransportRouteResultSegment (net.osmand.router.TransportRoutePlanner.TransportRouteResultSegment)13 LatLon (net.osmand.data.LatLon)4 SpannableString (android.text.SpannableString)2 Pair (android.util.Pair)2 ArrayList (java.util.ArrayList)2 QuadRect (net.osmand.data.QuadRect)2 Node (net.osmand.osm.edit.Node)2 Way (net.osmand.osm.edit.Way)2 TransportRouteResult (net.osmand.router.TransportRouteResult)2 SuppressLint (android.annotation.SuppressLint)1 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Typeface (android.graphics.Typeface)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 HashSet (java.util.HashSet)1 Location (net.osmand.Location)1