Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7ed4ebd
refactor: Cleanup TemporaryStreetLocation.
t2gran Nov 20, 2024
381e51a
refactor: Cleanup CoordinateInputType and add unit-test
t2gran Nov 27, 2024
8aef71d
feature: Add Coordinate to via-visit in transmodel API
t2gran Jan 31, 2025
1d75868
feature: Add ViaCoordinateTransfer generation to TransitRouter
t2gran Feb 21, 2025
a30af5e
refactor: Small cleanup to PlannerResource
t2gran Jan 31, 2025
c8720bc
feature: Include access and egress duration in "walk time" for path d…
t2gran Feb 3, 2025
a1dcb91
fix: Avoid cast and use safe duration method in
t2gran Feb 14, 2025
719cf5c
doc: Fix line break in RaptorViaConnection.java
t2gran Feb 3, 2025
8e3996f
refactor: Applcation tests should use DefaultRaptorTransfer, not Rapt…
t2gran Feb 17, 2025
f5212c3
refactor: Rename factory TestTransfer to TestTransfers
t2gran Feb 17, 2025
63002f5
refactor: Make sure walkSteps is an empty list not null in StreetLeg
t2gran Jan 31, 2025
d119f95
refactor: improve method name in PathBuilderLeg
t2gran Feb 14, 2025
a1aca7a
feature: Handle ViaCoordinateTransfer in ItineraryMapping
t2gran Jan 31, 2025
e7bd110
refactor: Rename Raptor module test for via stop search
t2gran Feb 17, 2025
cc8c0b8
refactor: Use lamda in array creating in LifeCycleEventPublisher
t2gran Feb 17, 2025
a3926f9
refactor: Use inheritance for via connections in Raptor
t2gran Feb 17, 2025
9c7a8f5
refactor: Make stopNameResolver in RaptorTestConstants static so it c…
t2gran Feb 19, 2025
a6b06ab
refactor: Remove unused code in RaptorTestConstants
t2gran Feb 19, 2025
436ecbd
refactor: Code cleanup RaptorViaLocation
t2gran Feb 19, 2025
af0a44f
refactor: Update package-info.md in o.o.raptor.moduletests
t2gran Feb 19, 2025
e8f7548
feature: Add support for via using transfer in Raptor
t2gran Feb 19, 2025
a1ee277
refactor: Cleanup RaptorViaLocation
t2gran Feb 20, 2025
801bd1e
feature: Use the new viaLocation request parameters for pass-through
t2gran Feb 20, 2025
9b978b3
feature: Use the new Raptor API for pass-through in application module
t2gran Feb 20, 2025
78a4ad5
feature: Use the via label+coordinate to name vertex in graph - this …
t2gran Feb 20, 2025
048f39b
review: Remove `LinkingDirection` from TemporaryStreetLocation.
t2gran Feb 24, 2025
589ee59
refactor: Rename BOTH_WAYS to BIDIRECTIONAL
t2gran Feb 25, 2025
13e1245
refactor: Move LinkingDirection to o.o.street.model.edge
t2gran Feb 25, 2025
f365779
doc: Remove old warning about coordinates not supported
t2gran Feb 25, 2025
e5177b8
doc: Add JavaDoc to ViaCoordinateTransferFactory
t2gran Feb 25, 2025
5dcc881
doc: Fix spelling
t2gran Feb 25, 2025
2eda822
refactor: Remove check enforced by the Transmodel Schema validation
t2gran Feb 26, 2025
7a97e8f
doc: Fix spelling in SearchContextBuilder
t2gran Feb 26, 2025
6aa80e3
refactor: Move via request mapping out one level
t2gran Feb 26, 2025
43e6882
refactor: Add toString to AllowAllTransitFilter
t2gran Feb 26, 2025
5be0edf
feature: Remove none pareto optimal via options
t2gran Feb 26, 2025
37ad6e7
refactor: Apply review comments
t2gran Feb 27, 2025
53810e9
Merge remote-tracking branch 'otp/dev-2.x' into via_coordinate
t2gran Feb 27, 2025
dd10d3c
refactor: Rename `radiusByDuration` -> `radiusAsDuration`
t2gran Feb 27, 2025
94d89ad
Apply suggestions from code review
t2gran Feb 27, 2025
51624cf
refactor: Rename `byFromStop` -> `groupByFromStop`
t2gran Feb 27, 2025
d99e081
refactor: Remove commented-out code
t2gran Feb 27, 2025
7fb79a7
Merge remote-tracking branch 'otp/dev-2.x' into via_coordinate
t2gran Feb 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.opentripplanner.ext.restapi.model.ElevationMetadata;
import org.opentripplanner.ext.restapi.model.TripPlannerResponse;
import org.opentripplanner.framework.application.OTPRequestTimeoutException;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.api.response.RoutingResponse;
import org.opentripplanner.routing.error.RoutingValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -62,14 +60,12 @@ public Response plan(@Context UriInfo uriInfo, @Context Request grizzlyRequest)

