Skip to content

Commit

Permalink
Merge branch 'dev-2.x' into azure-pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Jan 9, 2025
2 parents c5ba17f + 0fb152d commit 4d48ebf
Show file tree
Hide file tree
Showing 93 changed files with 2,885 additions and 1,401 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 @@ -18,7 +18,7 @@
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene912.Lucene912Codec;
import org.apache.lucene.codecs.lucene101.Lucene101Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.StoredField;
Expand All @@ -34,7 +34,7 @@
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.suggest.document.Completion912PostingsFormat;
import org.apache.lucene.search.suggest.document.Completion101PostingsFormat;
import org.apache.lucene.search.suggest.document.CompletionAnalyzer;
import org.apache.lucene.search.suggest.document.ContextQuery;
import org.apache.lucene.search.suggest.document.ContextSuggestField;
Expand Down Expand Up @@ -203,8 +203,8 @@ private StopCluster toStopCluster(Document document) {

static IndexWriterConfig iwcWithSuggestField(Analyzer analyzer, final Set<String> suggestFields) {
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
Codec filterCodec = new Lucene912Codec() {
final PostingsFormat postingsFormat = new Completion912PostingsFormat();
Codec filterCodec = new Lucene101Codec() {
final PostingsFormat postingsFormat = new Completion101PostingsFormat();

@Override
public PostingsFormat getPostingsFormatForField(String field) {
Expand Down Expand Up @@ -285,7 +285,7 @@ private Stream<Document> matchingDocuments(
.stream(topDocs.scoreDocs)
.map(scoreDoc -> {
try {
return searcher.doc(scoreDoc.doc);
return searcher.storedFields().document(scoreDoc.doc);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ private Stream<Document> matchingDocuments(
.stream(topDocs.scoreDocs)
.map(scoreDoc -> {
try {
return searcher.doc(scoreDoc.doc);
return searcher.storedFields().document(scoreDoc.doc);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ParkAndRideResource(
// - serverContext.graphFinder(). This needs at least a comment!
// - This can be replaced with a search done with the SiteRepository
// - if we have a radius search there.
this.graphFinder = new DirectGraphFinder(serverContext.transitService()::findRegularStops);
this.graphFinder = new DirectGraphFinder(serverContext.transitService()::findRegularStopsByBoundingBox);
}

/** Envelopes are in latitude, longitude format */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public List<ApiStopShort> getStopsInRadius(

radius = Math.min(radius, MAX_STOP_SEARCH_RADIUS);

return new DirectGraphFinder(serverContext.transitService()::findRegularStops)
return new DirectGraphFinder(serverContext.transitService()::findRegularStopsByBoundingBox)
.findClosestStops(new Coordinate(lon, lat), radius)
.stream()
.map(it -> StopMapper.mapToApiShort(it.stop, it.distance))
Expand All @@ -221,10 +221,9 @@ public List<ApiStopShort> getStopsInRadius(
new Coordinate(maxLon, maxLat)
);

var stops = transitService().findRegularStops(envelope);
var stops = transitService().findRegularStopsByBoundingBox(envelope);
return stops
.stream()
.filter(stop -> envelope.contains(stop.getCoordinate().asJtsCoordinate()))
.map(StopMapper::mapToApiShort)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public StopsLayerBuilder(

protected List<Geometry> getGeometries(Envelope query) {
return transitService
.findRegularStops(query)
.findRegularStopsByBoundingBox(query)
.stream()
.filter(filter)
.map(stop -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,8 @@ public DataFetcher<Iterable<Object>> stopsByBbox() {
);

Stream<RegularStop> stopStream = getTransitService(environment)
.findRegularStops(envelope)
.stream()
.filter(stop -> envelope.contains(stop.getCoordinate().asJtsCoordinate()));
.findRegularStopsByBoundingBox(envelope)
.stream();

if (args.getGraphQLFeeds() != null) {
List<String> feedIds = args.getGraphQLFeeds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.lang.Boolean.TRUE;
import static java.util.Collections.emptyList;
import static org.opentripplanner.apis.transmodel.mapping.SeverityMapper.getTransmodelSeverity;
import static org.opentripplanner.apis.transmodel.mapping.TransitIdMapper.mapIDToDomain;
import static org.opentripplanner.apis.transmodel.mapping.TransitIdMapper.mapIDsToDomainNullSafe;
import static org.opentripplanner.apis.transmodel.model.EnumTypes.FILTER_PLACE_TYPE_ENUM;
import static org.opentripplanner.apis.transmodel.model.EnumTypes.MULTI_MODAL_MODE;
Expand Down Expand Up @@ -115,6 +116,7 @@
import org.opentripplanner.routing.graphfinder.PlaceType;
import org.opentripplanner.service.vehiclerental.model.VehicleRentalPlace;
import org.opentripplanner.transit.api.model.FilterValues;
import org.opentripplanner.transit.api.request.FindRegularStopsByBoundingBoxRequest;
import org.opentripplanner.transit.api.request.TripRequest;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand Down Expand Up @@ -439,10 +441,7 @@ private GraphQLSchema create() {
.build()
)
.dataFetcher(env ->
StopPlaceType.fetchStopPlaceById(
TransitIdMapper.mapIDToDomain(env.getArgument("id")),
env
)
StopPlaceType.fetchStopPlaceById(mapIDToDomain(env.getArgument("id")), env)
)
.build()
)
Expand Down Expand Up @@ -576,7 +575,7 @@ private GraphQLSchema create() {
.dataFetcher(environment ->
GqlUtil
.getTransitService(environment)
.getStopLocation(TransitIdMapper.mapIDToDomain(environment.getArgument("id")))
.getStopLocation(mapIDToDomain(environment.getArgument("id")))
)
.build()
)
Expand Down Expand Up @@ -610,7 +609,7 @@ private GraphQLSchema create() {
}
TransitService transitService = GqlUtil.getTransitService(environment);
return ((List<String>) environment.getArgument("ids")).stream()
.map(id -> transitService.getStopLocation(TransitIdMapper.mapIDToDomain(id)))
.map(id -> transitService.getStopLocation(mapIDToDomain(id)))
.collect(Collectors.toList());
}
if (environment.getArgument("name") == null) {
Expand Down Expand Up @@ -661,15 +660,22 @@ private GraphQLSchema create() {
.build()
)
.argument(
GraphQLArgument.newArgument().name("authority").type(Scalars.GraphQLString).build()
GraphQLArgument
.newArgument()
.name("authority")
.deprecate(
"This is the Transmodel namespace or the GTFS feedID - avoid using this. Request a new field if necessary."
)
.type(Scalars.GraphQLString)
.build()
)
.argument(
GraphQLArgument
.newArgument()
.name("filterByInUse")
.description("If true only quays with at least one visiting line are included.")
.type(Scalars.GraphQLBoolean)
.defaultValue(Boolean.FALSE)
.defaultValueProgrammatic(Boolean.FALSE)
.build()
)
.dataFetcher(environment -> {
Expand All @@ -683,24 +689,19 @@ private GraphQLSchema create() {
environment.getArgument("maximumLatitude")
)
);

var authority = environment.<String>getArgument("authority");
var filterInUse = environment.<Boolean>getArgument("filterByInUse");

FindRegularStopsByBoundingBoxRequest findRegularStopsByBoundingBoxRequest = FindRegularStopsByBoundingBoxRequest
.of(envelope)
.withFeedId(authority)
.filterByInUse(filterInUse)
.build();

return GqlUtil
.getTransitService(environment)
.findRegularStops(envelope)
.stream()
.filter(stop -> envelope.contains(stop.getCoordinate().asJtsCoordinate()))
.filter(stop ->
environment.getArgument("authority") == null ||
stop.getId().getFeedId().equalsIgnoreCase(environment.getArgument("authority"))
)
.filter(stop -> {
boolean filterByInUse = TRUE.equals(environment.getArgument("filterByInUse"));
boolean inUse = !GqlUtil
.getTransitService(environment)
.findPatterns(stop, true)
.isEmpty();
return !filterByInUse || inUse;
})
.collect(Collectors.toList());
.findRegularStopsByBoundingBox(findRegularStopsByBoundingBoxRequest);
})
.build()
)
Expand Down Expand Up @@ -1438,7 +1439,7 @@ private GraphQLSchema create() {
.build()
)
.dataFetcher(environment -> {
var bikeParkId = TransitIdMapper.mapIDToDomain(environment.getArgument("id"));
var bikeParkId = mapIDToDomain(environment.getArgument("id"));
return GqlUtil
.getVehicleParkingService(environment)
.listBikeParks()
Expand Down Expand Up @@ -1573,7 +1574,7 @@ private GraphQLSchema create() {
return GqlUtil
.getTransitService(environment)
.getTransitAlertService()
.getAlertById(TransitIdMapper.mapIDToDomain(situationNumber));
.getAlertById(mapIDToDomain(situationNumber));
})
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,8 @@ public static Collection<MonoOrMultiModalStation> fetchStopPlaces(
);

Stream<Station> stations = transitService
.findRegularStops(envelope)
.findRegularStopsByBoundingBox(envelope)
.stream()
.filter(stop -> envelope.contains(stop.getCoordinate().asJtsCoordinate()))
.map(StopLocation::getParentStation)
.filter(Objects::nonNull)
.distinct();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private static LayerBuilder<?> createLayerBuilder(
case RegularStop -> new StopLayerBuilder<>(
layerParameters,
locale,
e -> context.transitService().findRegularStops(e)
e -> context.transitService().findRegularStopsByBoundingBox(e)
);
case AreaStop -> new StopLayerBuilder<>(
layerParameters,
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 @@ -22,7 +22,7 @@ public StraightLineNearbyStopFinder(TransitService transitService, Duration dura
// We need to accommodate straight line distance (in meters) but when streets are present we
// use an earliest arrival search, which optimizes on time. Ideally we'd specify in meters,
// but we don't have much of a choice here. Use the default walking speed to convert.
this.directGraphFinder = new DirectGraphFinder(transitService::findRegularStops);
this.directGraphFinder = new DirectGraphFinder(transitService::findRegularStopsByBoundingBox);
}

/**
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 @@ -121,7 +121,7 @@ public interface OtpServerRequestContext {
TraverseVisitor<State, Edge> traverseVisitor();

default GraphFinder graphFinder() {
return GraphFinder.getInstance(graph(), transitService()::findRegularStops);
return GraphFinder.getInstance(graph(), transitService()::findRegularStopsByBoundingBox);
}

FlexParameters flexParameters();
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
Loading

0 comments on commit 4d48ebf

Please sign in to comment.