Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upgrade-protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 7, 2025
2 parents 1518e38 + af5fe63 commit f3ed454
Show file tree
Hide file tree
Showing 63 changed files with 2,562 additions and 1,332 deletions.
4 changes: 2 additions & 2 deletions application/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/12/2024-12-17T11:50/assets/index-CMyj5Qyr.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/12/2024-12-17T11:50/assets/index-BDL0-veX.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2025/01/2025-01-02T15:56/assets/index-DODY0n0n.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2025/01/2025-01-02T15:56/assets/index-BDL0-veX.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void linkTransitStops(Graph graph, TimetableRepository timetableRepositor
continue;
}
// check if stop is already linked, to allow multiple idempotent linking cycles
if (tStop.isConnectedToGraph()) {
if (isAlreadyLinked(tStop, stopLocationsUsedForFlexTrips)) {
continue;
}

Expand All @@ -127,6 +127,26 @@ public void linkTransitStops(Graph graph, TimetableRepository timetableRepositor
LOG.info(progress.completeMessage());
}

/**
* Determines if a given transit stop vertex is already linked to the street network, taking into
* account that flex stops need special linking to both a walkable and drivable edge. For example,
* the {@link OsmBoardingLocationsModule}, which runs before this one, often links stops to
* walkable edges only.
*
* @param stopVertex The transit stop vertex to be checked.
* @param stopLocationsUsedForFlexTrips A set of stop locations that are used for flexible trips.
*/
private static boolean isAlreadyLinked(
TransitStopVertex stopVertex,
Set<StopLocation> stopLocationsUsedForFlexTrips
) {
if (stopLocationsUsedForFlexTrips.contains(stopVertex.getStop())) {
return stopVertex.isLinkedToDrivableEdge() && stopVertex.isLinkedToWalkableEdge();
} else {
return stopVertex.isConnectedToGraph();
}
}

/**
* Link a stop to the nearest "relevant" edges.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ public void populateProperties(WayPropertySet props) {
props.setSlopeOverride(new BestMatchSpecifier("indoor=yes"), true);
}

public void populateNotesAndNames(WayPropertySet props) {
static void populateNotesAndNames(WayPropertySet props) {
/* and the notes */
// TODO: The curly brackets in the string below mean that the CreativeNamer should substitute in OSM tag values.
// However they are not taken into account when passed to the translation function.
Expand Down Expand Up @@ -667,6 +667,7 @@ public void populateNotesAndNames(WayPropertySet props) {
props.createNames("highway=footway", "name.pedestrian_path");
props.createNames("highway=bridleway", "name.bridleway");
props.createNames("highway=footway;bicycle=no", "name.pedestrian_path");
props.createNames("highway=corridor", "name.corridor");

// Platforms
props.createNames("otp:route_ref=*", "name.otp_route_ref");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_AZURE_ET_UPDATER;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_AZURE_SX_UPDATER;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_ET_GOOGLE_PUBSUB_UPDATER;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_ET_LITE;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_ET_UPDATER;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_SX_LITE;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.SIRI_SX_UPDATER;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.STOP_TIME_UPDATER;
import static org.opentripplanner.standalone.config.routerconfig.UpdatersConfig.Type.VEHICLE_PARKING;
Expand All @@ -30,7 +32,9 @@
import org.opentripplanner.standalone.config.routerconfig.updaters.MqttGtfsRealtimeUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.PollingTripUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.SiriETGooglePubsubUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.SiriETLiteUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.SiriETUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.SiriSXLiteUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.SiriSXUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.VehicleParkingUpdaterConfig;
import org.opentripplanner.standalone.config.routerconfig.updaters.VehiclePositionsUpdaterConfig;
Expand All @@ -44,6 +48,8 @@
import org.opentripplanner.updater.siri.updater.SiriETUpdaterParameters;
import org.opentripplanner.updater.siri.updater.SiriSXUpdaterParameters;
import org.opentripplanner.updater.siri.updater.google.SiriETGooglePubsubUpdaterParameters;
import org.opentripplanner.updater.siri.updater.lite.SiriETLiteUpdaterParameters;
import org.opentripplanner.updater.siri.updater.lite.SiriSXLiteUpdaterParameters;
import org.opentripplanner.updater.trip.MqttGtfsRealtimeUpdaterParameters;
import org.opentripplanner.updater.trip.PollingTripUpdaterParameters;
import org.opentripplanner.updater.vehicle_parking.VehicleParkingUpdaterParameters;
Expand Down Expand Up @@ -182,6 +188,16 @@ public List<SiriSXUpdaterParameters> getSiriSXUpdaterParameters() {
return getParameters(SIRI_SX_UPDATER);
}

@Override
public List<SiriETLiteUpdaterParameters> getSiriETLiteUpdaterParameters() {
return getParameters(SIRI_ET_LITE);
}

@Override
public List<SiriSXLiteUpdaterParameters> getSiriSXLiteUpdaterParameters() {
return getParameters(SIRI_SX_LITE);
}

@Override
public List<MqttGtfsRealtimeUpdaterParameters> getMqttGtfsRealtimeUpdaterParameters() {
return getParameters(MQTT_GTFS_RT_UPDATER);
Expand Down Expand Up @@ -218,8 +234,10 @@ public enum Type {
REAL_TIME_ALERTS(GtfsRealtimeAlertsUpdaterConfig::create),
VEHICLE_POSITIONS(VehiclePositionsUpdaterConfig::create),
SIRI_ET_UPDATER(SiriETUpdaterConfig::create),
SIRI_ET_LITE(SiriETLiteUpdaterConfig::create),
SIRI_ET_GOOGLE_PUBSUB_UPDATER(SiriETGooglePubsubUpdaterConfig::create),
SIRI_SX_UPDATER(SiriSXUpdaterConfig::create),
SIRI_SX_LITE(SiriSXLiteUpdaterConfig::create),
SIRI_AZURE_ET_UPDATER(SiriAzureETUpdaterConfig::create),
SIRI_AZURE_SX_UPDATER(SiriAzureSXUpdaterConfig::create);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.opentripplanner.standalone.config.routerconfig.updaters;

import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_7;

import java.time.Duration;
import org.opentripplanner.standalone.config.framework.json.NodeAdapter;
import org.opentripplanner.updater.siri.updater.lite.SiriETLiteUpdaterParameters;

public class SiriETLiteUpdaterConfig {

public static SiriETLiteUpdaterParameters create(String configRef, NodeAdapter c) {
return new SiriETLiteUpdaterParameters(
configRef,
c.of("feedId").since(V2_7).summary("The ID of the feed to apply the updates to.").asString(),
c
.of("url")
.since(V2_7)
.summary("The URL to send the HTTP requests to.")
.description(SiriSXUpdaterConfig.URL_DESCRIPTION)
.asUri(),
c
.of("frequency")
.since(V2_7)
.summary("How often the updates should be retrieved.")
.asDuration(Duration.ofMinutes(1)),
c
.of("timeout")
.since(V2_7)
.summary("The HTTP timeout to download the updates.")
.asDuration(Duration.ofSeconds(15)),
c
.of("fuzzyTripMatching")
.since(V2_7)
.summary("If the fuzzy trip matcher should be used to match trips.")
.asBoolean(false),
HttpHeadersConfig.headers(c, V2_7)
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.opentripplanner.standalone.config.routerconfig.updaters;

import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_0;
import static org.opentripplanner.standalone.config.framework.json.OtpVersion.V2_7;

import java.time.Duration;
import org.opentripplanner.standalone.config.framework.json.NodeAdapter;
import org.opentripplanner.updater.siri.updater.lite.SiriSXLiteUpdaterParameters;

public class SiriSXLiteUpdaterConfig {

public static SiriSXLiteUpdaterParameters create(String configRef, NodeAdapter c) {
return new SiriSXLiteUpdaterParameters(
configRef,
c.of("feedId").since(V2_7).summary("The ID of the feed to apply the updates to.").asString(),
c
.of("url")
.since(V2_7)
.summary("The URL to send the HTTP requests to.")
.description(SiriSXUpdaterConfig.URL_DESCRIPTION)
.asUri(),
c
.of("frequency")
.since(V2_7)
.summary("How often the updates should be retrieved.")
.asDuration(Duration.ofMinutes(1)),
c
.of("timeout")
.since(V2_7)
.summary("The HTTP timeout to download the updates.")
.asDuration(Duration.ofSeconds(15)),
c
.of("earlyStart")
.since(V2_0)
.summary("This value is subtracted from the actual validity defined in the message.")
.description(
"""
Normally the planned departure time is used, so setting this to 10s will cause the
SX-message to be included in trip-results 10 seconds before the the planned departure
time."""
)
.asDuration(Duration.ZERO),
HttpHeadersConfig.headers(c, V2_7)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package org.opentripplanner.street.model.vertex;

import static org.opentripplanner.street.search.TraverseMode.CAR;
import static org.opentripplanner.street.search.TraverseMode.WALK;

import java.util.HashSet;
import java.util.Set;
import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.edge.PathwayEdge;
import org.opentripplanner.street.model.edge.StreetTransitEntityLink;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.transit.model.basic.Accessibility;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.site.RegularStop;
Expand Down Expand Up @@ -94,4 +99,37 @@ public StationElement getStationElement() {
public boolean isConnectedToGraph() {
return getDegreeOut() + getDegreeIn() > 0;
}

/**
* Determines if this vertex is linked (via a {@link StreetTransitEntityLink}) to a drivable edge
* in the street network.
* <p>
* This method is slow: only use this during graph build.
*/
public boolean isLinkedToDrivableEdge() {
return isLinkedToEdgeWhichAllows(CAR);
}

/**
* Determines if this vertex is linked (via a {@link StreetTransitEntityLink}) to a walkable edge
* in the street network.
* <p>
* This method is slow: only use this during graph build.
*/
public boolean isLinkedToWalkableEdge() {
return isLinkedToEdgeWhichAllows(WALK);
}

private boolean isLinkedToEdgeWhichAllows(TraverseMode traverseMode) {
return getOutgoing()
.stream()
.anyMatch(edge ->
edge instanceof StreetTransitEntityLink<?> link &&
link
.getToVertex()
.getOutgoingStreetEdges()
.stream()
.anyMatch(se -> se.canTraverse(traverseMode))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.opentripplanner.updater.siri.updater.SiriETUpdaterParameters;
import org.opentripplanner.updater.siri.updater.SiriSXUpdaterParameters;
import org.opentripplanner.updater.siri.updater.google.SiriETGooglePubsubUpdaterParameters;
import org.opentripplanner.updater.siri.updater.lite.SiriETLiteUpdaterParameters;
import org.opentripplanner.updater.siri.updater.lite.SiriSXLiteUpdaterParameters;
import org.opentripplanner.updater.trip.MqttGtfsRealtimeUpdaterParameters;
import org.opentripplanner.updater.trip.PollingTripUpdaterParameters;
import org.opentripplanner.updater.vehicle_parking.VehicleParkingUpdaterParameters;
Expand All @@ -33,6 +35,10 @@ public interface UpdatersParameters {

List<SiriSXUpdaterParameters> getSiriSXUpdaterParameters();

List<SiriETLiteUpdaterParameters> getSiriETLiteUpdaterParameters();

List<SiriSXLiteUpdaterParameters> getSiriSXLiteUpdaterParameters();

List<MqttGtfsRealtimeUpdaterParameters> getMqttGtfsRealtimeUpdaterParameters();

List<VehicleParkingUpdaterParameters> getVehicleParkingUpdaterParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import org.opentripplanner.updater.UpdatersParameters;
import org.opentripplanner.updater.alert.GtfsRealtimeAlertsUpdater;
import org.opentripplanner.updater.siri.SiriTimetableSnapshotSource;
import org.opentripplanner.updater.siri.updater.SiriETUpdater;
import org.opentripplanner.updater.siri.updater.SiriHttpLoader;
import org.opentripplanner.updater.siri.updater.SiriSXUpdater;
import org.opentripplanner.updater.siri.updater.configure.SiriUpdaterModule;
import org.opentripplanner.updater.siri.updater.google.SiriETGooglePubsubUpdater;
import org.opentripplanner.updater.siri.updater.lite.SiriLiteHttpLoader;
import org.opentripplanner.updater.spi.GraphUpdater;
import org.opentripplanner.updater.spi.TimetableSnapshotFlush;
import org.opentripplanner.updater.trip.MqttGtfsRealtimeUpdater;
Expand Down Expand Up @@ -182,13 +184,23 @@ private List<GraphUpdater> createUpdatersFromConfig() {
updaters.add(new PollingVehiclePositionUpdater(configItem, realtimeVehicleRepository));
}
for (var configItem : updatersParameters.getSiriETUpdaterParameters()) {
updaters.add(new SiriETUpdater(configItem, provideSiriTimetableSnapshot()));
updaters.add(
SiriUpdaterModule.createSiriETUpdater(configItem, provideSiriTimetableSnapshot())
);
}
for (var configItem : updatersParameters.getSiriETLiteUpdaterParameters()) {
updaters.add(
SiriUpdaterModule.createSiriETUpdater(configItem, provideSiriTimetableSnapshot())
);
}
for (var configItem : updatersParameters.getSiriETGooglePubsubUpdaterParameters()) {
updaters.add(new SiriETGooglePubsubUpdater(configItem, provideSiriTimetableSnapshot()));
}
for (var configItem : updatersParameters.getSiriSXUpdaterParameters()) {
updaters.add(new SiriSXUpdater(configItem, timetableRepository));
updaters.add(SiriUpdaterModule.createSiriSXUpdater(configItem, timetableRepository));
}
for (var configItem : updatersParameters.getSiriSXLiteUpdaterParameters()) {
updaters.add(SiriUpdaterModule.createSiriSXUpdater(configItem, timetableRepository));
}
for (var configItem : updatersParameters.getMqttGtfsRealtimeUpdaterParameters()) {
updaters.add(new MqttGtfsRealtimeUpdater(configItem, provideGtfsTimetableSnapshot()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ public interface EstimatedTimetableSource {
* {@link UpdateIncrementality}
*/
UpdateIncrementality incrementalityOfLastUpdates();

String getFeedId();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.opentripplanner.framework.io.OtpHttpClientException;
import org.opentripplanner.updater.spi.HttpHeaders;
import org.opentripplanner.updater.trip.UpdateIncrementality;
import org.opentripplanner.utils.tostring.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.org.siri.siri20.Siri;
Expand All @@ -19,11 +20,6 @@ public class SiriETHttpTripUpdateSource implements EstimatedTimetableSource {

private static final Logger LOG = LoggerFactory.getLogger(SiriETHttpTripUpdateSource.class);

/**
* Feed id that is used to match trip ids in the TripUpdates
*/
private final String feedId;

private final String url;

private final SiriLoader siriLoader;
Expand All @@ -35,16 +31,15 @@ public class SiriETHttpTripUpdateSource implements EstimatedTimetableSource {
private UpdateIncrementality updateIncrementality = FULL_DATASET;
private ZonedDateTime lastTimestamp = ZonedDateTime.now().minusMonths(1);

public SiriETHttpTripUpdateSource(Parameters parameters) {
this.feedId = parameters.feedId();
public SiriETHttpTripUpdateSource(Parameters parameters, SiriLoader siriLoader) {
this.url = parameters.url();

this.requestorRef =
parameters.requestorRef() == null || parameters.requestorRef().isEmpty()
? "otp-" + UUID.randomUUID()
: parameters.requestorRef();

this.siriLoader = createLoader(url, parameters);
this.siriLoader = siriLoader;
}

@Override
Expand Down Expand Up @@ -82,28 +77,8 @@ public UpdateIncrementality incrementalityOfLastUpdates() {
}

@Override
public String getFeedId() {
return this.feedId;
}

public String toString() {
return "SiriETHttpTripUpdateSource(" + url + ")";
}

private static SiriLoader createLoader(String url, Parameters parameters) {
// Load real-time updates from a file.
if (SiriFileLoader.matchesUrl(url)) {
return new SiriFileLoader(url);
}
// Fallback to default loader
else {
return new SiriHttpLoader(
url,
parameters.timeout(),
parameters.httpRequestHeaders(),
parameters.previewInterval()
);
}
return ToStringBuilder.of(SiriETHttpTripUpdateSource.class).addStr("url", url).toString();
}

public interface Parameters {
Expand Down
Loading

0 comments on commit f3ed454

Please sign in to comment.