// Create response object, containing a copy of all request parameters. Maybe they should be in the debug section of the response.
TripPlannerResponse response = new TripPlannerResponse(uriInfo);
RouteRequest request = null;
RoutingResponse res = null;
try {
/* Fill in request fields from query parameters via shared superclass method, catching any errors. */
request = super.buildRequest(uriInfo.getQueryParameters());
var request = super.buildRequest(uriInfo.getQueryParameters());

// Route
res = serverContext.routingService().route(request);
var res = serverContext.routingService().route(request);

// Map to API
// TODO VIA (Leonard) - we should store the default showIntermediateStops somewhere
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
import java.util.Map;
import java.util.Objects;
import javax.annotation.Nullable;
import org.opentripplanner.apis.transmodel.model.framework.CoordinateInputType;
import org.opentripplanner.apis.transmodel.model.plan.TripQuery;
import org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType;
import org.opentripplanner.apis.transmodel.support.OneOfInputValidator;
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.routing.api.request.via.PassThroughViaLocation;
import org.opentripplanner.routing.api.request.via.ViaLocation;
import org.opentripplanner.routing.api.request.via.VisitViaLocation;
import org.opentripplanner.transit.model.framework.FeedScopedId;

@SuppressWarnings("unchecked")
class TripViaLocationMapper {

static List<ViaLocation> mapToViaLocations(final List<Map<String, Object>> via) {
Expand Down Expand Up @@ -57,7 +60,8 @@ private static VisitViaLocation mapVisitViaLocation(Map<String, Object> inputMap
var label = (String) inputMap.get(ViaLocationInputType.FIELD_LABEL);
var minimumWaitTime = (Duration) inputMap.get(ViaLocationInputType.FIELD_MINIMUM_WAIT_TIME);
var stopLocationIds = mapStopLocationIds(inputMap);
return new VisitViaLocation(label, minimumWaitTime, stopLocationIds, List.of());
var coordinate = mapCoordinate(inputMap);
return new VisitViaLocation(label, minimumWaitTime, stopLocationIds, coordinate);
}

private static PassThroughViaLocation mapPassThroughViaLocation(Map<String, Object> inputMap) {
Expand All @@ -68,14 +72,14 @@ private static PassThroughViaLocation mapPassThroughViaLocation(Map<String, Obje

private static List<FeedScopedId> mapStopLocationIds(Map<String, Object> map) {
var c = (Collection<String>) map.get(ViaLocationInputType.FIELD_STOP_LOCATION_IDS);
return c == null ? List.of() : c.stream().map(TransitIdMapper::mapIDToDomain).toList();
}

// When coordinates are added, we need to accept null here...
if (c == null) {
throw new IllegalArgumentException(
"'" + ViaLocationInputType.FIELD_STOP_LOCATION_IDS + "' is not set!"
);
}
return c.stream().map(TransitIdMapper::mapIDToDomain).toList();
private static List<WgsCoordinate> mapCoordinate(Map<String, Object> map) {
return CoordinateInputType
.mapToWgsCoordinate(ViaLocationInputType.FIELD_COORDINATE, map)
.map(List::of)
.orElseGet(List::of);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,58 @@
import graphql.schema.GraphQLInputObjectField;
import graphql.schema.GraphQLInputObjectType;
import graphql.schema.GraphQLNonNull;
import java.util.Map;
import java.util.Optional;
import org.opentripplanner.framework.geometry.WgsCoordinate;

@SuppressWarnings("unchecked")
public class CoordinateInputType {

/* Constants are package local to be used in unit-tests */
static final String LATITUDE = "latitude";
static final String LONGITUDE = "longitude";

public static final GraphQLInputObjectType INPUT_TYPE = GraphQLInputObjectType
.newInputObject()
.name("InputCoordinates")
.description("Input type for coordinates in the WGS84 system")
.field(
GraphQLInputObjectField
.newInputObjectField()
.name("latitude")
.name(LATITUDE)
.description("The latitude of the place.")
.type(new GraphQLNonNull(Scalars.GraphQLFloat))
.build()
)
.field(
GraphQLInputObjectField
.newInputObjectField()
.name("longitude")
.name(LONGITUDE)
.description("The longitude of the place.")
.type(new GraphQLNonNull(Scalars.GraphQLFloat))
.build()
)
.build();

public static Optional<WgsCoordinate> mapToWgsCoordinate(
String fieldName,
Map<String, Object> input
) {
Map<String, Object> coordinate = (Map<String, Object>) input.get(fieldName);

if (coordinate == null) {
return Optional.empty();
}

return Optional.of(
new WgsCoordinate((Double) coordinate.get(LATITUDE), (Double) coordinate.get(LONGITUDE))
);
}

public static Map<String, Object> mapForTest(WgsCoordinate coordinate) {
return Map.ofEntries(
Map.entry(LATITUDE, coordinate.latitude()),
Map.entry(LONGITUDE, coordinate.longitude())
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLNonNull;
import java.time.Duration;
import org.opentripplanner.apis.transmodel.model.framework.CoordinateInputType;
import org.opentripplanner.apis.transmodel.model.framework.TransmodelScalars;

public class ViaLocationInputType {
Expand All @@ -25,8 +26,6 @@ public class ViaLocationInputType {
on-board visit does not count, the traveler must alight or board at the given stop for it to to
be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the closest point
in the street network from a stop and back to another stop to join the transit network.

NOTE! Coordinates are NOT supported yet.
""";
private static final String DOC_PASS_THROUGH_VIA_LOCATION =
"""
Expand All @@ -44,9 +43,8 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
public static final String FIELD_LABEL = "label";
public static final String FIELD_MINIMUM_WAIT_TIME = "minimumWaitTime";
public static final String FIELD_STOP_LOCATION_IDS = "stopLocationIds";
public static final String FIELD_COORDINATE = "coordinate";

// TODO : Add coordinates
//private static final String FIELD_COORDINATES = "coordinates";
public static final String FIELD_VISIT = "visit";
public static final String DOC_FIELD_VISIT =
"Board or alight at a stop location or visit a coordinate.";
Expand All @@ -68,6 +66,7 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
stop place or a group of stop places. It is enough to visit ONE of the locations
listed.
""";
private static final String DOC_COORDINATE = "A coordinate to route through.";

static final GraphQLInputObjectType VISIT_VIA_LOCATION_INPUT = GraphQLInputObjectType
.newInputObject()
Expand All @@ -85,11 +84,11 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
b
.name(FIELD_STOP_LOCATION_IDS)
.description(DOC_STOP_LOCATION_IDS)
.type(requiredListOfNonNullStrings())
.type(optionalListOfNonNullStrings())
)
.field(b ->
b.name(FIELD_COORDINATE).description(DOC_COORDINATE).type(CoordinateInputType.INPUT_TYPE)
)
/*
TODO: Add support for coordinates
*/
.build();

static final GraphQLInputObjectType PASS_THROUGH_VIA_LOCATION_INPUT = GraphQLInputObjectType
Expand Down Expand Up @@ -121,6 +120,10 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
.build();

private static GraphQLInputType requiredListOfNonNullStrings() {
return new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString)));
return new GraphQLNonNull(optionalListOfNonNullStrings());
}

private static GraphQLInputType optionalListOfNonNullStrings() {
return new GraphQLList(new GraphQLNonNull(GraphQLString));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,17 @@ public void buildGraph() {
* whether the graph has a street network and if ConsiderPatternsForDirectTransfers feature is
* enabled.
*/
private NearbyStopFinder createNearbyStopFinder(Duration radiusByDuration) {
private NearbyStopFinder createNearbyStopFinder(Duration radiusAsDuration) {
var transitService = new DefaultTransitService(timetableRepository);
NearbyStopFinder finder;
if (!graph.hasStreets) {
LOG.info(
"Creating direct transfer edges between stops using straight line distance (not streets)..."
);
finder = new StraightLineNearbyStopFinder(transitService, radiusByDuration);
finder = new StraightLineNearbyStopFinder(transitService, radiusAsDuration);
} else {
LOG.info("Creating direct transfer edges between stops using the street network from OSM...");
finder = new StreetNearbyStopFinder(radiusByDuration, 0, null);
finder = new StreetNearbyStopFinder(radiusAsDuration, 0, null);
}

if (OTPFeature.ConsiderPatternsForDirectTransfers.isOn()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graph.index.StreetIndex;
import org.opentripplanner.routing.linking.LinkingDirection;
import org.opentripplanner.routing.linking.VertexLinker;
import org.opentripplanner.service.osminfo.OsmInfoGraphBuildService;
import org.opentripplanner.service.osminfo.model.Platform;
Expand All @@ -27,6 +26,7 @@
import org.opentripplanner.street.model.edge.AreaEdge;
import org.opentripplanner.street.model.edge.BoardingLocationToStopLink;
import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.edge.LinkingDirection;
import org.opentripplanner.street.model.edge.StreetEdge;
import org.opentripplanner.street.model.edge.StreetEdgeBuilder;
import org.opentripplanner.street.model.edge.StreetTransitStopLink;
Expand Down Expand Up @@ -212,7 +212,7 @@ private boolean connectVertexToWay(TransitStopVertex ts, StreetIndex index) {
for (var vertex : linker.linkToSpecificStreetEdgesPermanently(
boardingLocation,
new TraverseModeSet(TraverseMode.WALK),
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
platformEdgeList.getValue().stream().map(StreetEdge.class::cast).collect(Collectors.toSet())
)) {
linkBoardingLocationToStop(ts, stop.getCode(), vertex);
Expand Down Expand Up @@ -243,7 +243,7 @@ private boolean connectVertexToNode(TransitStopVertex ts, StreetIndex index) {
linker.linkVertexPermanently(
boardingLocation,
new TraverseModeSet(TraverseMode.WALK),
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
(osmBoardingLocationVertex, splitVertex) ->
getConnectingEdges(boardingLocation, osmBoardingLocationVertex, splitVertex)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import org.opentripplanner.graph_builder.issues.ParkAndRideEntranceRemoved;
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.linking.LinkingDirection;
import org.opentripplanner.service.vehicleparking.VehicleParkingRepository;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingHelper;
import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.edge.LinkingDirection;
import org.opentripplanner.street.model.edge.StreetStationCentroidLink;
import org.opentripplanner.street.model.edge.StreetTransitEntranceLink;
import org.opentripplanner.street.model.edge.StreetTransitStopLink;
Expand Down Expand Up @@ -160,7 +160,7 @@ private void linkStopToStreetNetwork(TransitStopVertex tStop, StopLinkType linkT
.linkVertexPermanently(
tStop,
WALK_ONLY,
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
(transitVertex, streetVertex) -> {
var linkEdges = createStopLinkEdges((TransitStopVertex) transitVertex, streetVertex);

Expand All @@ -187,7 +187,7 @@ private void linkToDriveableEdge(TransitStopVertex tStop) {
.linkVertexPermanently(
tStop,
CAR_ONLY,
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
(transitVertex, streetVertex) ->
createStopLinkEdges((TransitStopVertex) transitVertex, streetVertex)
);
Expand All @@ -213,7 +213,7 @@ private static void linkVehicleParkingWithLinker(
.linkVertexPermanently(
vehicleParkingVertex,
new TraverseModeSet(TraverseMode.WALK),
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
(vertex, streetVertex) ->
List.of(
StreetVehicleParkingLink.createStreetVehicleParkingLink(
Expand All @@ -234,7 +234,7 @@ private static void linkVehicleParkingWithLinker(
.linkVertexPermanently(
vehicleParkingVertex,
new TraverseModeSet(TraverseMode.CAR),
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
(vertex, streetVertex) ->
List.of(
StreetVehicleParkingLink.createStreetVehicleParkingLink(
Expand All @@ -258,7 +258,7 @@ private void linkTransitEntrances(Graph graph) {
.linkVertexPermanently(
tEntrance,
new TraverseModeSet(TraverseMode.WALK),
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
(vertex, streetVertex) ->
List.of(
StreetTransitEntranceLink.createStreetTransitEntranceLink(
Expand Down Expand Up @@ -296,7 +296,7 @@ private void linkStationCentroids(Graph graph) {
.linkVertexPermanently(
station,
new TraverseModeSet(TraverseMode.WALK),
LinkingDirection.BOTH_WAYS,
LinkingDirection.BIDIRECTIONAL,
stationAndStreetVertexLinker
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public StreetLeg(StreetLegBuilder builder) {
this.generalizedCost = builder.getGeneralizedCost();
this.elevationProfile = builder.getElevationProfile();
this.legGeometry = builder.getGeometry();
this.walkSteps = builder.getWalkSteps();
this.walkSteps = Objects.requireNonNull(builder.getWalkSteps());
this.streetNotes = Set.copyOf(builder.getStreetNotes());
this.walkingBike = builder.getWalkingBike();
this.rentedVehicle = builder.getRentedVehicle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.ZonedDateTime;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.street.model.note.StreetNote;
Expand All @@ -19,7 +20,7 @@ public class StreetLegBuilder {
private int generalizedCost;
private LineString geometry;
private ElevationProfile elevationProfile;
private List<WalkStep> walkSteps;
private List<WalkStep> walkSteps = List.of();
private Boolean walkingBike;
private Boolean rentedVehicle;
private String vehicleRentalNetwork;
Expand Down Expand Up @@ -157,7 +158,7 @@ public StreetLegBuilder withElevationProfile(ElevationProfile elevationProfile)
}

public StreetLegBuilder withWalkSteps(List<WalkStep> walkSteps) {
this.walkSteps = walkSteps;
this.walkSteps = Objects.requireNonNull(walkSteps);
return this;
}

Expand Down
Loading
Loading