Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
Browse files Browse the repository at this point in the history
…025-01-13
  • Loading branch information
leonardehrenfried committed Jan 13, 2025
2 parents 98dd162 + 0312487 commit fa33204
Show file tree
Hide file tree
Showing 93 changed files with 1,894 additions and 485 deletions.
8 changes: 4 additions & 4 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
<dependency>
<groupId>org.onebusaway</groupId>
<artifactId>onebusaway-gtfs</artifactId>
<version>4.3.0</version>
<version>5.0.0</version>
</dependency>
<!-- Processing is used for the debug GUI (though we could probably use just Java2D) -->
<dependency>
Expand All @@ -318,9 +318,9 @@
</dependency>
<!-- OpenStreetMap protobuf (PBF) definitions and parser -->
<dependency>
<groupId>org.openstreetmap.osmosis</groupId>
<artifactId>osmosis-osm-binary</artifactId>
<version>0.48.3</version>
<groupId>org.openstreetmap.pbf</groupId>
<artifactId>osmpbf</artifactId>
<version>1.6.0</version>
</dependency>
<!-- Command line parameter parsing -->
<dependency>
Expand Down
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/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">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2025/01/2025-01-11T19:23/assets/index-D--h-dOg.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2025/01/2025-01-11T19:23/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 @@ -92,6 +92,12 @@ public enum OTPFeature {
false,
"Whether the @async annotation in the GraphQL schema should lead to the fetch being executed asynchronously. This allows batch or alias queries to run in parallel at the cost of consuming extra threads."
),
WaitForGraphUpdateInPollingUpdaters(
true,
false,
"Make all polling updaters wait for graph updates to complete before finishing. " +
"If this is not enabled, the updaters will finish after submitting the task to update the graph."
),
Co2Emissions(false, true, "Enable the emissions sandbox module."),
DataOverlay(
false,
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 @@ -14,6 +14,7 @@
import org.onebusaway.csv_entities.EntityHandler;
import org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl;
import org.onebusaway.gtfs.model.Agency;
import org.onebusaway.gtfs.model.Area;
import org.onebusaway.gtfs.model.FareAttribute;
import org.onebusaway.gtfs.model.FareLegRule;
import org.onebusaway.gtfs.model.FareMedium;
Expand All @@ -27,7 +28,7 @@
import org.onebusaway.gtfs.model.ServiceCalendarDate;
import org.onebusaway.gtfs.model.ShapePoint;
import org.onebusaway.gtfs.model.Stop;
import org.onebusaway.gtfs.model.StopArea;
import org.onebusaway.gtfs.model.StopAreaElement;
import org.onebusaway.gtfs.model.Trip;
import org.onebusaway.gtfs.serialization.GtfsReader;
import org.onebusaway.gtfs.services.GenericMutableDao;
Expand Down Expand Up @@ -66,7 +67,8 @@ public class GtfsModule implements GraphBuilderModule {
FareTransferRule.class,
RiderCategory.class,
FareMedium.class,
StopArea.class
StopAreaElement.class,
Area.class
);

private static final Logger LOG = LoggerFactory.getLogger(GtfsModule.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ protected ScheduledTransitLeg(ScheduledTransitLegBuilder<?> builder) {
getDistanceFromCoordinates(
List.of(transitLegCoordinates.getFirst(), transitLegCoordinates.getLast())
);
this.transitAlerts.addAll(builder.alerts());
}

public ZoneId getZoneId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.HashSet;
import java.util.Set;
import org.opentripplanner.model.transfer.ConstrainedTransfer;
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
import org.opentripplanner.transit.model.timetable.TripTimes;
Expand All @@ -23,6 +26,7 @@ public class ScheduledTransitLegBuilder<B extends ScheduledTransitLegBuilder<B>>
private ConstrainedTransfer transferToNextLeg;
private int generalizedCost;
private Float accessibilityScore;
private Set<TransitAlert> alerts = new HashSet<>();

public ScheduledTransitLegBuilder() {}

Expand All @@ -40,6 +44,7 @@ public ScheduledTransitLegBuilder(ScheduledTransitLeg original) {
generalizedCost = original.getGeneralizedCost();
accessibilityScore = original.accessibilityScore();
zoneId = original.getZoneId();
alerts = original.getTransitAlerts();
}

public B withTripTimes(TripTimes tripTimes) {
Expand Down Expand Up @@ -159,6 +164,10 @@ public Float accessibilityScore() {
return accessibilityScore;
}

public Set<TransitAlert> alerts() {
return alerts;
}

public ScheduledTransitLeg build() {
return new ScheduledTransitLeg(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.opentripplanner.osm;

import crosby.binary.BinaryParser;
import crosby.binary.Osmformat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.openstreetmap.osmosis.osmbinary.BinaryParser;
import org.openstreetmap.osmosis.osmbinary.Osmformat;
import org.opentripplanner.graph_builder.module.osm.OsmDatabase;
import org.opentripplanner.osm.model.OsmMemberType;
import org.opentripplanner.osm.model.OsmNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.opentripplanner.osm;

import crosby.binary.file.BlockInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.time.ZoneId;
import org.openstreetmap.osmosis.osmbinary.file.BlockInputStream;
import org.opentripplanner.datastore.api.DataSource;
import org.opentripplanner.datastore.api.FileType;
import org.opentripplanner.datastore.file.FileDataSource;
Expand Down
Loading

0 comments on commit fa33204

Please sign in to comment.