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;
}
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;
}
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;
}
Aggregations