diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java index 8197b916252..b3eb566a196 100644 --- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapper.java @@ -39,7 +39,7 @@ private static ViaLocation mapViaLocation(Map via) { visit.getGraphQLLabel(), visit.getGraphQLMinimumWaitTime(), mapStopLocationIds(visit.getGraphQLStopLocationIds()), - mapCoordinate(visit.getGraphQLCoordinate()).map(List::of).orElse(List.of()) + mapCoordinate(visit.getGraphQLCoordinate()).orElse(null) ); } else { throw new IllegalArgumentException("ViaLocation must define either pass-through or visit."); diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java index ea9329a359a..4026fc4b98c 100644 --- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java +++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java @@ -82,10 +82,12 @@ private List mapStopLocationIds(Map map) { return c == null ? List.of() : idMapper.parseList(c); } - private static List mapCoordinate(Map map) { - return CoordinateInputType.mapToWgsCoordinate(ViaLocationInputType.FIELD_COORDINATE, map) - .map(List::of) - .orElseGet(List::of); + @Nullable + private static WgsCoordinate mapCoordinate(Map map) { + return CoordinateInputType.mapToWgsCoordinate( + ViaLocationInputType.FIELD_COORDINATE, + map + ).orElse(null); } /** diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java b/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java index a3cd4eab526..0d13c7184f0 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java @@ -24,7 +24,7 @@ import org.opentripplanner.routing.algorithm.raptoradapter.router.FilterTransitWhenDirectModeIsEmpty; import org.opentripplanner.routing.algorithm.raptoradapter.router.TransitRouter; import org.opentripplanner.routing.algorithm.raptoradapter.router.street.DirectFlexRouter; -import org.opentripplanner.routing.algorithm.raptoradapter.router.street.DirectStreetRouter; +import org.opentripplanner.routing.algorithm.raptoradapter.router.street.DirectStreetRouterFactory; import org.opentripplanner.routing.api.request.RouteRequest; import org.opentripplanner.routing.api.request.StreetMode; import org.opentripplanner.routing.api.request.request.StreetRequest; @@ -221,14 +221,6 @@ private Duration searchWindowUsed() { } private RoutingResult routeDirectStreet() { - // TODO: Add support for via search to the direct-street search and remove this. - // The direct search is used to prune away silly transit results and it - // would be nice to also support via as a feature in the direct-street - // search. - if (request.isViaSearch()) { - return RoutingResult.empty(); - } - // If no direct mode is set, then we set one. // See {@link FilterTransitWhenDirectModeIsEmpty} var emptyDirectModeHandler = new FilterTransitWhenDirectModeIsEmpty( @@ -243,8 +235,9 @@ private RoutingResult routeDirectStreet() { debugTimingAggregator.startedDirectStreetRouter(); try { + var directStreetRouter = DirectStreetRouterFactory.create(request); return RoutingResult.ok( - DirectStreetRouter.route(serverContext, directBuilder.buildRequest(), linkingContext()), + directStreetRouter.route(serverContext, directBuilder.buildRequest(), linkingContext()), emptyDirectModeHandler.removeWalkAllTheWayResults() ); } finally { diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java index 5aa9e782629..e01f1d2e510 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/GraphPathToItineraryMapper.java @@ -361,6 +361,7 @@ private StreetLeg generateLeg(List states, WalkStep previousStep) { // link to the user so we remove it here .filter(e -> !(e.backEdge instanceof BoardingLocationToStopLink)) .map(State::getBackEdge) + .filter(Objects::nonNull) .toList(); State firstState = states.get(0); diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DefaultDirectStreetRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DefaultDirectStreetRouter.java new file mode 100644 index 00000000000..5abcf3e029e --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DefaultDirectStreetRouter.java @@ -0,0 +1,85 @@ +package org.opentripplanner.routing.algorithm.raptoradapter.router.street; + +import java.util.Collections; +import java.util.List; +import org.opentripplanner.astar.model.GraphPath; +import org.opentripplanner.framework.application.OTPRequestTimeoutException; +import org.opentripplanner.framework.geometry.SphericalDistanceLibrary; +import org.opentripplanner.model.plan.Itinerary; +import org.opentripplanner.routing.algorithm.mapping.GraphPathToItineraryMapper; +import org.opentripplanner.routing.algorithm.mapping.ItinerariesHelper; +import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.routing.api.request.StreetMode; +import org.opentripplanner.routing.error.PathNotFoundException; +import org.opentripplanner.routing.impl.GraphPathFinder; +import org.opentripplanner.routing.linking.LinkingContext; +import org.opentripplanner.standalone.api.OtpServerRequestContext; +import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.vertex.Vertex; +import org.opentripplanner.street.search.state.State; + +/** + * Generates "direct" street routes, i.e. those that do not use transit and are on the street + * network for the entire itinerary. Doesn't support via locations or flex. + */ +public class DefaultDirectStreetRouter implements DirectStreetRouter { + + public List route( + OtpServerRequestContext serverContext, + RouteRequest request, + LinkingContext linkingContext + ) { + if (request.journey().direct().mode() == StreetMode.NOT_SET) { + return Collections.emptyList(); + } + OTPRequestTimeoutException.checkForTimeout(); + try { + var maxCarSpeed = serverContext.streetLimitationParametersService().maxCarSpeed(); + if (!straightLineDistanceIsWithinLimit(request, maxCarSpeed, linkingContext)) { + return Collections.emptyList(); + } + + // we could also get a persistent router-scoped GraphPathFinder but there's no setup cost here + GraphPathFinder gpFinder = new GraphPathFinder( + serverContext.traverseVisitor(), + serverContext.listExtensionRequestContexts(request), + maxCarSpeed + ); + List> paths = gpFinder.graphPathFinderEntryPoint( + request, + linkingContext + ); + + // Convert the internal GraphPaths to itineraries + final GraphPathToItineraryMapper graphPathToItineraryMapper = new GraphPathToItineraryMapper( + serverContext.transitService()::getRegularStop, + serverContext.transitService().getTimeZone(), + serverContext.graph().streetNotesService, + serverContext.graph().ellipsoidToGeoidDifference + ); + List response = graphPathToItineraryMapper.mapItineraries(paths); + response = ItinerariesHelper.decorateItinerariesWithRequestData( + response, + request.journey().wheelchair(), + request.preferences().wheelchair() + ); + return response; + } catch (PathNotFoundException e) { + return Collections.emptyList(); + } + } + + private static boolean straightLineDistanceIsWithinLimit( + RouteRequest request, + float maxCarSpeed, + LinkingContext linkingContext + ) { + // TODO This currently only calculates the distances between the first fromVertex + // and the first toVertex + double distance = SphericalDistanceLibrary.distance( + linkingContext.findVertices(request.from()).iterator().next().getCoordinate(), + linkingContext.findVertices(request.to()).iterator().next().getCoordinate() + ); + return distance < request.getMaximumDirectDistance(maxCarSpeed); + } +} diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java index 4219e00e4e4..39c72d05769 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouter.java @@ -1,114 +1,19 @@ package org.opentripplanner.routing.algorithm.raptoradapter.router.street; -import java.util.Collections; import java.util.List; -import org.opentripplanner.astar.model.GraphPath; -import org.opentripplanner.framework.application.OTPRequestTimeoutException; -import org.opentripplanner.framework.geometry.SphericalDistanceLibrary; import org.opentripplanner.model.plan.Itinerary; -import org.opentripplanner.routing.algorithm.mapping.GraphPathToItineraryMapper; -import org.opentripplanner.routing.algorithm.mapping.ItinerariesHelper; import org.opentripplanner.routing.api.request.RouteRequest; -import org.opentripplanner.routing.api.request.StreetMode; -import org.opentripplanner.routing.error.PathNotFoundException; -import org.opentripplanner.routing.impl.GraphPathFinder; import org.opentripplanner.routing.linking.LinkingContext; import org.opentripplanner.standalone.api.OtpServerRequestContext; -import org.opentripplanner.street.model.edge.Edge; -import org.opentripplanner.street.model.vertex.Vertex; -import org.opentripplanner.street.search.state.State; /** * Generates "direct" street routes, i.e. those that do not use transit and are on the street - * network for the entire itinerary. - * - * @see DirectFlexRouter + * network for the entire itinerary. For flex routing, use {@link DirectFlexRouter}. */ -public class DirectStreetRouter { - - public static List route( +public interface DirectStreetRouter { + List route( OtpServerRequestContext serverContext, RouteRequest request, LinkingContext linkingContext - ) { - if (request.journey().direct().mode() == StreetMode.NOT_SET) { - return Collections.emptyList(); - } - OTPRequestTimeoutException.checkForTimeout(); - try { - var maxCarSpeed = serverContext.streetLimitationParametersService().maxCarSpeed(); - if (!straightLineDistanceIsWithinLimit(request, maxCarSpeed, linkingContext)) { - return Collections.emptyList(); - } - - // we could also get a persistent router-scoped GraphPathFinder but there's no setup cost here - GraphPathFinder gpFinder = new GraphPathFinder( - serverContext.traverseVisitor(), - serverContext.listExtensionRequestContexts(request), - maxCarSpeed - ); - List> paths = gpFinder.graphPathFinderEntryPoint( - request, - linkingContext - ); - - // Convert the internal GraphPaths to itineraries - final GraphPathToItineraryMapper graphPathToItineraryMapper = new GraphPathToItineraryMapper( - serverContext.transitService()::getRegularStop, - serverContext.transitService().getTimeZone(), - serverContext.graph().streetNotesService, - serverContext.graph().ellipsoidToGeoidDifference - ); - List response = graphPathToItineraryMapper.mapItineraries(paths); - response = ItinerariesHelper.decorateItinerariesWithRequestData( - response, - request.journey().wheelchair(), - request.preferences().wheelchair() - ); - return response; - } catch (PathNotFoundException e) { - return Collections.emptyList(); - } - } - - private static boolean straightLineDistanceIsWithinLimit( - RouteRequest request, - float maxCarSpeed, - LinkingContext linkingContext - ) { - // TODO This currently only calculates the distances between the first fromVertex - // and the first toVertex - double distance = SphericalDistanceLibrary.distance( - linkingContext.findVertices(request.from()).iterator().next().getCoordinate(), - linkingContext.findVertices(request.to()).iterator().next().getCoordinate() - ); - return distance < calculateDistanceMaxLimit(request, maxCarSpeed); - } - - /** - * Calculates the maximum distance in meters based on the maxDirectStreetDuration and the - * fastest mode available. This assumes that it is not possible to exceed the speed defined in the - * RouteRequest. - */ - private static double calculateDistanceMaxLimit(RouteRequest request, float maxCarSpeed) { - var preferences = request.preferences(); - double distanceLimit; - StreetMode mode = request.journey().direct().mode(); - - double durationLimit = preferences.street().maxDirectDuration().valueOf(mode).toSeconds(); - - if (mode.includesDriving()) { - distanceLimit = durationLimit * maxCarSpeed; - } else if (mode.includesBiking()) { - distanceLimit = durationLimit * preferences.bike().speed(); - } else if (mode.includesScooter()) { - distanceLimit = durationLimit * preferences.scooter().speed(); - } else if (mode.includesWalking()) { - distanceLimit = durationLimit * preferences.walk().speed(); - } else { - throw new IllegalStateException("Could not set max limit for StreetMode"); - } - - return distanceLimit; - } + ); } diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouterFactory.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouterFactory.java new file mode 100644 index 00000000000..15a76bde618 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/DirectStreetRouterFactory.java @@ -0,0 +1,17 @@ +package org.opentripplanner.routing.algorithm.raptoradapter.router.street; + +import org.opentripplanner.routing.api.request.RouteRequest; + +/** + * This factory encapsulates the logic for deciding which direct street router to use. + */ +public class DirectStreetRouterFactory { + + /** + * @return {@link DefaultDirectStreetRouter} if there are no via locations, otherwise + * {@link ViaDirectStreetRouter}. + */ + public static DirectStreetRouter create(RouteRequest request) { + return request.isViaSearch() ? new ViaDirectStreetRouter() : new DefaultDirectStreetRouter(); + } +} diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/ViaDirectStreetRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/ViaDirectStreetRouter.java new file mode 100644 index 00000000000..055e191c8a1 --- /dev/null +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/street/ViaDirectStreetRouter.java @@ -0,0 +1,194 @@ +package org.opentripplanner.routing.algorithm.raptoradapter.router.street; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.opentripplanner.astar.model.GraphPath; +import org.opentripplanner.framework.application.OTPRequestTimeoutException; +import org.opentripplanner.framework.geometry.SphericalDistanceLibrary; +import org.opentripplanner.model.plan.Itinerary; +import org.opentripplanner.routing.algorithm.mapping.GraphPathToItineraryMapper; +import org.opentripplanner.routing.algorithm.mapping.ItinerariesHelper; +import org.opentripplanner.routing.api.request.RouteRequest; +import org.opentripplanner.routing.api.request.StreetMode; +import org.opentripplanner.routing.api.request.request.StreetRequest; +import org.opentripplanner.routing.error.PathNotFoundException; +import org.opentripplanner.routing.impl.GraphPathFinder; +import org.opentripplanner.routing.linking.LinkingContext; +import org.opentripplanner.standalone.api.OtpServerRequestContext; +import org.opentripplanner.street.model.edge.Edge; +import org.opentripplanner.street.model.vertex.Vertex; +import org.opentripplanner.street.search.state.State; + +/** + * Generates "direct" street routes, i.e. those that do not use transit and are on the street + * network for the entire itinerary, that go through via locations. + * + * TODO Currently lacks support for delaying rental return or parking after first via. + */ +public class ViaDirectStreetRouter implements DirectStreetRouter { + + public List route( + OtpServerRequestContext serverContext, + RouteRequest request, + LinkingContext linkingContext + ) { + // No support for pass-through locations or visit via locations with just stops as they force + // you to use transit. + var vias = request.listViaLocationsWithCoordinates(); + if (request.listViaLocations().size() != vias.size()) { + return Collections.emptyList(); + } + if (request.journey().direct().mode() == StreetMode.NOT_SET) { + return Collections.emptyList(); + } + + var maxCarSpeed = serverContext.streetLimitationParametersService().maxCarSpeed(); + if (!straightLineDistanceIsWithinLimit(request, maxCarSpeed, linkingContext)) { + return Collections.emptyList(); + } + + OTPRequestTimeoutException.checkForTimeout(); + try { + // we could also get a persistent router-scoped GraphPathFinder but there's no setup cost here + GraphPathFinder gpFinder = new GraphPathFinder( + serverContext.traverseVisitor(), + serverContext.listExtensionRequestContexts(request), + maxCarSpeed + ); + var firstRequest = request.copyOf().withTo(vias.getFirst()).buildRequest(); + List> paths = new ArrayList<>( + gpFinder.graphPathFinderEntryPoint(firstRequest, linkingContext) + ); + + var mode = request.journey().direct().mode(); + var newMode = getStreetRequestAfterFirstVia(mode); + var requestWithNewMode = request + .copyOf() + .withJourney(journeyRequestBuilder -> journeyRequestBuilder.withDirect(newMode)) + // TODO we might want to change this behaviour + .withPreferences(preferences -> + preferences + .withBike(bike -> + bike.withRental(rental -> rental.withAllowArrivingInRentedVehicleAtDestination(false)) + ) + .withScooter(scooter -> + scooter.withRental(rental -> + rental.withAllowArrivingInRentedVehicleAtDestination(false) + ) + ) + .withCar(car -> + car.withRental(rental -> rental.withAllowArrivingInRentedVehicleAtDestination(false)) + ) + ) + .buildRequest(); + + var lastLocations = new ArrayList<>(vias); + lastLocations.add(request.to()); + for (int i = 0; i < lastLocations.size() - 1; i++) { + var from = lastLocations.get(i); + var to = lastLocations.get(i + 1); + var minimumWaitTime = request.listViaLocations().get(i).minimumWaitTime(); + var newStartTime = Instant.ofEpochSecond(paths.getFirst().getEndTime()).plus( + minimumWaitTime + ); + var lastDuration = minimumWaitTime.plusSeconds(paths.getFirst().getDuration()); + var patchedRequest = requestWithNewMode + .copyOf() + .withFrom(from) + .withTo(to) + .withDateTime(newStartTime) + .withPreferences(preferences -> + preferences.withStreet(street -> + street.withMaxDirectDuration(streetModeBuilder -> + streetModeBuilder.with( + newMode.mode(), + request + .preferences() + .street() + .maxDirectDuration() + .valueOf(mode) + .minus(lastDuration) + ) + ) + ) + ) + .buildRequest(); + var lastState = paths.getFirst().states.getLast(); + paths = gpFinder.graphPathFinderEntryPoint(patchedRequest, linkingContext, lastState); + } + + // Convert the internal GraphPaths to itineraries + final GraphPathToItineraryMapper graphPathToItineraryMapper = new GraphPathToItineraryMapper( + serverContext.transitService()::getRegularStop, + serverContext.transitService().getTimeZone(), + serverContext.graph().streetNotesService, + serverContext.graph().ellipsoidToGeoidDifference + ); + List response = graphPathToItineraryMapper.mapItineraries(paths); + response = ItinerariesHelper.decorateItinerariesWithRequestData( + response, + request.journey().wheelchair(), + request.preferences().wheelchair() + ); + return response; + } catch (PathNotFoundException e) { + return Collections.emptyList(); + } + } + + /** + * This uses the total straight line distance between locations (not just the distance between + * from and to). + */ + private static boolean straightLineDistanceIsWithinLimit( + RouteRequest request, + float maxCarSpeed, + LinkingContext linkingContext + ) { + // TODO This currently only calculates the distances between the first vertex from each + // location + double distance = SphericalDistanceLibrary.distance( + linkingContext.findVertices(request.from()).iterator().next().getCoordinate(), + linkingContext + .findVertices(request.listViaLocationsWithCoordinates().getFirst()) + .iterator() + .next() + .getCoordinate() + ); + for (int i = 0; i < request.listViaLocationsWithCoordinates().size() - 1; i++) { + distance += SphericalDistanceLibrary.distance( + linkingContext + .findVertices(request.listViaLocationsWithCoordinates().get(i)) + .iterator() + .next() + .getCoordinate(), + linkingContext + .findVertices(request.listViaLocationsWithCoordinates().get(i + 1)) + .iterator() + .next() + .getCoordinate() + ); + } + distance += SphericalDistanceLibrary.distance( + linkingContext + .findVertices(request.listViaLocationsWithCoordinates().getLast()) + .iterator() + .next() + .getCoordinate(), + linkingContext.findVertices(request.to()).iterator().next().getCoordinate() + ); + return distance < request.getMaximumDirectDistance(maxCarSpeed); + } + + /** + * TODO we might want to continue on a vehicle if there is no wait time defined for a via point. + */ + private StreetRequest getStreetRequestAfterFirstVia(StreetMode mode) { + if (mode.includesParking() || mode.includesRenting()) { + return new StreetRequest(StreetMode.WALK); + } + return new StreetRequest(mode); + } +} diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java index de2697ecca5..6f813862d40 100644 --- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java +++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java @@ -256,17 +256,20 @@ private RaptorViaLocation mapViaLocation(ViaLocation input) { builder.addViaStop(stopIndex); viaStops.add(stopIndex); } - for (var coordinate : input.coordinates()) { + if (input.coordinate().isPresent()) { var vertices = linkingContext.findVertices(((VisitViaLocation) input).coordinateLocation()); if (vertices.isEmpty()) { LOG.warn( "Found no vertices for the visit via location {} which indicates a problem.", input ); - continue; } for (var vertex : vertices) { - var viaTransfers = viaTransferResolver.createViaTransfers(request, vertex, coordinate); + var viaTransfers = viaTransferResolver.createViaTransfers( + request, + vertex, + input.coordinate().get() + ); for (var it : viaTransfers) { // If via-stop and via-transfers are used together then walking from a stop // to the coordinate and back is not pareto optimal, using just the stop diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java index 88a758eeaaf..5153113149a 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java @@ -423,6 +423,30 @@ public int numItineraries() { return numItineraries; } + /** + * Calculates the maximum distance in meters based on the maxDirectStreetDuration and the + * fastest mode available. This assumes that it is not possible to exceed the speed defined in the + * preferences. + */ + public double getMaximumDirectDistance(float maxCarSpeed) { + StreetMode mode = journey.direct().mode(); + double durationLimit = preferences.street().maxDirectDuration().valueOf(mode).toSeconds(); + + if (mode.includesDriving()) { + return durationLimit * maxCarSpeed; + } + if (mode.includesBiking()) { + return durationLimit * preferences.bike().speed(); + } + if (mode.includesScooter()) { + return durationLimit * preferences.scooter().speed(); + } + if (mode.includesWalking()) { + return durationLimit * preferences.walk().speed(); + } + throw new IllegalStateException("Direct mode is not specified or there is no support for it."); + } + boolean isDefaultRequest() { return defaultRequest; } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/ViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/ViaLocation.java index 4a3476954c8..5d2e145e7e4 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/via/ViaLocation.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/ViaLocation.java @@ -2,6 +2,7 @@ import java.time.Duration; import java.util.List; +import java.util.Optional; import javax.annotation.Nullable; import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.transit.model.framework.FeedScopedId; @@ -47,10 +48,10 @@ default Duration minimumWaitTime() { List stopLocationIds(); /** - * A list of coordinates used together with the {@code stopLocationIds} as the via location. - * This is optional, an empty list is returned if no coordinates are available. + * A coordinate used together with the {@code stopLocationIds} as the via location. + * This is optional. */ - default List coordinates() { - return List.of(); + default Optional coordinate() { + return Optional.empty(); } } diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java index 57d4d8a20d5..e2a1894d57e 100644 --- a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java +++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java @@ -3,6 +3,7 @@ import java.time.Duration; import java.util.List; import java.util.Objects; +import java.util.Optional; import javax.annotation.Nullable; import org.opentripplanner.framework.geometry.WgsCoordinate; import org.opentripplanner.model.GenericLocation; @@ -20,14 +21,17 @@ public class VisitViaLocation extends AbstractViaLocation { private static final Duration MINIMUM_WAIT_TIME_MAX_LIMIT = Duration.ofHours(24); + @Nullable private final Duration minimumWaitTime; - private final List coordinates; + + @Nullable + private final WgsCoordinate coordinate; public VisitViaLocation( @Nullable String label, @Nullable Duration minimumWaitTime, List stopLocationIds, - List coordinates + @Nullable WgsCoordinate coordinate ) { super(label, stopLocationIds); this.minimumWaitTime = DurationUtils.requireNonNegative( @@ -35,9 +39,9 @@ public VisitViaLocation( MINIMUM_WAIT_TIME_MAX_LIMIT, "minimumWaitTime" ); - this.coordinates = List.copyOf(coordinates); + this.coordinate = coordinate; - if (stopLocationIds().isEmpty() && coordinates().isEmpty()) { + if (stopLocationIds().isEmpty() && coordinate().isEmpty()) { throw new IllegalArgumentException( "A via location must have at least one stop location or a coordinate." + (label == null ? "" : " Label: " + label) @@ -51,11 +55,9 @@ public VisitViaLocation( */ @Nullable public GenericLocation coordinateLocation() { - if (coordinates.isEmpty()) { + if (coordinate == null) { return null; } - // TODO we will remove support for multiple coordinates - var coordinate = coordinates.getFirst(); return new GenericLocation(label(), null, coordinate.latitude(), coordinate.longitude()); } @@ -75,8 +77,8 @@ public boolean isPassThroughLocation() { } @Override - public List coordinates() { - return coordinates; + public Optional coordinate() { + return Optional.ofNullable(coordinate); } @Override @@ -85,7 +87,7 @@ public String toString() { .addObj("label", label()) .addDuration("minimumWaitTime", minimumWaitTime, Duration.ZERO) .addCol("stopLocationIds", stopLocationIds()) - .addObj("coordinates", coordinates) + .addObj("coordinate", coordinate) .toString(); } @@ -103,12 +105,12 @@ public boolean equals(Object o) { VisitViaLocation that = (VisitViaLocation) o; return ( Objects.equals(minimumWaitTime, that.minimumWaitTime) && - Objects.equals(coordinates, that.coordinates) + Objects.equals(coordinate, that.coordinate) ); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), minimumWaitTime, coordinates); + return Objects.hash(super.hashCode(), minimumWaitTime, coordinate); } } diff --git a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java index 2f50b57d0cc..6b971e131ac 100644 --- a/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java +++ b/application/src/main/java/org/opentripplanner/routing/impl/GraphPathFinder.java @@ -80,7 +80,8 @@ public GraphPathFinder( public List> getPaths( RouteRequest request, Set from, - Set to + Set to, + @Nullable State parentState ) { StreetPreferences preferences = request.preferences().street(); @@ -106,6 +107,10 @@ public List> getPaths( aStar.withTraverseVisitor(traverseVisitor); } + if (parentState != null) { + aStar.withParentState(parentState); + } + LOG.debug("rreq={}", request); long searchBeginTime = System.currentTimeMillis(); @@ -133,15 +138,40 @@ public List> graphPathFinderEntryPoint( ); } + /** + * Try to find N paths through the Graph starting from an existing state + */ + public List> graphPathFinderEntryPoint( + RouteRequest request, + LinkingContext linkingContext, + State parentState + ) { + return graphPathFinderEntryPoint( + request, + linkingContext.findVertices(request.from()), + linkingContext.findVertices(request.to()), + parentState + ); + } + public List> graphPathFinderEntryPoint( RouteRequest request, Set from, Set to + ) { + return graphPathFinderEntryPoint(request, from, to, null); + } + + public List> graphPathFinderEntryPoint( + RouteRequest request, + Set from, + Set to, + @Nullable State parentState ) { OTPRequestTimeoutException.checkForTimeout(); var reqTime = request.dateTime() == null ? RouteRequest.normalizeNow() : request.dateTime(); - List> paths = getPaths(request, from, to); + List> paths = getPaths(request, from, to, parentState); // Detect and report that most obnoxious of bugs: path reversal asymmetry. // Removing paths might result in an empty list, so do this check before the empty list check. @@ -151,7 +181,9 @@ public List> graphPathFinderEntryPoint( GraphPath graphPath = gpi.next(); // TODO check, is it possible that arriveBy and time are modifed in-place by the search? if (request.arriveBy()) { - if (graphPath.states.getLast().getTimeAccurate().isAfter(reqTime)) { + if ( + parentState == null && graphPath.states.getLast().getTimeAccurate().isAfter(reqTime) + ) { LOG.error( "A graph path arrives {} after the requested time {}. This implies a bug.", graphPath.states.getLast().getTimeAccurate(), @@ -160,7 +192,9 @@ public List> graphPathFinderEntryPoint( gpi.remove(); } } else { - if (graphPath.states.getFirst().getTimeAccurate().isBefore(reqTime)) { + if ( + parentState == null && graphPath.states.getFirst().getTimeAccurate().isBefore(reqTime) + ) { LOG.error( "A graph path leaves {} before the requested time {}. This implies a bug.", graphPath.states.getFirst().getTimeAccurate(), diff --git a/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java b/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java index 24d0cfefc8a..f9eb1ba6318 100644 --- a/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java +++ b/application/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java @@ -26,6 +26,7 @@ public class StreetSearchBuilder extends AStarBuilder extensionRequestContexts = List.of(); + private State parentState; public static StreetSearchBuilder of() { return new StreetSearchBuilder(); @@ -61,6 +62,11 @@ public StreetSearchBuilder withExtensionRequestContexts( return this; } + public StreetSearchBuilder withParentState(State parentState) { + this.parentState = parentState; + return this; + } + @Override protected Duration streetRoutingTimeout() { return routeRequest.preferences().street().routingTimeout(); @@ -73,7 +79,7 @@ protected Collection createInitialStates(Set originVertices) { .withArriveBy(arriveBy()) .build(); - return State.getInitialStates(originVertices, streetSearchRequest); + return State.getInitialStates(originVertices, streetSearchRequest, parentState); } @Override diff --git a/application/src/main/java/org/opentripplanner/street/search/state/State.java b/application/src/main/java/org/opentripplanner/street/search/state/State.java index 926bfc609c2..3430676a86d 100644 --- a/application/src/main/java/org/opentripplanner/street/search/state/State.java +++ b/application/src/main/java/org/opentripplanner/street/search/state/State.java @@ -42,6 +42,7 @@ public class State implements AStarState, Cloneable { // allow path reconstruction from states protected State backState; + @Nullable public Edge backEdge; /* StateData contains data which is unlikely to change as often */ @@ -81,6 +82,27 @@ public State(Vertex vertex, Instant startTime, StateData stateData, StreetSearch this.time_ms = startTime.toEpochMilli(); } + public State( + Vertex vertex, + Instant startTime, + StateData stateData, + StreetSearchRequest request, + @Nullable State parentState + ) { + this.request = request; + this.weight = parentState == null ? 0 : parentState.getWeight(); + this.vertex = vertex; + this.backState = parentState; + this.stateData = stateData; + if (request.arriveBy() && !vertex.rentalRestrictions().noDropOffNetworks().isEmpty()) { + this.stateData.noRentalDropOffZonesAtStartOfReverseSearch = vertex + .rentalRestrictions() + .noDropOffNetworks(); + } + this.walkDistance = parentState == null ? 0 : parentState.getWalkDistance(); + this.time_ms = startTime.toEpochMilli(); + } + /** * Create an initial state representing the beginning of a search for the given routing request. * Initial "parent-less" states can only be created at the beginning of a trip. elsewhere, all @@ -89,12 +111,31 @@ public State(Vertex vertex, Instant startTime, StateData stateData, StreetSearch public static Collection getInitialStates( Set vertices, StreetSearchRequest streetSearchRequest + ) { + return getInitialStates(vertices, streetSearchRequest, null); + } + + /** + * Create an initial state representing the beginning of a search for the given routing request. + * Initial "parent-less" states can only be created at the beginning of a trip. elsewhere, all + * states must be created from a parent and associated with an edge. + */ + public static Collection getInitialStates( + Set vertices, + StreetSearchRequest streetSearchRequest, + @Nullable State parentState ) { Collection states = new ArrayList<>(); for (Vertex vertex : vertices) { for (StateData stateData : StateData.getInitialStateDatas(streetSearchRequest)) { states.add( - new State(vertex, streetSearchRequest.startTime(), stateData, streetSearchRequest) + new State( + vertex, + streetSearchRequest.startTime(), + stateData, + streetSearchRequest, + parentState + ) ); } } @@ -306,6 +347,12 @@ public boolean isBackWalkingBike() { return stateData.backWalkingBike; } + /** + * The state that was traversed to reach this state. + *

+ * Back edge can be null for the first state. + */ + @Nullable public Edge getBackEdge() { return this.backEdge; } diff --git a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapperTest.java b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapperTest.java index d09e5cccd18..9022d38de54 100644 --- a/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ViaLocationMapperTest.java @@ -77,9 +77,9 @@ void mapToVisitViaLocations() { var secondVia = result.get(1); - assertThat(secondVia.coordinates()).hasSize(1); - assertEquals(SECOND_LAT, secondVia.coordinates().get(0).latitude()); - assertEquals(SECOND_LON, secondVia.coordinates().get(0).longitude()); + assertThat(secondVia.coordinate()).isPresent(); + assertEquals(SECOND_LAT, secondVia.coordinate().get().latitude()); + assertEquals(SECOND_LON, secondVia.coordinate().get().longitude()); assertFalse(secondVia.isPassThroughLocation()); var thirdVia = result.get(2); @@ -87,16 +87,16 @@ void mapToVisitViaLocations() { assertEquals(LABEL_THIRD, thirdVia.label()); assertEquals(MIN_WAIT_TIME_THIRD, thirdVia.minimumWaitTime()); assertEquals(EXPECTED_IDS_AS_STRING_THIRD, thirdVia.stopLocationIds().toString()); - assertThat(thirdVia.coordinates()).hasSize(1); - assertEquals(THIRD_LAT, thirdVia.coordinates().get(0).latitude()); - assertEquals(THIRD_LON, thirdVia.coordinates().get(0).longitude()); + assertThat(thirdVia.coordinate()).isPresent(); + assertEquals(THIRD_LAT, thirdVia.coordinate().get().latitude()); + assertEquals(THIRD_LON, thirdVia.coordinate().get().longitude()); assertFalse(thirdVia.isPassThroughLocation()); assertEquals( "[" + - "VisitViaLocation{label: TestLabel1, minimumWaitTime: 5m, stopLocationIds: [F:ID1, F:ID2], coordinates: []}, " + - "VisitViaLocation{coordinates: [(30.5, 40.2)]}, " + - "VisitViaLocation{label: TestLabel3, minimumWaitTime: 10m, stopLocationIds: [F:ID3, F:ID4], coordinates: [(35.5, 45.5)]}" + + "VisitViaLocation{label: TestLabel1, minimumWaitTime: 5m, stopLocationIds: [F:ID1, F:ID2]}, " + + "VisitViaLocation{coordinate: (30.5, 40.2)}, " + + "VisitViaLocation{label: TestLabel3, minimumWaitTime: 10m, stopLocationIds: [F:ID3, F:ID4], coordinate: (35.5, 45.5)}" + "]", result.toString() ); diff --git a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java index 31cce752795..a014ef1f9f2 100644 --- a/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java +++ b/application/src/test/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapperTest.java @@ -53,7 +53,7 @@ void testMapToVisitViaLocations() { assertEquals(EXPECTED_IDS_AS_STRING, via.stopLocationIds().toString()); assertFalse(via.isPassThroughLocation()); assertEquals( - "[VisitViaLocation{label: TestLabel, minimumWaitTime: 5m, stopLocationIds: [F:ID1, F:ID2], coordinates: []}]", + "[VisitViaLocation{label: TestLabel, minimumWaitTime: 5m, stopLocationIds: [F:ID1, F:ID2]}]", result.toString() ); } diff --git a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java index ccfb6c55b54..324b2308324 100644 --- a/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapperTest.java @@ -53,7 +53,7 @@ class RaptorRequestMapperTest { "Via A", null, List.of(STOP_A.getId()), - List.of() + null ); private static final int VIA_FROM_STOP_INDEX = 47; private static final int VIA_TO_STOP_INDEX = 123; @@ -73,7 +73,7 @@ class RaptorRequestMapperTest { "Via coordinate", Duration.ofMinutes(10), List.of(), - List.of(VIA_COORDINATE) + VIA_COORDINATE ); private static final CostLinearFunction R1 = CostLinearFunction.of("50 + 1.0x"); @@ -112,7 +112,7 @@ void testViaLocation() { var minWaitTime = Duration.ofMinutes(13); req.withViaLocations( - List.of(new VisitViaLocation("Via A", minWaitTime, List.of(STOP_A.getId()), List.of())) + List.of(new VisitViaLocation("Via A", minWaitTime, List.of(STOP_A.getId()), null)) ); var result = map(req.buildRequest()); @@ -144,6 +144,12 @@ void testViaCoordinate() { var req = requestBuilder(); req.withViaLocations(List.of(VISIT_VIA_LOCATION_COORDINATE)); + req.withViaLocations( + List.of( + new VisitViaLocation("Via coordinate", Duration.ofMinutes(10), List.of(), VIA_COORDINATE) + ) + ); + var result = map(req.buildRequest()); assertFalse(result.searchParams().viaLocations().isEmpty()); diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java index 7696108aab6..febf752a9ea 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocationTest.java @@ -40,7 +40,7 @@ void stopLocationIds() { @Test void coordinates() { - assertEquals("[]", subject.coordinates().toString()); + assertTrue(subject.coordinate().isEmpty()); } @Test diff --git a/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java b/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java index 47d5ecfb4b7..3f7a7ae2f3e 100644 --- a/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java +++ b/application/src/test/java/org/opentripplanner/routing/api/request/via/VisitViaLocationTest.java @@ -21,7 +21,7 @@ class VisitViaLocationTest { LABEL, MINIMUM_WAIT_TIME, List.of(ID), - List.of(WgsCoordinate.GREENWICH) + WgsCoordinate.GREENWICH ); @Test @@ -46,13 +46,13 @@ void stopLocationIds() { @Test void coordinates() { - assertEquals("[" + WgsCoordinate.GREENWICH + "]", subject.coordinates().toString()); + assertEquals(WgsCoordinate.GREENWICH, subject.coordinate().get()); } @Test void testToString() { assertEquals( - "VisitViaLocation{label: AName, minimumWaitTime: 5m, stopLocationIds: [F:1], coordinates: [(51.48, 0.0)]}", + "VisitViaLocation{label: AName, minimumWaitTime: 5m, stopLocationIds: [F:1], coordinate: (51.48, 0.0)}", subject.toString() ); } @@ -62,15 +62,15 @@ void testEqAndHashCode() { var l = subject.label(); var mwt = subject.minimumWaitTime(); var ids = subject.stopLocationIds(); - var cs = subject.coordinates(); + var cs = subject.coordinate(); AssertEqualsAndHashCode.verify(subject) - .sameAs(new VisitViaLocation(l, mwt, ids, cs)) + .sameAs(new VisitViaLocation(l, mwt, ids, cs.orElse(null))) .differentFrom( - new VisitViaLocation("other", mwt, ids, cs), - new VisitViaLocation(l, Duration.ZERO, ids, cs), - new VisitViaLocation(l, mwt, List.of(), cs), - new VisitViaLocation(l, mwt, ids, List.of()) + new VisitViaLocation("other", mwt, ids, cs.orElse(null)), + new VisitViaLocation(l, Duration.ZERO, ids, cs.orElse(null)), + new VisitViaLocation(l, mwt, List.of(), cs.orElse(null)), + new VisitViaLocation(l, mwt, ids, null) ); } } diff --git a/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java b/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java index 254a386944d..7b170ccf039 100644 --- a/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java +++ b/application/src/test/java/org/opentripplanner/routing/core/RouteRequestTest.java @@ -43,7 +43,7 @@ class RouteRequestTest { "Via1", Duration.ofMinutes(10), List.of(), - List.of(new WgsCoordinate(59.5, 11.0)) + new WgsCoordinate(59.5, 11.0) ); private static final PassThroughViaLocation SECOND_VIA = new PassThroughViaLocation( "Via2", @@ -53,7 +53,7 @@ class RouteRequestTest { "Via3", Duration.ofMinutes(10), List.of(new FeedScopedId("F", "2")), - List.of() + null ); private static final List VIA = List.of(FIRST_VIA, SECOND_VIA, THIRD_VIA); private static final Instant DATE_TIME = LocalDateTime.of(2025, Month.MAY, 17, 11, 15).toInstant( @@ -235,9 +235,9 @@ void testToString() { from:(60.0,10.0), to:(59.0,12.0), via: [ - VisitViaLocation{label:Via1,minimumWaitTime:10m,coordinates:[(59.5,11.0)]}, + VisitViaLocation{label:Via1,minimumWaitTime:10m,coordinate:(59.5,11.0)}, PassThroughViaLocation{label:Via2,stopLocationIds:[F:1]}, - VisitViaLocation{label:Via3,minimumWaitTime:10m,stopLocationIds:[F:2],coordinates:[]} + VisitViaLocation{label:Via3,minimumWaitTime:10m,stopLocationIds:[F:2]} ], dateTime:2025-05-17T11:15:00Z, arriveBy, @@ -304,7 +304,7 @@ void allowTransferOptimization() { assertTrue(builder.buildDefault().allowTransferOptimization()); builder.withViaLocations( - List.of(new VisitViaLocation("VIA", null, List.of(new FeedScopedId("F", "1")), List.of())) + List.of(new VisitViaLocation("VIA", null, List.of(new FeedScopedId("F", "1")), null)) ); assertFalse(builder.buildDefault().allowTransferOptimization()); } diff --git a/application/src/test/java/org/opentripplanner/routing/linking/mapping/LinkingContextRequestMapperTest.java b/application/src/test/java/org/opentripplanner/routing/linking/mapping/LinkingContextRequestMapperTest.java index 371a882872d..80f4e70675c 100644 --- a/application/src/test/java/org/opentripplanner/routing/linking/mapping/LinkingContextRequestMapperTest.java +++ b/application/src/test/java/org/opentripplanner/routing/linking/mapping/LinkingContextRequestMapperTest.java @@ -18,7 +18,7 @@ class LinkingContextRequestMapperTest { private static final GenericLocation FROM = new GenericLocation("from", null, 1.0, 0.0); private static final GenericLocation TO = new GenericLocation("to", null, 0.0, 1.0); private static final List VIA = List.of( - new VisitViaLocation("via", null, List.of(), List.of(WgsCoordinate.GREENWICH)) + new VisitViaLocation("via", null, List.of(), WgsCoordinate.GREENWICH) ); private static final StreetMode DIRECT_MODE = StreetMode.CAR; private static final StreetMode ACCESS_MODE = StreetMode.BIKE_TO_PARK; @@ -44,7 +44,7 @@ void map() { assertEquals(TO, subject.to()); assertThat(subject.viaLocationsWithCoordinates()).hasSize(1); assertEquals( - VIA.getFirst().coordinates().getFirst().asJtsCoordinate(), + VIA.getFirst().coordinate().map(WgsCoordinate::asJtsCoordinate).get(), subject.viaLocationsWithCoordinates().getFirst().getCoordinate() ); assertEquals(DIRECT_MODE, subject.directMode()); diff --git a/raptor/src/main/java/org/opentripplanner/raptor/api/model/RaptorAccessEgress.java b/raptor/src/main/java/org/opentripplanner/raptor/api/model/RaptorAccessEgress.java index 4facce0577c..c713d725837 100644 --- a/raptor/src/main/java/org/opentripplanner/raptor/api/model/RaptorAccessEgress.java +++ b/raptor/src/main/java/org/opentripplanner/raptor/api/model/RaptorAccessEgress.java @@ -123,6 +123,17 @@ default boolean hasTimePenalty() { */ int latestArrivalTime(int requestedArrivalTime); + /** + * In a via-search (both pass-through and visit-via) the access/egress may contain one + * ore more via-locations. If so Raptor needs to know how many via-locations are included + * so it can skip these. + *

+ * The default is zero via-lcations visited. + */ + default int numberOfViaLocationsVisited() { + return RaptorConstants.ZERO; + } + /** * This method should return {@code true} if, and only if the instance has restricted * opening-hours.