paint = new HashMap<>();
+
+ public static LayerStyleBuilder ofId(String id) {
+ return new LayerStyleBuilder(id);
+ }
+
+ public LayerStyleBuilder vectorSourceLayer(VectorSourceLayer source) {
+ source(source.vectorSource());
+ return sourceLayer(source.vectorLayer());
+ }
+
+ public enum LayerType {
+ Circle,
+ Raster,
+ }
+
+ private LayerStyleBuilder(String id) {
+ props.put("id", id);
+ }
+
+ public LayerStyleBuilder minZoom(int i) {
+ props.put("minzoom", i);
+ return this;
+ }
+
+ public LayerStyleBuilder maxZoom(int i) {
+ props.put("maxzoom", i);
+ return this;
+ }
+
+ /**
+ * Which vector tile source this should apply to.
+ */
+ public LayerStyleBuilder source(TileSource source) {
+ props.put("source", source.id());
+ return this;
+ }
+
+ /**
+ * For vector tile sources, specify which source layer in the tile the styles should apply to.
+ * There is an unfortunate collision in the name "layer" as it can both refer to a styling layer
+ * and the layer inside the vector tile.
+ */
+ public LayerStyleBuilder sourceLayer(String source) {
+ props.put(SOURCE_LAYER, source);
+ return this;
+ }
+
+ public LayerStyleBuilder typeRaster() {
+ return type(LayerType.Raster);
+ }
+
+ public LayerStyleBuilder typeCircle() {
+ return type(LayerType.Circle);
+ }
+
+ private LayerStyleBuilder type(LayerType type) {
+ props.put(TYPE, type.name().toLowerCase());
+ return this;
+ }
+
+ public LayerStyleBuilder circleColor(String color) {
+ paint.put("circle-color", validateColor(color));
+ return this;
+ }
+
+ public LayerStyleBuilder circleStroke(String color, int width) {
+ paint.put("circle-stroke-color", validateColor(color));
+ paint.put("circle-stroke-width", width);
+ return this;
+ }
+
+ public JsonNode toJson() {
+ validate();
+
+ var copy = new HashMap<>(props);
+ if (!paint.isEmpty()) {
+ copy.put("paint", paint);
+ }
+ return OBJECT_MAPPER.valueToTree(copy);
+ }
+
+ private String validateColor(String color) {
+ if (!color.startsWith("#")) {
+ throw new IllegalArgumentException("Colors must start with '#'");
+ }
+ return color;
+ }
+
+ private void validate() {
+ Stream
+ .of(TYPE)
+ .forEach(p -> Objects.requireNonNull(props.get(p), "%s must be set".formatted(p)));
+ }
+}
diff --git a/src/main/java/org/opentripplanner/apis/vectortiles/model/LayerType.java b/src/main/java/org/opentripplanner/apis/vectortiles/model/LayerType.java
new file mode 100644
index 00000000000..f4cb7a636fa
--- /dev/null
+++ b/src/main/java/org/opentripplanner/apis/vectortiles/model/LayerType.java
@@ -0,0 +1,7 @@
+package org.opentripplanner.apis.vectortiles.model;
+
+public enum LayerType {
+ RegularStop,
+ AreaStop,
+ GeofencingZones,
+}
diff --git a/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleSpec.java b/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleSpec.java
new file mode 100644
index 00000000000..84e19f25364
--- /dev/null
+++ b/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleSpec.java
@@ -0,0 +1,48 @@
+package org.opentripplanner.apis.vectortiles.model;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a style specification for Maplibre/Mapbox vector tile layers.
+ * https://maplibre.org/maplibre-style-spec/root/
+ *
+ * Maplibre uses these to render vector maps in the browser.
+ */
+public final class StyleSpec {
+
+ private final String name;
+ private final List sources;
+ private final List layers;
+
+ public StyleSpec(String name, List sources, List layers) {
+ this.name = name;
+ this.sources = sources;
+ this.layers = layers.stream().map(LayerStyleBuilder::toJson).toList();
+ }
+
+ @JsonSerialize
+ public int version() {
+ return 8;
+ }
+
+ @JsonSerialize
+ public String name() {
+ return name;
+ }
+
+ @JsonSerialize
+ public Map sources() {
+ var output = new HashMap();
+ sources.forEach(s -> output.put(s.id(), s));
+ return output;
+ }
+
+ @JsonSerialize
+ public List layers() {
+ return layers;
+ }
+}
diff --git a/src/main/java/org/opentripplanner/apis/vectortiles/model/TileSource.java b/src/main/java/org/opentripplanner/apis/vectortiles/model/TileSource.java
new file mode 100644
index 00000000000..06af294a4f0
--- /dev/null
+++ b/src/main/java/org/opentripplanner/apis/vectortiles/model/TileSource.java
@@ -0,0 +1,36 @@
+package org.opentripplanner.apis.vectortiles.model;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import java.util.List;
+
+/**
+ * Represent a data source where Maplibre can fetch data for rendering directly in the browser.
+ */
+public sealed interface TileSource {
+ @JsonSerialize
+ String type();
+
+ String id();
+
+ /**
+ * Represents a vector tile source which is rendered into a map in the browser.
+ */
+ record VectorSource(String id, String url) implements TileSource {
+ @Override
+ public String type() {
+ return "vector";
+ }
+ }
+
+ /**
+ * Represents a raster-based source for map tiles. These are used mainly for background
+ * map layers with vector data being rendered on top of it.
+ */
+ record RasterSource(String id, List tiles, int tileSize, String attribution)
+ implements TileSource {
+ @Override
+ public String type() {
+ return "raster";
+ }
+ }
+}
diff --git a/src/main/java/org/opentripplanner/astar/model/BinHeap.java b/src/main/java/org/opentripplanner/astar/model/BinHeap.java
index 9bc2b0762a8..1e9b540a77a 100644
--- a/src/main/java/org/opentripplanner/astar/model/BinHeap.java
+++ b/src/main/java/org/opentripplanner/astar/model/BinHeap.java
@@ -79,14 +79,6 @@ public void rekey(T e, double p) {
prio[i] = p;
}
- public void dump() {
- for (int i = 0; i <= capacity; i++) {
- String topMarker = (i > size) ? "(UNUSED)" : "";
- System.out.printf("%d\t%f\t%s\t%s\n", i, prio[i], elem[i], topMarker);
- }
- System.out.printf("-----------------------\n");
- }
-
public void reset() {
// empties the queue in one operation
size = 0;
@@ -135,8 +127,4 @@ public void resize(int capacity) {
prio = Arrays.copyOf(prio, capacity + 1);
elem = Arrays.copyOf(elem, capacity + 1);
}
-
- public int getCapacity() {
- return capacity;
- }
}
diff --git a/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java b/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java
index e373f9c785e..a6d7123cdfe 100644
--- a/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java
+++ b/src/main/java/org/opentripplanner/astar/model/ShortestPathTree.java
@@ -244,10 +244,6 @@ public void setAborted() {
aborted = true;
}
- public boolean isAborted() {
- return aborted;
- }
-
public String toString() {
return "ShortestPathTree(" + this.stateSets.size() + " vertices)";
}
diff --git a/src/main/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategy.java b/src/main/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategy.java
index bcae9dcdb86..0369e3e29db 100644
--- a/src/main/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategy.java
+++ b/src/main/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategy.java
@@ -1,12 +1,12 @@
package org.opentripplanner.astar.strategy;
-import java.util.function.Function;
+import java.util.function.Predicate;
import org.opentripplanner.astar.spi.AStarEdge;
import org.opentripplanner.astar.spi.AStarState;
import org.opentripplanner.astar.spi.SkipEdgeStrategy;
/**
- * Skips edges when the specified number of desired vertices have been visited
+ * Skips edges when the specified number of desired vertices have been visited.
*/
public class MaxCountSkipEdgeStrategy<
State extends AStarState, Edge extends AStarEdge
@@ -14,11 +14,11 @@ public class MaxCountSkipEdgeStrategy<
implements SkipEdgeStrategy {
private final int maxCount;
- private final Function shouldIncreaseCount;
+ private final Predicate shouldIncreaseCount;
private int visited;
- public MaxCountSkipEdgeStrategy(int count, Function shouldIncreaseCount) {
+ public MaxCountSkipEdgeStrategy(int count, Predicate shouldIncreaseCount) {
this.maxCount = count;
this.shouldIncreaseCount = shouldIncreaseCount;
this.visited = 0;
@@ -26,7 +26,7 @@ public MaxCountSkipEdgeStrategy(int count, Function shouldIncrea
@Override
public boolean shouldSkipEdge(State current, Edge edge) {
- if (this.shouldIncreaseCount.apply(current)) {
+ if (shouldIncreaseCount.test(current)) {
visited++;
}
return visited > maxCount;
diff --git a/src/main/java/org/opentripplanner/framework/application/OTPFeature.java b/src/main/java/org/opentripplanner/framework/application/OTPFeature.java
index 05d1284a883..4847b204077 100644
--- a/src/main/java/org/opentripplanner/framework/application/OTPFeature.java
+++ b/src/main/java/org/opentripplanner/framework/application/OTPFeature.java
@@ -16,20 +16,23 @@
public enum OTPFeature {
APIBikeRental(true, false, "Enable the bike rental endpoint."),
APIServerInfo(true, false, "Enable the server info endpoint."),
- APIGraphInspectorTile(
- true,
- false,
- "Enable the inspector endpoint for graph information for inspection/debugging purpose."
- ),
APIUpdaterStatus(true, false, "Enable endpoint for graph updaters status."),
ConsiderPatternsForDirectTransfers(
true,
false,
"Enable limiting transfers so that there is only a single transfer to each pattern."
),
- DebugClient(true, false, "Enable the debug web client located at the root of the web server."),
+ DebugUi(
+ true,
+ false,
+ """
+ Enable the debug GraphQL client and web UI and located at the root of the web server as well as the debug map tiles it uses.
+ Be aware that the map tiles are not a stable API and can change without notice.
+ Use the [vector tiles feature if](sandbox/MapboxVectorTilesApi.md) you want a stable map tiles API.
+ """
+ ),
FloatingBike(true, false, "Enable floating bike routing."),
- GtfsGraphQlApi(true, false, "Enable GTFS GraphQL API."),
+ GtfsGraphQlApi(true, false, "Enable the [GTFS GraphQL API](apis/GTFS-GraphQL-API.md)."),
GtfsGraphQlApiRentalStationFuzzyMatching(
false,
false,
@@ -63,7 +66,11 @@ public enum OTPFeature {
false,
"Enforce transfers to happen according to the _transfers.txt_ (GTFS) and Interchanges (NeTEx). Turning this _off_ will increase the routing performance a little."
),
- TransmodelGraphQlApi(true, true, "Enable Transmodel (NeTEx) GraphQL API."),
+ TransmodelGraphQlApi(
+ true,
+ true,
+ "Enable the [Transmodel (NeTEx) GraphQL API](apis/TransmodelApi.md)."
+ ),
/* Sandbox extension features - Must be turned OFF by default */
@@ -82,6 +89,7 @@ public enum OTPFeature {
FaresV2(false, true, "Enable import of GTFS-Fares v2 data."),
FlexRouting(false, true, "Enable FLEX routing."),
GoogleCloudStorage(false, true, "Enable Google Cloud Storage integration."),
+ LegacyRestApi(true, true, "Enable legacy REST API. This API will be removed in the future."),
RealtimeResolver(
false,
true,
diff --git a/src/main/java/org/opentripplanner/api/json/GraphQLResponseSerializer.java b/src/main/java/org/opentripplanner/framework/graphql/GraphQLResponseSerializer.java
similarity index 94%
rename from src/main/java/org/opentripplanner/api/json/GraphQLResponseSerializer.java
rename to src/main/java/org/opentripplanner/framework/graphql/GraphQLResponseSerializer.java
index caba621294c..cb3b146a113 100644
--- a/src/main/java/org/opentripplanner/api/json/GraphQLResponseSerializer.java
+++ b/src/main/java/org/opentripplanner/framework/graphql/GraphQLResponseSerializer.java
@@ -1,4 +1,4 @@
-package org.opentripplanner.api.json;
+package org.opentripplanner.framework.graphql;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -10,6 +10,7 @@
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import org.opentripplanner.ext.restapi.serialization.JSONObjectMapperProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java b/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java
new file mode 100644
index 00000000000..6f710328174
--- /dev/null
+++ b/src/main/java/org/opentripplanner/framework/graphql/scalar/CostScalarFactory.java
@@ -0,0 +1,83 @@
+package org.opentripplanner.framework.graphql.scalar;
+
+import graphql.GraphQLContext;
+import graphql.execution.CoercedVariables;
+import graphql.language.StringValue;
+import graphql.language.Value;
+import graphql.schema.Coercing;
+import graphql.schema.CoercingParseLiteralException;
+import graphql.schema.CoercingParseValueException;
+import graphql.schema.GraphQLScalarType;
+import java.util.Locale;
+import java.util.NoSuchElementException;
+import javax.annotation.Nonnull;
+import org.opentripplanner.framework.model.Cost;
+import org.opentripplanner.framework.time.DurationUtils;
+
+public class CostScalarFactory {
+
+ private static final String TYPENAME = "Cost";
+
+ private static final String DOCUMENTATION =
+ "A cost value, normally a value of 1 is equivalent to riding transit for 1 second, " +
+ "but it might not depending on the use-case. Format: 3665 = DT1h1m5s = 1h1m5s";
+
+ private static final GraphQLScalarType SCALAR_INSTANCE = createCostScalar();
+
+ private CostScalarFactory() {}
+
+ public static GraphQLScalarType costScalar() {
+ return SCALAR_INSTANCE;
+ }
+
+ private static GraphQLScalarType createCostScalar() {
+ return GraphQLScalarType
+ .newScalar()
+ .name(TYPENAME)
+ .description(DOCUMENTATION)
+ .coercing(createCoercing())
+ .build();
+ }
+
+ private static String serializeCost(Cost cost) {
+ return cost.asDuration().toString();
+ }
+
+ private static Cost parseCost(String input) throws CoercingParseValueException {
+ try {
+ return Cost.fromDuration(DurationUtils.parseSecondsOrDuration(input).orElseThrow());
+ } catch (IllegalArgumentException | NoSuchElementException e) {
+ throw new CoercingParseValueException(e.getMessage(), e);
+ }
+ }
+
+ private static Coercing createCoercing() {
+ return new Coercing<>() {
+ @Override
+ public String serialize(@Nonnull Object result, GraphQLContext c, Locale l) {
+ return serializeCost((Cost) result);
+ }
+
+ @Override
+ public Cost parseValue(Object input, GraphQLContext c, Locale l)
+ throws CoercingParseValueException {
+ return parseCost((String) input);
+ }
+
+ @Override
+ public Cost parseLiteral(Value> input, CoercedVariables v, GraphQLContext c, Locale l)
+ throws CoercingParseLiteralException {
+ if (input instanceof StringValue stringValue) {
+ return parseCost(stringValue.getValue());
+ }
+ return null;
+ }
+
+ @Override
+ @Nonnull
+ public Value> valueToLiteral(Object input, GraphQLContext c, Locale l) {
+ return StringValue.of((String) input);
+ }
+ };
+ }
+}
diff --git a/src/main/java/org/opentripplanner/api/mapping/I18NStringMapper.java b/src/main/java/org/opentripplanner/framework/i18n/I18NStringMapper.java
similarity index 77%
rename from src/main/java/org/opentripplanner/api/mapping/I18NStringMapper.java
rename to src/main/java/org/opentripplanner/framework/i18n/I18NStringMapper.java
index 6b40a07b953..acdb30b301f 100644
--- a/src/main/java/org/opentripplanner/api/mapping/I18NStringMapper.java
+++ b/src/main/java/org/opentripplanner/framework/i18n/I18NStringMapper.java
@@ -1,9 +1,8 @@
-package org.opentripplanner.api.mapping;
+package org.opentripplanner.framework.i18n;
import java.util.Locale;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opentripplanner.framework.i18n.I18NString;
public class I18NStringMapper {
@@ -24,7 +23,7 @@ public String mapNonnullToApi(I18NString string) {
}
@Nullable
- static String mapToApi(I18NString string, Locale locale) {
+ public static String mapToApi(I18NString string, Locale locale) {
return string == null ? null : string.toString(locale);
}
}
diff --git a/src/main/java/org/opentripplanner/framework/io/HttpUtils.java b/src/main/java/org/opentripplanner/framework/io/HttpUtils.java
index 3450cf0786c..4981a8ab91b 100644
--- a/src/main/java/org/opentripplanner/framework/io/HttpUtils.java
+++ b/src/main/java/org/opentripplanner/framework/io/HttpUtils.java
@@ -24,16 +24,16 @@ private HttpUtils() {}
public static String getBaseAddress(UriInfo uri, HttpHeaders headers) {
String protocol;
if (headers.getRequestHeader(HEADER_X_FORWARDED_PROTO) != null) {
- protocol = headers.getRequestHeader(HEADER_X_FORWARDED_PROTO).get(0);
+ protocol = headers.getRequestHeader(HEADER_X_FORWARDED_PROTO).getFirst();
} else {
protocol = uri.getRequestUri().getScheme();
}
String host;
if (headers.getRequestHeader(HEADER_X_FORWARDED_HOST) != null) {
- host = headers.getRequestHeader(HEADER_X_FORWARDED_HOST).get(0);
+ host = headers.getRequestHeader(HEADER_X_FORWARDED_HOST).getFirst();
} else if (headers.getRequestHeader(HEADER_HOST) != null) {
- host = headers.getRequestHeader(HEADER_HOST).get(0);
+ host = headers.getRequestHeader(HEADER_HOST).getFirst();
} else {
host = uri.getBaseUri().getHost() + ":" + uri.getBaseUri().getPort();
}
diff --git a/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java b/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java
index ba776ac5243..360cdaee363 100644
--- a/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java
+++ b/src/main/java/org/opentripplanner/graph_builder/module/NearbyStopFinder.java
@@ -47,14 +47,8 @@
import org.opentripplanner.transit.service.TransitService;
/**
- * These library functions are used by the streetless and streetful stop linkers, and in profile
- * transfer generation.
- * TODO OTP2 Fold these into org.opentripplanner.routing.graphfinder.StreetGraphFinder
- * These are not library functions, this is instantiated as an object. Define lifecycle of the object (reuse?).
- * Because AStar instances should only be used once, NearbyStopFinder should only be used once.
- * Ideally they could also be used in long distance mode and profile routing for the street segments.
- * For each stop, it finds the closest stops on all other patterns. This reduces the number of transfer edges
- * significantly compared to simple radius-constrained all-to-all stop linkage.
+ * This class contains code for finding nearby stops from a given vertex. It is being used by access
+ * and egress searches as well as transfer generation.
*/
public class NearbyStopFinder {
@@ -100,6 +94,8 @@ public NearbyStopFinder(
* that the result will include the origin vertex if it is an instance of StopVertex. This is
* intentional: we don't want to return the next stop down the line for trip patterns that pass
* through the origin vertex.
+ * Taking the patterns into account reduces the number of transfers significantly compared to
+ * simple traverse-duration-constrained all-to-all stop linkage.
*/
public Set findNearbyStopsConsideringPatterns(
Vertex vertex,
@@ -227,15 +223,12 @@ public List findNearbyStopsViaStreets(
for (State state : spt.getAllStates()) {
Vertex targetVertex = state.getVertex();
if (originVertices.contains(targetVertex)) continue;
- if (targetVertex instanceof TransitStopVertex && state.isFinal()) {
- stopsFound.add(
- NearbyStop.nearbyStopForState(state, ((TransitStopVertex) targetVertex).getStop())
- );
+ if (targetVertex instanceof TransitStopVertex tsv && state.isFinal()) {
+ stopsFound.add(NearbyStop.nearbyStopForState(state, tsv.getStop()));
}
if (
OTPFeature.FlexRouting.isOn() &&
- targetVertex instanceof StreetVertex &&
- !((StreetVertex) targetVertex).areaStops().isEmpty()
+ targetVertex instanceof StreetVertex streetVertex && !streetVertex.areaStops().isEmpty()
) {
for (AreaStop areaStop : ((StreetVertex) targetVertex).areaStops()) {
// This is for a simplification, so that we only return one vertex from each
@@ -314,7 +307,7 @@ private SkipEdgeStrategy getSkipEdgeStrategy(
if (maxStopCount > 0) {
var strategy = new MaxCountSkipEdgeStrategy<>(
maxStopCount,
- NearbyStopFinder::isTransitVertex
+ NearbyStopFinder::hasReachedStop
);
return new ComposingSkipEdgeStrategy<>(strategy, durationSkipEdgeStrategy);
}
@@ -360,15 +353,23 @@ private boolean canBoardFlex(State state, boolean reverse) {
return edges
.stream()
- .anyMatch(e ->
- e instanceof StreetEdge && ((StreetEdge) e).getPermission().allows(TraverseMode.CAR)
- );
+ .anyMatch(e -> e instanceof StreetEdge se && se.getPermission().allows(TraverseMode.CAR));
}
/**
- * Checks if the {@code state} as at a transit vertex.
+ * Checks if the {@code state} is at a transit vertex and if it's final, which means that the state
+ * can actually board a vehicle.
+ *
+ * This is important because there can be cases where states that cannot actually board the vehicle
+ * can dominate those that can thereby leading to zero found stops when this predicate is used with
+ * the {@link MaxCountSkipEdgeStrategy}.
+ *
+ * An example of this would be an egress/reverse search with a very high walk reluctance where
+ * the states that speculatively rent a vehicle move the walk states down the A* priority queue
+ * until the required number of stops are reached to abort the search, leading to zero egress
+ * results.
*/
- public static boolean isTransitVertex(State state) {
- return state.getVertex() instanceof TransitStopVertex;
+ public static boolean hasReachedStop(State state) {
+ return state.getVertex() instanceof TransitStopVertex && state.isFinal();
}
}
diff --git a/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java b/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java
index d3024a144f5..00404845349 100644
--- a/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java
+++ b/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java
@@ -25,10 +25,7 @@
import org.opentripplanner.street.model.edge.AreaEdge;
import org.opentripplanner.street.model.edge.AreaEdgeList;
import org.opentripplanner.street.model.edge.Edge;
-import org.opentripplanner.street.model.edge.ElevatorEdge;
-import org.opentripplanner.street.model.edge.FreeEdge;
import org.opentripplanner.street.model.edge.StreetEdge;
-import org.opentripplanner.street.model.edge.StreetTransitEntityLink;
import org.opentripplanner.street.model.vertex.StreetVertex;
import org.opentripplanner.street.model.vertex.TransitStopVertex;
import org.opentripplanner.street.model.vertex.Vertex;
@@ -338,16 +335,6 @@ private void collectNeighbourVertices(
}
State s0 = new State(gv, request);
for (Edge e : gv.getOutgoing()) {
- if (
- !(
- e instanceof StreetEdge ||
- e instanceof ElevatorEdge ||
- e instanceof FreeEdge ||
- e instanceof StreetTransitEntityLink
- )
- ) {
- continue;
- }
if (
e instanceof StreetEdge &&
shouldMatchNoThruType != ((StreetEdge) e).isNoThruTraffic(traverseMode)
diff --git a/src/main/java/org/opentripplanner/inspector/vector/AreaStopsLayerBuilder.java b/src/main/java/org/opentripplanner/inspector/vector/AreaStopsLayerBuilder.java
deleted file mode 100644
index 1604cf7d8d1..00000000000
--- a/src/main/java/org/opentripplanner/inspector/vector/AreaStopsLayerBuilder.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.opentripplanner.inspector.vector;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.function.Function;
-import org.locationtech.jts.geom.Envelope;
-import org.locationtech.jts.geom.Geometry;
-import org.opentripplanner.api.mapping.PropertyMapper;
-import org.opentripplanner.transit.model.site.AreaStop;
-import org.opentripplanner.transit.service.TransitService;
-
-/**
- * A vector tile layer containing all {@link AreaStop}s inside the vector tile bounds.
- */
-public class AreaStopsLayerBuilder extends LayerBuilder {
-
- private static final Map mappers = Map.of(
- MapperType.DebugClient,
- DebugClientAreaStopPropertyMapper::create
- );
- private final Function> findAreaStops;
-
- public AreaStopsLayerBuilder(
- TransitService transitService,
- LayerParameters layerParameters,
- Locale locale
- ) {
- super(
- mappers.get(MapperType.valueOf(layerParameters.mapper())).build(transitService, locale),
- layerParameters.name(),
- layerParameters.expansionFactor()
- );
- this.findAreaStops = transitService::findAreaStops;
- }
-
- @Override
- protected List getGeometries(Envelope query) {
- return findAreaStops
- .apply(query)
- .stream()
- .map(areaStop -> {
- Geometry geometry = areaStop.getGeometry().copy();
-
- geometry.setUserData(areaStop);
-
- return geometry;
- })
- .toList();
- }
-
- enum MapperType {
- DebugClient,
- }
-
- @FunctionalInterface
- private interface MapperFactory {
- PropertyMapper build(TransitService transitService, Locale locale);
- }
-}
diff --git a/src/main/java/org/opentripplanner/inspector/vector/DebugClientAreaStopPropertyMapper.java b/src/main/java/org/opentripplanner/inspector/vector/DebugClientAreaStopPropertyMapper.java
deleted file mode 100644
index 88f7a17385b..00000000000
--- a/src/main/java/org/opentripplanner/inspector/vector/DebugClientAreaStopPropertyMapper.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.opentripplanner.inspector.vector;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Locale;
-import org.opentripplanner.api.mapping.I18NStringMapper;
-import org.opentripplanner.api.mapping.PropertyMapper;
-import org.opentripplanner.transit.model.site.AreaStop;
-import org.opentripplanner.transit.service.TransitService;
-
-/**
- * A {@link PropertyMapper} for the {@link AreaStopsLayerBuilder} for the OTP debug client.
- */
-public class DebugClientAreaStopPropertyMapper extends PropertyMapper {
-
- private final I18NStringMapper i18NStringMapper;
-
- public DebugClientAreaStopPropertyMapper(TransitService transitService, Locale locale) {
- this.i18NStringMapper = new I18NStringMapper(locale);
- }
-
- public static PropertyMapper create(TransitService transitService, Locale locale) {
- return new DebugClientAreaStopPropertyMapper(transitService, locale);
- }
-
- @Override
- protected Collection map(AreaStop input) {
- return List.of(
- new KeyValue("id", input.getId().toString()),
- new KeyValue("name", i18NStringMapper.mapNonnullToApi(input.getName()))
- );
- }
-}
diff --git a/src/main/java/org/opentripplanner/inspector/vector/KeyValue.java b/src/main/java/org/opentripplanner/inspector/vector/KeyValue.java
index d57afd3429e..6c8b0f3aa4e 100644
--- a/src/main/java/org/opentripplanner/inspector/vector/KeyValue.java
+++ b/src/main/java/org/opentripplanner/inspector/vector/KeyValue.java
@@ -1,3 +1,7 @@
package org.opentripplanner.inspector.vector;
-public record KeyValue(String key, Object value) {}
+public record KeyValue(String key, Object value) {
+ public static KeyValue kv(String key, Object value) {
+ return new KeyValue(key, value);
+ }
+}
diff --git a/src/main/java/org/opentripplanner/inspector/vector/LayerBuilder.java b/src/main/java/org/opentripplanner/inspector/vector/LayerBuilder.java
index 3e796487271..949bbef0a94 100644
--- a/src/main/java/org/opentripplanner/inspector/vector/LayerBuilder.java
+++ b/src/main/java/org/opentripplanner/inspector/vector/LayerBuilder.java
@@ -10,7 +10,7 @@
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
-import org.opentripplanner.api.mapping.PropertyMapper;
+import org.opentripplanner.apis.support.mapping.PropertyMapper;
import org.opentripplanner.framework.geometry.GeometryUtils;
/**
diff --git a/src/main/java/org/opentripplanner/inspector/vector/LayerParameters.java b/src/main/java/org/opentripplanner/inspector/vector/LayerParameters.java
index 2718c649797..ca4a6a64c76 100644
--- a/src/main/java/org/opentripplanner/inspector/vector/LayerParameters.java
+++ b/src/main/java/org/opentripplanner/inspector/vector/LayerParameters.java
@@ -1,6 +1,6 @@
package org.opentripplanner.inspector.vector;
-import org.opentripplanner.api.mapping.PropertyMapper;
+import org.opentripplanner.apis.support.mapping.PropertyMapper;
/**
* Configuration options for a single vector tile layer.
diff --git a/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesLayerBuilder.java b/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesLayerBuilder.java
index 8a77b8502ea..24be8d202a8 100644
--- a/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesLayerBuilder.java
+++ b/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesLayerBuilder.java
@@ -1,10 +1,8 @@
package org.opentripplanner.inspector.vector.geofencing;
import java.util.List;
-import java.util.Map;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
-import org.opentripplanner.api.mapping.PropertyMapper;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.inspector.vector.LayerBuilder;
import org.opentripplanner.inspector.vector.LayerParameters;
@@ -19,15 +17,11 @@
*/
public class GeofencingZonesLayerBuilder extends LayerBuilder {
- private static final Map mappers = Map.of(
- MapperType.DebugClient,
- transitService -> new GeofencingZonesPropertyMapper()
- );
private final StreetIndex streetIndex;
public GeofencingZonesLayerBuilder(Graph graph, LayerParameters layerParameters) {
super(
- mappers.get(MapperType.valueOf(layerParameters.mapper())).build(graph),
+ new GeofencingZonesPropertyMapper(),
layerParameters.name(),
layerParameters.expansionFactor()
);
@@ -47,13 +41,4 @@ protected List getGeometries(Envelope query) {
})
.toList();
}
-
- enum MapperType {
- DebugClient,
- }
-
- @FunctionalInterface
- private interface MapperFactory {
- PropertyMapper build(Graph transitService);
- }
}
diff --git a/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesPropertyMapper.java b/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesPropertyMapper.java
index 0d0f7b44fe9..98c9cf23eca 100644
--- a/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesPropertyMapper.java
+++ b/src/main/java/org/opentripplanner/inspector/vector/geofencing/GeofencingZonesPropertyMapper.java
@@ -6,7 +6,7 @@
import java.util.Collection;
import java.util.List;
-import org.opentripplanner.api.mapping.PropertyMapper;
+import org.opentripplanner.apis.support.mapping.PropertyMapper;
import org.opentripplanner.inspector.vector.KeyValue;
import org.opentripplanner.street.model.vertex.Vertex;
diff --git a/src/main/java/org/opentripplanner/inspector/vector/stop/StopLayerBuilder.java b/src/main/java/org/opentripplanner/inspector/vector/stop/StopLayerBuilder.java
new file mode 100644
index 00000000000..70ce6a58735
--- /dev/null
+++ b/src/main/java/org/opentripplanner/inspector/vector/stop/StopLayerBuilder.java
@@ -0,0 +1,49 @@
+package org.opentripplanner.inspector.vector.stop;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.function.Function;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.opentripplanner.inspector.vector.LayerBuilder;
+import org.opentripplanner.inspector.vector.LayerParameters;
+import org.opentripplanner.transit.model.site.AreaStop;
+import org.opentripplanner.transit.model.site.RegularStop;
+import org.opentripplanner.transit.model.site.StopLocation;
+
+/**
+ * A vector tile layer for {@link StopLocation}s inside the vector tile bounds. These can be further
+ * filtered to get only a subset of stop implementations like {@link RegularStop}
+ * or {@link AreaStop}.
+ */
+public class StopLayerBuilder extends LayerBuilder {
+
+ private final Function> findStops;
+
+ public StopLayerBuilder(
+ LayerParameters layerParameters,
+ Locale locale,
+ Function> findStops
+ ) {
+ super(
+ new StopLocationPropertyMapper(locale),
+ layerParameters.name(),
+ layerParameters.expansionFactor()
+ );
+ this.findStops = findStops;
+ }
+
+ @Override
+ protected List getGeometries(Envelope query) {
+ return findStops
+ .apply(query)
+ .stream()
+ .map(stop -> {
+ Geometry geometry = stop.getGeometry().copy();
+ geometry.setUserData(stop);
+ return geometry;
+ })
+ .toList();
+ }
+}
diff --git a/src/main/java/org/opentripplanner/inspector/vector/stop/StopLocationPropertyMapper.java b/src/main/java/org/opentripplanner/inspector/vector/stop/StopLocationPropertyMapper.java
new file mode 100644
index 00000000000..ab9685dd0f6
--- /dev/null
+++ b/src/main/java/org/opentripplanner/inspector/vector/stop/StopLocationPropertyMapper.java
@@ -0,0 +1,32 @@
+package org.opentripplanner.inspector.vector.stop;
+
+import static org.opentripplanner.inspector.vector.KeyValue.kv;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import org.opentripplanner.apis.support.mapping.PropertyMapper;
+import org.opentripplanner.framework.i18n.I18NStringMapper;
+import org.opentripplanner.inspector.vector.KeyValue;
+import org.opentripplanner.transit.model.site.StopLocation;
+
+/**
+ * A {@link PropertyMapper} for the {@link StopLocationPropertyMapper} for the OTP debug client.
+ */
+public class StopLocationPropertyMapper extends PropertyMapper {
+
+ private final I18NStringMapper i18NStringMapper;
+
+ public StopLocationPropertyMapper(Locale locale) {
+ this.i18NStringMapper = new I18NStringMapper(locale);
+ }
+
+ @Override
+ protected Collection map(StopLocation stop) {
+ return List.of(
+ kv("name", i18NStringMapper.mapToApi(stop.getName())),
+ kv("id", stop.getId().toString()),
+ kv("parentId", stop.isPartOfStation() ? stop.getParentStation().getId().toString() : null)
+ );
+ }
+}
diff --git a/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java b/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
index 26016947c09..30bd04eea73 100644
--- a/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
+++ b/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
@@ -460,19 +460,36 @@ private void mapTripPatterns(Map serviceIds) {
for (JourneyPattern_VersionStructure journeyPattern : currentNetexIndex
.getJourneyPatternsById()
.localValues()) {
- TripPatternMapperResult result = tripPatternMapper.mapTripPattern(journeyPattern);
+ tripPatternMapper
+ .mapTripPattern(journeyPattern)
+ .ifPresent(this::applyTripPatternMapperResult);
+ }
+ }
- for (Map.Entry> it : result.tripStopTimes.entrySet()) {
- transitBuilder.getStopTimesSortedByTrip().put(it.getKey(), it.getValue());
- transitBuilder.getTripsById().add(it.getKey());
- }
- for (var it : result.tripPatterns.entries()) {
- transitBuilder.getTripPatterns().put(it.getKey(), it.getValue());
- }
- currentMapperIndexes.addStopTimesByNetexId(result.stopTimeByNetexId);
- groupMapper.scheduledStopPointsIndex.putAll(Multimaps.asMap(result.scheduledStopPointsIndex));
- transitBuilder.getTripOnServiceDates().addAll(result.tripOnServiceDates);
+ private void applyTripPatternMapperResult(TripPatternMapperResult result) {
+ var stopPattern = result.tripPattern().getStopPattern();
+ var journeyPatternExists = transitBuilder
+ .getTripPatterns()
+ .get(stopPattern)
+ .stream()
+ .anyMatch(tripPattern -> result.tripPattern().getId().equals(tripPattern.getId()));
+ if (journeyPatternExists) {
+ issueStore.add(
+ "DuplicateJourneyPattern",
+ "Duplicate of JourneyPattern %s found",
+ result.tripPattern().getId().getId()
+ );
+ }
+
+ for (Map.Entry> it : result.tripStopTimes().entrySet()) {
+ transitBuilder.getStopTimesSortedByTrip().put(it.getKey(), it.getValue());
+ transitBuilder.getTripsById().add(it.getKey());
}
+
+ transitBuilder.getTripPatterns().put(stopPattern, result.tripPattern());
+ currentMapperIndexes.addStopTimesByNetexId(result.stopTimeByNetexId());
+ groupMapper.scheduledStopPointsIndex.putAll(Multimaps.asMap(result.scheduledStopPointsIndex()));
+ transitBuilder.getTripOnServiceDates().addAll(result.tripOnServiceDates());
}
private void mapNoticeAssignments() {
diff --git a/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java b/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java
index 6fa000c1049..765a9b5c47f 100644
--- a/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java
+++ b/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapper.java
@@ -5,10 +5,12 @@
import jakarta.xml.bind.JAXBElement;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.stream.Collectors;
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.model.StopTime;
@@ -24,7 +26,6 @@
import org.opentripplanner.transit.model.framework.ImmutableEntityById;
import org.opentripplanner.transit.model.network.StopPattern;
import org.opentripplanner.transit.model.network.TripPattern;
-import org.opentripplanner.transit.model.network.TripPatternBuilder;
import org.opentripplanner.transit.model.organization.Operator;
import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.model.site.GroupStop;
@@ -84,8 +85,6 @@ class TripPatternMapper {
private final Deduplicator deduplicator;
- private TripPatternMapperResult result;
-
TripPatternMapper(
DataImportIssueStore issueStore,
FeedScopedIdFactory idFactory,
@@ -157,9 +156,7 @@ class TripPatternMapper {
}
}
- TripPatternMapperResult mapTripPattern(JourneyPattern_VersionStructure journeyPattern) {
- // Make sure the result is clean, by creating a new object.
- result = new TripPatternMapperResult();
+ Optional mapTripPattern(JourneyPattern_VersionStructure journeyPattern) {
Collection serviceJourneys = serviceJourniesByPatternId.get(
journeyPattern.getId()
);
@@ -170,10 +167,14 @@ TripPatternMapperResult mapTripPattern(JourneyPattern_VersionStructure journeyPa
"ServiceJourneyPattern %s does not contain any serviceJourneys.",
journeyPattern.getId()
);
- return result;
+ return Optional.empty();
}
List trips = new ArrayList<>();
+ ArrayListMultimap scheduledStopPointsIndex = ArrayListMultimap.create();
+ HashMap> tripStopTimes = new HashMap<>();
+ Map stopTimeByNetexId = new HashMap<>();
+ ArrayList tripOnServiceDates = new ArrayList<>();
for (ServiceJourney serviceJourney : serviceJourneys) {
Trip trip = mapTrip(journeyPattern, serviceJourney);
@@ -184,7 +185,7 @@ TripPatternMapperResult mapTripPattern(JourneyPattern_VersionStructure journeyPa
}
// Add the dated service journey to the model for this trip [if it exists]
- mapDatedServiceJourney(journeyPattern, serviceJourney, trip);
+ tripOnServiceDates.addAll(mapDatedServiceJourney(journeyPattern, serviceJourney, trip));
StopTimesMapperResult stopTimes = stopTimesMapper.mapToStopTimes(
journeyPattern,
@@ -198,25 +199,22 @@ TripPatternMapperResult mapTripPattern(JourneyPattern_VersionStructure journeyPa
continue;
}
- result.scheduledStopPointsIndex.putAll(
- serviceJourney.getId(),
- stopTimes.scheduledStopPointIds
- );
- result.tripStopTimes.put(trip, stopTimes.stopTimes);
- result.stopTimeByNetexId.putAll(stopTimes.stopTimeByNetexId);
+ scheduledStopPointsIndex.putAll(serviceJourney.getId(), stopTimes.scheduledStopPointIds);
+ tripStopTimes.put(trip, stopTimes.stopTimes);
+ stopTimeByNetexId.putAll(stopTimes.stopTimeByNetexId);
trips.add(trip);
}
// No trips successfully mapped
if (trips.isEmpty()) {
- return result;
+ return Optional.empty();
}
// Create StopPattern from any trip (since they are part of the same JourneyPattern)
StopPattern stopPattern = deduplicator.deduplicateObject(
StopPattern.class,
- new StopPattern(result.tripStopTimes.get(trips.get(0)))
+ new StopPattern(tripStopTimes.get(trips.get(0)))
);
var tripPatternModes = new HashSet();
@@ -246,7 +244,7 @@ TripPatternMapperResult mapTripPattern(JourneyPattern_VersionStructure journeyPa
);
}
- TripPatternBuilder tripPatternBuilder = TripPattern
+ var tripPattern = TripPattern
.of(idFactory.createId(journeyPattern.getId()))
.withRoute(lookupRoute(journeyPattern))
.withStopPattern(stopPattern)
@@ -256,30 +254,35 @@ TripPatternMapperResult mapTripPattern(JourneyPattern_VersionStructure journeyPa
.withName(journeyPattern.getName() == null ? "" : journeyPattern.getName().getValue())
.withHopGeometries(
serviceLinkMapper.getGeometriesByJourneyPattern(journeyPattern, stopPattern)
- );
-
- TripPattern tripPattern = tripPatternBuilder.build();
- createTripTimes(trips, tripPattern);
-
- result.tripPatterns.put(stopPattern, tripPattern);
-
- return result;
+ )
+ .build();
+ createTripTimes(trips, tripStopTimes).forEach(tripPattern::add);
+
+ return Optional.of(
+ new TripPatternMapperResult(
+ tripPattern,
+ scheduledStopPointsIndex,
+ tripStopTimes,
+ stopTimeByNetexId,
+ tripOnServiceDates
+ )
+ );
}
- private void mapDatedServiceJourney(
+ private ArrayList mapDatedServiceJourney(
JourneyPattern_VersionStructure journeyPattern,
ServiceJourney serviceJourney,
Trip trip
) {
+ var tripsOnServiceDates = new ArrayList();
if (datedServiceJourneysBySJId.containsKey(serviceJourney.getId())) {
for (DatedServiceJourney datedServiceJourney : datedServiceJourneysBySJId.get(
serviceJourney.getId()
)) {
- result.tripOnServiceDates.add(
- mapDatedServiceJourney(journeyPattern, trip, datedServiceJourney)
- );
+ tripsOnServiceDates.add(mapDatedServiceJourney(journeyPattern, trip, datedServiceJourney));
}
}
+ return tripsOnServiceDates;
}
private TripOnServiceDate mapDatedServiceJourney(
@@ -360,9 +363,13 @@ private org.opentripplanner.transit.model.network.Route lookupRoute(
return otpRouteById.get(idFactory.createId(lineId));
}
- private void createTripTimes(List trips, TripPattern tripPattern) {
+ private List createTripTimes(
+ List trips,
+ Map> tripStopTimes
+ ) {
+ var tripTimesResult = new ArrayList();
for (Trip trip : trips) {
- List stopTimes = result.tripStopTimes.get(trip);
+ List stopTimes = tripStopTimes.get(trip);
if (stopTimes.isEmpty()) {
issueStore.add(
"TripWithoutTripTimes",
@@ -372,12 +379,13 @@ private void createTripTimes(List trips, TripPattern tripPattern) {
} else {
try {
TripTimes tripTimes = TripTimesFactory.tripTimes(trip, stopTimes, deduplicator);
- tripPattern.add(tripTimes);
+ tripTimesResult.add(tripTimes);
} catch (DataValidationException e) {
issueStore.add(e.error());
}
}
}
+ return tripTimesResult;
}
private Trip mapTrip(
diff --git a/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapperResult.java b/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapperResult.java
index 6b14fea5d31..370c24a7a41 100644
--- a/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapperResult.java
+++ b/src/main/java/org/opentripplanner/netex/mapping/TripPatternMapperResult.java
@@ -1,36 +1,24 @@
package org.opentripplanner.netex.mapping;
import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opentripplanner.model.StopTime;
-import org.opentripplanner.transit.model.network.StopPattern;
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.timetable.Trip;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
/**
- * This mapper returnes two collections, so we need to use a simple wraper to be able to return the
- * result from the mapping method.
+ * Wrapper class for the result of TripPatternMapper
+ *
+ * @param scheduledStopPointsIndex A map from trip/serviceJourney id to an ordered list of scheduled stop point ids.
+ * @param stopTimeByNetexId stopTimes by the timetabled-passing-time id
*/
-class TripPatternMapperResult {
-
- /**
- * A map from trip/serviceJourney id to an ordered list of scheduled stop point ids.
- */
- final ArrayListMultimap scheduledStopPointsIndex = ArrayListMultimap.create();
-
- final Map> tripStopTimes = new HashMap<>();
-
- final Multimap tripPatterns = ArrayListMultimap.create();
-
- /**
- * stopTimes by the timetabled-passing-time id
- */
- final Map stopTimeByNetexId = new HashMap<>();
-
- final ArrayList tripOnServiceDates = new ArrayList<>();
-}
+record TripPatternMapperResult(
+ TripPattern tripPattern,
+ ArrayListMultimap scheduledStopPointsIndex,
+ Map> tripStopTimes,
+ Map stopTimeByNetexId,
+ ArrayList tripOnServiceDates
+) {}
diff --git a/src/main/java/org/opentripplanner/raptor/api/model/RaptorTripPattern.java b/src/main/java/org/opentripplanner/raptor/api/model/RaptorTripPattern.java
index 98a2533486b..e5be1cab0d5 100644
--- a/src/main/java/org/opentripplanner/raptor/api/model/RaptorTripPattern.java
+++ b/src/main/java/org/opentripplanner/raptor/api/model/RaptorTripPattern.java
@@ -46,7 +46,7 @@ public interface RaptorTripPattern {
int slackIndex();
/**
- * A pattern may belong to a transit-priority-group. Each group is given an advantage during
+ * A pattern may belong to a transit-group-priority. Each group is given an advantage during
* the multi-criteria search, so the best alternative for each group is found.
*/
int priorityGroupId();
diff --git a/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java b/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java
index 64cd9dae1a5..368b4660922 100644
--- a/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java
+++ b/src/main/java/org/opentripplanner/raptor/api/request/MultiCriteriaRequest.java
@@ -18,7 +18,7 @@ public class MultiCriteriaRequest {
private final RelaxFunction relaxC1;
@Nullable
- private final RaptorTransitPriorityGroupCalculator transitPriorityCalculator;
+ private final RaptorTransitGroupCalculator transitPriorityCalculator;
private final List passThroughPoints;
@@ -63,7 +63,7 @@ public RelaxFunction relaxC1() {
return relaxC1;
}
- public Optional transitPriorityCalculator() {
+ public Optional transitPriorityCalculator() {
return Optional.ofNullable(transitPriorityCalculator);
}
@@ -140,7 +140,7 @@ public static class Builder {
private final MultiCriteriaRequest original;
private RelaxFunction relaxC1;
- private RaptorTransitPriorityGroupCalculator transitPriorityCalculator;
+ private RaptorTransitGroupCalculator transitPriorityCalculator;
private List passThroughPoints;
private Double relaxCostAtDestination;
@@ -163,11 +163,11 @@ public Builder withRelaxC1(RelaxFunction relaxC1) {
}
@Nullable
- public RaptorTransitPriorityGroupCalculator transitPriorityCalculator() {
+ public RaptorTransitGroupCalculator transitPriorityCalculator() {
return transitPriorityCalculator;
}
- public Builder withTransitPriorityCalculator(RaptorTransitPriorityGroupCalculator value) {
+ public Builder withTransitPriorityCalculator(RaptorTransitGroupCalculator value) {
transitPriorityCalculator = value;
return this;
}
diff --git a/src/main/java/org/opentripplanner/raptor/api/request/RaptorTransitPriorityGroupCalculator.java b/src/main/java/org/opentripplanner/raptor/api/request/RaptorTransitGroupCalculator.java
similarity index 71%
rename from src/main/java/org/opentripplanner/raptor/api/request/RaptorTransitPriorityGroupCalculator.java
rename to src/main/java/org/opentripplanner/raptor/api/request/RaptorTransitGroupCalculator.java
index c3890fa47b3..b5f0598415e 100644
--- a/src/main/java/org/opentripplanner/raptor/api/request/RaptorTransitPriorityGroupCalculator.java
+++ b/src/main/java/org/opentripplanner/raptor/api/request/RaptorTransitGroupCalculator.java
@@ -2,19 +2,19 @@
import org.opentripplanner.raptor.api.model.DominanceFunction;
-public interface RaptorTransitPriorityGroupCalculator {
+public interface RaptorTransitGroupCalculator {
/**
- * Merge in the trip transit priority group id with an existing set. Note! Both the set
+ * Merge in the transit group id with an existing set. Note! Both the set
* and the group id type is {@code int}.
*
* @param currentGroupIds the set of groupIds for all legs in a path.
* @param boardingGroupId the transit group id to add to the given set.
* @return the new computed set of groupIds
*/
- int mergeTransitPriorityGroupIds(int currentGroupIds, int boardingGroupId);
+ int mergeGroupIds(int currentGroupIds, int boardingGroupId);
/**
- * This is the dominance function to use for comparing transit-priority-groupIds.
+ * This is the dominance function to use for comparing transit-groups.
* It is critical that the implementation is "static" so it can be inlined, since it
* is run in the innermost loop of Raptor.
*/
diff --git a/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/PassThroughPointsService.java b/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/PassThroughPointsService.java
index 69899b55688..4932d9c46fe 100644
--- a/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/PassThroughPointsService.java
+++ b/src/main/java/org/opentripplanner/raptor/rangeraptor/internalapi/PassThroughPointsService.java
@@ -54,7 +54,7 @@ default boolean isNoop() {
void updateC2Value(int currentPathC2, IntConsumer update);
/**
- * This is the dominance function to use for comparing transit-priority-groupIds.
+ * This is the dominance function to use for comparing transit-group-priorityIds.
* It is critical that the implementation is "static" so it can be inlined, since it
* is run in the innermost loop of Raptor.
*/
diff --git a/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java b/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java
index e7aa07fb914..8eef90950dd 100644
--- a/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java
+++ b/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/configure/McRangeRaptorConfig.java
@@ -6,7 +6,7 @@
import org.opentripplanner.raptor.api.model.DominanceFunction;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
import org.opentripplanner.raptor.api.request.MultiCriteriaRequest;
-import org.opentripplanner.raptor.api.request.RaptorTransitPriorityGroupCalculator;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
import org.opentripplanner.raptor.rangeraptor.context.SearchContext;
import org.opentripplanner.raptor.rangeraptor.internalapi.Heuristics;
import org.opentripplanner.raptor.rangeraptor.internalapi.ParetoSetCost;
@@ -29,7 +29,7 @@
import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.c1.PatternRideC1;
import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.c2.PassThroughRideFactory;
import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.c2.PatternRideC2;
-import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.c2.TransitPriorityGroupRideFactory;
+import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.c2.TransitGroupPriorityRideFactory;
import org.opentripplanner.raptor.rangeraptor.path.DestinationArrivalPaths;
import org.opentripplanner.raptor.rangeraptor.path.configure.PathConfig;
import org.opentripplanner.raptor.util.paretoset.ParetoComparator;
@@ -173,7 +173,8 @@ private MultiCriteriaRequest mcRequest() {
}
/**
- * Currently "transit-priority-groups" is the only feature using two multi-criteria(c2).
+ * Use c2 in the search, this is use-case specific. For example the pass-through or
+ * transit-group-priority features uses the c2 value.
*/
private boolean includeC2() {
return mcRequest().includeC2();
@@ -184,7 +185,7 @@ private PatternRideFactory> createPatternRideC2Factory() {
return new PassThroughRideFactory<>(passThroughPointsService);
}
if (isTransitPriority()) {
- return new TransitPriorityGroupRideFactory<>(getTransitPriorityGroupCalculator());
+ return new TransitGroupPriorityRideFactory<>(getTransitGroupPriorityCalculator());
}
throw new IllegalStateException("Only pass-through and transit-priority uses c2.");
}
@@ -195,12 +196,12 @@ private DominanceFunction dominanceFunctionC2() {
return passThroughPointsService.dominanceFunction();
}
if (isTransitPriority()) {
- return getTransitPriorityGroupCalculator().dominanceFunction();
+ return getTransitGroupPriorityCalculator().dominanceFunction();
}
return null;
}
- private RaptorTransitPriorityGroupCalculator getTransitPriorityGroupCalculator() {
+ private RaptorTransitGroupCalculator getTransitGroupPriorityCalculator() {
return mcRequest().transitPriorityCalculator().orElseThrow();
}
diff --git a/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/TransitPriorityGroupRideFactory.java b/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/TransitGroupPriorityRideFactory.java
similarity index 67%
rename from src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/TransitPriorityGroupRideFactory.java
rename to src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/TransitGroupPriorityRideFactory.java
index eca049233b9..5d65c40d021 100644
--- a/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/TransitPriorityGroupRideFactory.java
+++ b/src/main/java/org/opentripplanner/raptor/rangeraptor/multicriteria/ride/c2/TransitGroupPriorityRideFactory.java
@@ -2,25 +2,25 @@
import org.opentripplanner.raptor.api.model.RaptorTripPattern;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
-import org.opentripplanner.raptor.api.request.RaptorTransitPriorityGroupCalculator;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
import org.opentripplanner.raptor.rangeraptor.multicriteria.arrivals.McStopArrival;
import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.PatternRide;
import org.opentripplanner.raptor.rangeraptor.multicriteria.ride.PatternRideFactory;
/**
- * This factory creates new {@link PatternRide}s and merge in transit-priority-group ids
+ * This factory creates new {@link PatternRide}s and merge in transit-group-priority ids
* into c2.
*/
-public class TransitPriorityGroupRideFactory
+public class TransitGroupPriorityRideFactory
implements PatternRideFactory> {
private int currentPatternGroupPriority;
- private final RaptorTransitPriorityGroupCalculator transitPriorityGroupCalculator;
+ private final RaptorTransitGroupCalculator transitGroupPriorityCalculator;
- public TransitPriorityGroupRideFactory(
- RaptorTransitPriorityGroupCalculator transitPriorityGroupCalculator
+ public TransitGroupPriorityRideFactory(
+ RaptorTransitGroupCalculator transitGroupPriorityCalculator
) {
- this.transitPriorityGroupCalculator = transitPriorityGroupCalculator;
+ this.transitGroupPriorityCalculator = transitGroupPriorityCalculator;
}
@Override
@@ -52,12 +52,9 @@ public void prepareForTransitWith(RaptorTripPattern pattern) {
}
/**
- * Currently transit-priority-group is the only usage of c2
+ * Currently transit-group-priority is the only usage of c2
*/
private int calculateC2(int c2) {
- return transitPriorityGroupCalculator.mergeTransitPriorityGroupIds(
- c2,
- currentPatternGroupPriority
- );
+ return transitGroupPriorityCalculator.mergeGroupIds(c2, currentPatternGroupPriority);
}
}
diff --git a/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlert.java b/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlert.java
index 98127555e56..d5d260a8218 100644
--- a/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlert.java
+++ b/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlert.java
@@ -33,6 +33,7 @@ public class TransitAlert extends AbstractTransitEntity entities;
@@ -52,6 +53,7 @@ public class TransitAlert extends AbstractTransitEntitynull
+ */
+ @Nullable
+ public Integer version() {
+ return version;
+ }
+
public ZonedDateTime updatedTime() {
return updatedTime;
}
@@ -195,6 +207,7 @@ public boolean sameAs(@Nonnull TransitAlert other) {
Objects.equals(effect, other.effect) &&
Objects.equals(priority, other.priority) &&
Objects.equals(creationTime, other.creationTime) &&
+ Objects.equals(version, other.version) &&
Objects.equals(updatedTime, other.updatedTime) &&
Objects.equals(siriCodespace, other.siriCodespace) &&
Objects.equals(entities, other.entities) &&
diff --git a/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlertBuilder.java b/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlertBuilder.java
index fda6b571585..654a47fe12b 100644
--- a/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlertBuilder.java
+++ b/src/main/java/org/opentripplanner/routing/alertpatch/TransitAlertBuilder.java
@@ -27,6 +27,7 @@ public class TransitAlertBuilder extends AbstractEntityBuilder entities = new HashSet<>();
private final List timePeriods = new ArrayList<>();
@@ -167,6 +168,15 @@ public TransitAlertBuilder withCreationTime(ZonedDateTime creationTime) {
return this;
}
+ public Integer version() {
+ return version;
+ }
+
+ public TransitAlertBuilder withVersion(Integer version) {
+ this.version = version;
+ return this;
+ }
+
public ZonedDateTime updatedTime() {
return updatedTime;
}
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java
index 0f5a84ed79c..1b5c836c832 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java
@@ -229,7 +229,10 @@ private Collection fetchAccessEgresses(AccessEgressType typ
RouteRequest accessRequest = request.clone();
if (type.isAccess()) {
- accessRequest.journey().rental().setAllowArrivingInRentedVehicleAtDestination(false);
+ accessRequest.withPreferences(p -> {
+ p.withBike(b -> b.withRental(r -> r.withAllowArrivingInRentedVehicleAtDestination(false)));
+ p.withCar(c -> c.withRental(r -> r.withAllowArrivingInRentedVehicleAtDestination(false)));
+ });
}
Duration durationLimit = accessRequest
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitPriorityGroup32n.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitGroupPriority32n.java
similarity index 76%
rename from src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitPriorityGroup32n.java
rename to src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitGroupPriority32n.java
index 9b744932b8b..feb3f6f7b3a 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitPriorityGroup32n.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitGroupPriority32n.java
@@ -1,33 +1,33 @@
package org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.grouppriority;
import org.opentripplanner.raptor.api.model.DominanceFunction;
-import org.opentripplanner.raptor.api.request.RaptorTransitPriorityGroupCalculator;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
/**
* This is a "BitSet" implementation for groupId. It can store upto 32 groups,
* a set with few elements does NOT dominate a set with more elements.
*/
-public class TransitPriorityGroup32n {
+public class TransitGroupPriority32n {
private static final int GROUP_ZERO = 0;
private static final int MIN_SEQ_NO = 0;
private static final int MAX_SEQ_NO = 32;
- public static RaptorTransitPriorityGroupCalculator priorityCalculator() {
- return new RaptorTransitPriorityGroupCalculator() {
+ public static RaptorTransitGroupCalculator priorityCalculator() {
+ return new RaptorTransitGroupCalculator() {
@Override
- public int mergeTransitPriorityGroupIds(int currentGroupIds, int boardingGroupId) {
+ public int mergeGroupIds(int currentGroupIds, int boardingGroupId) {
return mergeInGroupId(currentGroupIds, boardingGroupId);
}
@Override
public DominanceFunction dominanceFunction() {
- return TransitPriorityGroup32n::dominate;
+ return TransitGroupPriority32n::dominate;
}
@Override
public String toString() {
- return "TransitPriorityGroup32nCalculator{}";
+ return "TransitGroupPriority32nCalculator{}";
}
};
}
@@ -42,7 +42,7 @@ public static boolean dominate(int left, int right) {
@Override
public String toString() {
- return "TransitPriorityGroup32n{}";
+ return "TransitGroupPriority32n{}";
}
/**
@@ -64,12 +64,12 @@ public static int mergeInGroupId(final int currentSetOfGroupIds, final int newGr
private static void assertValidGroupSeqNo(int priorityGroupIndex) {
if (priorityGroupIndex < MIN_SEQ_NO) {
throw new IllegalArgumentException(
- "Transit priority group can not be a negative number: " + priorityGroupIndex
+ "Transit group priority can not be a negative number: " + priorityGroupIndex
);
}
if (priorityGroupIndex > MAX_SEQ_NO) {
throw new IllegalArgumentException(
- "Transit priority group exceeds max number of groups: " +
+ "Transit group priority exceeds max number of groups: " +
priorityGroupIndex +
" (MAX=" +
MAX_SEQ_NO +
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java
index e63546a87a2..5f3b4b13746 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/RaptorRequestMapper.java
@@ -22,7 +22,7 @@
import org.opentripplanner.routing.algorithm.raptoradapter.router.performance.PerformanceTimersForRaptor;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.RaptorCostConverter;
-import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.grouppriority.TransitPriorityGroup32n;
+import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.grouppriority.TransitGroupPriority32n;
import org.opentripplanner.routing.api.request.DebugEventType;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.api.request.framework.CostLinearFunction;
@@ -119,9 +119,9 @@ private RaptorRequest doMap() {
builder.withMultiCriteria(mcBuilder -> {
var pt = preferences.transit();
var r = pt.raptor();
- if (!pt.relaxTransitPriorityGroup().isNormal()) {
- mcBuilder.withTransitPriorityCalculator(TransitPriorityGroup32n.priorityCalculator());
- mcBuilder.withRelaxC1(mapRelaxCost(pt.relaxTransitPriorityGroup()));
+ if (!pt.relaxTransitGroupPriority().isNormal()) {
+ mcBuilder.withTransitPriorityCalculator(TransitGroupPriority32n.priorityCalculator());
+ mcBuilder.withRelaxC1(mapRelaxCost(pt.relaxTransitGroupPriority()));
} else {
mcBuilder.withPassThroughPoints(mapPassThroughPoints());
r.relaxGeneralizedCostAtDestination().ifPresent(mcBuilder::withRelaxCostAtDestination);
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfigurator.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfigurator.java
index 25006af49d8..826b9c09a13 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfigurator.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfigurator.java
@@ -8,14 +8,14 @@
import java.util.List;
import java.util.stream.Stream;
import org.opentripplanner.framework.lang.ArrayUtils;
-import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.grouppriority.TransitPriorityGroup32n;
-import org.opentripplanner.routing.api.request.request.filter.TransitPriorityGroupSelect;
+import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.grouppriority.TransitGroupPriority32n;
+import org.opentripplanner.routing.api.request.request.filter.TransitGroupSelect;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.RoutingTripPattern;
/**
* This class dynamically builds an index of transit-group-ids from the
- * provided {@link TransitPriorityGroupSelect}s while serving the caller with
+ * provided {@link TransitGroupSelect}s while serving the caller with
* group-ids for each requested pattern. It is made for optimal
* performance, since it is used in request scope.
*
@@ -44,7 +44,7 @@ public class PriorityGroupConfigurator {
*/
private static final int GROUP_INDEX_COUNTER_START = 1;
- private final int baseGroupId = TransitPriorityGroup32n.groupId(GROUP_INDEX_COUNTER_START);
+ private final int baseGroupId = TransitGroupPriority32n.groupId(GROUP_INDEX_COUNTER_START);
private int groupIndexCounter = GROUP_INDEX_COUNTER_START;
private final boolean enabled;
private final PriorityGroupMatcher[] agencyMatchers;
@@ -63,8 +63,8 @@ private PriorityGroupConfigurator() {
}
private PriorityGroupConfigurator(
- Collection byAgency,
- Collection global
+ Collection byAgency,
+ Collection global
) {
this.agencyMatchers = PriorityGroupMatcher.of(byAgency);
this.globalMatchers = PriorityGroupMatcher.of(global);
@@ -80,8 +80,8 @@ public static PriorityGroupConfigurator empty() {
}
public static PriorityGroupConfigurator of(
- Collection byAgency,
- Collection global
+ Collection byAgency,
+ Collection global
) {
if (Stream.of(byAgency, global).allMatch(Collection::isEmpty)) {
return empty();
@@ -94,7 +94,7 @@ public static PriorityGroupConfigurator of(
*
* @throws IllegalArgumentException if more than 32 group-ids are requested.
*/
- public int lookupTransitPriorityGroupId(RoutingTripPattern tripPattern) {
+ public int lookupTransitGroupPriorityId(RoutingTripPattern tripPattern) {
if (!enabled || tripPattern == null) {
return baseGroupId;
}
@@ -128,7 +128,7 @@ public int baseGroupId() {
}
private int nextGroupId() {
- return TransitPriorityGroup32n.groupId(++groupIndexCounter);
+ return TransitGroupPriority32n.groupId(++groupIndexCounter);
}
/** Pair of matcher and groupId. Used only inside this class. */
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcher.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcher.java
index 4d8a0475239..c017f2862ab 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcher.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcher.java
@@ -15,13 +15,13 @@
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import org.opentripplanner.routing.api.request.request.filter.TransitPriorityGroupSelect;
+import org.opentripplanner.routing.api.request.request.filter.TransitGroupSelect;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.TripPattern;
/**
- * This class turns a {@link TransitPriorityGroupSelect} into a matcher.
+ * This class turns a {@link TransitGroupSelect} into a matcher.
*
* Design: It uses the composite design pattern. A matcher is created for each
* value in the "select", then the list of non-empty matchers is merged into
@@ -42,7 +42,7 @@ boolean isEmpty() {
}
};
- public static PriorityGroupMatcher of(TransitPriorityGroupSelect select) {
+ public static PriorityGroupMatcher of(TransitGroupSelect select) {
if (select.isEmpty()) {
return NOOP;
}
@@ -65,7 +65,7 @@ public static PriorityGroupMatcher of(TransitPriorityGroupSelect select) {
return andOf(list);
}
- static PriorityGroupMatcher[] of(Collection selectors) {
+ static PriorityGroupMatcher[] of(Collection selectors) {
return selectors
.stream()
.map(PriorityGroupMatcher::of)
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java
index f1212b2f545..4338593d59d 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitData.java
@@ -92,7 +92,7 @@ public RaptorRoutingRequestTransitData(
additionalPastSearchDays,
additionalFutureSearchDays,
filter,
- createTransitPriorityGroupConfigurator(request)
+ createTransitGroupPriorityConfigurator(request)
);
this.patternIndex = transitDataCreator.createPatternIndex(tripPatterns);
this.activeTripPatternsPerStop = transitDataCreator.createTripPatternsPerStop(tripPatterns);
@@ -243,8 +243,8 @@ public RaptorConstrainedBoardingSearch transferConstraintsReverseS
return new ConstrainedBoardingSearch(false, toStopTransfers, fromStopTransfers);
}
- private PriorityGroupConfigurator createTransitPriorityGroupConfigurator(RouteRequest request) {
- if (request.preferences().transit().relaxTransitPriorityGroup().isNormal()) {
+ private PriorityGroupConfigurator createTransitGroupPriorityConfigurator(RouteRequest request) {
+ if (request.preferences().transit().relaxTransitGroupPriority().isNormal()) {
return PriorityGroupConfigurator.empty();
}
var transitRequest = request.journey().transit();
diff --git a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java
index 0cb155facd5..b8f915d6eb4 100644
--- a/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java
+++ b/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RaptorRoutingRequestTransitDataCreator.java
@@ -147,7 +147,7 @@ static List merge(
tripPattern.getAlightingPossible(),
BoardAlight.ALIGHT
),
- priorityGroupConfigurator.lookupTransitPriorityGroupId(tripPattern)
+ priorityGroupConfigurator.lookupTransitGroupPriorityId(tripPattern)
)
);
}
diff --git a/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java b/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java
index bda369433a3..5717876bbfc 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/preference/BikePreferences.java
@@ -30,6 +30,7 @@ public final class BikePreferences implements Serializable {
private final int switchTime;
private final Cost switchCost;
private final VehicleParkingPreferences parking;
+ private final VehicleRentalPreferences rental;
private final double stairsReluctance;
private final BicycleOptimizeType optimizeType;
private final TimeSlopeSafetyTriangle optimizeTriangle;
@@ -43,6 +44,7 @@ private BikePreferences() {
this.switchTime = 0;
this.switchCost = Cost.ZERO;
this.parking = VehicleParkingPreferences.DEFAULT;
+ this.rental = VehicleRentalPreferences.DEFAULT;
this.optimizeType = BicycleOptimizeType.SAFE;
this.optimizeTriangle = TimeSlopeSafetyTriangle.DEFAULT;
// very high reluctance to carry the bike up/down a flight of stairs
@@ -58,6 +60,7 @@ private BikePreferences(Builder builder) {
this.switchTime = Units.duration(builder.switchTime);
this.switchCost = builder.switchCost;
this.parking = builder.parking;
+ this.rental = builder.rental;
this.optimizeType = Objects.requireNonNull(builder.optimizeType);
this.optimizeTriangle = Objects.requireNonNull(builder.optimizeTriangle);
this.stairsReluctance = Units.reluctance(builder.stairsReluctance);
@@ -126,6 +129,11 @@ public VehicleParkingPreferences parking() {
return parking;
}
+ /** Rental preferences that can be different per request */
+ public VehicleRentalPreferences rental() {
+ return rental;
+ }
+
/**
* The set of characteristics that the user wants to optimize for -- defaults to SAFE.
*/
@@ -155,6 +163,7 @@ public boolean equals(Object o) {
switchTime == that.switchTime &&
switchCost.equals(that.switchCost) &&
parking.equals(that.parking) &&
+ rental.equals(that.rental) &&
optimizeType == that.optimizeType &&
optimizeTriangle.equals(that.optimizeTriangle) &&
doubleEquals(stairsReluctance, that.stairsReluctance)
@@ -172,6 +181,7 @@ public int hashCode() {
switchTime,
switchCost,
parking,
+ rental,
optimizeType,
optimizeTriangle,
stairsReluctance
@@ -190,6 +200,7 @@ public String toString() {
.addDurationSec("switchTime", switchTime, DEFAULT.switchTime)
.addObj("switchCost", switchCost, DEFAULT.switchCost)
.addObj("parking", parking, DEFAULT.parking)
+ .addObj("rental", rental, DEFAULT.rental)
.addEnum("optimizeType", optimizeType, DEFAULT.optimizeType)
.addObj("optimizeTriangle", optimizeTriangle, DEFAULT.optimizeTriangle)
.addNum("stairsReluctance", stairsReluctance, DEFAULT.stairsReluctance)
@@ -208,6 +219,7 @@ public static class Builder {
private int switchTime;
private Cost switchCost;
private VehicleParkingPreferences parking;
+ private VehicleRentalPreferences rental;
private BicycleOptimizeType optimizeType;
private TimeSlopeSafetyTriangle optimizeTriangle;
@@ -223,6 +235,7 @@ public Builder(BikePreferences original) {
this.switchTime = original.switchTime;
this.switchCost = original.switchCost;
this.parking = original.parking;
+ this.rental = original.rental;
this.optimizeType = original.optimizeType;
this.optimizeTriangle = original.optimizeTriangle;
this.stairsReluctance = original.stairsReluctance;
@@ -300,6 +313,11 @@ public Builder withParking(Consumer body) {
return this;
}
+ public Builder withRental(Consumer body) {
+ this.rental = ifNotNull(this.rental, original.rental).copyOf().apply(body).build();
+ return this;
+ }
+
public BicycleOptimizeType optimizeType() {
return optimizeType;
}
diff --git a/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java b/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java
index 523e19afb70..6b103e8f3b7 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/preference/CarPreferences.java
@@ -24,6 +24,7 @@ public final class CarPreferences implements Serializable {
private final double speed;
private final double reluctance;
private final VehicleParkingPreferences parking;
+ private final VehicleRentalPreferences rental;
private final int pickupTime;
private final Cost pickupCost;
private final int dropoffTime;
@@ -35,6 +36,7 @@ private CarPreferences() {
this.speed = 40.0;
this.reluctance = 2.0;
this.parking = VehicleParkingPreferences.DEFAULT;
+ this.rental = VehicleRentalPreferences.DEFAULT;
this.pickupTime = 60;
this.pickupCost = Cost.costOfMinutes(2);
this.dropoffTime = 120;
@@ -46,6 +48,7 @@ private CarPreferences(Builder builder) {
this.speed = Units.speed(builder.speed);
this.reluctance = Units.reluctance(builder.reluctance);
this.parking = builder.parking;
+ this.rental = builder.rental;
this.pickupTime = Units.duration(builder.pickupTime);
this.pickupCost = builder.pickupCost;
this.dropoffTime = Units.duration(builder.dropoffTime);
@@ -79,6 +82,11 @@ public VehicleParkingPreferences parking() {
return parking;
}
+ /** Rental preferences that can be different per request */
+ public VehicleRentalPreferences rental() {
+ return rental;
+ }
+
/** Time of getting in/out of a carPickup (taxi) */
public int pickupTime() {
return pickupTime;
@@ -122,6 +130,7 @@ public boolean equals(Object o) {
DoubleUtils.doubleEquals(that.speed, speed) &&
DoubleUtils.doubleEquals(that.reluctance, reluctance) &&
parking.equals(that.parking) &&
+ rental.equals(that.rental) &&
pickupTime == that.pickupTime &&
pickupCost.equals(that.pickupCost) &&
dropoffTime == that.dropoffTime &&
@@ -136,6 +145,7 @@ public int hashCode() {
speed,
reluctance,
parking,
+ rental,
pickupTime,
pickupCost,
dropoffTime,
@@ -151,6 +161,7 @@ public String toString() {
.addNum("speed", speed, DEFAULT.speed)
.addNum("reluctance", reluctance, DEFAULT.reluctance)
.addObj("parking", parking, DEFAULT.parking)
+ .addObj("rental", rental, DEFAULT.rental)
.addNum("pickupTime", pickupTime, DEFAULT.pickupTime)
.addObj("pickupCost", pickupCost, DEFAULT.pickupCost)
.addNum("dropoffTime", dropoffTime, DEFAULT.dropoffTime)
@@ -166,6 +177,7 @@ public static class Builder {
private double speed;
private double reluctance;
private VehicleParkingPreferences parking;
+ private VehicleRentalPreferences rental;
private int pickupTime;
private Cost pickupCost;
private int dropoffTime;
@@ -177,6 +189,7 @@ public Builder(CarPreferences original) {
this.speed = original.speed;
this.reluctance = original.reluctance;
this.parking = original.parking;
+ this.rental = original.rental;
this.pickupTime = original.pickupTime;
this.pickupCost = original.pickupCost;
this.dropoffTime = original.dropoffTime;
@@ -203,6 +216,11 @@ public Builder withParking(Consumer body) {
return this;
}
+ public Builder withRental(Consumer body) {
+ this.rental = ifNotNull(this.rental, original.rental).copyOf().apply(body).build();
+ return this;
+ }
+
public Builder withPickupTime(int pickupTime) {
this.pickupTime = pickupTime;
return this;
diff --git a/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java b/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java
index b728b99f8e3..3230bbf5968 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/preference/RoutingPreferences.java
@@ -7,6 +7,7 @@
import java.util.Objects;
import java.util.function.Consumer;
import javax.annotation.Nonnull;
+import org.opentripplanner.routing.api.request.StreetMode;
import org.opentripplanner.street.search.TraverseMode;
/** User/trip cost/time/slack/reluctance search config. */
@@ -22,7 +23,6 @@ public final class RoutingPreferences implements Serializable {
private final WheelchairPreferences wheelchair;
private final BikePreferences bike;
private final CarPreferences car;
- private final VehicleRentalPreferences rental;
private final SystemPreferences system;
private final ItineraryFilterPreferences itineraryFilter;
@@ -34,7 +34,6 @@ public RoutingPreferences() {
this.wheelchair = WheelchairPreferences.DEFAULT;
this.bike = BikePreferences.DEFAULT;
this.car = CarPreferences.DEFAULT;
- this.rental = VehicleRentalPreferences.DEFAULT;
this.system = SystemPreferences.DEFAULT;
this.itineraryFilter = ItineraryFilterPreferences.DEFAULT;
}
@@ -47,7 +46,6 @@ private RoutingPreferences(Builder builder) {
this.street = requireNonNull(builder.street());
this.bike = requireNonNull(builder.bike());
this.car = requireNonNull(builder.car());
- this.rental = requireNonNull(builder.rental());
this.system = requireNonNull(builder.system());
this.itineraryFilter = requireNonNull(builder.itineraryFilter());
}
@@ -92,10 +90,6 @@ public CarPreferences car() {
return car;
}
- public VehicleRentalPreferences rental() {
- return rental;
- }
-
/**
* Get parking preferences for the traverse mode. Note, only car and bike are supported.
*/
@@ -103,6 +97,24 @@ public VehicleParkingPreferences parking(TraverseMode mode) {
return mode == TraverseMode.CAR ? car.parking() : bike.parking();
}
+ /**
+ * Get rental preferences for the traverse mode. Note, only car, scooter and bike are supported.
+ *
+ * TODO make scooter preferences independent of bike
+ */
+ public VehicleRentalPreferences rental(TraverseMode mode) {
+ return mode == TraverseMode.CAR ? car.rental() : bike.rental();
+ }
+
+ /**
+ * Get rental preferences for the traverse mode. Note, only car, scooter and bike are supported.
+ *
+ * TODO make scooter preferences independent of bike
+ */
+ public VehicleRentalPreferences rental(StreetMode mode) {
+ return mode == StreetMode.CAR_RENTAL ? car.rental() : bike.rental();
+ }
+
@Nonnull
public ItineraryFilterPreferences itineraryFilter() {
return itineraryFilter;
@@ -137,7 +149,6 @@ public boolean equals(Object o) {
Objects.equals(wheelchair, that.wheelchair) &&
Objects.equals(bike, that.bike) &&
Objects.equals(car, that.car) &&
- Objects.equals(rental, that.rental) &&
Objects.equals(system, that.system) &&
Objects.equals(itineraryFilter, that.itineraryFilter)
);
@@ -153,7 +164,6 @@ public int hashCode() {
wheelchair,
bike,
car,
- rental,
system,
itineraryFilter
);
@@ -169,7 +179,6 @@ public static class Builder {
private WheelchairPreferences wheelchair = null;
private BikePreferences bike = null;
private CarPreferences car = null;
- private VehicleRentalPreferences rental = null;
private SystemPreferences system = null;
private ItineraryFilterPreferences itineraryFilter = null;
@@ -250,15 +259,6 @@ public Builder withCar(Consumer body) {
return this;
}
- public VehicleRentalPreferences rental() {
- return rental == null ? original.rental : rental;
- }
-
- public Builder withRental(Consumer body) {
- this.rental = ifNotNull(this.rental, original.rental).copyOf().apply(body).build();
- return this;
- }
-
public SystemPreferences system() {
return system == null ? original.system : system;
}
diff --git a/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java b/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java
index 1ad6e8ddacd..78f30277e72 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/preference/TransitPreferences.java
@@ -26,7 +26,7 @@ public final class TransitPreferences implements Serializable {
private final Map reluctanceForMode;
private final Cost otherThanPreferredRoutesPenalty;
private final CostLinearFunction unpreferredCost;
- private final CostLinearFunction relaxTransitPriorityGroup;
+ private final CostLinearFunction relaxTransitGroupPriority;
private final boolean ignoreRealtimeUpdates;
private final boolean includePlannedCancellations;
private final boolean includeRealtimeCancellations;
@@ -37,7 +37,7 @@ private TransitPreferences() {
this.reluctanceForMode = Map.of();
this.otherThanPreferredRoutesPenalty = Cost.costOfMinutes(5);
this.unpreferredCost = CostLinearFunction.NORMAL;
- this.relaxTransitPriorityGroup = CostLinearFunction.NORMAL;
+ this.relaxTransitGroupPriority = CostLinearFunction.NORMAL;
this.ignoreRealtimeUpdates = false;
this.includePlannedCancellations = false;
this.includeRealtimeCancellations = false;
@@ -50,7 +50,7 @@ private TransitPreferences(Builder builder) {
this.reluctanceForMode = Map.copyOf(requireNonNull(builder.reluctanceForMode));
this.otherThanPreferredRoutesPenalty = builder.otherThanPreferredRoutesPenalty;
this.unpreferredCost = requireNonNull(builder.unpreferredCost);
- this.relaxTransitPriorityGroup = Objects.requireNonNull(builder.relaxTransitPriorityGroup);
+ this.relaxTransitGroupPriority = Objects.requireNonNull(builder.relaxTransitGroupPriority);
this.ignoreRealtimeUpdates = builder.ignoreRealtimeUpdates;
this.includePlannedCancellations = builder.includePlannedCancellations;
this.includeRealtimeCancellations = builder.includeRealtimeCancellations;
@@ -128,13 +128,13 @@ public CostLinearFunction unpreferredCost() {
}
/**
- * This is used to relax the cost when comparing transit-priority-groups. The default is the
- * NORMAL function({@code f(x) = x}. This is the same as not using priority-groups. The
+ * This is used to relax the cost when comparing transit-groups. The default is the
+ * NORMAL function({@code f(t) = t}. This is the same as not using priority-groups. The
* coefficient must be in range {@code [1.0 to 4.0]} and the constant must be in range
* {@code [$0 to $1440(4h)]}.
*/
- public CostLinearFunction relaxTransitPriorityGroup() {
- return relaxTransitPriorityGroup;
+ public CostLinearFunction relaxTransitGroupPriority() {
+ return relaxTransitGroupPriority;
}
/**
@@ -176,7 +176,7 @@ public boolean equals(Object o) {
reluctanceForMode.equals(that.reluctanceForMode) &&
Objects.equals(otherThanPreferredRoutesPenalty, that.otherThanPreferredRoutesPenalty) &&
unpreferredCost.equals(that.unpreferredCost) &&
- Objects.equals(relaxTransitPriorityGroup, that.relaxTransitPriorityGroup) &&
+ Objects.equals(relaxTransitGroupPriority, that.relaxTransitGroupPriority) &&
ignoreRealtimeUpdates == that.ignoreRealtimeUpdates &&
includePlannedCancellations == that.includePlannedCancellations &&
includeRealtimeCancellations == that.includeRealtimeCancellations &&
@@ -192,7 +192,7 @@ public int hashCode() {
reluctanceForMode,
otherThanPreferredRoutesPenalty,
unpreferredCost,
- relaxTransitPriorityGroup,
+ relaxTransitGroupPriority,
ignoreRealtimeUpdates,
includePlannedCancellations,
includeRealtimeCancellations,
@@ -213,7 +213,7 @@ public String toString() {
DEFAULT.otherThanPreferredRoutesPenalty
)
.addObj("unpreferredCost", unpreferredCost, DEFAULT.unpreferredCost)
- .addObj("relaxTransitPriorityGroup", relaxTransitPriorityGroup, CostLinearFunction.NORMAL)
+ .addObj("relaxTransitGroupPriority", relaxTransitGroupPriority, CostLinearFunction.NORMAL)
.addBoolIfTrue(
"ignoreRealtimeUpdates",
ignoreRealtimeUpdates != DEFAULT.ignoreRealtimeUpdates
@@ -240,7 +240,7 @@ public static class Builder {
private Map reluctanceForMode;
private Cost otherThanPreferredRoutesPenalty;
private CostLinearFunction unpreferredCost;
- private CostLinearFunction relaxTransitPriorityGroup;
+ private CostLinearFunction relaxTransitGroupPriority;
private boolean ignoreRealtimeUpdates;
private boolean includePlannedCancellations;
private boolean includeRealtimeCancellations;
@@ -253,7 +253,7 @@ public Builder(TransitPreferences original) {
this.reluctanceForMode = original.reluctanceForMode;
this.otherThanPreferredRoutesPenalty = original.otherThanPreferredRoutesPenalty;
this.unpreferredCost = original.unpreferredCost;
- this.relaxTransitPriorityGroup = original.relaxTransitPriorityGroup;
+ this.relaxTransitGroupPriority = original.relaxTransitGroupPriority;
this.ignoreRealtimeUpdates = original.ignoreRealtimeUpdates;
this.includePlannedCancellations = original.includePlannedCancellations;
this.includeRealtimeCancellations = original.includeRealtimeCancellations;
@@ -302,8 +302,8 @@ public Builder setUnpreferredCostString(String constFunction) {
return setUnpreferredCost(CostLinearFunction.of(constFunction));
}
- public Builder withTransitGroupPriorityGeneralizedCostSlack(CostLinearFunction value) {
- this.relaxTransitPriorityGroup = value;
+ public Builder withRelaxTransitGroupPriority(CostLinearFunction value) {
+ this.relaxTransitGroupPriority = value;
return this;
}
diff --git a/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java b/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java
index b2917df3782..8e18d2a81d5 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferences.java
@@ -2,12 +2,12 @@
import java.io.Serializable;
import java.util.Objects;
+import java.util.Set;
import java.util.function.Consumer;
import org.opentripplanner.framework.lang.DoubleUtils;
import org.opentripplanner.framework.model.Cost;
import org.opentripplanner.framework.model.Units;
import org.opentripplanner.framework.tostring.ToStringBuilder;
-import org.opentripplanner.routing.api.request.request.VehicleRentalRequest;
/**
* Preferences for renting a Bike, Car or other type of vehicle.
@@ -24,6 +24,10 @@ public final class VehicleRentalPreferences implements Serializable {
private final boolean useAvailabilityInformation;
private final double arrivingInRentalVehicleAtDestinationCost;
+ private final boolean allowArrivingInRentedVehicleAtDestination;
+
+ private final Set allowedNetworks;
+ private final Set bannedNetworks;
private VehicleRentalPreferences() {
this.pickupTime = 60;
@@ -32,6 +36,9 @@ private VehicleRentalPreferences() {
this.dropoffCost = Cost.costOfSeconds(30);
this.useAvailabilityInformation = false;
this.arrivingInRentalVehicleAtDestinationCost = 0;
+ this.allowArrivingInRentedVehicleAtDestination = false;
+ this.allowedNetworks = Set.of();
+ this.bannedNetworks = Set.of();
}
private VehicleRentalPreferences(Builder builder) {
@@ -42,6 +49,10 @@ private VehicleRentalPreferences(Builder builder) {
this.useAvailabilityInformation = builder.useAvailabilityInformation;
this.arrivingInRentalVehicleAtDestinationCost =
DoubleUtils.roundTo1Decimal(builder.arrivingInRentalVehicleAtDestinationCost);
+ this.allowArrivingInRentedVehicleAtDestination =
+ builder.allowArrivingInRentedVehicleAtDestination;
+ this.allowedNetworks = builder.allowedNetworks;
+ this.bannedNetworks = builder.bannedNetworks;
}
public static Builder of() {
@@ -78,8 +89,6 @@ public int dropoffCost() {
/**
* Whether or not vehicle rental availability information will be used to plan vehicle rental
* trips
- *
- * TODO: This belong in the request?
*/
public boolean useAvailabilityInformation() {
return useAvailabilityInformation;
@@ -87,13 +96,31 @@ public boolean useAvailabilityInformation() {
/**
* The cost of arriving at the destination with the rented vehicle, to discourage doing so.
- *
- * @see VehicleRentalRequest#allowArrivingInRentedVehicleAtDestination()
*/
public double arrivingInRentalVehicleAtDestinationCost() {
return arrivingInRentalVehicleAtDestinationCost;
}
+ /**
+ * Whether arriving at the destination with a rented (station) vehicle is allowed without dropping
+ * it off.
+ *
+ * @see VehicleRentalPreferences#arrivingInRentalVehicleAtDestinationCost()
+ */
+ public boolean allowArrivingInRentedVehicleAtDestination() {
+ return allowArrivingInRentedVehicleAtDestination;
+ }
+
+ /** The vehicle rental networks which may be used. If empty all networks may be used. */
+ public Set allowedNetworks() {
+ return allowedNetworks;
+ }
+
+ /** The vehicle rental networks which may not be used. If empty, no networks are banned. */
+ public Set bannedNetworks() {
+ return bannedNetworks;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -109,7 +136,10 @@ public boolean equals(Object o) {
that.arrivingInRentalVehicleAtDestinationCost,
arrivingInRentalVehicleAtDestinationCost
) ==
- 0
+ 0 &&
+ allowArrivingInRentedVehicleAtDestination == that.allowArrivingInRentedVehicleAtDestination &&
+ allowedNetworks.equals(that.allowedNetworks) &&
+ bannedNetworks.equals(that.bannedNetworks)
);
}
@@ -121,7 +151,10 @@ public int hashCode() {
dropoffTime,
dropoffCost,
useAvailabilityInformation,
- arrivingInRentalVehicleAtDestinationCost
+ arrivingInRentalVehicleAtDestinationCost,
+ allowArrivingInRentedVehicleAtDestination,
+ allowedNetworks,
+ bannedNetworks
);
}
@@ -139,6 +172,12 @@ public String toString() {
arrivingInRentalVehicleAtDestinationCost,
DEFAULT.arrivingInRentalVehicleAtDestinationCost
)
+ .addBoolIfTrue(
+ "allowArrivingInRentedVehicleAtDestination",
+ allowArrivingInRentedVehicleAtDestination
+ )
+ .addCol("allowedNetworks", allowedNetworks, DEFAULT.allowedNetworks)
+ .addCol("bannedNetworks", bannedNetworks, DEFAULT.bannedNetworks)
.toString();
}
@@ -151,6 +190,9 @@ public static class Builder {
private Cost dropoffCost;
private boolean useAvailabilityInformation;
private double arrivingInRentalVehicleAtDestinationCost;
+ private boolean allowArrivingInRentedVehicleAtDestination;
+ private Set allowedNetworks;
+ private Set bannedNetworks;
private Builder(VehicleRentalPreferences original) {
this.original = original;
@@ -161,6 +203,10 @@ private Builder(VehicleRentalPreferences original) {
this.useAvailabilityInformation = original.useAvailabilityInformation;
this.arrivingInRentalVehicleAtDestinationCost =
original.arrivingInRentalVehicleAtDestinationCost;
+ this.allowArrivingInRentedVehicleAtDestination =
+ original.allowArrivingInRentedVehicleAtDestination;
+ this.allowedNetworks = original.allowedNetworks;
+ this.bannedNetworks = original.bannedNetworks;
}
public VehicleRentalPreferences original() {
@@ -199,6 +245,23 @@ public Builder withArrivingInRentalVehicleAtDestinationCost(
return this;
}
+ public Builder withAllowArrivingInRentedVehicleAtDestination(
+ boolean allowArrivingInRentedVehicleAtDestination
+ ) {
+ this.allowArrivingInRentedVehicleAtDestination = allowArrivingInRentedVehicleAtDestination;
+ return this;
+ }
+
+ public Builder withAllowedNetworks(Set allowedNetworks) {
+ this.allowedNetworks = allowedNetworks;
+ return this;
+ }
+
+ public Builder withBannedNetworks(Set bannedNetworks) {
+ this.bannedNetworks = bannedNetworks;
+ return this;
+ }
+
public Builder apply(Consumer body) {
body.accept(this);
return this;
diff --git a/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java b/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java
index 39a775bf7f5..50e802690b3 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/request/JourneyRequest.java
@@ -6,18 +6,12 @@
// TODO VIA: Javadoc
public class JourneyRequest implements Cloneable, Serializable {
- // TODO VIA (Hannes): Move the fields below into StreetRequest
- private VehicleRentalRequest rental = new VehicleRentalRequest();
private TransitRequest transit = new TransitRequest();
private StreetRequest access = new StreetRequest();
private StreetRequest egress = new StreetRequest();
private StreetRequest transfer = new StreetRequest();
private StreetRequest direct = new StreetRequest();
- public VehicleRentalRequest rental() {
- return rental;
- }
-
public TransitRequest transit() {
return transit;
}
@@ -58,7 +52,6 @@ public RequestModes modes() {
public JourneyRequest clone() {
try {
var clone = (JourneyRequest) super.clone();
- clone.rental = this.rental.clone();
clone.transit = this.transit.clone();
clone.access = this.access.clone();
clone.egress = this.egress.clone();
diff --git a/src/main/java/org/opentripplanner/routing/api/request/request/StreetRequest.java b/src/main/java/org/opentripplanner/routing/api/request/request/StreetRequest.java
index 587efda6e05..42928a0a70a 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/request/StreetRequest.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/request/StreetRequest.java
@@ -4,7 +4,6 @@
import org.opentripplanner.routing.api.request.StreetMode;
// TODO VIA: Javadoc
-// TODO VIA (Hannes): Missing VehicleRentalRequest and VehicleParkingRequest
public class StreetRequest implements Cloneable, Serializable {
private StreetMode mode;
diff --git a/src/main/java/org/opentripplanner/routing/api/request/request/TransitRequest.java b/src/main/java/org/opentripplanner/routing/api/request/request/TransitRequest.java
index 67a56249328..b5626c479a0 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/request/TransitRequest.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/request/TransitRequest.java
@@ -8,7 +8,7 @@
import org.opentripplanner.routing.api.request.DebugRaptor;
import org.opentripplanner.routing.api.request.request.filter.AllowAllTransitFilter;
import org.opentripplanner.routing.api.request.request.filter.TransitFilter;
-import org.opentripplanner.routing.api.request.request.filter.TransitPriorityGroupSelect;
+import org.opentripplanner.routing.api.request.request.filter.TransitGroupSelect;
import org.opentripplanner.transit.model.framework.FeedScopedId;
// TODO VIA: Javadoc
@@ -31,8 +31,8 @@ public class TransitRequest implements Cloneable, Serializable {
private List unpreferredRoutes = List.of();
- private List priorityGroupsByAgency = new ArrayList<>();
- private List priorityGroupsGlobal = new ArrayList<>();
+ private List priorityGroupsByAgency = new ArrayList<>();
+ private List priorityGroupsGlobal = new ArrayList<>();
private DebugRaptor raptorDebugging = new DebugRaptor();
public void setBannedTripsFromString(String ids) {
@@ -64,16 +64,14 @@ public void setFilters(List filters) {
*
* Note! Entities that are not matched are put in the BASE-GROUP with id 0.
*/
- public List priorityGroupsByAgency() {
+ public List priorityGroupsByAgency() {
return priorityGroupsByAgency;
}
/**
* All patterns matching the same select will be assigned the same group-id.
*/
- public void addPriorityGroupsByAgency(
- Collection priorityGroupsByAgency
- ) {
+ public void addPriorityGroupsByAgency(Collection priorityGroupsByAgency) {
this.priorityGroupsByAgency.addAll(priorityGroupsByAgency);
}
@@ -82,11 +80,11 @@ public void addPriorityGroupsByAgency(
*
* Note! Entities that are not matched are put in the BASE-GROUP with id 0.
*/
- public List priorityGroupsGlobal() {
+ public List priorityGroupsGlobal() {
return priorityGroupsGlobal;
}
- public void addPriorityGroupsGlobal(Collection priorityGroupsGlobal) {
+ public void addPriorityGroupsGlobal(Collection priorityGroupsGlobal) {
this.priorityGroupsGlobal.addAll(priorityGroupsGlobal);
}
diff --git a/src/main/java/org/opentripplanner/routing/api/request/request/VehicleRentalRequest.java b/src/main/java/org/opentripplanner/routing/api/request/request/VehicleRentalRequest.java
deleted file mode 100644
index 90e39b22ff7..00000000000
--- a/src/main/java/org/opentripplanner/routing/api/request/request/VehicleRentalRequest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.opentripplanner.routing.api.request.request;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-import org.opentripplanner.routing.api.request.preference.VehicleRentalPreferences;
-import org.opentripplanner.service.vehiclerental.model.VehicleRentalStation;
-
-// TODO VIA: Javadoc
-public class VehicleRentalRequest implements Cloneable, Serializable {
-
- private Set allowedNetworks = Set.of();
- private Set bannedNetworks = Set.of();
-
- private boolean allowArrivingInRentedVehicleAtDestination = false;
-
- // TODO VIA (Hannes): Move useAvailabilityInformation here
-
- public void setAllowedNetworks(Set allowedNetworks) {
- this.allowedNetworks = allowedNetworks;
- }
-
- /** The vehicle rental networks which may be used. If empty all networks may be used. */
- public Set allowedNetworks() {
- return allowedNetworks;
- }
-
- public void setBannedNetworks(Set bannedNetworks) {
- this.bannedNetworks = bannedNetworks;
- }
-
- /** The vehicle rental networks which may not be used. If empty, no networks are banned. */
- public Set bannedNetworks() {
- return bannedNetworks;
- }
-
- public void setAllowArrivingInRentedVehicleAtDestination(
- boolean allowArrivingInRentedVehicleAtDestination
- ) {
- this.allowArrivingInRentedVehicleAtDestination = allowArrivingInRentedVehicleAtDestination;
- }
-
- /**
- * Whether arriving at the destination with a rented (station) bicycle is allowed without dropping
- * it off.
- *
- * @see VehicleRentalPreferences#arrivingInRentalVehicleAtDestinationCost()
- * @see VehicleRentalStation#isArrivingInRentalVehicleAtDestinationAllowed
- */
- public boolean allowArrivingInRentedVehicleAtDestination() {
- return allowArrivingInRentedVehicleAtDestination;
- }
-
- public VehicleRentalRequest clone() {
- try {
- var clone = (VehicleRentalRequest) super.clone();
- clone.allowedNetworks = new HashSet<>(this.allowedNetworks);
- clone.bannedNetworks = new HashSet<>(this.bannedNetworks);
-
- return clone;
- } catch (CloneNotSupportedException e) {
- /* this will never happen since our super is the cloneable object */
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitPriorityGroupSelect.java b/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java
similarity index 87%
rename from src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitPriorityGroupSelect.java
rename to src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java
index 6d763e9c3bc..dfa5daa0e31 100644
--- a/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitPriorityGroupSelect.java
+++ b/src/main/java/org/opentripplanner/routing/api/request/request/filter/TransitGroupSelect.java
@@ -21,23 +21,23 @@
* {@code Entity(mode:SUBWAY, agency:A3)}
*
*/
-public class TransitPriorityGroupSelect {
+public class TransitGroupSelect {
- private static final TransitPriorityGroupSelect DEFAULT = new TransitPriorityGroupSelect();
+ private static final TransitGroupSelect DEFAULT = new TransitGroupSelect();
private final List modes;
private final List subModeRegexp;
private final List agencyIds;
private final List routeIds;
- public TransitPriorityGroupSelect() {
+ public TransitGroupSelect() {
this.modes = List.of();
this.subModeRegexp = List.of();
this.agencyIds = List.of();
this.routeIds = List.of();
}
- private TransitPriorityGroupSelect(Builder builder) {
+ private TransitGroupSelect(Builder builder) {
// Sort and keep only unique entries, this make this
// implementation consistent for eq/hc/toString.
this.modes =
@@ -77,7 +77,7 @@ public boolean isEmpty() {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
- TransitPriorityGroupSelect that = (TransitPriorityGroupSelect) o;
+ TransitGroupSelect that = (TransitGroupSelect) o;
return (
Objects.equals(modes, that.modes) &&
Objects.equals(subModeRegexp, that.subModeRegexp) &&
@@ -96,7 +96,7 @@ public String toString() {
return isEmpty()
? "TransitGroupSelect{ EMPTY }"
: ToStringBuilder
- .of(TransitPriorityGroupSelect.class)
+ .of(TransitGroupSelect.class)
.addCol("modes", modes)
.addCol("subModeRegexp", subModeRegexp)
.addCol("agencyIds", agencyIds)
@@ -106,13 +106,13 @@ public String toString() {
public static class Builder {
- private final TransitPriorityGroupSelect original;
+ private final TransitGroupSelect original;
private final List modes;
private final List subModeRegexp;
private final List agencyIds;
private final List routeIds;
- public Builder(TransitPriorityGroupSelect original) {
+ public Builder(TransitGroupSelect original) {
this.original = original;
this.modes = new ArrayList<>(original.modes);
this.subModeRegexp = new ArrayList<>(original.subModeRegexp);
@@ -140,8 +140,8 @@ public Builder addRouteIds(Collection routeIds) {
return this;
}
- public TransitPriorityGroupSelect build() {
- var obj = new TransitPriorityGroupSelect(this);
+ public TransitGroupSelect build() {
+ var obj = new TransitGroupSelect(this);
return original.equals(obj) ? original : obj;
}
}
diff --git a/src/main/java/org/opentripplanner/routing/error/PathNotFoundException.java b/src/main/java/org/opentripplanner/routing/error/PathNotFoundException.java
index 18d94d23038..a4071f9911e 100644
--- a/src/main/java/org/opentripplanner/routing/error/PathNotFoundException.java
+++ b/src/main/java/org/opentripplanner/routing/error/PathNotFoundException.java
@@ -4,6 +4,5 @@
* Indicates that the call to org.opentripplanner.routing.services.PathService returned either null
* or ZERO paths.
*
- * @see org.opentripplanner.api.resource.PlannerResource for where this is (locally) thrown.
*/
public class PathNotFoundException extends RuntimeException {}
diff --git a/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalPlace.java b/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalPlace.java
index ee181f7b3c1..1725e7df2dd 100644
--- a/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalPlace.java
+++ b/src/main/java/org/opentripplanner/service/vehiclerental/model/VehicleRentalPlace.java
@@ -2,7 +2,7 @@
import java.util.Set;
import org.opentripplanner.framework.i18n.I18NString;
-import org.opentripplanner.routing.api.request.request.VehicleRentalRequest;
+import org.opentripplanner.routing.api.request.preference.VehicleRentalPreferences;
import org.opentripplanner.street.model.RentalFormFactor;
import org.opentripplanner.transit.model.framework.FeedScopedId;
@@ -80,22 +80,22 @@ public interface VehicleRentalPlace {
/** Deep links for this rental station or individual vehicle */
VehicleRentalStationUris getRentalUris();
- default boolean networkIsNotAllowed(VehicleRentalRequest request) {
+ default boolean networkIsNotAllowed(VehicleRentalPreferences preferences) {
if (
getNetwork() == null &&
- (!request.allowedNetworks().isEmpty() || !request.bannedNetworks().isEmpty())
+ (!preferences.allowedNetworks().isEmpty() || !preferences.bannedNetworks().isEmpty())
) {
return false;
}
- if (request.bannedNetworks().contains(getNetwork())) {
+ if (preferences.bannedNetworks().contains(getNetwork())) {
return true;
}
- if (request.allowedNetworks().isEmpty()) {
+ if (preferences.allowedNetworks().isEmpty()) {
return false;
}
- return !request.allowedNetworks().contains(getNetwork());
+ return !preferences.allowedNetworks().contains(getNetwork());
}
}
diff --git a/src/main/java/org/opentripplanner/service/vehiclerental/street/StreetVehicleRentalLink.java b/src/main/java/org/opentripplanner/service/vehiclerental/street/StreetVehicleRentalLink.java
index 96bbdaf4c0d..4a18aae03c2 100644
--- a/src/main/java/org/opentripplanner/service/vehiclerental/street/StreetVehicleRentalLink.java
+++ b/src/main/java/org/opentripplanner/service/vehiclerental/street/StreetVehicleRentalLink.java
@@ -52,7 +52,8 @@ public State[] traverse(State s0) {
return State.empty();
}
- if (vehicleRentalPlaceVertex.getStation().networkIsNotAllowed(s0.getRequest().rental())) {
+ var preferences = s0.getPreferences().rental(s0.getRequest().mode());
+ if (vehicleRentalPlaceVertex.getStation().networkIsNotAllowed(preferences)) {
return State.empty();
}
diff --git a/src/main/java/org/opentripplanner/service/vehiclerental/street/VehicleRentalEdge.java b/src/main/java/org/opentripplanner/service/vehiclerental/street/VehicleRentalEdge.java
index 9ec6cf79003..66665f73b54 100644
--- a/src/main/java/org/opentripplanner/service/vehiclerental/street/VehicleRentalEdge.java
+++ b/src/main/java/org/opentripplanner/service/vehiclerental/street/VehicleRentalEdge.java
@@ -49,10 +49,10 @@ public State[] traverse(State s0) {
VehicleRentalPlaceVertex stationVertex = (VehicleRentalPlaceVertex) tov;
VehicleRentalPlace station = stationVertex.getStation();
String network = station.getNetwork();
- var preferences = s0.getPreferences();
- boolean realtimeAvailability = preferences.rental().useAvailabilityInformation();
+ var preferences = s0.getPreferences().rental(formFactor.traverseMode);
+ boolean realtimeAvailability = preferences.useAvailabilityInformation();
- if (station.networkIsNotAllowed(s0.getRequest().rental())) {
+ if (station.networkIsNotAllowed(preferences)) {
return State.empty();
}
@@ -128,7 +128,7 @@ public State[] traverse(State s0) {
s1.beginFloatingVehicleRenting(formFactor, network, false);
} else {
boolean mayKeep =
- s0.getRequest().rental().allowArrivingInRentedVehicleAtDestination() &&
+ preferences.allowArrivingInRentedVehicleAtDestination() &&
station.isArrivingInRentalVehicleAtDestinationAllowed();
s1.beginVehicleRentingAtStation(formFactor, network, mayKeep, false);
}
@@ -161,12 +161,8 @@ public State[] traverse(State s0) {
}
}
- s1.incrementWeight(
- pickedUp ? preferences.rental().pickupCost() : preferences.rental().dropoffCost()
- );
- s1.incrementTimeInSeconds(
- pickedUp ? preferences.rental().pickupTime() : preferences.rental().dropoffTime()
- );
+ s1.incrementWeight(pickedUp ? preferences.pickupCost() : preferences.dropoffCost());
+ s1.incrementTimeInSeconds(pickedUp ? preferences.pickupTime() : preferences.dropoffTime());
s1.setBackMode(null);
return s1.makeStateArray();
}
diff --git a/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java b/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java
index 0f61fa4f7a2..08371660b8a 100644
--- a/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java
+++ b/src/main/java/org/opentripplanner/standalone/config/routerconfig/UpdatersConfig.java
@@ -14,7 +14,6 @@
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.VEHICLE_PARKING;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.VEHICLE_POSITIONS;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.VEHICLE_RENTAL;
-import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.WEBSOCKET_GTFS_RT_UPDATER;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@@ -39,7 +38,6 @@
import org.opentripplanner.standalone.config.routerconfig.updaters.VehicleParkingUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.VehiclePositionsUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.VehicleRentalUpdaterConfig;
-import org.opentripplanner.standalone.config.routerconfig.updaters.WebsocketGtfsRealtimeUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.azure.SiriAzureETUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.azure.SiriAzureSXUpdaterConfig;
import org.opentripplanner.standalone.config.sandbox.VehicleRentalServiceDirectoryFetcherConfig;
@@ -48,7 +46,6 @@
import org.opentripplanner.updater.alert.GtfsRealtimeAlertsUpdaterParameters;
import org.opentripplanner.updater.trip.MqttGtfsRealtimeUpdaterParameters;
import org.opentripplanner.updater.trip.PollingTripUpdaterParameters;
-import org.opentripplanner.updater.trip.WebsocketGtfsRealtimeUpdaterParameters;
import org.opentripplanner.updater.vehicle_parking.VehicleParkingUpdaterParameters;
import org.opentripplanner.updater.vehicle_position.VehiclePositionsUpdaterParameters;
import org.opentripplanner.updater.vehicle_rental.VehicleRentalUpdaterParameters;
@@ -185,11 +182,6 @@ public List getSiriSXUpdaterParameters() {
return getParameters(SIRI_SX_UPDATER);
}
- @Override
- public List getWebsocketGtfsRealtimeUpdaterParameters() {
- return getParameters(WEBSOCKET_GTFS_RT_UPDATER);
- }
-
@Override
public List getMqttGtfsRealtimeUpdaterParameters() {
return getParameters(MQTT_GTFS_RT_UPDATER);
@@ -222,7 +214,6 @@ public enum Type {
BIKE_RENTAL(VehicleRentalUpdaterConfig::create),
VEHICLE_RENTAL(VehicleRentalUpdaterConfig::create),
STOP_TIME_UPDATER(PollingTripUpdaterConfig::create),
- WEBSOCKET_GTFS_RT_UPDATER(WebsocketGtfsRealtimeUpdaterConfig::create),
MQTT_GTFS_RT_UPDATER(MqttGtfsRealtimeUpdaterConfig::create),
REAL_TIME_ALERTS(GtfsRealtimeAlertsUpdaterConfig::create),
VEHICLE_POSITIONS(VehiclePositionsUpdaterConfig::create),
diff --git a/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java b/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java
index 372bd36227e..ccc4ca5e80f 100644
--- a/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java
+++ b/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/MqttGtfsRealtimeUpdaterConfig.java
@@ -1,6 +1,6 @@
package org.opentripplanner.standalone.config.routerconfig.updaters;
-import static org.opentripplanner.standalone.config.framework.json.OtpVersion.NA;
+import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_0;
import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_2;
import org.opentripplanner.standalone.config.framework.json.NodeAdapter;
@@ -12,13 +12,13 @@ public class MqttGtfsRealtimeUpdaterConfig {
public static MqttGtfsRealtimeUpdaterParameters create(String configRef, NodeAdapter c) {
return new MqttGtfsRealtimeUpdaterParameters(
configRef,
- c.of("feedId").since(NA).summary("The feed id to apply the updates to.").asString(),
- c.of("url").since(NA).summary("URL of the MQTT broker.").asString(),
- c.of("topic").since(NA).summary("The topic to subscribe to.").asString(),
- c.of("qos").since(NA).summary("QOS level.").asInt(0),
+ c.of("feedId").since(V2_0).summary("The feed id to apply the updates to.").asString(),
+ c.of("url").since(V2_0).summary("URL of the MQTT broker.").asString(),
+ c.of("topic").since(V2_0).summary("The topic to subscribe to.").asString(),
+ c.of("qos").since(V2_0).summary("QOS level.").asInt(0),
c
.of("fuzzyTripMatching")
- .since(NA)
+ .since(V2_0)
.summary("Whether to match trips fuzzily.")
.asBoolean(false),
c
diff --git a/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/WebsocketGtfsRealtimeUpdaterConfig.java b/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/WebsocketGtfsRealtimeUpdaterConfig.java
deleted file mode 100644
index 5f1c203ca43..00000000000
--- a/src/main/java/org/opentripplanner/standalone/config/routerconfig/updaters/WebsocketGtfsRealtimeUpdaterConfig.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.opentripplanner.standalone.config.routerconfig.updaters;
-
-import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V1_5;
-
-import org.opentripplanner.standalone.config.framework.json.NodeAdapter;
-import org.opentripplanner.updater.trip.BackwardsDelayPropagationType;
-import org.opentripplanner.updater.trip.WebsocketGtfsRealtimeUpdaterParameters;
-
-public class WebsocketGtfsRealtimeUpdaterConfig {
-
- public static WebsocketGtfsRealtimeUpdaterParameters create(String configRef, NodeAdapter c) {
- return new WebsocketGtfsRealtimeUpdaterParameters(
- configRef,
- c.of("feedId").since(V1_5).summary("TODO").asString(),
- c.of("url").since(V1_5).summary("TODO").asString(null),
- c.of("reconnectPeriodSec").since(V1_5).summary("TODO").asInt(60),
- c
- .of("backwardsDelayPropagationType")
- .since(V1_5)
- .summary("TODO")
- .asEnum(BackwardsDelayPropagationType.REQUIRED_NO_DATA)
- );
- }
-}
diff --git a/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java b/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java
index f6a79ea9192..b733b2c7d8d 100644
--- a/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java
+++ b/src/main/java/org/opentripplanner/standalone/config/routerequest/RouteRequestConfig.java
@@ -167,25 +167,20 @@ cost function. The cost function (`unpreferredCost`) is defined as a linear func
.asFeedScopedIds(request.journey().transit().unpreferredAgencies())
);
- TransitPriorityGroupConfig.mapTransitRequest(c, request.journey().transit());
+ TransitGroupPriorityConfig.mapTransitRequest(c, request.journey().transit());
// Map preferences
- request.withPreferences(preferences -> mapPreferences(c, request, preferences));
+ request.withPreferences(preferences -> mapPreferences(c, preferences));
return request;
}
- private static void mapPreferences(
- NodeAdapter c,
- RouteRequest request,
- RoutingPreferences.Builder preferences
- ) {
+ private static void mapPreferences(NodeAdapter c, RoutingPreferences.Builder preferences) {
preferences.withTransit(it -> mapTransitPreferences(c, it));
preferences.withBike(it -> mapBikePreferences(c, it));
preferences.withStreet(it -> mapStreetPreferences(c, it));
preferences.withCar(it -> mapCarPreferences(c, it));
preferences.withSystem(it -> mapSystemPreferences(c, it));
- preferences.withRental(it -> setVehicleRental(c, request, it));
preferences.withTransfer(it -> mapTransferPreferences(c, it));
preferences.withWalk(it -> mapWalkPreferences(c, it));
preferences.withWheelchair(it -> mapWheelchairPreferences(c, it, WHEELCHAIR_ACCESSIBILITY));
@@ -297,25 +292,24 @@ The board time is added to the time when going from the stop (offboard) to onboa
.asCostLinearFunction(dft.unpreferredCost())
);
- String relaxTransitPriorityGroupValue = c
- .of("relaxTransitPriorityGroup")
+ String relaxTransitGroupPriorityValue = c
+ .of("relaxTransitGroupPriority")
.since(V2_5)
- .summary("The relax function for transit-priority-groups")
+ .summary("The relax function for transit-group-priority")
.description(
"""
- A path is considered optimal if the generalized-cost is less than the
- generalized-cost of another path. If this parameter is set, the comparison is relaxed
- further if they belong to different transit-priority-groups.
+ A path is considered optimal if the generalized-cost is less than the generalized-cost of
+ another path. If this parameter is set, the comparison is relaxed further if they belong
+ to different transit groups.
"""
)
- .asString(dft.relaxTransitPriorityGroup().toString());
+ .asString(dft.relaxTransitGroupPriority().toString());
- if (relaxTransitPriorityGroupValue != null) {
- builder.withTransitGroupPriorityGeneralizedCostSlack(
- CostLinearFunction.of(relaxTransitPriorityGroupValue)
- );
+ if (relaxTransitGroupPriorityValue != null) {
+ builder.withRelaxTransitGroupPriority(CostLinearFunction.of(relaxTransitGroupPriorityValue));
}
+ // TODO REMOVE THIS
builder.withRaptor(it ->
c
.of("relaxTransitSearchGeneralizedCostAtDestination")
@@ -508,7 +502,8 @@ Vehicle parking tags can originate from different places depending on the origin
)
.asStringSet(List.of())
)
- );
+ )
+ .withRental(it -> setVehicleRental(c, it));
}
private static void mapStreetPreferences(NodeAdapter c, StreetPreferences.Builder builder) {
@@ -821,7 +816,8 @@ Vehicle parking tags can originate from different places depending on the origin
)
.asStringSet(List.of())
)
- );
+ )
+ .withRental(it -> setVehicleRental(c, it));
}
private static void mapSystemPreferences(NodeAdapter c, SystemPreferences.Builder builder) {
diff --git a/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitPriorityGroupConfig.java b/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java
similarity index 76%
rename from src/main/java/org/opentripplanner/standalone/config/routerequest/TransitPriorityGroupConfig.java
rename to src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java
index 51faafc7cbf..e5f1ccd784a 100644
--- a/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitPriorityGroupConfig.java
+++ b/src/main/java/org/opentripplanner/standalone/config/routerequest/TransitGroupPriorityConfig.java
@@ -6,36 +6,36 @@
import java.util.Collection;
import java.util.List;
import org.opentripplanner.routing.api.request.request.TransitRequest;
-import org.opentripplanner.routing.api.request.request.filter.TransitPriorityGroupSelect;
+import org.opentripplanner.routing.api.request.request.filter.TransitGroupSelect;
import org.opentripplanner.standalone.config.framework.json.NodeAdapter;
import org.opentripplanner.standalone.config.framework.json.OtpVersion;
import org.opentripplanner.transit.model.basic.TransitMode;
-public class TransitPriorityGroupConfig {
+public class TransitGroupPriorityConfig {
public static void mapTransitRequest(NodeAdapter root, TransitRequest transit) {
var c = root
- .of("transitPriorityGroups")
+ .of("transitGroupPriority")
.since(OtpVersion.V2_5)
- .summary("Transit priority groups configuration")
+ .summary(
+ "Group transit patterns and give each group a mutual advantage in the Raptor search."
+ )
.description(
"""
Use this to separate transit patterns into groups. Each group will be given a group-id. A
path (multiple legs) will then have a set of group-ids based on the group-id from each leg.
Hence, two paths with a different set of group-ids will BOTH be optimal unless the cost is
- worse than the relaxation specified in the `relaxTransitPriorityGroup` parameter. This is
+ worse than the relaxation specified in the `relaxTransitGroupPriority` parameter. This is
only available in the TransmodelAPI for now.
- Unmatched patterns are put in the BASE priority-group (group id: 0). This group is special.
- If a path only have legs in the base group, then that path dominates other paths, but other
- paths must be better to make it.
+ Unmatched patterns are put in the BASE priority-group.
"""
)
.experimentalFeature()
.asObject();
transit.addPriorityGroupsByAgency(
- TransitPriorityGroupConfig.mapList(
+ TransitGroupPriorityConfig.mapList(
c,
"byAgency",
"All groups here are split by agency. For example if you list mode " +
@@ -44,7 +44,7 @@ public static void mapTransitRequest(NodeAdapter root, TransitRequest transit) {
)
);
transit.addPriorityGroupsGlobal(
- TransitPriorityGroupConfig.mapList(
+ TransitGroupPriorityConfig.mapList(
c,
"global",
"All services matching a 'global' group will get the same group-id. Use this " +
@@ -53,7 +53,7 @@ public static void mapTransitRequest(NodeAdapter root, TransitRequest transit) {
);
}
- private static Collection mapList(
+ private static Collection mapList(
NodeAdapter root,
String parameterName,
String description
@@ -61,13 +61,13 @@ private static Collection mapList(
return root
.of(parameterName)
.since(V2_5)
- .summary("Configuration for transit priority groups.")
+ .summary("List of transit groups.")
.description(description + " The max total number of group-ids are 32, so be careful.")
- .asObjects(TransitPriorityGroupConfig::mapTransitGroupSelect);
+ .asObjects(TransitGroupPriorityConfig::mapTransitGroupSelect);
}
- private static TransitPriorityGroupSelect mapTransitGroupSelect(NodeAdapter c) {
- return TransitPriorityGroupSelect
+ private static TransitGroupSelect mapTransitGroupSelect(NodeAdapter c) {
+ return TransitGroupSelect
.of()
.addModes(
c
diff --git a/src/main/java/org/opentripplanner/standalone/config/routerequest/VehicleRentalConfig.java b/src/main/java/org/opentripplanner/standalone/config/routerequest/VehicleRentalConfig.java
index 94f392cc313..057daa7001c 100644
--- a/src/main/java/org/opentripplanner/standalone/config/routerequest/VehicleRentalConfig.java
+++ b/src/main/java/org/opentripplanner/standalone/config/routerequest/VehicleRentalConfig.java
@@ -5,10 +5,7 @@
import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_2;
import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_3;
-import org.opentripplanner.routing.api.request.RouteRequest;
-import org.opentripplanner.routing.api.request.preference.RoutingPreferences;
import org.opentripplanner.routing.api.request.preference.VehicleRentalPreferences;
-import org.opentripplanner.routing.api.request.request.VehicleRentalRequest;
import org.opentripplanner.standalone.config.framework.json.NodeAdapter;
public class VehicleRentalConfig {
@@ -53,56 +50,42 @@ static void mapRentalPreferences(NodeAdapter c, VehicleRentalPreferences.Builder
"The cost of arriving at the destination with the rented vehicle, to discourage doing so."
)
.asDouble(dft.arrivingInRentalVehicleAtDestinationCost())
- );
- }
-
- static void setVehicleRentalRequestOptions(NodeAdapter c, RouteRequest request) {
- VehicleRentalRequest vehicleRentalRequest = request.journey().rental();
-
- vehicleRentalRequest.setAllowedNetworks(
- c
- .of("allowedNetworks")
- .since(V2_1)
- .summary(
- "The vehicle rental networks which may be used. If empty all networks may be used."
- )
- .asStringSet(vehicleRentalRequest.allowedNetworks())
- );
- vehicleRentalRequest.setBannedNetworks(
- c
- .of("bannedNetworks")
- .since(V2_1)
- .summary(
- "The vehicle rental networks which may not be used. If empty, no networks are banned."
- )
- .asStringSet(vehicleRentalRequest.bannedNetworks())
- );
-
- request
- .journey()
- .rental()
- .setAllowArrivingInRentedVehicleAtDestination(
+ )
+ .withAllowArrivingInRentedVehicleAtDestination(
c
.of("allowKeepingAtDestination")
.since(V2_2)
.summary(
"If a vehicle should be allowed to be kept at the end of a station-based rental."
)
- .asBoolean(request.journey().rental().allowArrivingInRentedVehicleAtDestination())
+ .asBoolean(dft.allowArrivingInRentedVehicleAtDestination())
+ )
+ .withAllowedNetworks(
+ c
+ .of("allowedNetworks")
+ .since(V2_1)
+ .summary(
+ "The vehicle rental networks which may be used. If empty all networks may be used."
+ )
+ .asStringSet(dft.allowedNetworks())
+ )
+ .withBannedNetworks(
+ c
+ .of("bannedNetworks")
+ .since(V2_1)
+ .summary(
+ "The vehicle rental networks which may not be used. If empty, no networks are banned."
+ )
+ .asStringSet(dft.bannedNetworks())
);
}
- static void setVehicleRental(
- NodeAdapter c,
- RouteRequest request,
- VehicleRentalPreferences.Builder preferences
- ) {
+ static void setVehicleRental(NodeAdapter c, VehicleRentalPreferences.Builder preferences) {
var vehicleRental = c
.of("vehicleRental")
.since(V2_3)
.summary("Vehicle rental options")
.asObject();
mapRentalPreferences(vehicleRental, preferences);
- setVehicleRentalRequestOptions(vehicleRental, request);
}
}
diff --git a/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java b/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java
index c422e9c24f3..7dc7c87f735 100644
--- a/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java
+++ b/src/main/java/org/opentripplanner/standalone/server/GrizzlyServer.java
@@ -102,7 +102,7 @@ public void run() {
httpServer.getServerConfiguration().addHttpHandler(dynamicHandler, "/otp/");
/* 2. A static content handler to serve the client JS apps etc. from the classpath. */
- if (OTPFeature.DebugClient.isOn()) {
+ if (OTPFeature.DebugUi.isOn()) {
CLStaticHttpHandler staticHandler = new CLStaticHttpHandler(
GrizzlyServer.class.getClassLoader(),
"/client/"
diff --git a/src/main/java/org/opentripplanner/standalone/server/OTPWebApplication.java b/src/main/java/org/opentripplanner/standalone/server/OTPWebApplication.java
index 56aaa2d1361..b238a74c7d3 100644
--- a/src/main/java/org/opentripplanner/standalone/server/OTPWebApplication.java
+++ b/src/main/java/org/opentripplanner/standalone/server/OTPWebApplication.java
@@ -7,7 +7,6 @@
import io.micrometer.prometheus.PrometheusMeterRegistry;
import jakarta.ws.rs.container.ContainerResponseFilter;
import jakarta.ws.rs.core.Application;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -17,10 +16,9 @@
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.internal.inject.Binder;
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
-import org.glassfish.jersey.server.ServerProperties;
import org.opentripplanner.api.common.OTPExceptionMapper;
-import org.opentripplanner.api.configuration.APIEndpoints;
-import org.opentripplanner.api.json.JSONObjectMapperProvider;
+import org.opentripplanner.apis.APIEndpoints;
+import org.opentripplanner.ext.restapi.serialization.JSONObjectMapperProvider;
import org.opentripplanner.framework.application.OTPFeature;
import org.opentripplanner.standalone.api.OtpServerRequestContext;
import org.slf4j.bridge.SLF4JBridgeHandler;
diff --git a/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java b/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java
index 4fe66735532..926eebc31d9 100644
--- a/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java
+++ b/src/main/java/org/opentripplanner/street/model/edge/StreetTransitEntityLink.java
@@ -98,7 +98,11 @@ else if (
s0.isRentingVehicleFromStation() &&
!(
s0.mayKeepRentedVehicleAtDestination() &&
- s0.getRequest().rental().allowArrivingInRentedVehicleAtDestination()
+ s0
+ .getRequest()
+ .preferences()
+ .rental(s0.getRequest().mode())
+ .allowArrivingInRentedVehicleAtDestination()
)
) {
yield State.empty();
@@ -133,12 +137,13 @@ else if (
@Nonnull
private State[] buildState(State s0, StateEditor s1, RoutingPreferences pref) {
+ var rentalPreferences = s0.getRequest().preferences().rental(s0.getRequest().mode());
if (
s0.isRentingVehicleFromStation() &&
s0.mayKeepRentedVehicleAtDestination() &&
- s0.getRequest().rental().allowArrivingInRentedVehicleAtDestination()
+ rentalPreferences.allowArrivingInRentedVehicleAtDestination()
) {
- s1.incrementWeight(pref.rental().arrivingInRentalVehicleAtDestinationCost());
+ s1.incrementWeight(rentalPreferences.arrivingInRentalVehicleAtDestinationCost());
}
s1.setBackMode(null);
diff --git a/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java b/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java
index 35045db848a..011d0fec7f1 100644
--- a/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java
+++ b/src/main/java/org/opentripplanner/street/model/edge/TemporaryFreeEdge.java
@@ -42,12 +42,13 @@ public State[] traverse(State s0) {
s1.incrementWeight(1);
s1.setBackMode(null);
+ var rentalPreferences = s0.getPreferences().rental(s0.getRequest().mode());
if (
s0.isRentingVehicleFromStation() &&
s0.mayKeepRentedVehicleAtDestination() &&
- s0.getRequest().rental().allowArrivingInRentedVehicleAtDestination()
+ rentalPreferences.allowArrivingInRentedVehicleAtDestination()
) {
- s1.incrementWeight(s0.getPreferences().rental().arrivingInRentalVehicleAtDestinationCost());
+ s1.incrementWeight(rentalPreferences.arrivingInRentalVehicleAtDestinationCost());
}
return s1.makeStateArray();
diff --git a/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java b/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java
index b4ac98674d0..079cd29706f 100644
--- a/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java
+++ b/src/main/java/org/opentripplanner/street/search/StreetSearchBuilder.java
@@ -102,7 +102,7 @@ protected void prepareInitialStates(Collection initialStates) {
@Override
protected void initializeHeuristic(
RemainingWeightHeuristic heuristic,
- Set origin,
+ Set ignored,
Set destination,
boolean arriveBy
) {
@@ -111,7 +111,6 @@ protected void initializeHeuristic(
} else if (heuristic instanceof EuclideanRemainingWeightHeuristic euclideanHeuristic) {
euclideanHeuristic.initialize(
streetRequest.mode(),
- origin,
destination,
arriveBy,
routeRequest.preferences()
diff --git a/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java b/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java
index 6d8bd5783f3..c33ed6a35e9 100644
--- a/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java
+++ b/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequest.java
@@ -12,7 +12,6 @@
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.api.request.StreetMode;
import org.opentripplanner.routing.api.request.preference.RoutingPreferences;
-import org.opentripplanner.routing.api.request.request.VehicleRentalRequest;
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.street.search.intersection_model.IntersectionTraversalCalculator;
import org.opentripplanner.street.search.state.State;
@@ -39,7 +38,6 @@ public class StreetSearchRequest implements AStarRequest {
private final StreetMode mode;
private final boolean arriveBy;
private final boolean wheelchair;
- private final VehicleRentalRequest rental;
private final GenericLocation from;
private final Envelope fromEnvelope;
@@ -60,7 +58,6 @@ private StreetSearchRequest() {
this.mode = StreetMode.WALK;
this.arriveBy = false;
this.wheelchair = false;
- this.rental = new VehicleRentalRequest();
this.from = null;
this.fromEnvelope = null;
this.to = null;
@@ -73,7 +70,6 @@ private StreetSearchRequest() {
this.mode = builder.mode;
this.arriveBy = builder.arriveBy;
this.wheelchair = builder.wheelchair;
- this.rental = builder.rental;
this.from = builder.from;
this.fromEnvelope = createEnvelope(from);
this.to = builder.to;
@@ -115,10 +111,6 @@ public boolean wheelchair() {
return wheelchair;
}
- public VehicleRentalRequest rental() {
- return rental;
- }
-
public GenericLocation from() {
return from;
}
diff --git a/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestBuilder.java b/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestBuilder.java
index 439e65a3289..fd2eff30e7e 100644
--- a/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestBuilder.java
+++ b/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestBuilder.java
@@ -5,7 +5,6 @@
import org.opentripplanner.model.GenericLocation;
import org.opentripplanner.routing.api.request.StreetMode;
import org.opentripplanner.routing.api.request.preference.RoutingPreferences;
-import org.opentripplanner.routing.api.request.request.VehicleRentalRequest;
public class StreetSearchRequestBuilder {
@@ -14,7 +13,6 @@ public class StreetSearchRequestBuilder {
RoutingPreferences preferences;
boolean arriveBy;
boolean wheelchair;
- VehicleRentalRequest rental;
GenericLocation from;
GenericLocation to;
@@ -24,7 +22,6 @@ public class StreetSearchRequestBuilder {
this.preferences = original.preferences();
this.arriveBy = original.arriveBy();
this.wheelchair = original.wheelchair();
- this.rental = original.rental();
this.from = original.from();
this.to = original.to();
}
@@ -58,11 +55,6 @@ public StreetSearchRequestBuilder withWheelchair(boolean wheelchair) {
return this;
}
- public StreetSearchRequestBuilder withRental(VehicleRentalRequest rental) {
- this.rental = rental;
- return this;
- }
-
public StreetSearchRequestBuilder withFrom(GenericLocation from) {
this.from = from;
return this;
diff --git a/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java b/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java
index 9f1f3c567f8..b4193e709e3 100644
--- a/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java
+++ b/src/main/java/org/opentripplanner/street/search/request/StreetSearchRequestMapper.java
@@ -11,7 +11,6 @@ public static StreetSearchRequestBuilder map(RouteRequest opt) {
.withStartTime(opt.dateTime())
.withPreferences(opt.preferences())
.withWheelchair(opt.wheelchair())
- .withRental(opt.journey().rental())
.withFrom(opt.from())
.withTo(opt.to());
}
@@ -22,7 +21,6 @@ public static StreetSearchRequestBuilder mapToTransferRequest(RouteRequest opt)
.withStartTime(Instant.ofEpochSecond(0))
.withPreferences(opt.preferences())
.withWheelchair(opt.wheelchair())
- .withRental(opt.journey().rental())
.withMode(opt.journey().transfer().mode());
}
}
diff --git a/src/main/java/org/opentripplanner/street/search/state/State.java b/src/main/java/org/opentripplanner/street/search/state/State.java
index 37c3e81c097..deef516a674 100644
--- a/src/main/java/org/opentripplanner/street/search/state/State.java
+++ b/src/main/java/org/opentripplanner/street/search/state/State.java
@@ -214,7 +214,10 @@ private boolean vehicleRentalIsFinished() {
!stateData.insideNoRentalDropOffArea
) ||
(
- getRequest().rental().allowArrivingInRentedVehicleAtDestination() &&
+ getRequest()
+ .preferences()
+ .rental(getRequest().mode())
+ .allowArrivingInRentedVehicleAtDestination() &&
stateData.mayKeepRentedVehicleAtDestination &&
stateData.vehicleRentalState == VehicleRentalState.RENTING_FROM_STATION
)
@@ -503,7 +506,10 @@ private double getWalkDistanceDelta() {
private State reversedClone() {
StreetSearchRequest reversedRequest = request
.copyOfReversed(getTime())
- .withPreferences(p -> p.withRental(r -> r.withUseAvailabilityInformation(false)))
+ .withPreferences(p -> {
+ p.withCar(c -> c.withRental(r -> r.withUseAvailabilityInformation(false)));
+ p.withBike(b -> b.withRental(r -> r.withUseAvailabilityInformation(false)));
+ })
.build();
StateData newStateData = stateData.clone();
newStateData.backMode = null;
diff --git a/src/main/java/org/opentripplanner/street/search/state/StateData.java b/src/main/java/org/opentripplanner/street/search/state/StateData.java
index 77d359248aa..cc2bfa5a57a 100644
--- a/src/main/java/org/opentripplanner/street/search/state/StateData.java
+++ b/src/main/java/org/opentripplanner/street/search/state/StateData.java
@@ -83,10 +83,11 @@ public static List getInitialStateDatas(
StreetSearchRequest request,
Function stateDataConstructor
) {
+ var rentalPreferences = request.preferences().rental(request.mode());
return getInitialStateDatas(
request.mode(),
request.arriveBy(),
- request.rental().allowArrivingInRentedVehicleAtDestination(),
+ rentalPreferences.allowArrivingInRentedVehicleAtDestination(),
stateDataConstructor
);
}
@@ -97,10 +98,11 @@ public static List getInitialStateDatas(
* the given {@code request}.
*/
public static StateData getBaseCaseStateData(StreetSearchRequest request) {
+ var rentalPreferences = request.preferences().rental(request.mode());
var stateDatas = getInitialStateDatas(
request.mode(),
request.arriveBy(),
- request.rental().allowArrivingInRentedVehicleAtDestination(),
+ rentalPreferences.allowArrivingInRentedVehicleAtDestination(),
StateData::new
);
diff --git a/src/main/java/org/opentripplanner/street/search/strategy/EuclideanRemainingWeightHeuristic.java b/src/main/java/org/opentripplanner/street/search/strategy/EuclideanRemainingWeightHeuristic.java
index 36e4a57f8ec..e43278901d4 100644
--- a/src/main/java/org/opentripplanner/street/search/strategy/EuclideanRemainingWeightHeuristic.java
+++ b/src/main/java/org/opentripplanner/street/search/strategy/EuclideanRemainingWeightHeuristic.java
@@ -26,7 +26,6 @@ public class EuclideanRemainingWeightHeuristic implements RemainingWeightHeurist
// not work correctly.
public void initialize(
StreetMode streetMode,
- Set fromVertices,
Set toVertices,
boolean arriveBy,
RoutingPreferences preferences
diff --git a/src/main/java/org/opentripplanner/updater/UpdatersParameters.java b/src/main/java/org/opentripplanner/updater/UpdatersParameters.java
index 8a7c422eb03..a955e757100 100644
--- a/src/main/java/org/opentripplanner/updater/UpdatersParameters.java
+++ b/src/main/java/org/opentripplanner/updater/UpdatersParameters.java
@@ -10,7 +10,6 @@
import org.opentripplanner.updater.alert.GtfsRealtimeAlertsUpdaterParameters;
import org.opentripplanner.updater.trip.MqttGtfsRealtimeUpdaterParameters;
import org.opentripplanner.updater.trip.PollingTripUpdaterParameters;
-import org.opentripplanner.updater.trip.WebsocketGtfsRealtimeUpdaterParameters;
import org.opentripplanner.updater.vehicle_parking.VehicleParkingUpdaterParameters;
import org.opentripplanner.updater.vehicle_position.VehiclePositionsUpdaterParameters;
import org.opentripplanner.updater.vehicle_rental.VehicleRentalUpdaterParameters;
@@ -34,8 +33,6 @@ public interface UpdatersParameters {
List getSiriSXUpdaterParameters();
- List getWebsocketGtfsRealtimeUpdaterParameters();
-
List getMqttGtfsRealtimeUpdaterParameters();
List getVehicleParkingUpdaterParameters();
diff --git a/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java b/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java
index 037bd080f47..c755578da41 100644
--- a/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java
+++ b/src/main/java/org/opentripplanner/updater/configure/UpdaterConfigurator.java
@@ -23,14 +23,11 @@
import org.opentripplanner.updater.trip.MqttGtfsRealtimeUpdater;
import org.opentripplanner.updater.trip.PollingTripUpdater;
import org.opentripplanner.updater.trip.TimetableSnapshotSource;
-import org.opentripplanner.updater.trip.WebsocketGtfsRealtimeUpdater;
import org.opentripplanner.updater.vehicle_parking.VehicleParkingDataSourceFactory;
import org.opentripplanner.updater.vehicle_parking.VehicleParkingUpdater;
import org.opentripplanner.updater.vehicle_position.PollingVehiclePositionUpdater;
import org.opentripplanner.updater.vehicle_rental.VehicleRentalUpdater;
import org.opentripplanner.updater.vehicle_rental.datasources.VehicleRentalDataSourceFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Sets up and starts all the graph updaters.
@@ -41,8 +38,6 @@
*/
public class UpdaterConfigurator {
- private static final Logger LOG = LoggerFactory.getLogger(UpdaterConfigurator.class);
-
private final Graph graph;
private final TransitModel transitModel;
private final UpdatersParameters updatersParameters;
@@ -177,11 +172,6 @@ private List createUpdatersFromConfig() {
for (var configItem : updatersParameters.getSiriSXUpdaterParameters()) {
updaters.add(new SiriSXUpdater(configItem, transitModel));
}
- for (var configItem : updatersParameters.getWebsocketGtfsRealtimeUpdaterParameters()) {
- updaters.add(
- new WebsocketGtfsRealtimeUpdater(configItem, provideGtfsTimetableSnapshot(), transitModel)
- );
- }
for (var configItem : updatersParameters.getMqttGtfsRealtimeUpdaterParameters()) {
updaters.add(
new MqttGtfsRealtimeUpdater(configItem, transitModel, provideGtfsTimetableSnapshot())
diff --git a/src/main/java/org/opentripplanner/updater/trip/WebsocketGtfsRealtimeUpdater.java b/src/main/java/org/opentripplanner/updater/trip/WebsocketGtfsRealtimeUpdater.java
deleted file mode 100644
index 007c73d9b9b..00000000000
--- a/src/main/java/org/opentripplanner/updater/trip/WebsocketGtfsRealtimeUpdater.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.opentripplanner.updater.trip;
-
-import static org.asynchttpclient.Dsl.asyncHttpClient;
-
-import com.google.protobuf.InvalidProtocolBufferException;
-import com.google.transit.realtime.GtfsRealtime;
-import com.google.transit.realtime.GtfsRealtime.FeedEntity;
-import com.google.transit.realtime.GtfsRealtime.FeedMessage;
-import com.google.transit.realtime.GtfsRealtime.TripUpdate;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.function.Consumer;
-import org.asynchttpclient.AsyncHttpClient;
-import org.asynchttpclient.ws.WebSocket;
-import org.asynchttpclient.ws.WebSocketListener;
-import org.asynchttpclient.ws.WebSocketUpgradeHandler;
-import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.TransitModel;
-import org.opentripplanner.updater.GtfsRealtimeFuzzyTripMatcher;
-import org.opentripplanner.updater.spi.GraphUpdater;
-import org.opentripplanner.updater.spi.UpdateResult;
-import org.opentripplanner.updater.spi.WriteToGraphCallback;
-import org.opentripplanner.updater.trip.metrics.TripUpdateMetrics;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class starts an HTTP client which opens a websocket connection to a GTFS-RT data source. A
- * callback is registered which handles incoming GTFS-RT messages as they stream in by placing a
- * GTFS-RT decoder Runnable task in the single-threaded executor for handling.
- *
- *
- * websocket.type = websocket-gtfs-rt-updater
- * websocket.defaultAgencyId = agency
- * websocket.url = ws://localhost:8088/tripUpdates
- *
- */
-public class WebsocketGtfsRealtimeUpdater implements GraphUpdater {
-
- private static final Logger LOG = LoggerFactory.getLogger(WebsocketGtfsRealtimeUpdater.class);
-
- /**
- * Number of seconds to wait before checking again whether we are still connected
- */
- private static final int CHECK_CONNECTION_PERIOD_SEC = 1;
-
- /**
- * Url of the websocket server
- */
- private final String url;
-
- /**
- * The ID for the static feed to which these TripUpdates are applied
- */
- private final String feedId;
-
- /**
- * The number of seconds to wait before reconnecting after a failed connection.
- */
- private final int reconnectPeriodSec;
-
- private final String configRef;
-
- private final BackwardsDelayPropagationType backwardsDelayPropagationType;
-
- private final TimetableSnapshotSource snapshotSource;
-
- /**
- * Parent update manager. Is used to execute graph writer runnables.
- */
- private WriteToGraphCallback saveResultOnGraph;
-
- private GtfsRealtimeFuzzyTripMatcher fuzzyTripMatcher;
-
- private final Consumer recordMetrics;
-
- public WebsocketGtfsRealtimeUpdater(
- WebsocketGtfsRealtimeUpdaterParameters parameters,
- TimetableSnapshotSource snapshotSource,
- TransitModel transitModel
- ) {
- this.configRef = parameters.configRef();
- this.url = parameters.url();
- this.feedId = parameters.feedId();
- this.reconnectPeriodSec = parameters.getReconnectPeriodSec();
- this.backwardsDelayPropagationType = parameters.getBackwardsDelayPropagationType();
- this.snapshotSource = snapshotSource;
- this.fuzzyTripMatcher =
- new GtfsRealtimeFuzzyTripMatcher(new DefaultTransitService(transitModel));
- this.recordMetrics = TripUpdateMetrics.streaming(parameters);
- }
-
- @Override
- public void setGraphUpdaterManager(WriteToGraphCallback saveResultOnGraph) {
- this.saveResultOnGraph = saveResultOnGraph;
- }
-
- @Override
- public void run() throws InterruptedException, IOException {
- while (true) {
- AsyncHttpClient client = asyncHttpClient();
- WebSocketListener listener = new Listener();
- WebSocketUpgradeHandler handler = new WebSocketUpgradeHandler.Builder()
- .addWebSocketListener(listener)
- .build();
- WebSocket socket = null;
- boolean connectionSuccessful = true;
- // Try to create a websocket connection
- try {
- socket = client.prepareGet(url).execute(handler).get();
- LOG.info("Successfully connected to {}.", url);
- } catch (ExecutionException e) {
- LOG.error("Could not connect to {}: {}", url, e.getCause().getMessage());
- connectionSuccessful = false;
- } catch (Exception e) {
- LOG.error("Unknown exception when trying to connect to {}.", url, e);
- connectionSuccessful = false;
- }
-
- // If connection was unsuccessful, wait some time before trying again
- if (!connectionSuccessful) {
- Thread.sleep(reconnectPeriodSec * 1000);
- }
-
- // Keep checking whether connection is still open
- while (true) {
- if (socket == null || !socket.isOpen()) {
- // The connection is closed somehow, try to reconnect
- if (connectionSuccessful) {
- LOG.warn("Connection to {} was lost. Trying to reconnect...", url);
- }
- break;
- }
- Thread.sleep(CHECK_CONNECTION_PERIOD_SEC * 1000);
- }
-
- client.close();
- }
- }
-
- @Override
- public String getConfigRef() {
- return configRef;
- }
-
- /**
- * Auxiliary class to handle incoming messages via the websocket connection
- */
- private class Listener implements WebSocketListener {
-
- @Override
- public void onOpen(WebSocket websocket) {}
-
- @Override
- public void onClose(WebSocket websocket, int code, String reason) {}
-
- @Override
- public void onError(Throwable t) {}
-
- @Override
- public void onBinaryFrame(byte[] message, boolean finalFragment, int rsv) {
- FeedMessage feedMessage;
- List feedEntityList;
- List updates = null;
- boolean fullDataset = true;
- try {
- // Decode message
- feedMessage = FeedMessage.PARSER.parseFrom(message);
- feedEntityList = feedMessage.getEntityList();
-
- // Change fullDataset value if this is an incremental update
- if (
- feedMessage.hasHeader() &&
- feedMessage.getHeader().hasIncrementality() &&
- feedMessage
- .getHeader()
- .getIncrementality()
- .equals(GtfsRealtime.FeedHeader.Incrementality.DIFFERENTIAL)
- ) {
- fullDataset = false;
- }
-
- // Create List of TripUpdates
- updates = new ArrayList<>(feedEntityList.size());
- for (FeedEntity feedEntity : feedEntityList) {
- if (feedEntity.hasTripUpdate()) {
- updates.add(feedEntity.getTripUpdate());
- }
- }
- } catch (InvalidProtocolBufferException e) {
- LOG.error("Could not decode gtfs-rt message:", e);
- }
-
- if (updates != null) {
- // Handle trip updates via graph writer runnable
- TripUpdateGraphWriterRunnable runnable = new TripUpdateGraphWriterRunnable(
- snapshotSource,
- fuzzyTripMatcher,
- backwardsDelayPropagationType,
- fullDataset,
- updates,
- feedId,
- recordMetrics
- );
- saveResultOnGraph.execute(runnable);
- }
- }
- }
-}
diff --git a/src/main/java/org/opentripplanner/updater/trip/WebsocketGtfsRealtimeUpdaterParameters.java b/src/main/java/org/opentripplanner/updater/trip/WebsocketGtfsRealtimeUpdaterParameters.java
deleted file mode 100644
index d5eebd748af..00000000000
--- a/src/main/java/org/opentripplanner/updater/trip/WebsocketGtfsRealtimeUpdaterParameters.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.opentripplanner.updater.trip;
-
-public class WebsocketGtfsRealtimeUpdaterParameters implements UrlUpdaterParameters {
-
- private final String configRef;
- private final String feedId;
- private final String url;
- private final int reconnectPeriodSec;
- private final BackwardsDelayPropagationType backwardsDelayPropagationType;
-
- public WebsocketGtfsRealtimeUpdaterParameters(
- String configRef,
- String feedId,
- String url,
- int reconnectPeriodSec,
- BackwardsDelayPropagationType backwardsDelayPropagationType
- ) {
- this.configRef = configRef;
- this.feedId = feedId;
- this.url = url;
- this.reconnectPeriodSec = reconnectPeriodSec;
- this.backwardsDelayPropagationType = backwardsDelayPropagationType;
- }
-
- public String url() {
- return url;
- }
-
- public String feedId() {
- return feedId;
- }
-
- int getReconnectPeriodSec() {
- return reconnectPeriodSec;
- }
-
- /** The config name/type for the updater. Used to reference the configuration element. */
- public String configRef() {
- return configRef;
- }
-
- public BackwardsDelayPropagationType getBackwardsDelayPropagationType() {
- return backwardsDelayPropagationType;
- }
-}
diff --git a/src/main/java/org/opentripplanner/visualizer/GraphVisualizer.java b/src/main/java/org/opentripplanner/visualizer/GraphVisualizer.java
index 73516b0348f..9f8bbffb22d 100644
--- a/src/main/java/org/opentripplanner/visualizer/GraphVisualizer.java
+++ b/src/main/java/org/opentripplanner/visualizer/GraphVisualizer.java
@@ -157,6 +157,10 @@ public DisplayVertex getElementAt(int index) {
* TransitStops only, and allows a user to select stops, examine incoming and outgoing edges, and
* examine trip patterns. It's meant mainly for debugging, so it's totally OK if it develops (say) a
* bunch of weird buttons designed to debug specific cases.
+ *
+ * 2024-01-26: We talked about the visualizer in the developer meeting and while the code is a bit
+ * dusty, we decided that we want to keep the option open to build make the visualization of routing
+ * steps work again in the future and won't delete it.
*/
public class GraphVisualizer extends JFrame implements VertexSelectionListener {
diff --git a/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql b/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql
index 349c05f63dd..9b49283c180 100644
--- a/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql
+++ b/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql
@@ -549,6 +549,8 @@ type PtSituationElement {
summary: [MultilingualString!]!
"Period this situation is in effect"
validityPeriod: ValidityPeriod
+ "Operator's version number for the situation element."
+ version: Int
"Timestamp when the situation element was updated."
versionedAtTime: DateTime
}
@@ -825,21 +827,21 @@ type QueryType {
passThroughPoints: [PassThroughPoint!],
"""
Relax generalized-cost when comparing trips with a different set of
- transit-priority-groups. The groups are set server side for service-journey and
+ transit-group-priorities. The groups are set server side for service-journey and
can not be configured in the API. This mainly helps to return competition neutral
- services. Long distance authorities are put in different transit-priority-groups.
+ services. Long distance authorities are put in different transit-groups.
This relaxes the comparison inside the routing engine for each stop-arrival. If two
- paths have a different set of transit-priority-groups, then the generalized-cost
+ paths have a different set of transit-group-priorities, then the generalized-cost
comparison is relaxed. The final set of paths are filtered through the normal
itinerary-filters.
- The `ratio` must be greater or equal to 1.0 and less then 1.2.
- - The `slack` must be greater or equal to 0 and less then 3600.
+ - The `constant` must be greater or equal to '0s' and less then '1h'.
THIS IS STILL AN EXPERIMENTAL FEATURE - IT MAY CHANGE WITHOUT ANY NOTICE!
"""
- relaxTransitPriorityGroup: RelaxCostInput = null,
+ relaxTransitGroupPriority: RelaxCostInput = null,
"""
Whether non-optimal transit paths at the destination should be returned. Let c be the
existing minimum pareto optimal generalized-cost to beat. Then a trip with cost c' is
@@ -852,7 +854,7 @@ type QueryType {
Values less than 1.0 is not allowed, and values greater than 2.0 are not
supported, due to performance reasons.
"""
- relaxTransitSearchGeneralizedCostAtDestination: Float = null @deprecated(reason : "This is replaced by 'relaxTransitPriorityGroup'."),
+ relaxTransitSearchGeneralizedCostAtDestination: Float = null @deprecated(reason : "This is replaced by 'relaxTransitGroupPriority'."),
"""
The length of the search-window in minutes. This parameter is optional.
@@ -1867,6 +1869,9 @@ enum WheelchairBoarding {
"List of coordinates like: [[60.89, 11.12], [62.56, 12.10]]"
scalar Coordinates
+"A cost value, normally a value of 1 is equivalent to riding transit for 1 second, but it might not depending on the use-case. Format: 3665 = DT1h1m5s = 1h1m5s"
+scalar Cost
+
"Local date using the ISO 8601 format: `YYYY-MM-DD`. Example: `2020-05-17`."
scalar Date
@@ -2028,12 +2033,12 @@ This is used to include more results into the result. A `ratio=2.0` means a path
with twice as high cost as another one, is accepted. A `constant=$300` means a "fixed"
constant is added to the limit. A `{ratio=1.0, constant=0}` is said to be the NORMAL relaxed
cost - the limit is the same as the cost used to calculate the limit. The NORMAL is usually
-the default. We can express the RelaxCost as a function `f(x) = constant + ratio * x`.
-`f(x)=x` is the NORMAL function.
+the default. We can express the RelaxCost as a function `f(t) = constant + ratio * t`.
+`f(t)=t` is the NORMAL function.
"""
input RelaxCostInput {
- "The constant value to add to the limit. Must be a positive number. The unit is cost-seconds."
- constant: [ID!] = 0
+ "The constant value to add to the limit. Must be a positive number. The value is equivalent to transit-cost-seconds. Integers are treated as seconds, but you may use the duration format. Example: '3665 = 'DT1h1m5s' = '1h1m5s'."
+ constant: Cost = "0s"
"The factor to multiply with the 'other cost'. Minimum value is 1.0."
ratio: Float = 1.0
}
diff --git a/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java b/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java
new file mode 100644
index 00000000000..6fa235cdf0b
--- /dev/null
+++ b/src/test/java/org/opentripplanner/apis/transmodel/model/plan/RelaxCostTypeTest.java
@@ -0,0 +1,71 @@
+package org.opentripplanner.apis.transmodel.model.plan;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.opentripplanner.apis.transmodel.model.plan.RelaxCostType.CONSTANT;
+import static org.opentripplanner.apis.transmodel.model.plan.RelaxCostType.RATIO;
+
+import graphql.language.FloatValue;
+import graphql.language.ObjectField;
+import graphql.language.ObjectValue;
+import graphql.language.StringValue;
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+import org.opentripplanner.framework.model.Cost;
+import org.opentripplanner.routing.api.request.framework.CostLinearFunction;
+
+class RelaxCostTypeTest {
+
+ @Test
+ void valueOf() {
+ assertEquals(
+ ObjectValue
+ .newObjectValue()
+ .objectField(ObjectField.newObjectField().name(RATIO).value(FloatValue.of(1.0)).build())
+ .objectField(
+ ObjectField.newObjectField().name(CONSTANT).value(StringValue.of("0s")).build()
+ )
+ .build()
+ .toString(),
+ RelaxCostType.valueOf(CostLinearFunction.NORMAL).toString()
+ );
+ assertEquals(
+ ObjectValue
+ .newObjectValue()
+ .objectField(ObjectField.newObjectField().name(RATIO).value(FloatValue.of(1.3)).build())
+ .objectField(
+ ObjectField.newObjectField().name(CONSTANT).value(StringValue.of("1m7s")).build()
+ )
+ .build()
+ .toString(),
+ RelaxCostType.valueOf(CostLinearFunction.of(Cost.costOfSeconds(67), 1.3)).toString()
+ );
+ }
+
+ @Test
+ void mapToDomain() {
+ Map input;
+
+ input = Map.of(RATIO, 1.0, CONSTANT, Cost.ZERO);
+ assertEquals(
+ CostLinearFunction.NORMAL,
+ RelaxCostType.mapToDomain(input, CostLinearFunction.ZERO)
+ );
+
+ input = Map.of(RATIO, 0.0, CONSTANT, Cost.ZERO);
+ assertEquals(
+ CostLinearFunction.ZERO,
+ RelaxCostType.mapToDomain(input, CostLinearFunction.ZERO)
+ );
+
+ input = Map.of(RATIO, 1.7, CONSTANT, Cost.costOfSeconds(3600 + 3 * 60 + 7));
+ assertEquals(
+ CostLinearFunction.of("1h3m7s + 1.7t"),
+ RelaxCostType.mapToDomain(input, CostLinearFunction.ZERO)
+ );
+ assertEquals(
+ CostLinearFunction.NORMAL,
+ RelaxCostType.mapToDomain(null, CostLinearFunction.NORMAL)
+ );
+ assertEquals(CostLinearFunction.ZERO, RelaxCostType.mapToDomain(null, CostLinearFunction.ZERO));
+ }
+}
diff --git a/src/test/java/org/opentripplanner/apis/vectortiles/DebugStyleSpecTest.java b/src/test/java/org/opentripplanner/apis/vectortiles/DebugStyleSpecTest.java
new file mode 100644
index 00000000000..d685e07a2f2
--- /dev/null
+++ b/src/test/java/org/opentripplanner/apis/vectortiles/DebugStyleSpecTest.java
@@ -0,0 +1,25 @@
+package org.opentripplanner.apis.vectortiles;
+
+import static org.opentripplanner.test.support.JsonAssertions.assertEqualJson;
+
+import org.junit.jupiter.api.Test;
+import org.opentripplanner.apis.vectortiles.DebugStyleSpec.VectorSourceLayer;
+import org.opentripplanner.apis.vectortiles.model.TileSource.VectorSource;
+import org.opentripplanner.framework.json.ObjectMappers;
+import org.opentripplanner.test.support.ResourceLoader;
+
+class DebugStyleSpecTest {
+
+ private final ResourceLoader RES = ResourceLoader.of(this);
+
+ @Test
+ void spec() {
+ var vectorSource = new VectorSource("vectorSource", "https://example.com");
+ var regularStops = new VectorSourceLayer(vectorSource, "regularStops");
+ var spec = DebugStyleSpec.build(vectorSource, regularStops);
+
+ var json = ObjectMappers.ignoringExtraFields().valueToTree(spec);
+ var expectation = RES.fileToString("style.json");
+ assertEqualJson(expectation, json);
+ }
+}
diff --git a/src/test/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategyTest.java b/src/test/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategyTest.java
index 04844d65da2..17dc26a4c5e 100644
--- a/src/test/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategyTest.java
+++ b/src/test/java/org/opentripplanner/astar/strategy/MaxCountSkipEdgeStrategyTest.java
@@ -12,7 +12,7 @@ class MaxCountSkipEdgeStrategyTest {
@Test
void countStops() {
var state = TestStateBuilder.ofWalking().stop().build();
- var strategy = new MaxCountSkipEdgeStrategy<>(1, NearbyStopFinder::isTransitVertex);
+ var strategy = new MaxCountSkipEdgeStrategy<>(1, NearbyStopFinder::hasReachedStop);
assertFalse(strategy.shouldSkipEdge(state, null));
assertTrue(strategy.shouldSkipEdge(state, null));
}
@@ -20,9 +20,17 @@ void countStops() {
@Test
void doNotCountStop() {
var state = TestStateBuilder.ofWalking().build();
- var strategy = new MaxCountSkipEdgeStrategy<>(1, NearbyStopFinder::isTransitVertex);
+ var strategy = new MaxCountSkipEdgeStrategy<>(1, NearbyStopFinder::hasReachedStop);
assertFalse(strategy.shouldSkipEdge(state, null));
assertFalse(strategy.shouldSkipEdge(state, null));
assertFalse(strategy.shouldSkipEdge(state, null));
}
+
+ @Test
+ void nonFinalState() {
+ var state = TestStateBuilder.ofScooterRentalArriveBy().stop().build();
+ assertFalse(state.isFinal());
+ var strategy = new MaxCountSkipEdgeStrategy<>(1, NearbyStopFinder::hasReachedStop);
+ assertFalse(strategy.shouldSkipEdge(state, null));
+ }
}
diff --git a/src/test/java/org/opentripplanner/api/common/PlannerResourceTest.java b/src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java
similarity index 95%
rename from src/test/java/org/opentripplanner/api/common/PlannerResourceTest.java
rename to src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java
index 36e0650b081..a86e270a2af 100644
--- a/src/test/java/org/opentripplanner/api/common/PlannerResourceTest.java
+++ b/src/test/java/org/opentripplanner/ext/restapi/resources/PlannerResourceTest.java
@@ -1,4 +1,4 @@
-package org.opentripplanner.api.common;
+package org.opentripplanner.ext.restapi.resources;
import static graphql.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -12,7 +12,6 @@
import org.opentripplanner.TestServerContext;
import org.opentripplanner._support.time.ZoneIds;
import org.opentripplanner.api.parameter.QualifiedModeSet;
-import org.opentripplanner.api.resource.PlannerResource;
import org.opentripplanner.routing.api.request.RequestModes;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.standalone.api.OtpServerRequestContext;
diff --git a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java
index 832045b6469..90ffc33d848 100644
--- a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java
+++ b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/AdaptivePruningTest.java
@@ -1,37 +1,40 @@
package org.opentripplanner.graph_builder.module.islandpruning;
-import java.io.File;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.opentripplanner.graph_builder.module.islandpruning.IslandPruningUtils.buildOsmGraph;
+
import java.util.stream.Collectors;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
-import org.opentripplanner.graph_builder.module.osm.OsmModule;
-import org.opentripplanner.openstreetmap.OsmProvider;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.test.support.ResourceLoader;
-import org.opentripplanner.transit.model.framework.Deduplicator;
-import org.opentripplanner.transit.service.StopModel;
-import org.opentripplanner.transit.service.TransitModel;
-/* Test data consists of one bigger graph and two small sub graphs. These are totally disconnected.
- One small graphs is only at 5 meter distance from the big graph and another one 30 m away.
- Adaptive pruning retains the distant island but removes the closer one which appears to be
- disconnected part of the main graph.
+/**
+ * Test data consists of one bigger graph and two small sub graphs. These are totally disconnected.
+ * One small graphs is only at 5 meter distance from the big graph and another one 30 m away.
+ * Adaptive pruning retains the distant island but removes the closer one which appears to be
+ * disconnected part of the main graph.
*/
-
public class AdaptivePruningTest {
private static Graph graph;
@BeforeAll
static void setup() {
- graph = buildOsmGraph(ResourceLoader.of(AdaptivePruningTest.class).file("isoiiluoto.pbf"));
+ graph =
+ buildOsmGraph(
+ ResourceLoader.of(AdaptivePruningTest.class).file("isoiiluoto.pbf"),
+ 5,
+ 0,
+ 20,
+ 30
+ );
}
@Test
public void distantIslandIsRetained() {
- Assertions.assertTrue(
+ assertTrue(
graph
.getStreetEdges()
.stream()
@@ -55,7 +58,7 @@ public void nearIslandIsRemoved() {
@Test
public void mainGraphIsNotRemoved() {
- Assertions.assertTrue(
+ assertTrue(
graph
.getStreetEdges()
.stream()
@@ -64,42 +67,4 @@ public void mainGraphIsNotRemoved() {
.contains("73347312")
);
}
-
- private static Graph buildOsmGraph(File file) {
- try {
- var deduplicator = new Deduplicator();
- var graph = new Graph(deduplicator);
- var transitModel = new TransitModel(new StopModel(), deduplicator);
- // Add street data from OSM
- OsmProvider osmProvider = new OsmProvider(file, true);
- OsmModule osmModule = OsmModule.of(osmProvider, graph).withEdgeNamer(new TestNamer()).build();
-
- osmModule.buildGraph();
-
- transitModel.index();
- graph.index(transitModel.getStopModel());
-
- // Prune floating islands and set noThru where necessary
- PruneIslands pruneIslands = new PruneIslands(
- graph,
- transitModel,
- DataImportIssueStore.NOOP,
- null
- );
- // all 3 sub graphs are larger than 5 edges
- pruneIslands.setPruningThresholdIslandWithoutStops(5);
-
- // up to 5*20 = 100 edge graphs get pruned if they are too close
- pruneIslands.setAdaptivePruningFactor(20);
-
- // Distant island is 30 m away from main graph, let's keep it
- pruneIslands.setAdaptivePruningDistance(30);
-
- pruneIslands.buildGraph();
-
- return graph;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
}
diff --git a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/EscalatorPruningTest.java b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/EscalatorPruningTest.java
new file mode 100644
index 00000000000..540befb07e0
--- /dev/null
+++ b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/EscalatorPruningTest.java
@@ -0,0 +1,30 @@
+package org.opentripplanner.graph_builder.module.islandpruning;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.opentripplanner.graph_builder.module.islandpruning.IslandPruningUtils.buildOsmGraph;
+
+import java.util.stream.Collectors;
+import org.junit.jupiter.api.Test;
+import org.opentripplanner.test.support.ResourceLoader;
+
+public class EscalatorPruningTest {
+
+ @Test
+ public void streetEdgesBetweenEscalatorEdgesRetained() {
+ var graph = buildOsmGraph(
+ ResourceLoader.of(EscalatorPruningTest.class).file("matinkyla-escalator.pbf"),
+ 10,
+ 2,
+ 50,
+ 250
+ );
+ assertTrue(
+ graph
+ .getStreetEdges()
+ .stream()
+ .map(streetEdge -> streetEdge.getName().toString())
+ .collect(Collectors.toSet())
+ .contains("490072445")
+ );
+ }
+}
diff --git a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java
new file mode 100644
index 00000000000..59362472771
--- /dev/null
+++ b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/IslandPruningUtils.java
@@ -0,0 +1,52 @@
+package org.opentripplanner.graph_builder.module.islandpruning;
+
+import java.io.File;
+import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
+import org.opentripplanner.graph_builder.module.osm.OsmModule;
+import org.opentripplanner.openstreetmap.OsmProvider;
+import org.opentripplanner.routing.graph.Graph;
+import org.opentripplanner.transit.model.framework.Deduplicator;
+import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.TransitModel;
+
+class IslandPruningUtils {
+
+ static Graph buildOsmGraph(
+ File osmFile,
+ int thresholdIslandWithoutStops,
+ int thresholdIslandWithStops,
+ double adaptivePruningFactor,
+ int adaptivePruningDistance
+ ) {
+ try {
+ var deduplicator = new Deduplicator();
+ var graph = new Graph(deduplicator);
+ var transitModel = new TransitModel(new StopModel(), deduplicator);
+ // Add street data from OSM
+ OsmProvider osmProvider = new OsmProvider(osmFile, true);
+ OsmModule osmModule = OsmModule.of(osmProvider, graph).withEdgeNamer(new TestNamer()).build();
+
+ osmModule.buildGraph();
+
+ transitModel.index();
+ graph.index(transitModel.getStopModel());
+
+ // Prune floating islands and set noThru where necessary
+ PruneIslands pruneIslands = new PruneIslands(
+ graph,
+ transitModel,
+ DataImportIssueStore.NOOP,
+ null
+ );
+ pruneIslands.setPruningThresholdIslandWithoutStops(thresholdIslandWithoutStops);
+ pruneIslands.setPruningThresholdIslandWithStops(thresholdIslandWithStops);
+ pruneIslands.setAdaptivePruningFactor(adaptivePruningFactor);
+ pruneIslands.setAdaptivePruningDistance(adaptivePruningDistance);
+ pruneIslands.buildGraph();
+
+ return graph;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java
index 53a2d60fe0f..9070fb00f8f 100644
--- a/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java
+++ b/src/test/java/org/opentripplanner/graph_builder/module/islandpruning/PruneNoThruIslandsTest.java
@@ -1,20 +1,16 @@
package org.opentripplanner.graph_builder.module.islandpruning;
-import java.io.File;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.opentripplanner.graph_builder.module.islandpruning.IslandPruningUtils.buildOsmGraph;
+
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
-import org.opentripplanner.graph_builder.module.osm.OsmModule;
-import org.opentripplanner.openstreetmap.OsmProvider;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.street.model.edge.StreetEdge;
import org.opentripplanner.test.support.ResourceLoader;
-import org.opentripplanner.transit.model.framework.Deduplicator;
-import org.opentripplanner.transit.service.StopModel;
-import org.opentripplanner.transit.service.TransitModel;
public class PruneNoThruIslandsTest {
@@ -26,13 +22,17 @@ static void setup() {
buildOsmGraph(
ResourceLoader
.of(PruneNoThruIslandsTest.class)
- .file("herrenberg-island-prune-nothru.osm.pbf")
+ .file("herrenberg-island-prune-nothru.osm.pbf"),
+ 10,
+ 2,
+ 50,
+ 250
);
}
@Test
public void bicycleIslandsBecomeNoThru() {
- Assertions.assertTrue(
+ assertTrue(
graph
.getStreetEdges()
.stream()
@@ -45,7 +45,7 @@ public void bicycleIslandsBecomeNoThru() {
@Test
public void carIslandsBecomeNoThru() {
- Assertions.assertTrue(
+ assertTrue(
graph
.getStreetEdges()
.stream()
@@ -67,36 +67,4 @@ public void pruneFloatingBikeAndWalkIsland() {
.contains("159830257")
);
}
-
- private static Graph buildOsmGraph(File osmFile) {
- try {
- var deduplicator = new Deduplicator();
- var graph = new Graph(deduplicator);
- var transitModel = new TransitModel(new StopModel(), deduplicator);
- // Add street data from OSM
- OsmProvider osmProvider = new OsmProvider(osmFile, true);
- OsmModule osmModule = OsmModule.of(osmProvider, graph).withEdgeNamer(new TestNamer()).build();
-
- osmModule.buildGraph();
-
- transitModel.index();
- graph.index(transitModel.getStopModel());
-
- // Prune floating islands and set noThru where necessary
- PruneIslands pruneIslands = new PruneIslands(
- graph,
- transitModel,
- DataImportIssueStore.NOOP,
- null
- );
- pruneIslands.setPruningThresholdIslandWithoutStops(40);
- pruneIslands.setPruningThresholdIslandWithStops(5);
- pruneIslands.setAdaptivePruningFactor(1);
- pruneIslands.buildGraph();
-
- return graph;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
}
diff --git a/src/test/java/org/opentripplanner/inspector/vector/AreaStopLayerBuilderTest.java b/src/test/java/org/opentripplanner/inspector/vector/stop/AreaStopLayerBuilderTest.java
similarity index 50%
rename from src/test/java/org/opentripplanner/inspector/vector/AreaStopLayerBuilderTest.java
rename to src/test/java/org/opentripplanner/inspector/vector/stop/AreaStopLayerBuilderTest.java
index 09b64adcf75..a1c01ca2e99 100644
--- a/src/test/java/org/opentripplanner/inspector/vector/AreaStopLayerBuilderTest.java
+++ b/src/test/java/org/opentripplanner/inspector/vector/stop/AreaStopLayerBuilderTest.java
@@ -1,51 +1,36 @@
-package org.opentripplanner.inspector.vector;
+package org.opentripplanner.inspector.vector.stop;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Locale;
import org.junit.jupiter.api.Test;
-import org.locationtech.jts.geom.Coordinate;
-import org.opentripplanner.framework.geometry.GeometryUtils;
+import org.opentripplanner._support.geometry.Polygons;
import org.opentripplanner.framework.i18n.I18NString;
-import org.opentripplanner.framework.i18n.NonLocalizedString;
+import org.opentripplanner.inspector.vector.KeyValue;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.site.AreaStop;
-import org.opentripplanner.transit.service.DefaultTransitService;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.StopModelBuilder;
-import org.opentripplanner.transit.service.TransitModel;
class AreaStopLayerBuilderTest {
- private static final Coordinate[] COORDINATES = {
- new Coordinate(0, 0),
- new Coordinate(0, 1),
- new Coordinate(1, 1),
- new Coordinate(1, 0),
- new Coordinate(0, 0),
- };
private static final FeedScopedId ID = new FeedScopedId("FEED", "ID");
- private static final I18NString NAME = new NonLocalizedString("Test stop");
+ private static final I18NString NAME = I18NString.of("Test stop");
private final StopModelBuilder stopModelBuilder = StopModel.of();
private final AreaStop areaStop = stopModelBuilder
.areaStop(ID)
.withName(NAME)
- .withGeometry(GeometryUtils.getGeometryFactory().createPolygon(COORDINATES))
+ .withGeometry(Polygons.BERLIN)
.build();
@Test
void map() {
- var subject = new DebugClientAreaStopPropertyMapper(
- new DefaultTransitService(new TransitModel()),
- Locale.ENGLISH
- );
+ var subject = new StopLocationPropertyMapper(Locale.ENGLISH);
var properties = subject.map(areaStop);
- assertEquals(2, properties.size());
assertTrue(properties.contains(new KeyValue("id", ID.toString())));
assertTrue(properties.contains(new KeyValue("name", NAME.toString())));
}
diff --git a/src/test/java/org/opentripplanner/netex/mapping/TripPatternMapperTest.java b/src/test/java/org/opentripplanner/netex/mapping/TripPatternMapperTest.java
index f07a46ced2c..74448fb3638 100644
--- a/src/test/java/org/opentripplanner/netex/mapping/TripPatternMapperTest.java
+++ b/src/test/java/org/opentripplanner/netex/mapping/TripPatternMapperTest.java
@@ -1,9 +1,11 @@
package org.opentripplanner.netex.mapping;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.google.common.collect.ArrayListMultimap;
import java.util.Map;
+import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.netex.index.hierarchy.HierarchicalMap;
@@ -12,7 +14,6 @@
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.DefaultEntityById;
import org.opentripplanner.transit.model.framework.FeedScopedId;
-import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.timetable.Trip;
import org.opentripplanner.transit.model.timetable.TripAlteration;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
@@ -55,26 +56,28 @@ public void testMapTripPattern() {
150
);
- TripPatternMapperResult r = tripPatternMapper.mapTripPattern(sample.getJourneyPattern());
+ Optional res = tripPatternMapper.mapTripPattern(
+ sample.getJourneyPattern()
+ );
- assertEquals(1, r.tripPatterns.size());
+ assertTrue(res.isPresent());
- TripPattern tripPattern = r.tripPatterns.values().stream().findFirst().orElseThrow();
+ TripPatternMapperResult r = res.get();
- assertEquals(4, tripPattern.numberOfStops());
- assertEquals(1, tripPattern.scheduledTripsAsStream().count());
+ assertEquals(4, r.tripPattern().numberOfStops());
+ assertEquals(1, r.tripPattern().scheduledTripsAsStream().count());
- Trip trip = tripPattern.scheduledTripsAsStream().findFirst().get();
+ Trip trip = r.tripPattern().scheduledTripsAsStream().findFirst().get();
assertEquals("RUT:ServiceJourney:1", trip.getId().getId());
- assertEquals("NSR:Quay:1", tripPattern.getStop(0).getId().getId());
- assertEquals("NSR:Quay:2", tripPattern.getStop(1).getId().getId());
- assertEquals("NSR:Quay:3", tripPattern.getStop(2).getId().getId());
- assertEquals("NSR:Quay:4", tripPattern.getStop(3).getId().getId());
+ assertEquals("NSR:Quay:1", r.tripPattern().getStop(0).getId().getId());
+ assertEquals("NSR:Quay:2", r.tripPattern().getStop(1).getId().getId());
+ assertEquals("NSR:Quay:3", r.tripPattern().getStop(2).getId().getId());
+ assertEquals("NSR:Quay:4", r.tripPattern().getStop(3).getId().getId());
- assertEquals(1, tripPattern.getScheduledTimetable().getTripTimes().size());
+ assertEquals(1, r.tripPattern().getScheduledTimetable().getTripTimes().size());
- TripTimes tripTimes = tripPattern.getScheduledTimetable().getTripTimes().get(0);
+ TripTimes tripTimes = r.tripPattern().getScheduledTimetable().getTripTimes().get(0);
assertEquals(4, tripTimes.getNumStops());
@@ -115,15 +118,19 @@ public void testMapTripPattern_datedServiceJourney() {
150
);
- TripPatternMapperResult r = tripPatternMapper.mapTripPattern(sample.getJourneyPattern());
+ Optional res = tripPatternMapper.mapTripPattern(
+ sample.getJourneyPattern()
+ );
+
+ assertTrue(res.isPresent());
+
+ var r = res.get();
- assertEquals(1, r.tripPatterns.size());
- assertEquals(2, r.tripOnServiceDates.size());
+ assertEquals(2, r.tripOnServiceDates().size());
- TripPattern tripPattern = r.tripPatterns.values().stream().findFirst().orElseThrow();
- Trip trip = tripPattern.scheduledTripsAsStream().findFirst().get();
+ Trip trip = r.tripPattern().scheduledTripsAsStream().findFirst().get();
- for (TripOnServiceDate tripOnServiceDate : r.tripOnServiceDates) {
+ for (TripOnServiceDate tripOnServiceDate : r.tripOnServiceDates()) {
assertEquals(trip, tripOnServiceDate.getTrip());
assertEquals(TripAlteration.PLANNED, tripOnServiceDate.getTripAlteration());
assertEquals(
diff --git a/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java b/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java
index c1db11be779..00b1d528e7e 100644
--- a/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java
+++ b/src/test/java/org/opentripplanner/raptor/moduletests/K01_TransitPriorityTest.java
@@ -1,8 +1,6 @@
package org.opentripplanner.raptor.moduletests;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_B;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_C;
import static org.opentripplanner.raptor._data.RaptorTestConstants.T00_00;
@@ -12,6 +10,9 @@
import static org.opentripplanner.raptor._data.transit.TestRoute.route;
import static org.opentripplanner.raptor._data.transit.TestTripPattern.pattern;
import static org.opentripplanner.raptor._data.transit.TestTripSchedule.schedule;
+import static org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator.GROUP_A;
+import static org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator.GROUP_B;
+import static org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator.GROUP_C;
import java.time.Duration;
import org.junit.jupiter.api.BeforeEach;
@@ -19,11 +20,11 @@
import org.opentripplanner.raptor.RaptorService;
import org.opentripplanner.raptor._data.transit.TestTransitData;
import org.opentripplanner.raptor._data.transit.TestTripSchedule;
-import org.opentripplanner.raptor.api.model.DominanceFunction;
import org.opentripplanner.raptor.api.request.RaptorProfile;
import org.opentripplanner.raptor.api.request.RaptorRequestBuilder;
-import org.opentripplanner.raptor.api.request.RaptorTransitPriorityGroupCalculator;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
import org.opentripplanner.raptor.configure.RaptorConfig;
+import org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.RaptorCostConverter;
/**
@@ -33,32 +34,8 @@
*/
public class K01_TransitPriorityTest {
- private static final RaptorTransitPriorityGroupCalculator PRIORITY_GROUP_CALCULATOR = new RaptorTransitPriorityGroupCalculator() {
- @Override
- public int mergeTransitPriorityGroupIds(int currentGroupIds, int boardingGroupId) {
- return currentGroupIds | boardingGroupId;
- }
-
- /**
- * Left dominate right, if right has at least one priority group not in left.
- */
- @Override
- public DominanceFunction dominanceFunction() {
- return (l, r) -> ((l ^ r) & r) != 0;
- }
- };
-
- private static final int GROUP_A = 0x01;
- private static final int GROUP_B = 0x02;
- private static final int GROUP_C = 0x04;
- private static final int GROUP_AB = PRIORITY_GROUP_CALCULATOR.mergeTransitPriorityGroupIds(
- GROUP_A,
- GROUP_B
- );
- private static final int GROUP_AC = PRIORITY_GROUP_CALCULATOR.mergeTransitPriorityGroupIds(
- GROUP_A,
- GROUP_C
- );
+ private static final RaptorTransitGroupCalculator PRIORITY_GROUP_CALCULATOR =
+ TestGroupPriorityCalculator.PRIORITY_CALCULATOR;
private static final int C1_SLACK_90s = RaptorCostConverter.toRaptorCost(90);
private final TestTransitData data = new TestTransitData();
@@ -108,7 +85,6 @@ private void prepareRequest() {
);
// Add 1 second access/egress paths
requestBuilder.searchParams().addAccessPaths(walk(STOP_B, 1)).addEgressPaths(walk(STOP_C, 1));
- assetGroupCalculatorIsSetupCorrect();
}
@Test
@@ -122,21 +98,4 @@ public void transitPriority() {
pathsToString(raptorService.route(requestBuilder.build(), data))
);
}
-
- /**
- * Make sure the calculator and group setup is done correct.
- */
- void assetGroupCalculatorIsSetupCorrect() {
- var d = PRIORITY_GROUP_CALCULATOR.dominanceFunction();
-
- assertTrue(d.leftDominateRight(GROUP_A, GROUP_B));
- assertTrue(d.leftDominateRight(GROUP_B, GROUP_A));
- assertFalse(d.leftDominateRight(GROUP_A, GROUP_A));
- // 3 = 1&2, 5 = 1&4
- assertTrue(d.leftDominateRight(GROUP_A, GROUP_AB));
- assertFalse(d.leftDominateRight(GROUP_AB, GROUP_A));
- assertFalse(d.leftDominateRight(GROUP_AB, GROUP_AB));
- assertTrue(d.leftDominateRight(GROUP_AB, GROUP_AC));
- assertTrue(d.leftDominateRight(GROUP_AC, GROUP_AB));
- }
}
diff --git a/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java b/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java
index c7b64cb5b9e..c6ab8e337ea 100644
--- a/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java
+++ b/src/test/java/org/opentripplanner/raptor/moduletests/K02_TransitPriorityDestinationTest.java
@@ -1,14 +1,11 @@
package org.opentripplanner.raptor.moduletests;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_B;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_C;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_D;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_E;
import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_F;
-import static org.opentripplanner.raptor._data.RaptorTestConstants.STOP_G;
import static org.opentripplanner.raptor._data.RaptorTestConstants.T00_00;
import static org.opentripplanner.raptor._data.RaptorTestConstants.T01_00;
import static org.opentripplanner.raptor._data.api.PathUtils.pathsToString;
@@ -16,6 +13,9 @@
import static org.opentripplanner.raptor._data.transit.TestRoute.route;
import static org.opentripplanner.raptor._data.transit.TestTripPattern.pattern;
import static org.opentripplanner.raptor._data.transit.TestTripSchedule.schedule;
+import static org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator.GROUP_A;
+import static org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator.GROUP_B;
+import static org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator.GROUP_C;
import java.time.Duration;
import org.junit.jupiter.api.BeforeEach;
@@ -23,11 +23,11 @@
import org.opentripplanner.raptor.RaptorService;
import org.opentripplanner.raptor._data.transit.TestTransitData;
import org.opentripplanner.raptor._data.transit.TestTripSchedule;
-import org.opentripplanner.raptor.api.model.DominanceFunction;
import org.opentripplanner.raptor.api.request.RaptorProfile;
import org.opentripplanner.raptor.api.request.RaptorRequestBuilder;
-import org.opentripplanner.raptor.api.request.RaptorTransitPriorityGroupCalculator;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
import org.opentripplanner.raptor.configure.RaptorConfig;
+import org.opentripplanner.raptor.moduletests.support.TestGroupPriorityCalculator;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.RaptorCostConverter;
/**
@@ -37,32 +37,8 @@
*/
public class K02_TransitPriorityDestinationTest {
- private static final RaptorTransitPriorityGroupCalculator PRIORITY_GROUP_CALCULATOR = new RaptorTransitPriorityGroupCalculator() {
- @Override
- public int mergeTransitPriorityGroupIds(int currentGroupIds, int boardingGroupId) {
- return currentGroupIds | boardingGroupId;
- }
-
- /**
- * Left dominate right, if right has at least one priority group not in left.
- */
- @Override
- public DominanceFunction dominanceFunction() {
- return (l, r) -> ((l ^ r) & r) != 0;
- }
- };
-
- private static final int GROUP_A = 0x01;
- private static final int GROUP_B = 0x02;
- private static final int GROUP_C = 0x04;
- private static final int GROUP_AB = PRIORITY_GROUP_CALCULATOR.mergeTransitPriorityGroupIds(
- GROUP_A,
- GROUP_B
- );
- private static final int GROUP_AC = PRIORITY_GROUP_CALCULATOR.mergeTransitPriorityGroupIds(
- GROUP_A,
- GROUP_C
- );
+ private static final RaptorTransitGroupCalculator PRIORITY_GROUP_CALCULATOR =
+ TestGroupPriorityCalculator.PRIORITY_CALCULATOR;
private static final int C1_SLACK_90s = RaptorCostConverter.toRaptorCost(90);
private final TestTransitData data = new TestTransitData();
@@ -117,7 +93,6 @@ private void prepareRequest() {
.addEgressPaths(walk(STOP_D, 1))
.addEgressPaths(walk(STOP_E, 1))
.addEgressPaths(walk(STOP_F, 1));
- assetGroupCalculatorIsSetupCorrect();
}
@Test
@@ -131,21 +106,4 @@ public void transitPriority() {
pathsToString(raptorService.route(requestBuilder.build(), data))
);
}
-
- /**
- * Make sure the calculator and group setup is done correct.
- */
- void assetGroupCalculatorIsSetupCorrect() {
- var d = PRIORITY_GROUP_CALCULATOR.dominanceFunction();
-
- assertTrue(d.leftDominateRight(GROUP_A, GROUP_B));
- assertTrue(d.leftDominateRight(GROUP_B, GROUP_A));
- assertFalse(d.leftDominateRight(GROUP_A, GROUP_A));
- // 3 = 1&2, 5 = 1&4
- assertTrue(d.leftDominateRight(GROUP_A, GROUP_AB));
- assertFalse(d.leftDominateRight(GROUP_AB, GROUP_A));
- assertFalse(d.leftDominateRight(GROUP_AB, GROUP_AB));
- assertTrue(d.leftDominateRight(GROUP_AB, GROUP_AC));
- assertTrue(d.leftDominateRight(GROUP_AC, GROUP_AB));
- }
}
diff --git a/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java b/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java
new file mode 100644
index 00000000000..cdbe82f18a6
--- /dev/null
+++ b/src/test/java/org/opentripplanner/raptor/moduletests/support/TestGroupPriorityCalculator.java
@@ -0,0 +1,51 @@
+package org.opentripplanner.raptor.moduletests.support;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+import org.opentripplanner.raptor.api.model.DominanceFunction;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
+
+public class TestGroupPriorityCalculator implements RaptorTransitGroupCalculator {
+
+ public static final RaptorTransitGroupCalculator PRIORITY_CALCULATOR = new TestGroupPriorityCalculator();
+
+ public static final int GROUP_A = 0x01;
+ public static final int GROUP_B = 0x02;
+ public static final int GROUP_C = 0x04;
+
+ private static final int GROUP_AB = PRIORITY_CALCULATOR.mergeGroupIds(GROUP_A, GROUP_B);
+ private static final int GROUP_AC = PRIORITY_CALCULATOR.mergeGroupIds(GROUP_A, GROUP_C);
+
+ @Override
+ public int mergeGroupIds(int currentGroupIds, int boardingGroupId) {
+ return currentGroupIds | boardingGroupId;
+ }
+
+ /**
+ * Left dominate right, if right has at least one priority group not in left.
+ */
+ @Override
+ public DominanceFunction dominanceFunction() {
+ return (l, r) -> ((l ^ r) & r) != 0;
+ }
+
+ /**
+ * Make sure the calculator and group setup is done correct.
+ */
+ @Test
+ void assetGroupCalculatorIsSetupCorrect() {
+ var d = PRIORITY_CALCULATOR.dominanceFunction();
+
+ assertTrue(d.leftDominateRight(GROUP_A, GROUP_B));
+ assertTrue(d.leftDominateRight(GROUP_B, GROUP_A));
+ assertFalse(d.leftDominateRight(GROUP_A, GROUP_A));
+ // 3 = 1&2, 5 = 1&4
+ assertTrue(d.leftDominateRight(GROUP_A, GROUP_AB));
+ assertFalse(d.leftDominateRight(GROUP_AB, GROUP_A));
+ assertFalse(d.leftDominateRight(GROUP_AB, GROUP_AB));
+ assertTrue(d.leftDominateRight(GROUP_AB, GROUP_AC));
+ assertTrue(d.leftDominateRight(GROUP_AC, GROUP_AB));
+ }
+}
diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java b/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java
index 3fef2d957b9..988c6c5abf4 100644
--- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java
+++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/BikeRentalSnapshotTest.java
@@ -89,7 +89,7 @@ public void directBikeRentalArrivingAtDestinationWithDepartAt() {
request.journey().setModes(RequestModes.of().withDirectMode(StreetMode.BIKE_RENTAL).build());
request.journey().transit().setFilters(List.of(ExcludeAllTransitFilter.of()));
- request.journey().rental().setAllowArrivingInRentedVehicleAtDestination(true);
+ allowArrivalWithRentalVehicle(request);
request.setFrom(p1);
request.setTo(p2);
@@ -104,7 +104,7 @@ public void directBikeRentalArrivingAtDestinationWithArriveBy() {
request.journey().setModes(RequestModes.of().withDirectMode(StreetMode.BIKE_RENTAL).build());
request.journey().transit().setFilters(List.of(ExcludeAllTransitFilter.of()));
- request.journey().rental().setAllowArrivingInRentedVehicleAtDestination(true);
+ allowArrivalWithRentalVehicle(request);
request.setFrom(p1);
request.setTo(p2);
request.setArriveBy(true);
@@ -161,4 +161,12 @@ public void egressBikeRental() {
expectArriveByToMatchDepartAtAndSnapshot(request);
}
+
+ private void allowArrivalWithRentalVehicle(RouteRequest request) {
+ request.withPreferences(preferences ->
+ preferences.withBike(bike ->
+ bike.withRental(rental -> rental.withAllowArrivingInRentedVehicleAtDestination(true))
+ )
+ );
+ }
}
diff --git a/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java b/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java
index bf0e62dbc19..8dbf5536ea2 100644
--- a/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java
+++ b/src/test/java/org/opentripplanner/routing/algorithm/mapping/SnapshotTestBase.java
@@ -36,11 +36,11 @@
import org.opentripplanner.ConstantsForTests;
import org.opentripplanner.TestOtpModel;
import org.opentripplanner.TestServerContext;
-import org.opentripplanner.api.mapping.ItineraryMapper;
-import org.opentripplanner.api.model.ApiLeg;
import org.opentripplanner.api.parameter.ApiRequestMode;
import org.opentripplanner.api.parameter.QualifiedMode;
import org.opentripplanner.api.parameter.Qualifier;
+import org.opentripplanner.ext.restapi.mapping.ItineraryMapper;
+import org.opentripplanner.ext.restapi.model.ApiLeg;
import org.opentripplanner.framework.time.TimeUtils;
import org.opentripplanner.model.GenericLocation;
import org.opentripplanner.model.plan.Itinerary;
diff --git a/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitPriorityGroup32nTest.java b/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitGroupPriority32nTest.java
similarity index 51%
rename from src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitPriorityGroup32nTest.java
rename to src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitGroupPriority32nTest.java
index 85083a3ee6a..2713a190dbf 100644
--- a/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitPriorityGroup32nTest.java
+++ b/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/cost/grouppriority/TransitGroupPriority32nTest.java
@@ -6,9 +6,9 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
-import org.opentripplanner.raptor.api.request.RaptorTransitPriorityGroupCalculator;
+import org.opentripplanner.raptor.api.request.RaptorTransitGroupCalculator;
-class TransitPriorityGroup32nTest {
+class TransitGroupPriority32nTest {
private static final int GROUP_INDEX_0 = 0;
private static final int GROUP_INDEX_1 = 1;
@@ -16,35 +16,35 @@ class TransitPriorityGroup32nTest {
private static final int GROUP_INDEX_30 = 30;
private static final int GROUP_INDEX_31 = 31;
- private static final int GROUP_0 = TransitPriorityGroup32n.groupId(GROUP_INDEX_0);
- private static final int GROUP_1 = TransitPriorityGroup32n.groupId(GROUP_INDEX_1);
- private static final int GROUP_2 = TransitPriorityGroup32n.groupId(GROUP_INDEX_2);
- private static final int GROUP_30 = TransitPriorityGroup32n.groupId(GROUP_INDEX_30);
- private static final int GROUP_31 = TransitPriorityGroup32n.groupId(GROUP_INDEX_31);
- private static final RaptorTransitPriorityGroupCalculator subjct = TransitPriorityGroup32n.priorityCalculator();
+ private static final int GROUP_0 = TransitGroupPriority32n.groupId(GROUP_INDEX_0);
+ private static final int GROUP_1 = TransitGroupPriority32n.groupId(GROUP_INDEX_1);
+ private static final int GROUP_2 = TransitGroupPriority32n.groupId(GROUP_INDEX_2);
+ private static final int GROUP_30 = TransitGroupPriority32n.groupId(GROUP_INDEX_30);
+ private static final int GROUP_31 = TransitGroupPriority32n.groupId(GROUP_INDEX_31);
+ private static final RaptorTransitGroupCalculator subjct = TransitGroupPriority32n.priorityCalculator();
@Test
void groupId() {
- assertEqualsHex(0x00_00_00_00, TransitPriorityGroup32n.groupId(0));
- assertEqualsHex(0x00_00_00_01, TransitPriorityGroup32n.groupId(1));
- assertEqualsHex(0x00_00_00_02, TransitPriorityGroup32n.groupId(2));
- assertEqualsHex(0x00_00_00_04, TransitPriorityGroup32n.groupId(3));
- assertEqualsHex(0x40_00_00_00, TransitPriorityGroup32n.groupId(31));
- assertEqualsHex(0x80_00_00_00, TransitPriorityGroup32n.groupId(32));
+ assertEqualsHex(0x00_00_00_00, TransitGroupPriority32n.groupId(0));
+ assertEqualsHex(0x00_00_00_01, TransitGroupPriority32n.groupId(1));
+ assertEqualsHex(0x00_00_00_02, TransitGroupPriority32n.groupId(2));
+ assertEqualsHex(0x00_00_00_04, TransitGroupPriority32n.groupId(3));
+ assertEqualsHex(0x40_00_00_00, TransitGroupPriority32n.groupId(31));
+ assertEqualsHex(0x80_00_00_00, TransitGroupPriority32n.groupId(32));
- assertThrows(IllegalArgumentException.class, () -> TransitPriorityGroup32n.groupId(-1));
- assertThrows(IllegalArgumentException.class, () -> TransitPriorityGroup32n.groupId(33));
+ assertThrows(IllegalArgumentException.class, () -> TransitGroupPriority32n.groupId(-1));
+ assertThrows(IllegalArgumentException.class, () -> TransitGroupPriority32n.groupId(33));
}
@Test
- void mergeTransitPriorityGroupIds() {
- assertEqualsHex(GROUP_0, subjct.mergeTransitPriorityGroupIds(GROUP_0, GROUP_0));
- assertEqualsHex(GROUP_1, subjct.mergeTransitPriorityGroupIds(GROUP_1, GROUP_1));
- assertEqualsHex(GROUP_0 | GROUP_1, subjct.mergeTransitPriorityGroupIds(GROUP_0, GROUP_1));
- assertEqualsHex(GROUP_30 | GROUP_31, subjct.mergeTransitPriorityGroupIds(GROUP_30, GROUP_31));
+ void mergeTransitGroupPriorityIds() {
+ assertEqualsHex(GROUP_0, subjct.mergeGroupIds(GROUP_0, GROUP_0));
+ assertEqualsHex(GROUP_1, subjct.mergeGroupIds(GROUP_1, GROUP_1));
+ assertEqualsHex(GROUP_0 | GROUP_1, subjct.mergeGroupIds(GROUP_0, GROUP_1));
+ assertEqualsHex(GROUP_30 | GROUP_31, subjct.mergeGroupIds(GROUP_30, GROUP_31));
assertEqualsHex(
GROUP_0 | GROUP_1 | GROUP_2 | GROUP_30 | GROUP_31,
- subjct.mergeTransitPriorityGroupIds(GROUP_0 | GROUP_1 | GROUP_2 | GROUP_30, GROUP_31)
+ subjct.mergeGroupIds(GROUP_0 | GROUP_1 | GROUP_2 | GROUP_30, GROUP_31)
);
}
diff --git a/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfiguratorTest.java b/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfiguratorTest.java
index 777aee5352c..cc4bb09f01e 100644
--- a/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfiguratorTest.java
+++ b/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupConfiguratorTest.java
@@ -7,7 +7,7 @@
import java.util.List;
import org.junit.jupiter.api.Test;
-import org.opentripplanner.routing.api.request.request.filter.TransitPriorityGroupSelect;
+import org.opentripplanner.routing.api.request.request.filter.TransitGroupSelect;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.network.RoutingTripPattern;
import org.opentripplanner.transit.model.site.RegularStop;
@@ -69,14 +69,14 @@ class PriorityGroupConfiguratorTest {
@Test
void emptyConfigurationShouldReturnGroupZero() {
var subject = PriorityGroupConfigurator.of(List.of(), List.of());
- assertEquals(subject.baseGroupId(), subject.lookupTransitPriorityGroupId(railR1));
- assertEquals(subject.baseGroupId(), subject.lookupTransitPriorityGroupId(busB2));
- assertEquals(subject.baseGroupId(), subject.lookupTransitPriorityGroupId(null));
+ assertEquals(subject.baseGroupId(), subject.lookupTransitGroupPriorityId(railR1));
+ assertEquals(subject.baseGroupId(), subject.lookupTransitGroupPriorityId(busB2));
+ assertEquals(subject.baseGroupId(), subject.lookupTransitGroupPriorityId(null));
}
@Test
- void lookupTransitPriorityGroupIdByAgency() {
- var select = TransitPriorityGroupSelect
+ void lookupTransitGroupIdByAgency() {
+ var select = TransitGroupSelect
.of()
.addModes(List.of(TransitMode.BUS, TransitMode.RAIL))
.build();
@@ -85,12 +85,12 @@ void lookupTransitPriorityGroupIdByAgency() {
var subject = PriorityGroupConfigurator.of(List.of(select), List.of());
// Agency groups are indexed (group-id set) at request time
- assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitPriorityGroupId(null));
- assertEquals(EXP_GROUP_1, subject.lookupTransitPriorityGroupId(busB2));
- assertEquals(EXP_GROUP_2, subject.lookupTransitPriorityGroupId(railR3));
- assertEquals(EXP_GROUP_3, subject.lookupTransitPriorityGroupId(railR1));
- assertEquals(EXP_GROUP_2, subject.lookupTransitPriorityGroupId(busB3));
- assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitPriorityGroupId(ferryF3));
+ assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitGroupPriorityId(null));
+ assertEquals(EXP_GROUP_1, subject.lookupTransitGroupPriorityId(busB2));
+ assertEquals(EXP_GROUP_2, subject.lookupTransitGroupPriorityId(railR3));
+ assertEquals(EXP_GROUP_3, subject.lookupTransitGroupPriorityId(railR1));
+ assertEquals(EXP_GROUP_2, subject.lookupTransitGroupPriorityId(busB3));
+ assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitGroupPriorityId(ferryF3));
}
@Test
@@ -99,17 +99,17 @@ void lookupTransitPriorityGroupIdByGlobalMode() {
var subject = PriorityGroupConfigurator.of(
List.of(),
List.of(
- TransitPriorityGroupSelect.of().addModes(List.of(TransitMode.BUS)).build(),
- TransitPriorityGroupSelect.of().addModes(List.of(TransitMode.RAIL)).build()
+ TransitGroupSelect.of().addModes(List.of(TransitMode.BUS)).build(),
+ TransitGroupSelect.of().addModes(List.of(TransitMode.RAIL)).build()
)
);
- assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitPriorityGroupId(null));
- assertEquals(EXP_GROUP_2, subject.lookupTransitPriorityGroupId(railR1));
- assertEquals(EXP_GROUP_1, subject.lookupTransitPriorityGroupId(busB2));
- assertEquals(EXP_GROUP_2, subject.lookupTransitPriorityGroupId(railR3));
- assertEquals(EXP_GROUP_1, subject.lookupTransitPriorityGroupId(busB3));
- assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitPriorityGroupId(ferryF3));
+ assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitGroupPriorityId(null));
+ assertEquals(EXP_GROUP_2, subject.lookupTransitGroupPriorityId(railR1));
+ assertEquals(EXP_GROUP_1, subject.lookupTransitGroupPriorityId(busB2));
+ assertEquals(EXP_GROUP_2, subject.lookupTransitGroupPriorityId(railR3));
+ assertEquals(EXP_GROUP_1, subject.lookupTransitGroupPriorityId(busB3));
+ assertEquals(EXP_GROUP_ID_BASE, subject.lookupTransitGroupPriorityId(ferryF3));
}
private static TestRouteData route(
diff --git a/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcherTest.java b/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcherTest.java
index 880d8bc9b45..91d0142f9ef 100644
--- a/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcherTest.java
+++ b/src/test/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/PriorityGroupMatcherTest.java
@@ -6,7 +6,7 @@
import java.util.List;
import org.junit.jupiter.api.Test;
-import org.opentripplanner.routing.api.request.request.filter.TransitPriorityGroupSelect;
+import org.opentripplanner.routing.api.request.request.filter.TransitGroupSelect;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.TripPattern;
@@ -35,7 +35,7 @@ class PriorityGroupMatcherTest {
@Test
void testMode() {
var m = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect.of().addModes(List.of(TransitMode.BUS, TransitMode.TRAM)).build()
+ TransitGroupSelect.of().addModes(List.of(TransitMode.BUS, TransitMode.TRAM)).build()
);
assertEquals("Mode(BUS | TRAM)", m.toString());
assertFalse(m.isEmpty());
@@ -47,10 +47,10 @@ void testMode() {
@Test
void testAgencyIds() {
var m1 = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect.of().addAgencyIds(List.of(r1agencyId)).build()
+ TransitGroupSelect.of().addAgencyIds(List.of(r1agencyId)).build()
);
var m2 = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect.of().addAgencyIds(List.of(r1agencyId, anyId)).build()
+ TransitGroupSelect.of().addAgencyIds(List.of(r1agencyId, anyId)).build()
);
var matchers = List.of(m1, m2);
@@ -68,10 +68,10 @@ void testAgencyIds() {
@Test
void routeIds() {
var m1 = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect.of().addRouteIds(List.of(r1routeId)).build()
+ TransitGroupSelect.of().addRouteIds(List.of(r1routeId)).build()
);
var m2 = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect.of().addRouteIds(List.of(r1routeId, anyId)).build()
+ TransitGroupSelect.of().addRouteIds(List.of(r1routeId, anyId)).build()
);
var matchers = List.of(m1, m2);
@@ -89,7 +89,7 @@ void routeIds() {
@Test
void testSubMode() {
var subject = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect.of().addSubModeRegexp(List.of(".*local.*")).build()
+ TransitGroupSelect.of().addSubModeRegexp(List.of(".*local.*")).build()
);
assertEquals("SubModeRegexp(.*local.*)", subject.toString());
@@ -103,7 +103,7 @@ void testSubMode() {
@Test
void testAnd() {
var subject = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect
+ TransitGroupSelect
.of()
.addSubModeRegexp(List.of("express"))
.addRouteIds(List.of(r1routeId))
@@ -125,7 +125,7 @@ void testAnd() {
@Test
void testToString() {
var subject = PriorityGroupMatcher.of(
- TransitPriorityGroupSelect
+ TransitGroupSelect
.of()
.addModes(List.of(TransitMode.BUS, TransitMode.TRAM))
.addAgencyIds(List.of(anyId, r1agencyId))
diff --git a/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java b/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java
index e8e3ff576a9..9da7852cc2c 100644
--- a/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java
+++ b/src/test/java/org/opentripplanner/routing/api/request/preference/BikePreferencesTest.java
@@ -21,6 +21,8 @@ class BikePreferencesTest {
.withSlope(1)
.build();
public static final BicycleOptimizeType OPTIMIZE_TYPE = BicycleOptimizeType.TRIANGLE;
+ public static final int RENTAL_PICKUP_TIME = 30;
+ public static final int PARK_COST = 30;
private final BikePreferences subject = BikePreferences
.of()
@@ -32,6 +34,8 @@ class BikePreferencesTest {
.withSwitchTime(SWITCH_TIME)
.withSwitchCost(SWITCH_COST)
.withOptimizeType(OPTIMIZE_TYPE)
+ .withRental(rental -> rental.withPickupTime(RENTAL_PICKUP_TIME).build())
+ .withParking(parking -> parking.withParkCost(PARK_COST).build())
.withOptimizeTriangle(it -> it.withSlope(1).build())
.build();
@@ -80,6 +84,18 @@ void optimizeTriangle() {
assertEquals(TRIANGLE, subject.optimizeTriangle());
}
+ @Test
+ void rental() {
+ var vehicleRental = VehicleRentalPreferences.of().withPickupTime(RENTAL_PICKUP_TIME).build();
+ assertEquals(vehicleRental, subject.rental());
+ }
+
+ @Test
+ void parking() {
+ var vehicleParking = VehicleParkingPreferences.of().withParkCost(PARK_COST).build();
+ assertEquals(vehicleParking, subject.parking());
+ }
+
@Test
void testOfAndCopyOf() {
// Return same object if no value is set
@@ -107,6 +123,8 @@ void testToString() {
"walkingReluctance: 1.45, " +
"switchTime: 3m20s, " +
"switchCost: $450, " +
+ "parking: VehicleParkingPreferences{parkCost: $30}, " +
+ "rental: VehicleRentalPreferences{pickupTime: 30s}, " +
"optimizeType: TRIANGLE, " +
"optimizeTriangle: TimeSlopeSafetyTriangle[time=0.0, slope=1.0, safety=0.0]" +
"}",
diff --git a/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java b/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java
index 7bc0a1620ab..c81cb41d883 100644
--- a/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java
+++ b/src/test/java/org/opentripplanner/routing/api/request/preference/CarPreferencesTest.java
@@ -17,6 +17,8 @@ class CarPreferencesTest {
private static final double ACCELERATION_SPEED = 3.1;
private static final double DECELERATION_SPEED = 3.5;
public static final int DROPOFF_TIME = 450;
+ public static final int RENTAL_PICKUP_TIME = 30;
+ public static final int PARK_COST = 30;
private final CarPreferences subject = CarPreferences
.of()
@@ -27,6 +29,8 @@ class CarPreferencesTest {
.withDropoffTime(DROPOFF_TIME)
.withAccelerationSpeed(ACCELERATION_SPEED)
.withDecelerationSpeed(DECELERATION_SPEED)
+ .withRental(rental -> rental.withPickupTime(RENTAL_PICKUP_TIME).build())
+ .withParking(parking -> parking.withParkCost(PARK_COST).build())
.build();
@Test
@@ -64,6 +68,18 @@ void decelerationSpeed() {
assertEquals(DECELERATION_SPEED, subject.decelerationSpeed());
}
+ @Test
+ void rental() {
+ var vehicleRental = VehicleRentalPreferences.of().withPickupTime(RENTAL_PICKUP_TIME).build();
+ assertEquals(vehicleRental, subject.rental());
+ }
+
+ @Test
+ void parking() {
+ var vehicleParking = VehicleParkingPreferences.of().withParkCost(PARK_COST).build();
+ assertEquals(vehicleParking, subject.parking());
+ }
+
@Test
void testCopyOfEqualsAndHashCode() {
// Return same object if no value is set
@@ -83,6 +99,8 @@ void testToString() {
"CarPreferences{" +
"speed: 20.0, " +
"reluctance: 5.1, " +
+ "parking: VehicleParkingPreferences{parkCost: $30}, " +
+ "rental: VehicleRentalPreferences{pickupTime: 30s}, " +
"pickupTime: 600, " +
"pickupCost: $500, " +
"dropoffTime: 450, " +
diff --git a/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java b/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java
index 811c4a70b29..b77a7d9085b 100644
--- a/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java
+++ b/src/test/java/org/opentripplanner/routing/api/request/preference/TransitPreferencesTest.java
@@ -42,7 +42,7 @@ class TransitPreferencesTest {
.setUnpreferredCost(UNPREFERRED_COST)
.withBoardSlack(b -> b.withDefault(D45s).with(TransitMode.AIRPLANE, D35m))
.withAlightSlack(b -> b.withDefault(D15s).with(TransitMode.AIRPLANE, D25m))
- .withTransitGroupPriorityGeneralizedCostSlack(TRANSIT_GROUP_PRIORITY_RELAX)
+ .withRelaxTransitGroupPriority(TRANSIT_GROUP_PRIORITY_RELAX)
.setIgnoreRealtimeUpdates(IGNORE_REALTIME_UPDATES)
.setIncludePlannedCancellations(INCLUDE_PLANNED_CANCELLATIONS)
.setIncludeRealtimeCancellations(INCLUDE_REALTIME_CANCELLATIONS)
@@ -77,8 +77,8 @@ void unpreferredCost() {
}
@Test
- void relaxTransitPriorityGroup() {
- assertEquals(TRANSIT_GROUP_PRIORITY_RELAX, subject.relaxTransitPriorityGroup());
+ void relaxTransitGroupPriority() {
+ assertEquals(TRANSIT_GROUP_PRIORITY_RELAX, subject.relaxTransitGroupPriority());
}
@Test
@@ -125,7 +125,7 @@ void testToString() {
"reluctanceForMode: {AIRPLANE=2.1}, " +
"otherThanPreferredRoutesPenalty: $350, " +
"unpreferredCost: 5m + 1.15 t, " +
- "relaxTransitPriorityGroup: 5m + 1.50 t, " +
+ "relaxTransitGroupPriority: 5m + 1.50 t, " +
"ignoreRealtimeUpdates, " +
"includePlannedCancellations, " +
"includeRealtimeCancellations, " +
diff --git a/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java b/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java
index 402b885529c..6092c8139bc 100644
--- a/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java
+++ b/src/test/java/org/opentripplanner/routing/api/request/preference/VehicleRentalPreferencesTest.java
@@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.opentripplanner.routing.api.request.preference.ImmutablePreferencesAsserts.assertEqualsAndHashCode;
+import java.util.Set;
import org.junit.jupiter.api.Test;
class VehicleRentalPreferencesTest {
@@ -14,6 +15,10 @@ class VehicleRentalPreferencesTest {
public static final int DROPOFF_COST = 450;
public static final int ARRIVE_IN_RENTAL_COST = 500;
public static final boolean USE_AVAILABILITY_INFORMATION = true;
+ public static final boolean ALLOW_ARRIVING_IN_RENTED_VEHICLE = true;
+ public static final Set ALLOWED_NETWORKS = Set.of("foo");
+ public static final Set BANNED_NETWORKS = Set.of("bar");
+
private final VehicleRentalPreferences subject = VehicleRentalPreferences
.of()
.withPickupTime(PICKUP_TIME)
@@ -22,6 +27,9 @@ class VehicleRentalPreferencesTest {
.withDropoffCost(DROPOFF_COST)
.withArrivingInRentalVehicleAtDestinationCost(ARRIVE_IN_RENTAL_COST)
.withUseAvailabilityInformation(USE_AVAILABILITY_INFORMATION)
+ .withAllowArrivingInRentedVehicleAtDestination(ALLOW_ARRIVING_IN_RENTED_VEHICLE)
+ .withAllowedNetworks(ALLOWED_NETWORKS)
+ .withBannedNetworks(BANNED_NETWORKS)
.build();
@Test
@@ -54,6 +62,25 @@ void arrivingInRentalVehicleAtDestinationCost() {
assertEquals(ARRIVE_IN_RENTAL_COST, subject.arrivingInRentalVehicleAtDestinationCost());
}
+ @Test
+ void allowArrivingInRentedVehicleAtDestination() {
+ assertEquals(
+ ALLOW_ARRIVING_IN_RENTED_VEHICLE,
+ subject.allowArrivingInRentedVehicleAtDestination()
+ );
+ }
+
+ @Test
+ void allowedNetworks() {
+ assertEquals(ALLOWED_NETWORKS, subject.allowedNetworks());
+ }
+
+ @Test
+ void bannedNetworks() {
+ assertEquals(BANNED_NETWORKS, subject.bannedNetworks());
+ }
+
+ @Test
void testOfAndCopyOf() {
// Return same object if no value is set
assertSame(VehicleRentalPreferences.DEFAULT, VehicleRentalPreferences.of().build());
@@ -78,7 +105,10 @@ void testToString() {
"dropoffTime: 45s, " +
"dropoffCost: $450, " +
"useAvailabilityInformation, " +
- "arrivingInRentalVehicleAtDestinationCost: 500.0" +
+ "arrivingInRentalVehicleAtDestinationCost: 500.0, " +
+ "allowArrivingInRentedVehicleAtDestination, " +
+ "allowedNetworks: [foo], " +
+ "bannedNetworks: [bar]" +
"}",
subject.toString()
);
diff --git a/src/test/java/org/opentripplanner/routing/core/RoutingPreferencesTest.java b/src/test/java/org/opentripplanner/routing/core/RoutingPreferencesTest.java
index 8131fdd1299..c67d539e902 100644
--- a/src/test/java/org/opentripplanner/routing/core/RoutingPreferencesTest.java
+++ b/src/test/java/org/opentripplanner/routing/core/RoutingPreferencesTest.java
@@ -24,7 +24,6 @@ public void copyOfShouldReturnTheSameInstanceWhenBuild() {
assertSame(pref.wheelchair(), copy.wheelchair());
assertSame(pref.transit(), copy.transit());
assertSame(pref.street(), copy.street());
- assertSame(pref.rental(), copy.rental());
assertSame(pref.itineraryFilter(), copy.itineraryFilter());
assertSame(pref.system(), copy.system());
}
@@ -110,16 +109,6 @@ public void copyOfWithStreetChanges() {
assertNotSame(pref.street(), copy.street());
}
- @Test
- public void copyOfWithRentalChanges() {
- var pref = new RoutingPreferences();
- var copy = pref.copyOf().withRental(r -> r.withDropoffCost(2)).build();
-
- assertNotSame(pref, copy);
- assertNotSame(pref.rental(), copy.rental());
- assertSame(pref.itineraryFilter(), copy.itineraryFilter());
- }
-
@Test
public void copyOfWithItineraryFilterChanges() {
var pref = new RoutingPreferences();
diff --git a/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java b/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java
index 634c10863da..0694a991069 100644
--- a/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java
+++ b/src/test/java/org/opentripplanner/street/integration/BikeRentalTest.java
@@ -433,8 +433,14 @@ private void assertNoRental(
Set allowedNetworks
) {
Consumer setter = options -> {
- options.journey().rental().setAllowedNetworks(allowedNetworks);
- options.journey().rental().setBannedNetworks(bannedNetworks);
+ options.withPreferences(preferences ->
+ preferences.withBike(bike ->
+ bike.withRental(rental -> {
+ rental.withAllowedNetworks(allowedNetworks);
+ rental.withBannedNetworks(bannedNetworks);
+ })
+ )
+ );
};
assertEquals(
@@ -457,8 +463,14 @@ private void assertPathWithNetwork(
Set allowedNetworks
) {
Consumer setter = options -> {
- options.journey().rental().setAllowedNetworks(allowedNetworks);
- options.journey().rental().setBannedNetworks(bannedNetworks);
+ options.withPreferences(preferences ->
+ preferences.withBike(bike ->
+ bike.withRental(rental -> {
+ rental.withAllowedNetworks(allowedNetworks);
+ rental.withBannedNetworks(bannedNetworks);
+ })
+ )
+ );
};
assertEquals(
@@ -580,17 +592,15 @@ private List runStreetSearchAndCreateDescriptor(
toVertex,
arriveBy,
options -> {
- options.withPreferences(p ->
- p.withRental(rental ->
- rental
- .withUseAvailabilityInformation(useAvailabilityInformation)
- .withArrivingInRentalVehicleAtDestinationCost(keepRentedBicycleCost)
+ options.withPreferences(preferences ->
+ preferences.withBike(bike ->
+ bike.withRental(rental -> {
+ rental.withUseAvailabilityInformation(useAvailabilityInformation);
+ rental.withArrivingInRentalVehicleAtDestinationCost(keepRentedBicycleCost);
+ rental.withAllowArrivingInRentedVehicleAtDestination(keepRentedBicycleCost > 0);
+ })
)
);
- options
- .journey()
- .rental()
- .setAllowArrivingInRentedVehicleAtDestination(keepRentedBicycleCost > 0);
}
);
}
@@ -605,14 +615,16 @@ private List runStreetSearchAndCreateDescriptor(
request.setArriveBy(arriveBy);
+ optionsSetter.accept(request);
+
request.withPreferences(preferences ->
- preferences.withRental(rental ->
- rental.withPickupTime(42).withPickupCost(62).withDropoffCost(33).withDropoffTime(15)
+ preferences.withBike(bike ->
+ bike.withRental(rental ->
+ rental.withPickupTime(42).withPickupCost(62).withDropoffCost(33).withDropoffTime(15)
+ )
)
);
- optionsSetter.accept(request);
-
return runStreetSearchAndCreateDescriptor(
fromVertex,
toVertex,
diff --git a/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java b/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java
index 8cdb0bf3ed8..84f5efcc1c5 100644
--- a/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java
+++ b/src/test/java/org/opentripplanner/street/model/edge/VehicleRentalEdgeTest.java
@@ -10,7 +10,6 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.opentripplanner.routing.api.request.StreetMode;
-import org.opentripplanner.routing.api.request.request.VehicleRentalRequest;
import org.opentripplanner.service.vehiclerental.model.GeofencingZone;
import org.opentripplanner.service.vehiclerental.model.RentalVehicleType;
import org.opentripplanner.service.vehiclerental.model.TestVehicleRentalStationBuilder;
@@ -219,15 +218,18 @@ private void initEdgeAndRequest(
vehicleRentalEdge = VehicleRentalEdge.createVehicleRentalEdge(vertex, RentalFormFactor.BICYCLE);
- var rentalRequest = new VehicleRentalRequest();
this.request =
StreetSearchRequest
.of()
.withMode(mode)
- .withRental(rentalRequest)
.withPreferences(preferences ->
preferences
- .withRental(rental -> rental.withUseAvailabilityInformation(useRealtime).build())
+ .withCar(car ->
+ car.withRental(rental -> rental.withUseAvailabilityInformation(useRealtime))
+ )
+ .withBike(bike ->
+ bike.withRental(rental -> rental.withUseAvailabilityInformation(useRealtime))
+ )
.build()
)
.build();
diff --git a/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java b/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java
index 042ff5ba553..a4dbf76e55e 100644
--- a/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java
+++ b/src/test/java/org/opentripplanner/street/search/state/TestStateBuilder.java
@@ -1,6 +1,7 @@
package org.opentripplanner.street.search.state;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.opentripplanner.routing.algorithm.raptoradapter.router.street.AccessEgressType.EGRESS;
import static org.opentripplanner.transit.model.site.PathwayMode.WALKWAY;
import java.time.Instant;
@@ -10,6 +11,7 @@
import javax.annotation.Nonnull;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.framework.i18n.NonLocalizedString;
+import org.opentripplanner.routing.algorithm.raptoradapter.router.street.AccessEgressType;
import org.opentripplanner.routing.api.request.StreetMode;
import org.opentripplanner.service.vehiclerental.model.TestFreeFloatingRentalVehicleBuilder;
import org.opentripplanner.service.vehiclerental.model.TestVehicleRentalStationBuilder;
@@ -20,6 +22,7 @@
import org.opentripplanner.street.model.RentalFormFactor;
import org.opentripplanner.street.model.StreetTraversalPermission;
import org.opentripplanner.street.model._data.StreetModelForTest;
+import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.edge.ElevatorAlightEdge;
import org.opentripplanner.street.model.edge.ElevatorBoardEdge;
import org.opentripplanner.street.model.edge.ElevatorHopEdge;
@@ -51,10 +54,19 @@ public class TestStateBuilder {
private State currentState;
private TestStateBuilder(StreetMode mode) {
+ this(mode, AccessEgressType.ACCESS);
+ }
+
+ private TestStateBuilder(StreetMode mode, AccessEgressType type) {
currentState =
new State(
StreetModelForTest.intersectionVertex(count, count),
- StreetSearchRequest.of().withMode(mode).withStartTime(DEFAULT_START_TIME).build()
+ StreetSearchRequest
+ .of()
+ .withArriveBy(type.isEgress())
+ .withMode(mode)
+ .withStartTime(DEFAULT_START_TIME)
+ .build()
);
}
@@ -80,6 +92,14 @@ public static TestStateBuilder ofScooterRental() {
return new TestStateBuilder(StreetMode.SCOOTER_RENTAL);
}
+ /**
+ * Creates a state that starts the scooter rental in arriveBy mode, so starting with
+ * a rental scooter and going backwards until it finds a rental vertex where to drop it.
+ */
+ public static TestStateBuilder ofScooterRentalArriveBy() {
+ return new TestStateBuilder(StreetMode.SCOOTER_RENTAL, EGRESS);
+ }
+
public static TestStateBuilder ofBikeRental() {
return new TestStateBuilder(StreetMode.BIKE_RENTAL);
}
@@ -248,7 +268,12 @@ private TestStateBuilder arriveAtStop(RegularStop stop) {
var from = (StreetVertex) currentState.vertex;
var to = new TransitStopVertexBuilder().withStop(stop).build();
- var edge = StreetTransitStopLink.createStreetTransitStopLink(from, to);
+ Edge edge;
+ if (currentState.getRequest().arriveBy()) {
+ edge = StreetTransitStopLink.createStreetTransitStopLink(to, from);
+ } else {
+ edge = StreetTransitStopLink.createStreetTransitStopLink(from, to);
+ }
var states = edge.traverse(currentState);
if (states.length != 1) {
throw new IllegalStateException("Only single state transitions are supported.");
diff --git a/src/test/java/org/opentripplanner/test/support/JsonAssertions.java b/src/test/java/org/opentripplanner/test/support/JsonAssertions.java
index f3942c16f3b..2dab1e96190 100644
--- a/src/test/java/org/opentripplanner/test/support/JsonAssertions.java
+++ b/src/test/java/org/opentripplanner/test/support/JsonAssertions.java
@@ -3,6 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opentripplanner.standalone.config.framework.json.JsonSupport;
@@ -15,9 +16,19 @@ public class JsonAssertions {
*/
public static void assertEqualJson(String expected, String actual) {
try {
- var act = MAPPER.readTree(actual);
+ assertEqualJson(expected, MAPPER.readTree(actual));
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * @see JsonAssertions#assertEqualJson(String, String)
+ */
+ public static void assertEqualJson(String expected, JsonNode actual) {
+ try {
var exp = MAPPER.readTree(expected);
- assertEquals(JsonSupport.prettyPrint(exp), JsonSupport.prettyPrint(act));
+ assertEquals(JsonSupport.prettyPrint(exp), JsonSupport.prettyPrint(actual));
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
diff --git a/src/test/java/org/opentripplanner/test/support/ResourceLoader.java b/src/test/java/org/opentripplanner/test/support/ResourceLoader.java
index 38fe02a8c74..5eb51cac55a 100644
--- a/src/test/java/org/opentripplanner/test/support/ResourceLoader.java
+++ b/src/test/java/org/opentripplanner/test/support/ResourceLoader.java
@@ -55,6 +55,17 @@ public File file(String path) {
return file;
}
+ /**
+ * Returns the string content of a file.
+ */
+ public String fileToString(String p) {
+ try {
+ return Files.readString(file(p).toPath());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
/**
* Return a URL for the given resource.
*/
diff --git a/src/test/resources/org/opentripplanner/apis/vectortiles/style.json b/src/test/resources/org/opentripplanner/apis/vectortiles/style.json
new file mode 100644
index 00000000000..f5bb18f6f6a
--- /dev/null
+++ b/src/test/resources/org/opentripplanner/apis/vectortiles/style.json
@@ -0,0 +1,42 @@
+{
+ "name": "OTP Debug Tiles",
+ "sources": {
+ "background": {
+ "id": "background",
+ "tiles": [
+ "https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"
+ ],
+ "tileSize": 256,
+ "attribution" : "© OpenStreetMap Contributors",
+ "type": "raster"
+ },
+ "vectorSource": {
+ "id": "vectorSource",
+ "url": "https://example.com",
+ "type": "vector"
+ }
+ },
+ "layers": [
+ {
+ "id": "background",
+ "source": "background",
+ "type": "raster",
+ "maxzoom": 22,
+ "minzoom": 0
+ },
+ {
+ "maxzoom": 22,
+ "paint": {
+ "circle-stroke-width": 2,
+ "circle-color": "#fcf9fa",
+ "circle-stroke-color": "#140d0e"
+ },
+ "id": "regular-stop",
+ "source": "vectorSource",
+ "source-layer": "regularStops",
+ "type": "circle",
+ "minzoom": 13
+ }
+ ],
+ "version": 8
+}
diff --git a/src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/matinkyla-escalator.pbf b/src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/matinkyla-escalator.pbf
new file mode 100644
index 00000000000..bcae465ae99
Binary files /dev/null and b/src/test/resources/org/opentripplanner/graph_builder/module/islandpruning/matinkyla-escalator.pbf differ
diff --git a/src/test/resources/standalone/config/router-config.json b/src/test/resources/standalone/config/router-config.json
index 69f859d784d..5abb5ef87a6 100644
--- a/src/test/resources/standalone/config/router-config.json
+++ b/src/test/resources/standalone/config/router-config.json
@@ -283,6 +283,14 @@
"Authorization": "A-Token"
}
},
+ // Streaming GTFS-RT TripUpdates through an MQTT broker
+ {
+ "type": "mqtt-gtfs-rt-updater",
+ "url": "tcp://pred.rt.hsl.fi",
+ "topic": "gtfsrt/v2/fi/hsl/tu",
+ "feedId": "HSL",
+ "fuzzyTripMatching": true
+ },
// Polling for GTFS-RT Vehicle Positions - output can be fetched via trip pattern GraphQL API
{
"type": "vehicle-positions",
@@ -295,11 +303,6 @@
"fuzzyTripMatching": false,
"features": ["position"]
},
- // Streaming differential GTFS-RT TripUpdates over websockets
- {
- "type": "websocket-gtfs-rt-updater",
- "feedId": "ov"
- },
// Siri-ET over HTTP
{
"type": "siri-et-updater",