map = new HashMap<>();
mapper.map(station).forEach(o -> map.put(o.key(), o.value()));
diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java
index 796b2a204da..6723034f2a7 100644
--- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java
+++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/RealtimeStopsLayerTest.java
@@ -21,14 +21,14 @@
import org.opentripplanner.routing.alertpatch.TransitAlert;
import org.opentripplanner.routing.impl.TransitAlertServiceImpl;
import org.opentripplanner.routing.services.TransitAlertService;
-import org.opentripplanner.transit.model._data.TransitModelForTest;
+import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.StopModel;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.SiteRepository;
+import org.opentripplanner.transit.service.TimetableRepository;
public class RealtimeStopsLayerTest {
@@ -40,7 +40,7 @@ public void setUp() {
var name = I18NString.of("name");
var desc = I18NString.of("desc");
stop =
- StopModel
+ SiteRepository
.of()
.regularStop(new FeedScopedId("F", "name"))
.withName(name)
@@ -49,7 +49,7 @@ public void setUp() {
.withTimeZone(ZoneIds.HELSINKI)
.build();
stop2 =
- StopModel
+ SiteRepository
.of()
.regularStop(new FeedScopedId("F", "name"))
.withName(name)
@@ -62,11 +62,11 @@ public void setUp() {
@Test
void realtimeStopLayer() {
var deduplicator = new Deduplicator();
- var transitModel = new TransitModel(new StopModel(), deduplicator);
- transitModel.initTimeZone(ZoneIds.HELSINKI);
- transitModel.index();
- var transitService = new DefaultTransitService(transitModel) {
- final TransitAlertService alertService = new TransitAlertServiceImpl(transitModel);
+ var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
+ timetableRepository.initTimeZone(ZoneIds.HELSINKI);
+ timetableRepository.index();
+ var transitService = new DefaultTransitService(timetableRepository) {
+ final TransitAlertService alertService = new TransitAlertServiceImpl(timetableRepository);
@Override
public TransitAlertService getTransitAlertService() {
@@ -74,7 +74,7 @@ public TransitAlertService getTransitAlertService() {
}
};
- Route route = TransitModelForTest.route("route").build();
+ Route route = TimetableRepositoryForTest.route("route").build();
var itinerary = newItinerary(Place.forStop(stop), time("11:00"))
.bus(route, 1, time("11:05"), time("11:20"), Place.forStop(stop2))
.build();
diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java
index 7760eee13b8..d5d12576a1a 100644
--- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java
+++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/stops/StopsLayerTest.java
@@ -1,7 +1,7 @@
package org.opentripplanner.ext.vectortiles.layers.stops;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.opentripplanner.transit.model._data.TransitModelForTest.id;
+import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id;
import java.util.HashMap;
import java.util.Locale;
@@ -16,8 +16,8 @@
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.Station;
import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.StopModel;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.SiteRepository;
+import org.opentripplanner.transit.service.TimetableRepository;
public class StopsLayerTest {
@@ -47,7 +47,7 @@ public class StopsLayerTest {
.withCoordinate(WgsCoordinate.GREENWICH)
.withName(I18NString.of("A Station"))
.build();
- private static final RegularStop STOP = StopModel
+ private static final RegularStop STOP = SiteRepository
.of()
.regularStop(new FeedScopedId("F", "name"))
.withName(NAME_TRANSLATIONS)
@@ -59,9 +59,9 @@ public class StopsLayerTest {
@Test
public void digitransitStopPropertyMapperTest() {
var deduplicator = new Deduplicator();
- var transitModel = new TransitModel(new StopModel(), deduplicator);
- transitModel.index();
- var transitService = new TestTransitService(transitModel);
+ var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
+ timetableRepository.index();
+ var transitService = new TestTransitService(timetableRepository);
DigitransitStopPropertyMapper mapper = DigitransitStopPropertyMapper.create(
transitService,
@@ -81,9 +81,9 @@ public void digitransitStopPropertyMapperTest() {
@Test
public void digitransitStopPropertyMapperTranslationTest() {
var deduplicator = new Deduplicator();
- var transitModel = new TransitModel(new StopModel(), deduplicator);
- transitModel.index();
- var transitService = new DefaultTransitService(transitModel);
+ var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
+ timetableRepository.index();
+ var transitService = new DefaultTransitService(timetableRepository);
DigitransitStopPropertyMapper mapper = DigitransitStopPropertyMapper.create(
transitService,
diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java
index 1beca037457..95ad7ea713e 100644
--- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java
+++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingGroupsLayerTest.java
@@ -26,12 +26,12 @@
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.standalone.config.routerconfig.VectorTileConfig;
-import org.opentripplanner.transit.model._data.TransitModelForTest;
+import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.FeedScopedId;
public class VehicleParkingGroupsLayerTest {
- private static final FeedScopedId ID = TransitModelForTest.id("id");
+ private static final FeedScopedId ID = TimetableRepositoryForTest.id("id");
private VehicleParkingGroup vehicleParkingGroup;
private VehicleParking vehicleParking;
diff --git a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java
index 14e96e2aa28..b63c9c51bc6 100644
--- a/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java
+++ b/application/src/ext-test/java/org/opentripplanner/ext/vectortiles/layers/vehicleparkings/VehicleParkingsLayerTest.java
@@ -29,13 +29,13 @@
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.standalone.config.routerconfig.VectorTileConfig;
-import org.opentripplanner.transit.model._data.TransitModelForTest;
+import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.FeedScopedId;
public class VehicleParkingsLayerTest {
- private static final FeedScopedId ID = TransitModelForTest.id("id");
+ private static final FeedScopedId ID = TimetableRepositoryForTest.id("id");
private VehicleParking vehicleParking;
diff --git a/application/src/ext/java/org/opentripplanner/ext/datastore/gs/package-info.java b/application/src/ext/java/org/opentripplanner/ext/datastore/gs/package-info.java
deleted file mode 100644
index 82ebac6c832..00000000000
--- a/application/src/ext/java/org/opentripplanner/ext/datastore/gs/package-info.java
+++ /dev/null
@@ -1,8 +0,0 @@
-/**
- * Add support for Google Cloud Storage, getting all input files and storing the graph.obj in the
- * cloud.
- *
- * This implementation will use the existing {@link org.opentripplanner.standalone.config.OtpConfigLoader}
- * to load config from the local disk.
- */
-package org.opentripplanner.ext.datastore.gs;
diff --git a/application/src/ext/java/org/opentripplanner/ext/datastore/gs/package-info.md b/application/src/ext/java/org/opentripplanner/ext/datastore/gs/package-info.md
new file mode 100644
index 00000000000..22ae44bb3e3
--- /dev/null
+++ b/application/src/ext/java/org/opentripplanner/ext/datastore/gs/package-info.md
@@ -0,0 +1,6 @@
+# Google cloud storage integration
+
+Add support for Google Cloud Storage, getting all input files and storing the graph.obj in the
+cloud.
+
+This implementation will use the existing OtpConfigLoader to load config from the local disk.
diff --git a/application/src/ext/java/org/opentripplanner/ext/fares/impl/CombinedInterlinedTransitLeg.java b/application/src/ext/java/org/opentripplanner/ext/fares/impl/CombinedInterlinedTransitLeg.java
index ce838480186..d3608ccf8d9 100644
--- a/application/src/ext/java/org/opentripplanner/ext/fares/impl/CombinedInterlinedTransitLeg.java
+++ b/application/src/ext/java/org/opentripplanner/ext/fares/impl/CombinedInterlinedTransitLeg.java
@@ -5,6 +5,7 @@
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nullable;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.model.fare.FareProductUse;
@@ -94,6 +95,7 @@ public List getIntermediateStops() {
}
@Override
+ @Nullable
public LineString getLegGeometry() {
return null;
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapper.java b/application/src/ext/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapper.java
index 8b969c99344..796971a43b5 100644
--- a/application/src/ext/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapper.java
+++ b/application/src/ext/java/org/opentripplanner/ext/flex/AreaStopsToVerticesMapper.java
@@ -12,12 +12,12 @@
import org.opentripplanner.routing.graph.index.StreetIndex;
import org.opentripplanner.street.model.vertex.StreetVertex;
import org.opentripplanner.transit.model.site.AreaStop;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Iterates over all area stops in the stop model and adds them to vertices that are suitable for
+ * Iterates over all area stops in the stop and adds them to vertices that are suitable for
* boarding flex trips.
*/
public class AreaStopsToVerticesMapper implements GraphBuilderModule {
@@ -25,32 +25,32 @@ public class AreaStopsToVerticesMapper implements GraphBuilderModule {
private static final Logger LOG = LoggerFactory.getLogger(AreaStopsToVerticesMapper.class);
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
@Inject
- public AreaStopsToVerticesMapper(Graph graph, TransitModel transitModel) {
+ public AreaStopsToVerticesMapper(Graph graph, TimetableRepository timetableRepository) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
}
@Override
@SuppressWarnings("Convert2MethodRef")
public void buildGraph() {
- if (!transitModel.getStopModel().hasAreaStops()) {
+ if (!timetableRepository.getSiteRepository().hasAreaStops()) {
return;
}
- StreetIndex streetIndex = graph.getStreetIndexSafe(transitModel.getStopModel());
+ StreetIndex streetIndex = graph.getStreetIndexSafe(timetableRepository.getSiteRepository());
ProgressTracker progress = ProgressTracker.track(
"Add flex locations to street vertices",
1,
- transitModel.getStopModel().listAreaStops().size()
+ timetableRepository.getSiteRepository().listAreaStops().size()
);
LOG.info(progress.startMessage());
- var results = transitModel
- .getStopModel()
+ var results = timetableRepository
+ .getSiteRepository()
.listAreaStops()
.parallelStream()
.flatMap(areaStop -> {
diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java
index a875ba0f516..cd047de6d04 100644
--- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java
+++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexIndex.java
@@ -12,7 +12,7 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.site.GroupStop;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
public class FlexIndex {
@@ -24,11 +24,11 @@ public class FlexIndex {
private final Map> tripById = new HashMap<>();
- public FlexIndex(TransitModel transitModel) {
- for (PathTransfer transfer : transitModel.getAllPathTransfers()) {
+ public FlexIndex(TimetableRepository timetableRepository) {
+ for (PathTransfer transfer : timetableRepository.getAllPathTransfers()) {
transfersToStop.put(transfer.to, transfer);
}
- for (FlexTrip, ?> flexTrip : transitModel.getAllFlexTrips()) {
+ for (FlexTrip, ?> flexTrip : timetableRepository.getAllFlexTrips()) {
routeById.put(flexTrip.getTrip().getRoute().getId(), flexTrip.getTrip().getRoute());
tripById.put(flexTrip.getTrip().getId(), flexTrip);
for (StopLocation stop : flexTrip.getStops()) {
diff --git a/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java b/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java
index 24f996ca5fe..cf6c229c46f 100644
--- a/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java
+++ b/application/src/ext/java/org/opentripplanner/ext/flex/FlexibleTransitLeg.java
@@ -6,6 +6,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nullable;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.ext.flex.edgetype.FlexTripEdge;
import org.opentripplanner.framework.i18n.I18NString;
@@ -65,6 +66,7 @@ public Agency getAgency() {
}
@Override
+ @Nullable
public Operator getOperator() {
return getTrip().getOperator();
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java b/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java
index 764c40d3f86..72ac22b027a 100644
--- a/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java
+++ b/application/src/ext/java/org/opentripplanner/ext/geocoder/LuceneIndex.java
@@ -48,7 +48,7 @@
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.site.StopLocationsGroup;
import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.transit.service.TransitService;
public class LuceneIndex implements Serializable {
@@ -73,8 +73,11 @@ public class LuceneIndex implements Serializable {
* However, we do need some methods in the service and that's why we instantiate it manually in this
* constructor.
*/
- public LuceneIndex(TransitModel transitModel, StopConsolidationService stopConsolidationService) {
- this(new DefaultTransitService(transitModel), stopConsolidationService);
+ public LuceneIndex(
+ TimetableRepository timetableRepository,
+ StopConsolidationService stopConsolidationService
+ ) {
+ this(new DefaultTransitService(timetableRepository), stopConsolidationService);
}
/**
diff --git a/application/src/ext/java/org/opentripplanner/ext/geocoder/configure/GeocoderModule.java b/application/src/ext/java/org/opentripplanner/ext/geocoder/configure/GeocoderModule.java
index 9eaf6ade8e5..666ff5d7eaf 100644
--- a/application/src/ext/java/org/opentripplanner/ext/geocoder/configure/GeocoderModule.java
+++ b/application/src/ext/java/org/opentripplanner/ext/geocoder/configure/GeocoderModule.java
@@ -7,7 +7,7 @@
import org.opentripplanner.ext.geocoder.LuceneIndex;
import org.opentripplanner.ext.stopconsolidation.StopConsolidationService;
import org.opentripplanner.framework.application.OTPFeature;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* This module builds the Lucene geocoder based on whether the feature flag is on or off.
@@ -19,11 +19,11 @@ public class GeocoderModule {
@Singleton
@Nullable
LuceneIndex luceneIndex(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
@Nullable StopConsolidationService stopConsolidationService
) {
if (OTPFeature.SandboxAPIGeocoder.isOn()) {
- return new LuceneIndex(transitModel, stopConsolidationService);
+ return new LuceneIndex(timetableRepository, stopConsolidationService);
} else {
return null;
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java b/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java
index 4a577433bfe..6529fc4234d 100644
--- a/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java
+++ b/application/src/ext/java/org/opentripplanner/ext/parkAndRideApi/ParkAndRideResource.java
@@ -40,7 +40,7 @@ public ParkAndRideResource(
// TODO OTP2 - Why are we using the DirectGraphFinder here, not just
// - serverContext.graphFinder(). This needs at least a comment!
- // - This can be replaced with a search done with the StopModel
+ // - 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);
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/AgencyMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/AgencyMapper.java
index 4ea3ebb5209..5a86968153a 100644
--- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/AgencyMapper.java
+++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/AgencyMapper.java
@@ -28,7 +28,6 @@ public static ApiAgency mapToApi(Agency domain) {
api.lang = domain.getLang();
api.phone = domain.getPhone();
api.fareUrl = domain.getFareUrl();
- api.brandingUrl = domain.getBrandingUrl();
return api;
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java
index b642426cd6d..ce9ceeb7f46 100644
--- a/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java
+++ b/application/src/ext/java/org/opentripplanner/ext/restapi/mapping/LegMapper.java
@@ -100,7 +100,6 @@ public ApiLeg mapLeg(
api.agencyId = FeedScopedIdMapper.mapToApi(agency.getId());
api.agencyName = agency.getName();
api.agencyUrl = agency.getUrl();
- api.agencyBrandingUrl = agency.getBrandingUrl();
api.mode = ModeMapper.mapToApi(trLeg.getMode());
var route = domain.getRoute();
diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiAgency.java b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiAgency.java
index ada6739a795..d1c15b7f6f6 100644
--- a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiAgency.java
+++ b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiAgency.java
@@ -12,7 +12,6 @@ public class ApiAgency implements Serializable {
public String lang;
public String phone;
public String fareUrl;
- public String brandingUrl;
@Override
public int hashCode() {
diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiLeg.java b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiLeg.java
index 7bbd83f7c2d..2a434dfe92f 100644
--- a/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiLeg.java
+++ b/application/src/ext/java/org/opentripplanner/ext/restapi/model/ApiLeg.java
@@ -87,8 +87,6 @@ public class ApiLeg {
public String agencyUrl;
- public String agencyBrandingUrl;
-
public int agencyTimeZoneOffset;
/**
@@ -98,7 +96,7 @@ public class ApiLeg {
/**
* For transit legs, the type of the route. Non transit -1 When 0-7: 0 Tram, 1 Subway, 2 Train, 3
- * Bus, 4 Ferry, 5 Cable Car, 6 Gondola, 7 Funicular When equal or highter than 100, it is coded
+ * Bus, 4 Ferry, 5 Cable Tram, 6 Gondola, 7 Funicular When equal or highter than 100, it is coded
* using the Hierarchical Vehicle Type (HVT) codes from the European TPEG standard Also see
* http://groups.google.com/group/gtfs-changes/msg/ed917a69cf8c5bef
*/
diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/package-info.java b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/package-info.java
deleted file mode 100644
index 7b66666ee5d..00000000000
--- a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/package-info.java
+++ /dev/null
@@ -1,5 +0,0 @@
-/**
- * This package contains the JAX-RS-annotated REST resource classes for the OpenTripPlanner public
- * API, i.e. the Jersey REST endpoints.
- */
-package org.opentripplanner.ext.restapi.resources;
diff --git a/application/src/ext/java/org/opentripplanner/ext/restapi/resources/package-info.md b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/package-info.md
new file mode 100644
index 00000000000..a4bb7eb6f4f
--- /dev/null
+++ b/application/src/ext/java/org/opentripplanner/ext/restapi/resources/package-info.md
@@ -0,0 +1,4 @@
+# JAX-RS-annotated REST resource classes
+
+This package contains the JAX-RS-annotated REST resource classes for the OpenTripPlanner public
+API, i.e. the Jersey REST endpoints.
diff --git a/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java b/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java
index b6a9f014c81..0f3e2afe1ea 100644
--- a/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java
+++ b/application/src/ext/java/org/opentripplanner/ext/siri/updater/azure/SiriAzureSXUpdater.java
@@ -17,7 +17,7 @@
import org.apache.hc.core5.net.URIBuilder;
import org.opentripplanner.routing.impl.TransitAlertServiceImpl;
import org.opentripplanner.routing.services.TransitAlertService;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.updater.alert.TransitAlertProvider;
import org.opentripplanner.updater.siri.SiriAlertsUpdateHandler;
import org.rutebanken.siri20.util.SiriXml;
@@ -35,11 +35,14 @@ public class SiriAzureSXUpdater extends AbstractAzureSiriUpdater implements Tran
private final LocalDate fromDateTime;
private final LocalDate toDateTime;
- public SiriAzureSXUpdater(SiriAzureSXUpdaterParameters config, TransitModel transitModel) {
+ public SiriAzureSXUpdater(
+ SiriAzureSXUpdaterParameters config,
+ TimetableRepository timetableRepository
+ ) {
super(config);
this.fromDateTime = config.getFromDateTime();
this.toDateTime = config.getToDateTime();
- this.transitAlertService = new TransitAlertServiceImpl(transitModel);
+ this.transitAlertService = new TransitAlertServiceImpl(timetableRepository);
this.updateHandler = new SiriAlertsUpdateHandler(feedId, transitAlertService, Duration.ZERO);
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationModule.java b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationModule.java
index ca7254aa2fa..c4fca42d129 100644
--- a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationModule.java
+++ b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/StopConsolidationModule.java
@@ -10,7 +10,7 @@
import org.opentripplanner.ext.stopconsolidation.model.StopReplacement;
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
import org.opentripplanner.transit.model.network.TripPattern;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,15 +28,15 @@ public class StopConsolidationModule implements GraphBuilderModule {
private static final Logger LOG = LoggerFactory.getLogger(StopConsolidationModule.class);
private final StopConsolidationRepository repository;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final Collection groups;
public StopConsolidationModule(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
StopConsolidationRepository repository,
Collection groups
) {
- this.transitModel = Objects.requireNonNull(transitModel);
+ this.timetableRepository = Objects.requireNonNull(timetableRepository);
this.repository = Objects.requireNonNull(repository);
this.groups = Objects.requireNonNull(groups);
}
@@ -45,19 +45,19 @@ public StopConsolidationModule(
public void buildGraph() {
repository.addGroups(groups);
- var service = new DefaultStopConsolidationService(repository, transitModel);
+ var service = new DefaultStopConsolidationService(repository, timetableRepository);
var stopsToReplace = service.secondaryStops();
var replacements = service.replacements();
- transitModel
+ timetableRepository
.getAllTripPatterns()
.stream()
.filter(pattern -> pattern.containsAnyStopId(stopsToReplace))
.forEach(pattern -> {
LOG.info("Replacing stop(s) in pattern {}", pattern);
var modifiedPattern = modifyStopsInPattern(pattern, replacements);
- transitModel.addTripPattern(modifiedPattern.getId(), modifiedPattern);
+ timetableRepository.addTripPattern(modifiedPattern.getId(), modifiedPattern);
});
}
@@ -71,14 +71,14 @@ private TripPattern modifyStopsInPattern(
}
public static StopConsolidationModule of(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
StopConsolidationRepository repo,
DataSource ds
) {
LOG.info("Reading stop consolidation information from '{}'", ds);
try (var inputStream = ds.asInputStream()) {
var groups = StopConsolidationParser.parseGroups(inputStream);
- return new StopConsolidationModule(transitModel, repo, groups);
+ return new StopConsolidationModule(timetableRepository, repo, groups);
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/configure/StopConsolidationServiceModule.java b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/configure/StopConsolidationServiceModule.java
index 3851435641c..5c829b20b67 100644
--- a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/configure/StopConsolidationServiceModule.java
+++ b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/configure/StopConsolidationServiceModule.java
@@ -7,7 +7,7 @@
import org.opentripplanner.ext.stopconsolidation.StopConsolidationRepository;
import org.opentripplanner.ext.stopconsolidation.StopConsolidationService;
import org.opentripplanner.ext.stopconsolidation.internal.DefaultStopConsolidationService;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
@Module
public class StopConsolidationServiceModule {
@@ -15,7 +15,10 @@ public class StopConsolidationServiceModule {
@Provides
@Singleton
@Nullable
- StopConsolidationService service(@Nullable StopConsolidationRepository repo, TransitModel tm) {
+ StopConsolidationService service(
+ @Nullable StopConsolidationRepository repo,
+ TimetableRepository tm
+ ) {
if (repo == null) {
return null;
} else {
diff --git a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/internal/DefaultStopConsolidationService.java b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/internal/DefaultStopConsolidationService.java
index 80d3d700866..8e6f31fb6fe 100644
--- a/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/internal/DefaultStopConsolidationService.java
+++ b/application/src/ext/java/org/opentripplanner/ext/stopconsolidation/internal/DefaultStopConsolidationService.java
@@ -12,7 +12,7 @@
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,14 +21,14 @@ public class DefaultStopConsolidationService implements StopConsolidationService
private static final Logger LOG = LoggerFactory.getLogger(DefaultStopConsolidationService.class);
private final StopConsolidationRepository repo;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
public DefaultStopConsolidationService(
StopConsolidationRepository repo,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
this.repo = Objects.requireNonNull(repo);
- this.transitModel = Objects.requireNonNull(transitModel);
+ this.timetableRepository = Objects.requireNonNull(timetableRepository);
}
@Override
@@ -37,7 +37,7 @@ public List replacements() {
.groups()
.stream()
.flatMap(group -> {
- var primaryStop = transitModel.getStopModel().getRegularStop(group.primary());
+ var primaryStop = timetableRepository.getSiteRepository().getRegularStop(group.primary());
if (primaryStop == null) {
LOG.error(
"Could not find primary stop with id {}. Ignoring stop group {}.",
@@ -98,7 +98,7 @@ private Optional findAgencySpecificStop(StopLocation stop, Agency
.flatMap(g -> g.secondaries().stream())
.filter(secondary -> secondary.getFeedId().equals(agency.getId().getFeedId()))
.findAny()
- .map(id -> transitModel.getStopModel().getRegularStop(id));
+ .map(id -> timetableRepository.getSiteRepository().getRegularStop(id));
}
@Override
@@ -110,6 +110,6 @@ public Optional primaryStop(FeedScopedId id) {
.map(ConsolidatedStopGroup::primary)
.findAny()
.orElse(id);
- return Optional.ofNullable(transitModel.getStopModel().getRegularStop(primaryId));
+ return Optional.ofNullable(timetableRepository.getSiteRepository().getRegularStop(primaryId));
}
}
diff --git a/application/src/ext/java/org/opentripplanner/ext/transferanalyzer/DirectTransferAnalyzer.java b/application/src/ext/java/org/opentripplanner/ext/transferanalyzer/DirectTransferAnalyzer.java
index 979912c5f37..61cd9a0789b 100644
--- a/application/src/ext/java/org/opentripplanner/ext/transferanalyzer/DirectTransferAnalyzer.java
+++ b/application/src/ext/java/org/opentripplanner/ext/transferanalyzer/DirectTransferAnalyzer.java
@@ -18,7 +18,7 @@
import org.opentripplanner.routing.graphfinder.StreetGraphFinder;
import org.opentripplanner.street.model.vertex.TransitStopVertex;
import org.opentripplanner.transit.model.site.RegularStop;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,18 +41,18 @@ public class DirectTransferAnalyzer implements GraphBuilderModule {
private static final Logger LOG = LoggerFactory.getLogger(DirectTransferAnalyzer.class);
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final DataImportIssueStore issueStore;
private final double radiusMeters;
public DirectTransferAnalyzer(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore,
double radiusMeters
) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.issueStore = issueStore;
this.radiusMeters = radiusMeters;
}
@@ -60,7 +60,7 @@ public DirectTransferAnalyzer(
@Override
public void buildGraph() {
/* Initialize transit index which is needed by the nearby stop finder. */
- transitModel.index();
+ timetableRepository.index();
LOG.info("Analyzing transfers (this can be time consuming)...");
@@ -68,7 +68,7 @@ public void buildGraph() {
List directTransfersNotFound = new ArrayList<>();
DirectGraphFinder nearbyStopFinderEuclidian = new DirectGraphFinder(
- transitModel.getStopModel()::findRegularStops
+ timetableRepository.getSiteRepository()::findRegularStops
);
StreetGraphFinder nearbyStopFinderStreets = new StreetGraphFinder(graph);
diff --git a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java
index 449a1489d89..25959d5ec7a 100644
--- a/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java
+++ b/application/src/ext/java/org/opentripplanner/ext/vectortiles/layers/stations/StationsLayerBuilder.java
@@ -23,7 +23,7 @@ public class StationsLayerBuilder extends LayerBuilder {
MapperType.Digitransit,
DigitransitStationPropertyMapper::create
);
- private final TransitService transitModel;
+ private final TransitService transitService;
public StationsLayerBuilder(
TransitService transitService,
@@ -35,11 +35,11 @@ public StationsLayerBuilder(
layerParameters.name(),
layerParameters.expansionFactor()
);
- this.transitModel = transitService;
+ this.transitService = transitService;
}
protected List getGeometries(Envelope query) {
- return transitModel
+ return transitService
.getStations()
.stream()
.map(station -> {
diff --git a/application/src/main/java/org/opentripplanner/api/parameter/package-info.java b/application/src/main/java/org/opentripplanner/api/parameter/package-info.java
deleted file mode 100644
index ed9df0c1f61..00000000000
--- a/application/src/main/java/org/opentripplanner/api/parameter/package-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * This package contains classes which interpret incoming HTTP query parameters. Query parameters
- * arrive as Strings, and Jersey will automatically call constructors with a single String
- * argument.
- */
-package org.opentripplanner.api.parameter;
diff --git a/application/src/main/java/org/opentripplanner/api/parameter/package-info.md b/application/src/main/java/org/opentripplanner/api/parameter/package-info.md
new file mode 100644
index 00000000000..75c928773f9
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/api/parameter/package-info.md
@@ -0,0 +1,5 @@
+# HTTP query parameters
+
+This package contains classes which interpret incoming HTTP query parameters. Query parameters
+arrive as Strings, and Jersey will automatically call constructors with a single String
+argument.
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java
index 3cd98b15652..48d60701a96 100644
--- a/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLTypes.java
@@ -972,24 +972,34 @@ public static class GraphQLInputModeWeightInput {
private Double AIRPLANE;
private Double BUS;
private Double CABLE_CAR;
+ private Double CARPOOL;
+ private Double COACH;
private Double FERRY;
private Double FUNICULAR;
private Double GONDOLA;
+ private Double MONORAIL;
private Double RAIL;
private Double SUBWAY;
+ private Double TAXI;
private Double TRAM;
+ private Double TROLLEYBUS;
public GraphQLInputModeWeightInput(Map args) {
if (args != null) {
this.AIRPLANE = (Double) args.get("AIRPLANE");
this.BUS = (Double) args.get("BUS");
this.CABLE_CAR = (Double) args.get("CABLE_CAR");
+ this.CARPOOL = (Double) args.get("CARPOOL");
+ this.COACH = (Double) args.get("COACH");
this.FERRY = (Double) args.get("FERRY");
this.FUNICULAR = (Double) args.get("FUNICULAR");
this.GONDOLA = (Double) args.get("GONDOLA");
+ this.MONORAIL = (Double) args.get("MONORAIL");
this.RAIL = (Double) args.get("RAIL");
this.SUBWAY = (Double) args.get("SUBWAY");
+ this.TAXI = (Double) args.get("TAXI");
this.TRAM = (Double) args.get("TRAM");
+ this.TROLLEYBUS = (Double) args.get("TROLLEYBUS");
}
}
@@ -1005,6 +1015,14 @@ public Double getGraphQLCable_Car() {
return this.CABLE_CAR;
}
+ public Double getGraphQLCarpool() {
+ return this.CARPOOL;
+ }
+
+ public Double getGraphQLCoach() {
+ return this.COACH;
+ }
+
public Double getGraphQLFerry() {
return this.FERRY;
}
@@ -1017,6 +1035,10 @@ public Double getGraphQLGondola() {
return this.GONDOLA;
}
+ public Double getGraphQLMonorail() {
+ return this.MONORAIL;
+ }
+
public Double getGraphQLRail() {
return this.RAIL;
}
@@ -1025,10 +1047,18 @@ public Double getGraphQLSubway() {
return this.SUBWAY;
}
+ public Double getGraphQLTaxi() {
+ return this.TAXI;
+ }
+
public Double getGraphQLTram() {
return this.TRAM;
}
+ public Double getGraphQLTrolleybus() {
+ return this.TROLLEYBUS;
+ }
+
public void setGraphQLAirplane(Double AIRPLANE) {
this.AIRPLANE = AIRPLANE;
}
@@ -1041,6 +1071,14 @@ public void setGraphQLCable_Car(Double CABLE_CAR) {
this.CABLE_CAR = CABLE_CAR;
}
+ public void setGraphQLCarpool(Double CARPOOL) {
+ this.CARPOOL = CARPOOL;
+ }
+
+ public void setGraphQLCoach(Double COACH) {
+ this.COACH = COACH;
+ }
+
public void setGraphQLFerry(Double FERRY) {
this.FERRY = FERRY;
}
@@ -1053,6 +1091,10 @@ public void setGraphQLGondola(Double GONDOLA) {
this.GONDOLA = GONDOLA;
}
+ public void setGraphQLMonorail(Double MONORAIL) {
+ this.MONORAIL = MONORAIL;
+ }
+
public void setGraphQLRail(Double RAIL) {
this.RAIL = RAIL;
}
@@ -1061,9 +1103,17 @@ public void setGraphQLSubway(Double SUBWAY) {
this.SUBWAY = SUBWAY;
}
+ public void setGraphQLTaxi(Double TAXI) {
+ this.TAXI = TAXI;
+ }
+
public void setGraphQLTram(Double TRAM) {
this.TRAM = TRAM;
}
+
+ public void setGraphQLTrolleybus(Double TROLLEYBUS) {
+ this.TROLLEYBUS = TROLLEYBUS;
+ }
}
public static class GraphQLInputPreferredInput {
@@ -1492,6 +1542,7 @@ public enum GraphQLPlanAccessMode {
BICYCLE,
BICYCLE_PARKING,
BICYCLE_RENTAL,
+ CAR,
CAR_DROP_OFF,
CAR_PARKING,
CAR_RENTAL,
@@ -1575,6 +1626,7 @@ public enum GraphQLPlanDirectMode {
public enum GraphQLPlanEgressMode {
BICYCLE,
BICYCLE_RENTAL,
+ CAR,
CAR_PICKUP,
CAR_RENTAL,
FLEX,
@@ -1877,6 +1929,7 @@ public void setGraphQLWalk(GraphQLWalkPreferencesInput walk) {
public enum GraphQLPlanTransferMode {
BICYCLE,
+ CAR,
WALK,
}
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/AccessModeMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/AccessModeMapper.java
index ac4c90a1a56..e0e3ac0bbb2 100644
--- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/AccessModeMapper.java
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/AccessModeMapper.java
@@ -13,6 +13,7 @@ public static StreetMode map(GraphQLTypes.GraphQLPlanAccessMode mode) {
case BICYCLE -> StreetMode.BIKE;
case BICYCLE_RENTAL -> StreetMode.BIKE_RENTAL;
case BICYCLE_PARKING -> StreetMode.BIKE_TO_PARK;
+ case CAR -> StreetMode.CAR;
case CAR_RENTAL -> StreetMode.CAR_RENTAL;
case CAR_PARKING -> StreetMode.CAR_TO_PARK;
case CAR_DROP_OFF -> StreetMode.CAR_PICKUP;
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/EgressModeMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/EgressModeMapper.java
index f03b160ac97..ddcaa255f2a 100644
--- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/EgressModeMapper.java
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/EgressModeMapper.java
@@ -12,6 +12,7 @@ public static StreetMode map(GraphQLTypes.GraphQLPlanEgressMode mode) {
return switch (mode) {
case BICYCLE -> StreetMode.BIKE;
case BICYCLE_RENTAL -> StreetMode.BIKE_RENTAL;
+ case CAR -> StreetMode.CAR;
case CAR_RENTAL -> StreetMode.CAR_RENTAL;
case CAR_PICKUP -> StreetMode.CAR_PICKUP;
case FLEX -> StreetMode.FLEXIBLE;
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ModePreferencesMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ModePreferencesMapper.java
index 32d3456df57..663e93acca9 100644
--- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ModePreferencesMapper.java
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/ModePreferencesMapper.java
@@ -168,5 +168,10 @@ private static void validateStreetModes(JourneyRequest journey) {
"If BICYCLE is used for access, egress or transfer, then it should be used for all."
);
}
+ if (modes.contains(StreetMode.CAR) && modes.size() != 1) {
+ throw new IllegalArgumentException(
+ "If CAR is used for access, egress or transfer, then it should be used for all."
+ );
+ }
}
}
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/TransferModeMapper.java b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/TransferModeMapper.java
index ffa7363e3a7..18d2c0e3811 100644
--- a/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/TransferModeMapper.java
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/mapping/routerequest/TransferModeMapper.java
@@ -10,6 +10,7 @@ public class TransferModeMapper {
public static StreetMode map(GraphQLTypes.GraphQLPlanTransferMode mode) {
return switch (mode) {
+ case CAR -> StreetMode.CAR;
case BICYCLE -> StreetMode.BIKE;
case WALK -> StreetMode.WALK;
};
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java
index fa8601096dc..fe73e8b9887 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelAPI.java
@@ -22,7 +22,8 @@
import org.opentripplanner.apis.transmodel.mapping.TransitIdMapper;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.standalone.api.OtpServerRequestContext;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.standalone.config.routerconfig.TransitRoutingConfig;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -66,15 +67,21 @@ public TransmodelAPIOldPath(
*/
public static void setUp(
TransmodelAPIParameters config,
- TransitModel transitModel,
- RouteRequest defaultRouteRequest
+ TimetableRepository timetableRepository,
+ RouteRequest defaultRouteRequest,
+ TransitRoutingConfig transitRoutingConfig
) {
if (config.hideFeedId()) {
- TransitIdMapper.setupFixedFeedId(transitModel.getAgencies());
+ TransitIdMapper.setupFixedFeedId(timetableRepository.getAgencies());
}
tracingHeaderTags = config.tracingHeaderTags();
maxNumberOfResultFields = config.maxNumberOfResultFields();
- schema = TransmodelGraphQLSchema.create(defaultRouteRequest, transitModel.getTimeZone());
+ schema =
+ TransmodelGraphQLSchema.create(
+ defaultRouteRequest,
+ timetableRepository.getTimeZone(),
+ transitRoutingConfig
+ );
}
@POST
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java
index 5a9fa4cfb59..2ffb9941bc6 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchema.java
@@ -107,6 +107,7 @@
import org.opentripplanner.model.plan.legreference.LegReference;
import org.opentripplanner.model.plan.legreference.LegReferenceSerializer;
import org.opentripplanner.routing.alertpatch.TransitAlert;
+import org.opentripplanner.routing.algorithm.raptoradapter.transit.TransitTuningParameters;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.routing.error.RoutingValidationException;
import org.opentripplanner.routing.graphfinder.NearbyStop;
@@ -133,17 +134,29 @@ public class TransmodelGraphQLSchema {
private final DefaultRouteRequestType routing;
+ private final TransitTuningParameters transitTuningParameters;
+
private final ZoneId timeZoneId;
private final Relay relay = new Relay();
- private TransmodelGraphQLSchema(RouteRequest defaultRequest, ZoneId timeZoneId) {
+ private TransmodelGraphQLSchema(
+ RouteRequest defaultRequest,
+ ZoneId timeZoneId,
+ TransitTuningParameters transitTuningParameters
+ ) {
this.timeZoneId = timeZoneId;
this.routing = new DefaultRouteRequestType(defaultRequest);
+ this.transitTuningParameters = transitTuningParameters;
}
- public static GraphQLSchema create(RouteRequest defaultRequest, ZoneId timeZoneId) {
- return new TransmodelGraphQLSchema(defaultRequest, timeZoneId).create();
+ public static GraphQLSchema create(
+ RouteRequest defaultRequest,
+ ZoneId timeZoneId,
+ TransitTuningParameters transitTuningParameters
+ ) {
+ return new TransmodelGraphQLSchema(defaultRequest, timeZoneId, transitTuningParameters)
+ .create();
}
@SuppressWarnings("unchecked")
@@ -340,6 +353,7 @@ private GraphQLSchema create() {
GraphQLFieldDefinition tripQuery = TripQuery.create(
routing,
+ transitTuningParameters,
tripType,
durationPerStreetModeInput,
penaltyForStreetMode,
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapper.java
index 974b8dd10c3..bf9abd3a60d 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapper.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/RequestModesMapper.java
@@ -10,7 +10,8 @@
class RequestModesMapper {
- private static final Predicate IS_BIKE = m -> m == StreetMode.BIKE;
+ private static final Predicate IS_BIKE_OR_CAR = m ->
+ m == StreetMode.BIKE || m == StreetMode.CAR;
private static final String accessModeKey = "accessMode";
private static final String egressModeKey = "egressMode";
private static final String directModeKey = "directMode";
@@ -27,7 +28,10 @@ static RequestModes mapRequestModes(Map modesInput) {
ensureValueAndSet(accessMode, mBuilder::withAccessMode);
ensureValueAndSet((StreetMode) modesInput.get(egressModeKey), mBuilder::withEgressMode);
ensureValueAndSet((StreetMode) modesInput.get(directModeKey), mBuilder::withDirectMode);
- Optional.ofNullable(accessMode).filter(IS_BIKE).ifPresent(mBuilder::withTransferMode);
+ // The only cases in which the transferMode isn't WALK are when the accessMode is either BIKE or CAR.
+ // In these cases, the transferMode is the same as the accessMode. This check is not strictly necessary
+ // if there is a need for more freedom for specifying the transferMode.
+ Optional.ofNullable(accessMode).filter(IS_BIKE_OR_CAR).ifPresent(mBuilder::withTransferMode);
return mBuilder.build();
}
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java
index 50845aecef7..5f572c89da0 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/mapping/TripViaLocationMapper.java
@@ -6,6 +6,8 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+import javax.annotation.Nullable;
import org.opentripplanner.apis.transmodel.model.plan.TripQuery;
import org.opentripplanner.apis.transmodel.model.plan.ViaLocationInputType;
import org.opentripplanner.apis.transmodel.support.OneOfInputValidator;
@@ -30,6 +32,7 @@ static List toLegacyPassThroughLocations(
return passThroughPoints
.stream()
.map(TripViaLocationMapper::mapLegacyPassThroughViaLocation)
+ .filter(Objects::nonNull)
.collect(toList());
}
@@ -65,6 +68,13 @@ private static PassThroughViaLocation mapPassThroughViaLocation(Map mapStopLocationIds(Map map) {
var c = (Collection) map.get(ViaLocationInputType.FIELD_STOP_LOCATION_IDS);
+
+ // When coordinates are added, we need to accept null here...
+ if (c == null) {
+ throw new IllegalArgumentException(
+ "'" + ViaLocationInputType.FIELD_STOP_LOCATION_IDS + "' is not set!"
+ );
+ }
return c.stream().map(TransitIdMapper::mapIDToDomain).toList();
}
@@ -72,12 +82,17 @@ private static List mapStopLocationIds(Map map) {
* @deprecated Legacy passThrough, use via instead
*/
@Deprecated
+ @Nullable
private static ViaLocation mapLegacyPassThroughViaLocation(Map inputMap) {
final String name = (String) inputMap.get("name");
- final List stopLocationIds =
- ((List) inputMap.get("placeIds")).stream()
- .map(TransitIdMapper::mapIDToDomain)
- .toList();
+ List placeIds = (List) inputMap.get("placeIds");
+ if (placeIds == null || placeIds.isEmpty()) {
+ return null;
+ }
+ final List stopLocationIds = placeIds
+ .stream()
+ .map(TransitIdMapper::mapIDToDomain)
+ .toList();
return new PassThroughViaLocation(name, stopLocationIds);
}
}
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java
index b325eac3653..2f8e69cc593 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/EnumTypes.java
@@ -184,7 +184,7 @@ public class EnumTypes {
.value("air", TransitMode.AIRPLANE)
.value("bicycle", TraverseMode.BICYCLE)
.value("bus", TransitMode.BUS)
- .value("cableway", TransitMode.CABLE_CAR)
+ .value("cableway", TransitMode.GONDOLA)
.value("water", TransitMode.FERRY)
.value("funicular", TransitMode.FUNICULAR)
.value("lift", TransitMode.GONDOLA)
@@ -455,7 +455,7 @@ public class EnumTypes {
.name("TransportMode")
.value("air", TransitMode.AIRPLANE)
.value("bus", TransitMode.BUS)
- .value("cableway", TransitMode.CABLE_CAR)
+ .value("cableway", TransitMode.GONDOLA)
.value("water", TransitMode.FERRY)
.value("funicular", TransitMode.FUNICULAR)
.value("lift", TransitMode.GONDOLA)
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java
index 5b1bbd84373..ac496131954 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/TripQuery.java
@@ -20,6 +20,7 @@
import org.opentripplanner.apis.transmodel.model.framework.PassThroughPointInputType;
import org.opentripplanner.apis.transmodel.model.framework.PenaltyForStreetModeType;
import org.opentripplanner.apis.transmodel.model.framework.TransmodelDirectives;
+import org.opentripplanner.routing.algorithm.raptoradapter.transit.TransitTuningParameters;
import org.opentripplanner.routing.api.request.preference.RoutingPreferences;
import org.opentripplanner.routing.core.VehicleRoutingOptimizeType;
@@ -37,6 +38,7 @@ public class TripQuery {
public static GraphQLFieldDefinition create(
DefaultRouteRequestType routing,
+ TransitTuningParameters transitTuningParameters,
GraphQLOutputType tripType,
GraphQLInputObjectType durationPerStreetModeType,
GraphQLInputObjectType penaltyForStreetMode,
@@ -87,30 +89,42 @@ Normally this is when the search is performed (now), plus a small grace period t
.newArgument()
.name("searchWindow")
.description(
- "The length of the search-window in minutes. This parameter is optional." +
- "\n\n" +
- "The search-window is defined as the duration between the earliest-departure-time(EDT) and " +
- "the latest-departure-time(LDT). OTP will search for all itineraries in this departure " +
- "window. If `arriveBy=true` the `dateTime` parameter is the latest-arrival-time, so OTP " +
- "will dynamically calculate the EDT. Using a short search-window is faster than using a " +
- "longer one, but the search duration is not linear. Using a \"too\" short search-window will " +
- "waste resources server side, while using a search-window that is too long will be slow." +
- "\n\n" +
- "OTP will dynamically calculate a reasonable value for the search-window, if not provided. The " +
- "calculation comes with a significant overhead (10-20% extra). Whether you should use the " +
- "dynamic calculated value or pass in a value depends on your use-case. For a travel planner " +
- "in a small geographical area, with a dense network of public transportation, a fixed value " +
- "between 40 minutes and 2 hours makes sense. To find the appropriate search-window, adjust it " +
- "so that the number of itineraries on average is around the wanted `numItineraries`. Make " +
- "sure you set the `numItineraries` to a high number while testing. For a country wide area like " +
- "Norway, using the dynamic search-window is the best." +
- "\n\n" +
- "When paginating, the search-window is calculated using the `numItineraries` in the original " +
- "search together with statistics from the search for the last page. This behaviour is " +
- "configured server side, and can not be overridden from the client." +
- "\n\n" +
- "The search-window used is returned to the response metadata as `searchWindowUsed` for " +
- "debugging purposes."
+ """
+ The length of the search-window in minutes. This parameter is optional.
+
+ The search-window is defined as the duration between the earliest-departure-time(EDT) and
+ the latest-departure-time(LDT). OTP will search for all itineraries in this departure
+ window. If `arriveBy=true` the `dateTime` parameter is the latest-arrival-time, so OTP
+ will dynamically calculate the EDT. Using a short search-window is faster than using a
+ longer one, but the search duration is not linear. Using a \"too\" short search-window will
+ waste resources server side, while using a search-window that is too long will be slow.
+
+ OTP will dynamically calculate a reasonable value for the search-window, if not provided. The
+ calculation comes with a significant overhead (10-20%% extra). Whether you should use the
+ dynamic calculated value or pass in a value depends on your use-case. For a travel planner
+ in a small geographical area, with a dense network of public transportation, a fixed value
+ between 40 minutes and 2 hours makes sense. To find the appropriate search-window, adjust it
+ so that the number of itineraries on average is around the wanted `numTripPatterns`. Make
+ sure you set the `numTripPatterns` to a high number while testing. For a country wide area like
+ Norway, using the dynamic search-window is the best.
+
+ When paginating, the search-window is calculated using the `numTripPatterns` in the original
+ search together with statistics from the search for the last page. This behaviour is
+ configured server side, and can not be overridden from the client. The paging may even
+ exceed the maximum value.
+
+ The search-window used is returned to the response metadata as `searchWindowUsed`.
+ This can be used by the client to calculate the when the next page start/end.
+
+ Note! In some cases you may have to page many times to get all the results you want.
+ This is intended. Increasing the search-window beyond the max value is NOT going to be
+ much faster. Instead the client can inform the user about the progress.
+
+ Maximum value: %d minutes (%dh)
+ """.formatted(
+ transitTuningParameters.maxSearchWindow().toMinutes(),
+ transitTuningParameters.maxSearchWindow().toHours()
+ )
)
.type(Scalars.GraphQLInt)
.build()
@@ -120,9 +134,12 @@ Normally this is when the search is performed (now), plus a small grace period t
.newArgument()
.name("pageCursor")
.description(
- "Use the cursor to go to the next \"page\" of itineraries. Copy the cursor from " +
- "the last response and keep the original request as is. This will enable you to " +
- "search for itineraries in the next or previous time-window."
+ """
+ Use the cursor to go to the next \"page\" of itineraries. Copy the cursor from the last
+ response and keep the original request as is. This will enable you to search for
+ itineraries in the next or previous search-window. The paging will automatically scale
+ up/down the search-window to fit the `numTripPatterns`.
+ """
)
.type(Scalars.GraphQLString)
.build()
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java
index a808d934eed..ef13f8db18e 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/plan/ViaLocationInputType.java
@@ -5,6 +5,7 @@
import graphql.language.StringValue;
import graphql.schema.GraphQLInputObjectType;
+import graphql.schema.GraphQLInputType;
import graphql.schema.GraphQLList;
import graphql.schema.GraphQLNonNull;
import java.time.Duration;
@@ -84,7 +85,7 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
b
.name(FIELD_STOP_LOCATION_IDS)
.description(DOC_STOP_LOCATION_IDS)
- .type(gqlListOfNonNullStrings())
+ .type(requiredListOfNonNullStrings())
)
/*
TODO: Add support for coordinates
@@ -101,7 +102,7 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
b
.name(FIELD_STOP_LOCATION_IDS)
.description(DOC_STOP_LOCATION_IDS)
- .type(gqlListOfNonNullStrings())
+ .type(requiredListOfNonNullStrings())
)
.build();
@@ -119,7 +120,7 @@ be accepted. To visit a coordinate, the traveler must walk(bike or drive) to the
)
.build();
- private static GraphQLList gqlListOfNonNullStrings() {
- return new GraphQLList(new GraphQLNonNull(GraphQLString));
+ private static GraphQLInputType requiredListOfNonNullStrings() {
+ return new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(GraphQLString)));
}
}
diff --git a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java
index fabae563047..4301b0721c2 100644
--- a/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java
+++ b/application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/TripMetadataType.java
@@ -26,7 +26,7 @@ public static GraphQLObjectType create(GraphQLScalarType dateTimeScalar) {
"override the value if it is too small or too large. When paging OTP adjusts " +
"it to the appropriate size, depending on the number of itineraries found in " +
"the current search window. The scaling of the search window ensures faster " +
- "paging and limits resource usage. The unit is seconds."
+ "paging and limits resource usage. The unit is minutes."
)
.type(new GraphQLNonNull(Scalars.GraphQLInt))
.dataFetcher(e -> ((TripSearchMetadata) e.getSource()).searchWindowUsed.toMinutes())
diff --git a/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java b/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java
index 0dde1494f0a..1fc87176af8 100644
--- a/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java
+++ b/application/src/main/java/org/opentripplanner/apis/vectortiles/DebugStyleSpec.java
@@ -1,5 +1,6 @@
package org.opentripplanner.apis.vectortiles;
+import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -10,7 +11,9 @@
import org.opentripplanner.apis.vectortiles.model.VectorSourceLayer;
import org.opentripplanner.apis.vectortiles.model.ZoomDependentNumber;
import org.opentripplanner.apis.vectortiles.model.ZoomDependentNumber.ZoomStop;
+import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.service.vehiclerental.street.StreetVehicleRentalLink;
+import org.opentripplanner.street.model.StreetTraversalPermission;
import org.opentripplanner.street.model.edge.AreaEdge;
import org.opentripplanner.street.model.edge.BoardingLocationToStopLink;
import org.opentripplanner.street.model.edge.Edge;
@@ -44,17 +47,15 @@ public class DebugStyleSpec {
private static final String DARK_GREEN = "#136b04";
private static final String PURPLE = "#BC55F2";
private static final String BLACK = "#140d0e";
+
private static final int MAX_ZOOM = 23;
- private static final ZoomDependentNumber LINE_WIDTH = new ZoomDependentNumber(
- 1.3f,
- List.of(new ZoomStop(13, 0.5f), new ZoomStop(MAX_ZOOM, 10))
- );
private static final ZoomDependentNumber LINE_OFFSET = new ZoomDependentNumber(
- 1.3f,
List.of(new ZoomStop(13, 0.3f), new ZoomStop(MAX_ZOOM, 6))
);
+ private static final ZoomDependentNumber LINE_WIDTH = new ZoomDependentNumber(
+ List.of(new ZoomStop(13, 0.2f), new ZoomStop(MAX_ZOOM, 8))
+ );
private static final ZoomDependentNumber CIRCLE_STROKE = new ZoomDependentNumber(
- 1,
List.of(new ZoomStop(15, 0.2f), new ZoomStop(MAX_ZOOM, 3))
);
private static final Class[] EDGES_TO_DISPLAY = new Class[] {
@@ -66,6 +67,10 @@ public class DebugStyleSpec {
TemporaryPartialStreetEdge.class,
TemporaryFreeEdge.class,
};
+ private static final String EDGES_GROUP = "Edges";
+ private static final String STOPS_GROUP = "Stops";
+ private static final String VERTICES_GROUP = "Vertices";
+ private static final String TRAVERSAL_PERMISSIONS_GROUP = "Traversal permissions";
static StyleSpec build(
VectorSourceLayer regularStops,
@@ -83,104 +88,178 @@ static StyleSpec build(
return new StyleSpec(
"OTP Debug Tiles",
allSources,
- List.of(
- StyleBuilder.ofId("background").typeRaster().source(BACKGROUND_SOURCE).minZoom(0),
- StyleBuilder
- .ofId("edge")
- .typeLine()
- .vectorSourceLayer(edges)
- .lineColor(MAGENTA)
- .edgeFilter(EDGES_TO_DISPLAY)
- .lineWidth(LINE_WIDTH)
- .lineOffset(LINE_OFFSET)
- .minZoom(6)
- .maxZoom(MAX_ZOOM)
- .intiallyHidden(),
+ ListUtils.combine(
+ List.of(StyleBuilder.ofId("background").typeRaster().source(BACKGROUND_SOURCE).minZoom(0)),
+ traversalPermissions(edges),
+ edges(edges),
+ vertices(vertices),
+ stops(regularStops, areaStops, groupStops)
+ )
+ );
+ }
+
+ private static List stops(
+ VectorSourceLayer regularStops,
+ VectorSourceLayer areaStops,
+ VectorSourceLayer groupStops
+ ) {
+ return List.of(
+ StyleBuilder
+ .ofId("area-stop")
+ .group(STOPS_GROUP)
+ .typeFill()
+ .vectorSourceLayer(areaStops)
+ .fillColor(BRIGHT_GREEN)
+ .fillOpacity(0.5f)
+ .fillOutlineColor(BLACK)
+ .minZoom(6)
+ .maxZoom(MAX_ZOOM),
+ StyleBuilder
+ .ofId("group-stop")
+ .group(STOPS_GROUP)
+ .typeFill()
+ .vectorSourceLayer(groupStops)
+ .fillColor(BRIGHT_GREEN)
+ .fillOpacity(0.5f)
+ .fillOutlineColor(BLACK)
+ .minZoom(6)
+ .maxZoom(MAX_ZOOM),
+ StyleBuilder
+ .ofId("regular-stop")
+ .group(STOPS_GROUP)
+ .typeCircle()
+ .vectorSourceLayer(regularStops)
+ .circleStroke(
+ BLACK,
+ new ZoomDependentNumber(List.of(new ZoomStop(11, 0.5f), new ZoomStop(MAX_ZOOM, 5)))
+ )
+ .circleRadius(
+ new ZoomDependentNumber(List.of(new ZoomStop(11, 0.5f), new ZoomStop(MAX_ZOOM, 10)))
+ )
+ .circleColor("#fcf9fa")
+ .minZoom(10)
+ .maxZoom(MAX_ZOOM)
+ );
+ }
+
+ private static List vertices(VectorSourceLayer vertices) {
+ return List.of(
+ StyleBuilder
+ .ofId("vertex")
+ .group(VERTICES_GROUP)
+ .typeCircle()
+ .vectorSourceLayer(vertices)
+ .circleStroke(BLACK, CIRCLE_STROKE)
+ .circleRadius(
+ new ZoomDependentNumber(List.of(new ZoomStop(15, 1), new ZoomStop(MAX_ZOOM, 7)))
+ )
+ .circleColor(PURPLE)
+ .minZoom(15)
+ .maxZoom(MAX_ZOOM)
+ .intiallyHidden(),
+ StyleBuilder
+ .ofId("parking-vertex")
+ .group(VERTICES_GROUP)
+ .typeCircle()
+ .vectorSourceLayer(vertices)
+ .vertexFilter(VehicleParkingEntranceVertex.class)
+ .circleStroke(BLACK, CIRCLE_STROKE)
+ .circleRadius(
+ new ZoomDependentNumber(List.of(new ZoomStop(13, 1.4f), new ZoomStop(MAX_ZOOM, 10)))
+ )
+ .circleColor(DARK_GREEN)
+ .minZoom(13)
+ .maxZoom(MAX_ZOOM)
+ .intiallyHidden()
+ );
+ }
+
+ private static List edges(VectorSourceLayer edges) {
+ return List.of(
+ StyleBuilder
+ .ofId("edge")
+ .group(EDGES_GROUP)
+ .typeLine()
+ .vectorSourceLayer(edges)
+ .lineColor(MAGENTA)
+ .edgeFilter(EDGES_TO_DISPLAY)
+ .lineWidth(LINE_WIDTH)
+ .lineOffset(LINE_OFFSET)
+ .minZoom(6)
+ .maxZoom(MAX_ZOOM)
+ .intiallyHidden(),
+ StyleBuilder
+ .ofId("edge-name")
+ .group(EDGES_GROUP)
+ .typeSymbol()
+ .lineText("name")
+ .vectorSourceLayer(edges)
+ .edgeFilter(EDGES_TO_DISPLAY)
+ .minZoom(17)
+ .maxZoom(MAX_ZOOM)
+ .intiallyHidden(),
+ StyleBuilder
+ .ofId("link")
+ .group(EDGES_GROUP)
+ .typeLine()
+ .vectorSourceLayer(edges)
+ .lineColor(BRIGHT_GREEN)
+ .edgeFilter(
+ StreetTransitStopLink.class,
+ StreetTransitEntranceLink.class,
+ BoardingLocationToStopLink.class,
+ StreetVehicleRentalLink.class,
+ StreetVehicleParkingLink.class,
+ StreetStationCentroidLink.class
+ )
+ .lineWidth(LINE_WIDTH)
+ .lineOffset(LINE_OFFSET)
+ .minZoom(13)
+ .maxZoom(MAX_ZOOM)
+ .intiallyHidden()
+ );
+ }
+
+ private static List traversalPermissions(VectorSourceLayer edges) {
+ var permissionStyles = Arrays
+ .stream(StreetTraversalPermission.values())
+ .map(p ->
StyleBuilder
- .ofId("edge-name")
- .typeSymbol()
- .lineText("name")
+ .ofId(p.name())
.vectorSourceLayer(edges)
- .edgeFilter(EDGES_TO_DISPLAY)
- .minZoom(17)
- .maxZoom(MAX_ZOOM)
- .intiallyHidden(),
- StyleBuilder
- .ofId("link")
+ .group(TRAVERSAL_PERMISSIONS_GROUP)
.typeLine()
- .vectorSourceLayer(edges)
- .lineColor(BRIGHT_GREEN)
- .edgeFilter(
- StreetTransitStopLink.class,
- StreetTransitEntranceLink.class,
- BoardingLocationToStopLink.class,
- StreetVehicleRentalLink.class,
- StreetVehicleParkingLink.class,
- StreetStationCentroidLink.class
- )
+ .lineColor(permissionColor(p))
+ .permissionsFilter(p)
.lineWidth(LINE_WIDTH)
.lineOffset(LINE_OFFSET)
- .minZoom(13)
- .maxZoom(MAX_ZOOM)
- .intiallyHidden(),
- StyleBuilder
- .ofId("vertex")
- .typeCircle()
- .vectorSourceLayer(vertices)
- .circleStroke(BLACK, CIRCLE_STROKE)
- .circleRadius(
- new ZoomDependentNumber(1, List.of(new ZoomStop(15, 1), new ZoomStop(MAX_ZOOM, 7)))
- )
- .circleColor(PURPLE)
- .minZoom(15)
- .maxZoom(MAX_ZOOM)
- .intiallyHidden(),
- StyleBuilder
- .ofId("parking-vertex")
- .typeCircle()
- .vectorSourceLayer(vertices)
- .vertexFilter(VehicleParkingEntranceVertex.class)
- .circleStroke(BLACK, CIRCLE_STROKE)
- .circleRadius(
- new ZoomDependentNumber(1, List.of(new ZoomStop(13, 1.4f), new ZoomStop(MAX_ZOOM, 10)))
- )
- .circleColor(DARK_GREEN)
- .minZoom(13)
- .maxZoom(MAX_ZOOM)
- .intiallyHidden(),
- StyleBuilder
- .ofId("area-stop")
- .typeFill()
- .vectorSourceLayer(areaStops)
- .fillColor(BRIGHT_GREEN)
- .fillOpacity(0.5f)
- .fillOutlineColor(BLACK)
- .minZoom(6)
- .maxZoom(MAX_ZOOM),
- StyleBuilder
- .ofId("group-stop")
- .typeFill()
- .vectorSourceLayer(groupStops)
- .fillColor(BRIGHT_GREEN)
- .fillOpacity(0.5f)
- .fillOutlineColor(BLACK)
.minZoom(6)
- .maxZoom(MAX_ZOOM),
- StyleBuilder
- .ofId("regular-stop")
- .typeCircle()
- .vectorSourceLayer(regularStops)
- .circleStroke(
- BLACK,
- new ZoomDependentNumber(1, List.of(new ZoomStop(11, 0.5f), new ZoomStop(MAX_ZOOM, 5)))
- )
- .circleRadius(
- new ZoomDependentNumber(1, List.of(new ZoomStop(11, 0.5f), new ZoomStop(MAX_ZOOM, 10)))
- )
- .circleColor("#fcf9fa")
- .minZoom(10)
.maxZoom(MAX_ZOOM)
+ .intiallyHidden()
)
- );
+ .toList();
+ var textStyle = StyleBuilder
+ .ofId("permission-text")
+ .vectorSourceLayer(edges)
+ .group(TRAVERSAL_PERMISSIONS_GROUP)
+ .typeSymbol()
+ .lineText("permission")
+ .textOffset(1)
+ .edgeFilter(EDGES_TO_DISPLAY)
+ .minZoom(17)
+ .maxZoom(MAX_ZOOM)
+ .intiallyHidden();
+ return ListUtils.combine(permissionStyles, List.of(textStyle));
+ }
+
+ private static String permissionColor(StreetTraversalPermission p) {
+ return switch (p) {
+ case NONE -> "#000";
+ case PEDESTRIAN -> "#2ba812";
+ case BICYCLE, PEDESTRIAN_AND_BICYCLE -> "#10d3b6";
+ case CAR -> "#f92e13";
+ case BICYCLE_AND_CAR, PEDESTRIAN_AND_CAR -> "#e25f8f";
+ case ALL -> "#adb2b0";
+ };
}
}
diff --git a/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java b/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java
index 14b2fe8b014..93b7ea91e7c 100644
--- a/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java
+++ b/application/src/main/java/org/opentripplanner/apis/vectortiles/model/StyleBuilder.java
@@ -11,6 +11,7 @@
import org.opentripplanner.apis.vectortiles.model.ZoomDependentNumber.ZoomStop;
import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.framework.json.ObjectMappers;
+import org.opentripplanner.street.model.StreetTraversalPermission;
import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.vertex.Vertex;
@@ -26,6 +27,7 @@ public class StyleBuilder {
private final Map props = new LinkedHashMap<>();
private final Map paint = new LinkedHashMap<>();
private final Map layout = new LinkedHashMap<>();
+ private final Map metadata = new LinkedHashMap<>();
private final Map line = new LinkedHashMap<>();
private List filter = List.of();
@@ -48,6 +50,7 @@ public enum LayerType {
private StyleBuilder(String id) {
props.put("id", id);
+ metadata.put("group", "Other");
}
public StyleBuilder minZoom(int i) {
@@ -107,18 +110,28 @@ private StyleBuilder type(LayerType type) {
return this;
}
+ /**
+ * Puts the layer into an arbitrarily defined group in the layer selector. This allows you
+ * to switch the entire group on and off.
+ */
+ public StyleBuilder group(String group) {
+ metadata.put("group", group);
+ return this;
+ }
+
public StyleBuilder lineText(String name) {
- layout.put("symbol-placement", "line");
- layout.put("symbol-spacing", 500);
+ layout.put("symbol-placement", "line-center");
+ layout.put("symbol-spacing", 1000);
layout.put("text-field", "{%s}".formatted(name));
layout.put("text-font", List.of("KlokanTech Noto Sans Regular"));
layout.put(
"text-size",
- new ZoomDependentNumber(14, List.of(new ZoomStop(14, 12), new ZoomStop(20, 14))).toJson()
+ new ZoomDependentNumber(List.of(new ZoomStop(10, 6), new ZoomStop(24, 12))).toJson()
);
- layout.put("text-max-width", 5);
+ layout.put("text-max-width", 100);
layout.put("text-keep-upright", true);
layout.put("text-rotation-alignment", "map");
+ layout.put("text-overlap", "never");
paint.put("text-color", "#000");
paint.put("text-halo-color", "#fff");
paint.put("text-halo-blur", 4);
@@ -126,6 +139,11 @@ public StyleBuilder lineText(String name) {
return this;
}
+ public StyleBuilder textOffset(float offset) {
+ layout.put("text-offset", List.of(0, offset));
+ return this;
+ }
+
public StyleBuilder circleColor(String color) {
paint.put("circle-color", validateColor(color));
return this;
@@ -201,6 +219,14 @@ public final StyleBuilder edgeFilter(Class extends Edge>... classToFilter) {
return filterClasses(classToFilter);
}
+ /**
+ * Filter the entities by their "permission" property.
+ */
+ public final StyleBuilder permissionsFilter(StreetTraversalPermission p) {
+ filter = List.of("==", "permission", p.name());
+ return this;
+ }
+
/**
* Only apply the style to the given vertices.
*/
@@ -225,6 +251,7 @@ public JsonNode toJson() {
if (!line.isEmpty()) {
copy.put("line", line);
}
+ copy.put("metadata", metadata);
return OBJECT_MAPPER.valueToTree(copy);
}
diff --git a/application/src/main/java/org/opentripplanner/apis/vectortiles/model/ZoomDependentNumber.java b/application/src/main/java/org/opentripplanner/apis/vectortiles/model/ZoomDependentNumber.java
index d83c4b63495..4d1d83ee8a9 100644
--- a/application/src/main/java/org/opentripplanner/apis/vectortiles/model/ZoomDependentNumber.java
+++ b/application/src/main/java/org/opentripplanner/apis/vectortiles/model/ZoomDependentNumber.java
@@ -2,21 +2,26 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.stream.Stream;
+import org.opentripplanner.framework.collection.ListUtils;
import org.opentripplanner.framework.json.ObjectMappers;
/**
* A style parameter that allows you to specify a number that changes dependent on the zoom level.
*/
-public record ZoomDependentNumber(float base, List stops) {
+public record ZoomDependentNumber(List stops) {
private static final ObjectMapper OBJECT_MAPPER = ObjectMappers.ignoringExtraFields();
public JsonNode toJson() {
- var props = new LinkedHashMap<>();
- props.put("base", base);
- var vals = stops.stream().map(ZoomStop::toList).toList();
- props.put("stops", vals);
- return OBJECT_MAPPER.valueToTree(props);
+ var interpolation = new ArrayList<>();
+ interpolation.add("interpolate");
+ interpolation.add(List.of("linear"));
+ interpolation.add(List.of("zoom"));
+ stops.forEach(s -> interpolation.addAll(s.toList()));
+
+ return OBJECT_MAPPER.valueToTree(interpolation);
}
/**
diff --git a/application/src/main/java/org/opentripplanner/framework/application/OTPRequestTimeoutException.java b/application/src/main/java/org/opentripplanner/framework/application/OTPRequestTimeoutException.java
index a8b0789d7c0..9d71314f153 100644
--- a/application/src/main/java/org/opentripplanner/framework/application/OTPRequestTimeoutException.java
+++ b/application/src/main/java/org/opentripplanner/framework/application/OTPRequestTimeoutException.java
@@ -18,10 +18,9 @@ public String getMessage() {
/**
* The Grizzly web server is configured with a transaction timeout and will set the interrupt
- * flag on the current thread. OTP does not have many blocking operations which check the
- * interrupted flag, so instead we need to do the check manually. The check has a small
- * performance overhead so try to place the check in the beginning of significantly big block of
- * calculations.
+ * flag on the current thread. OTP has few blocking operations which check the interrupted flag,
+ * so instead we need to do the check manually. The check has a small performance overhead, so
+ * try to place the check at the beginning of a significant calculations.
*/
public static void checkForTimeout() {
// We call yield() to allow monitoring thread to interrupt current thread. If this work or not
diff --git a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java
index ebfeb3ff496..ccb88c3c74b 100644
--- a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java
+++ b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClient.java
@@ -378,6 +378,7 @@ private static RequestConfig requestConfig(Duration timeout) {
.custom()
.setResponseTimeout(Timeout.of(timeout))
.setConnectionRequestTimeout(Timeout.of(timeout))
+ .setProtocolUpgradeEnabled(false)
.build();
}
diff --git a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java
index a6436168541..8f7256f642f 100644
--- a/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java
+++ b/application/src/main/java/org/opentripplanner/framework/io/OtpHttpClientFactory.java
@@ -132,6 +132,7 @@ private static RequestConfig requestConfig(Duration timeout) {
.custom()
.setResponseTimeout(Timeout.of(timeout))
.setConnectionRequestTimeout(Timeout.of(timeout))
+ .setProtocolUpgradeEnabled(false)
.build();
}
}
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java b/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java
index d6f91696e64..f88cc6ea937 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/GraphBuilder.java
@@ -23,7 +23,7 @@
import org.opentripplanner.service.worldenvelope.WorldEnvelopeRepository;
import org.opentripplanner.standalone.config.BuildConfig;
import org.opentripplanner.street.model.StreetLimitationParameters;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,15 +37,19 @@ public class GraphBuilder implements Runnable {
private final List graphBuilderModules = new ArrayList<>();
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final DataImportIssueStore issueStore;
private boolean hasTransitData = false;
@Inject
- public GraphBuilder(Graph baseGraph, TransitModel transitModel, DataImportIssueStore issueStore) {
+ public GraphBuilder(
+ Graph baseGraph,
+ TimetableRepository timetableRepository,
+ DataImportIssueStore issueStore
+ ) {
this.graph = baseGraph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.issueStore = issueStore;
}
@@ -57,7 +61,7 @@ public static GraphBuilder create(
BuildConfig config,
GraphBuilderDataSources dataSources,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
WorldEnvelopeRepository worldEnvelopeRepository,
@Nullable EmissionsDataModel emissionsDataModel,
@Nullable StopConsolidationRepository stopConsolidationRepository,
@@ -70,18 +74,18 @@ public static GraphBuilder create(
boolean hasNetex = dataSources.has(NETEX);
boolean hasTransitData = hasGtfs || hasNetex;
- transitModel.initTimeZone(config.transitModelTimeZone);
+ timetableRepository.initTimeZone(config.transitModelTimeZone);
var builder = DaggerGraphBuilderFactory
.builder()
.config(config)
.graph(graph)
- .transitModel(transitModel)
+ .timetableRepository(timetableRepository)
.worldEnvelopeRepository(worldEnvelopeRepository)
.stopConsolidationRepository(stopConsolidationRepository)
.streetLimitationParameters(streetLimitationParameters)
.dataSources(dataSources)
- .timeZoneId(transitModel.getTimeZone());
+ .timeZoneId(timetableRepository.getTimeZone());
if (OTPFeature.Co2Emissions.isOn()) {
builder.emissionsDataModel(emissionsDataModel);
@@ -114,7 +118,7 @@ public static GraphBuilder create(
graphBuilder.addModule(factory.tripPatternNamer());
}
- if (hasTransitData && transitModel.getAgencyTimeZones().size() > 1) {
+ if (hasTransitData && timetableRepository.getAgencyTimeZones().size() > 1) {
graphBuilder.addModule(factory.timeZoneAdjusterModule());
}
@@ -194,7 +198,7 @@ public void run() {
new DataImportIssueSummary(issueStore.listIssues()).logSummary();
// Log before we validate, this way we have more information if the validation fails
- logGraphBuilderCompleteStatus(startTime, graph, transitModel);
+ logGraphBuilderCompleteStatus(startTime, graph, timetableRepository);
validate();
}
@@ -223,7 +227,7 @@ public DataImportIssueSummary issueSummary() {
* configuration, for example, then this function will throw a {@link OtpAppException}.
*/
private void validate() {
- if (hasTransitData() && !transitModel.hasTransit()) {
+ if (hasTransitData() && !timetableRepository.hasTransit()) {
throw new OtpAppException(
"The provided transit data have no trips within the configured transit service period. " +
"There is something wrong with your data - see the log above. Another possibility is that the " +
@@ -235,14 +239,14 @@ private void validate() {
private static void logGraphBuilderCompleteStatus(
long startTime,
Graph graph,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
long endTime = System.currentTimeMillis();
String time = DurationUtils.durationToStr(Duration.ofMillis(endTime - startTime));
var f = new OtpNumberFormat();
- var nStops = f.formatNumber(transitModel.getStopModel().stopIndexSize());
- var nPatterns = f.formatNumber(transitModel.getAllTripPatterns().size());
- var nTransfers = f.formatNumber(transitModel.getTransferService().listAll().size());
+ var nStops = f.formatNumber(timetableRepository.getSiteRepository().stopIndexSize());
+ var nPatterns = f.formatNumber(timetableRepository.getAllTripPatterns().size());
+ var nTransfers = f.formatNumber(timetableRepository.getTransferService().listAll().size());
var nVertices = f.formatNumber(graph.countVertices());
var nEdges = f.formatNumber(graph.countEdges());
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/GraphStats.java b/application/src/main/java/org/opentripplanner/graph_builder/GraphStats.java
index 718622a142d..199146667ed 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/GraphStats.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/GraphStats.java
@@ -27,7 +27,7 @@
import org.opentripplanner.street.model.vertex.TransitStopVertex;
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.transit.model.network.TripPattern;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ public class GraphStats {
private Graph graph;
- private TransitModel transitModel;
+ private TimetableRepository timetableRepository;
private CsvWriter writer;
@@ -97,7 +97,7 @@ private void run() {
File graphFile = new File(graphPath);
SerializedGraphObject serializedGraphObject = SerializedGraphObject.load(graphFile);
graph = serializedGraphObject.graph;
- transitModel = serializedGraphObject.transitModel;
+ timetableRepository = serializedGraphObject.timetableRepository;
/* open output stream (same for all commands) */
if (outPath != null) {
@@ -220,7 +220,7 @@ public void run() {
"empiricalDistTrips",
}
);
- Collection patterns = transitModel.getAllTripPatterns();
+ Collection patterns = timetableRepository.getAllTripPatterns();
Multiset counts = TreeMultiset.create();
int nPatterns = patterns.size();
LOG.info("total number of patterns is: {}", nPatterns);
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/issues/package-info.java b/application/src/main/java/org/opentripplanner/graph_builder/issues/package-info.java
deleted file mode 100644
index db899fdd206..00000000000
--- a/application/src/main/java/org/opentripplanner/graph_builder/issues/package-info.java
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * Graph builder data import issues represent errors or exceptional conditions encountered during
- * the graph building process. They contain descriptive messages and potentially references to the
- * objects in the graph that they annotate which facilitate visualization and cataloging/mapping of
- * problems.
- */
-package org.opentripplanner.graph_builder.issues;
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/issues/package-info.md b/application/src/main/java/org/opentripplanner/graph_builder/issues/package-info.md
new file mode 100644
index 00000000000..424605d5240
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/graph_builder/issues/package-info.md
@@ -0,0 +1,6 @@
+# Graph building issues
+
+Graph builder data import issues represent errors or exceptional conditions encountered during
+the graph building process. They contain descriptive messages and potentially references to the
+objects in the graph that they annotate which facilitate visualization and cataloging/mapping of
+problems.
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/model/GraphBuilderModule.java b/application/src/main/java/org/opentripplanner/graph_builder/model/GraphBuilderModule.java
index e4e67a0f3c1..0a551cff1c9 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/model/GraphBuilderModule.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/model/GraphBuilderModule.java
@@ -4,7 +4,7 @@
public interface GraphBuilderModule {
/**
* Process whatever inputs were supplied to this module and update the model objects(graph,
- * transitModel and issueStore).
+ * timetableRepository and issueStore).
*/
void buildGraph();
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java b/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java
similarity index 85%
rename from application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java
rename to application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java
index a4bbb10da68..1d335d7ff4f 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitModelEntitiesToGraph.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/AddTransitEntitiesToGraph.java
@@ -42,13 +42,13 @@
import org.opentripplanner.transit.model.site.Station;
import org.opentripplanner.transit.model.site.StationElement;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class AddTransitModelEntitiesToGraph {
+public class AddTransitEntitiesToGraph {
- private static final Logger LOG = LoggerFactory.getLogger(AddTransitModelEntitiesToGraph.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AddTransitEntitiesToGraph.class);
private final OtpTransitService otpTransitService;
@@ -62,7 +62,7 @@ public class AddTransitModelEntitiesToGraph {
* @param subwayAccessTime a positive integer for the extra time to access a subway platform, if
* negative the default value of zero is used.
*/
- private AddTransitModelEntitiesToGraph(
+ private AddTransitEntitiesToGraph(
OtpTransitService otpTransitService,
int subwayAccessTime,
Graph graph
@@ -76,16 +76,16 @@ public static void addToGraph(
OtpTransitService otpTransitService,
int subwayAccessTime,
Graph graph,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
- new AddTransitModelEntitiesToGraph(otpTransitService, subwayAccessTime, graph)
- .applyToGraph(transitModel);
+ new AddTransitEntitiesToGraph(otpTransitService, subwayAccessTime, graph)
+ .applyToGraph(timetableRepository);
}
- private void applyToGraph(TransitModel transitModel) {
- transitModel.mergeStopModels(otpTransitService.stopModel());
+ private void applyToGraph(TimetableRepository timetableRepository) {
+ timetableRepository.mergeSiteRepositories(otpTransitService.siteRepository());
- addStopsToGraphAndGenerateStopVertexes(transitModel);
+ addStopsToGraphAndGenerateStopVertexes(timetableRepository);
addEntrancesToGraph();
addStationCentroidsToGraph();
addPathwayNodesToGraph();
@@ -94,26 +94,26 @@ private void applyToGraph(TransitModel transitModel) {
// Although pathways are loaded from GTFS they are street data, so we will put them in the
// street graph.
createPathwayEdgesAndAddThemToGraph();
- addFeedInfoToGraph(transitModel);
- addAgenciesToGraph(transitModel);
- addServicesToTransitModel(transitModel);
- addTripPatternsToTransitModel(transitModel);
+ addFeedInfoToGraph(timetableRepository);
+ addAgenciesToGraph(timetableRepository);
+ addServicesToTimetableRepository(timetableRepository);
+ addTripPatternsToTimetableRepository(timetableRepository);
/* Interpret the transfers explicitly defined in transfers.txt. */
- addTransfersToGraph(transitModel);
+ addTransfersToGraph(timetableRepository);
if (OTPFeature.FlexRouting.isOn()) {
- addFlexTripsToGraph(transitModel);
+ addFlexTripsToGraph(timetableRepository);
}
}
- private void addStopsToGraphAndGenerateStopVertexes(TransitModel transitModel) {
+ private void addStopsToGraphAndGenerateStopVertexes(TimetableRepository timetableRepository) {
// Compute the set of modes for each stop based on all the TripPatterns it is part of
Map> stopModeMap = new HashMap<>();
for (TripPattern pattern : otpTransitService.getTripPatterns()) {
TransitMode mode = pattern.getMode();
- transitModel.addTransitMode(mode);
+ timetableRepository.addTransitMode(mode);
for (var stop : pattern.getStops()) {
Set set = stopModeMap.computeIfAbsent(stop, s -> new HashSet<>());
set.add(mode);
@@ -122,7 +122,7 @@ private void addStopsToGraphAndGenerateStopVertexes(TransitModel transitModel) {
// Add a vertex representing the stop.
// It is now possible for these vertices to not be connected to any edges.
- for (RegularStop stop : otpTransitService.stopModel().listRegularStops()) {
+ for (RegularStop stop : otpTransitService.siteRepository().listRegularStops()) {
Set modes = stopModeMap.get(stop);
TransitStopVertex stopVertex = vertexFactory.transitStop(
TransitStopVertex.of().withStop(stop).withModes(modes)
@@ -145,7 +145,7 @@ private void addEntrancesToGraph() {
}
private void addStationCentroidsToGraph() {
- for (Station station : otpTransitService.stopModel().listStations()) {
+ for (Station station : otpTransitService.siteRepository().listStations()) {
if (station.shouldRouteToCentroid()) {
vertexFactory.stationCentroid(station);
}
@@ -335,45 +335,47 @@ private StopLevel getStopLevel(StationElementVertex vertex) {
: new StopLevel(fromStation.getName(), null);
}
- private void addFeedInfoToGraph(TransitModel transitModel) {
+ private void addFeedInfoToGraph(TimetableRepository timetableRepository) {
for (FeedInfo info : otpTransitService.getAllFeedInfos()) {
- transitModel.addFeedInfo(info);
+ timetableRepository.addFeedInfo(info);
}
}
- private void addAgenciesToGraph(TransitModel transitModel) {
+ private void addAgenciesToGraph(TimetableRepository timetableRepository) {
for (Agency agency : otpTransitService.getAllAgencies()) {
- transitModel.addAgency(agency);
+ timetableRepository.addAgency(agency);
}
}
- private void addTransfersToGraph(TransitModel transitModel) {
- transitModel.getTransferService().addAll(otpTransitService.getAllTransfers());
+ private void addTransfersToGraph(TimetableRepository timetableRepository) {
+ timetableRepository.getTransferService().addAll(otpTransitService.getAllTransfers());
}
- private void addServicesToTransitModel(TransitModel transitModel) {
+ private void addServicesToTimetableRepository(TimetableRepository timetableRepository) {
/* Assign 0-based numeric codes to all GTFS service IDs. */
for (FeedScopedId serviceId : otpTransitService.getAllServiceIds()) {
- transitModel.getServiceCodes().put(serviceId, transitModel.getServiceCodes().size());
+ timetableRepository
+ .getServiceCodes()
+ .put(serviceId, timetableRepository.getServiceCodes().size());
}
}
- private void addTripPatternsToTransitModel(TransitModel transitModel) {
+ private void addTripPatternsToTimetableRepository(TimetableRepository timetableRepository) {
Collection tripPatterns = otpTransitService.getTripPatterns();
/* Loop over all new TripPatterns setting the service codes. */
for (TripPattern tripPattern : tripPatterns) {
// TODO this could be more elegant
- tripPattern.getScheduledTimetable().setServiceCodes(transitModel.getServiceCodes());
+ tripPattern.getScheduledTimetable().setServiceCodes(timetableRepository.getServiceCodes());
// Store the tripPattern in the Graph so it will be serialized and usable in routing.
- transitModel.addTripPattern(tripPattern.getId(), tripPattern);
+ timetableRepository.addTripPattern(tripPattern.getId(), tripPattern);
}
}
- private void addFlexTripsToGraph(TransitModel transitModel) {
+ private void addFlexTripsToGraph(TimetableRepository timetableRepository) {
for (FlexTrip, ?> flexTrip : otpTransitService.getAllFlexTrips()) {
- transitModel.addFlexTrip(flexTrip.getId(), flexTrip);
+ timetableRepository.addFlexTrip(flexTrip.getId(), flexTrip);
}
}
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java b/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java
index a87f28182ff..a1a0796c66a 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/DirectTransferGenerator.java
@@ -18,16 +18,14 @@
import org.opentripplanner.graph_builder.module.nearbystops.StreetNearbyStopFinder;
import org.opentripplanner.model.PathTransfer;
import org.opentripplanner.routing.api.request.RouteRequest;
-import org.opentripplanner.routing.api.request.request.StreetRequest;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.graphfinder.NearbyStop;
import org.opentripplanner.street.model.edge.Edge;
import org.opentripplanner.street.model.vertex.TransitStopVertex;
-import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,18 +45,18 @@ public class DirectTransferGenerator implements GraphBuilderModule {
private final List transferRequests;
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final DataImportIssueStore issueStore;
public DirectTransferGenerator(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore,
Duration radiusByDuration,
List transferRequests
) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.issueStore = issueStore;
this.radiusByDuration = radiusByDuration;
this.transferRequests = transferRequests;
@@ -67,7 +65,7 @@ public DirectTransferGenerator(
@Override
public void buildGraph() {
/* Initialize transit model index which is needed by the nearby stop finder. */
- transitModel.index();
+ timetableRepository.index();
/* The linker will use streets if they are available, or straight-line distance otherwise. */
NearbyStopFinder nearbyStopFinder = createNearbyStopFinder();
@@ -166,7 +164,7 @@ public void buildGraph() {
progress.step(m -> LOG.info(m));
});
- transitModel.addAllTransfersByStops(transfersByStop);
+ timetableRepository.addAllTransfersByStops(transfersByStop);
LOG.info(progress.completeMessage());
LOG.info(
@@ -182,7 +180,7 @@ public void buildGraph() {
* enabled.
*/
private NearbyStopFinder createNearbyStopFinder() {
- var transitService = new DefaultTransitService(transitModel);
+ var transitService = new DefaultTransitService(timetableRepository);
NearbyStopFinder finder;
if (!graph.hasStreets) {
LOG.info(
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java
index 3bb9c3745a8..c4acabefd6c 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/OsmBoardingLocationsModule.java
@@ -27,7 +27,7 @@
import org.opentripplanner.street.model.vertex.VertexFactory;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.street.search.TraverseModeSet;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,15 +55,15 @@ public class OsmBoardingLocationsModule implements GraphBuilderModule {
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final VertexFactory vertexFactory;
private VertexLinker linker;
@Inject
- public OsmBoardingLocationsModule(Graph graph, TransitModel transitModel) {
+ public OsmBoardingLocationsModule(Graph graph, TimetableRepository timetableRepository) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.vertexFactory = new VertexFactory(graph);
}
@@ -71,7 +71,7 @@ public OsmBoardingLocationsModule(Graph graph, TransitModel transitModel) {
public void buildGraph() {
LOG.info("Improving boarding locations by checking OSM entities...");
- StreetIndex streetIndex = graph.getStreetIndexSafe(transitModel.getStopModel());
+ StreetIndex streetIndex = graph.getStreetIndexSafe(timetableRepository.getSiteRepository());
this.linker = streetIndex.getVertexLinker();
int successes = 0;
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/RouteToCentroidStationIdsValidator.java b/application/src/main/java/org/opentripplanner/graph_builder/module/RouteToCentroidStationIdsValidator.java
index 0b17f956ae8..f7d8664e590 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/RouteToCentroidStationIdsValidator.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/RouteToCentroidStationIdsValidator.java
@@ -6,27 +6,27 @@
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
import org.opentripplanner.transit.model.framework.AbstractTransitEntity;
import org.opentripplanner.transit.model.framework.FeedScopedId;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
public class RouteToCentroidStationIdsValidator implements GraphBuilderModule {
private final DataImportIssueStore issueStore;
private final Collection transitRouteToStationCentroid;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
public RouteToCentroidStationIdsValidator(
DataImportIssueStore issueStore,
Collection transitRouteToStationCentroid,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
this.issueStore = issueStore;
this.transitRouteToStationCentroid = transitRouteToStationCentroid;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
}
private void validate() {
- var stationIds = transitModel
- .getStopModel()
+ var stationIds = timetableRepository
+ .getSiteRepository()
.listStations()
.stream()
.map(AbstractTransitEntity::getId)
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java
index a134dd3c75b..04aeac76049 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/StreetLinkerModule.java
@@ -28,10 +28,11 @@
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.street.search.TraverseModeSet;
+import org.opentripplanner.transit.model.network.CarAccess;
import org.opentripplanner.transit.model.site.GroupStop;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,30 +49,30 @@ public class StreetLinkerModule implements GraphBuilderModule {
private static final TraverseModeSet CAR_ONLY = new TraverseModeSet(TraverseMode.CAR);
private static final TraverseModeSet WALK_ONLY = new TraverseModeSet(TraverseMode.WALK);
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final DataImportIssueStore issueStore;
private final Boolean addExtraEdgesToAreas;
public StreetLinkerModule(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore,
boolean addExtraEdgesToAreas
) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.issueStore = issueStore;
this.addExtraEdgesToAreas = addExtraEdgesToAreas;
}
@Override
public void buildGraph() {
- transitModel.index();
- graph.index(transitModel.getStopModel());
+ timetableRepository.index();
+ graph.index(timetableRepository.getSiteRepository());
graph.getLinker().setAddExtraEdgesToAreas(this.addExtraEdgesToAreas);
if (graph.hasStreets) {
- linkTransitStops(graph, transitModel);
+ linkTransitStops(graph, timetableRepository);
linkTransitEntrances(graph);
linkStationCentroids(graph);
linkVehicleParks(graph, issueStore);
@@ -81,31 +82,18 @@ public void buildGraph() {
graph.calculateConvexHull();
}
- public void linkTransitStops(Graph graph, TransitModel transitModel) {
+ public void linkTransitStops(Graph graph, TimetableRepository timetableRepository) {
List vertices = graph.getVerticesOfType(TransitStopVertex.class);
var progress = ProgressTracker.track("Linking transit stops to graph", 5000, vertices.size());
LOG.info(progress.startMessage());
Set stopLocationsUsedForFlexTrips = Set.of();
-
if (OTPFeature.FlexRouting.isOn()) {
- stopLocationsUsedForFlexTrips =
- transitModel
- .getAllFlexTrips()
- .stream()
- .flatMap(t -> t.getStops().stream())
- .collect(Collectors.toSet());
-
- stopLocationsUsedForFlexTrips.addAll(
- stopLocationsUsedForFlexTrips
- .stream()
- .filter(GroupStop.class::isInstance)
- .map(GroupStop.class::cast)
- .flatMap(g -> g.getChildLocations().stream().filter(RegularStop.class::isInstance))
- .toList()
- );
+ stopLocationsUsedForFlexTrips = getStopLocationsUsedForFlexTrips(timetableRepository);
}
+ Set stopLocationsUsedForCarsAllowedTrips = timetableRepository.getStopLocationsUsedForCarsAllowedTrips();
+
for (TransitStopVertex tStop : vertices) {
// Stops with pathways do not need to be connected to the street network, since there are explicit entrances defined for that
if (tStop.hasPathways()) {
@@ -120,7 +108,10 @@ public void linkTransitStops(Graph graph, TransitModel transitModel) {
StopLinkType linkType = StopLinkType.WALK_ONLY;
if (
- OTPFeature.FlexRouting.isOn() && stopLocationsUsedForFlexTrips.contains(tStop.getStop())
+ (
+ OTPFeature.FlexRouting.isOn() && stopLocationsUsedForFlexTrips.contains(tStop.getStop())
+ ) ||
+ stopLocationsUsedForCarsAllowedTrips.contains(tStop.getStop())
) {
linkType = StopLinkType.WALK_AND_CAR;
}
@@ -366,6 +357,26 @@ private VehicleParking removeVehicleParkingEntranceVertexFromGraph(
}
}
+ private Set getStopLocationsUsedForFlexTrips(
+ TimetableRepository timetableRepository
+ ) {
+ Set stopLocations = timetableRepository
+ .getAllFlexTrips()
+ .stream()
+ .flatMap(t -> t.getStops().stream())
+ .collect(Collectors.toSet());
+
+ stopLocations.addAll(
+ stopLocations
+ .stream()
+ .filter(GroupStop.class::isInstance)
+ .map(GroupStop.class::cast)
+ .flatMap(g -> g.getChildLocations().stream().filter(RegularStop.class::isInstance))
+ .toList()
+ );
+ return stopLocations;
+ }
+
private enum StopLinkType {
/**
* Only ensure that the link leads to a walkable edge.
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/TimeZoneAdjusterModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/TimeZoneAdjusterModule.java
index 7168066afe3..3bd33f08a52 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/TimeZoneAdjusterModule.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/TimeZoneAdjusterModule.java
@@ -8,32 +8,32 @@
import java.util.Map;
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
import org.opentripplanner.transit.model.network.TripPattern;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* Adjust all scheduled times to match the transit model timezone.
*/
public class TimeZoneAdjusterModule implements GraphBuilderModule {
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
@Inject
- public TimeZoneAdjusterModule(TransitModel transitModel) {
- this.transitModel = transitModel;
+ public TimeZoneAdjusterModule(TimetableRepository timetableRepository) {
+ this.timetableRepository = timetableRepository;
}
@Override
public void buildGraph() {
// TODO: We assume that all time zones follow the same DST rules. In reality we need to split up
// the services for each DST transition
- final Instant serviceStart = transitModel.getTransitServiceStarts().toInstant();
+ final Instant serviceStart = timetableRepository.getTransitServiceStarts().toInstant();
var graphOffset = Duration.ofSeconds(
- transitModel.getTimeZone().getRules().getOffset(serviceStart).getTotalSeconds()
+ timetableRepository.getTimeZone().getRules().getOffset(serviceStart).getTotalSeconds()
);
Map agencyShift = new HashMap<>();
- transitModel
+ timetableRepository
.getAllTripPatterns()
.forEach(pattern -> {
var timeShift = agencyShift.computeIfAbsent(
@@ -53,8 +53,8 @@ public void buildGraph() {
)
.build();
// replace the original pattern with the updated pattern in the transit model
- transitModel.addTripPattern(updatedPattern.getId(), updatedPattern);
+ timetableRepository.addTripPattern(updatedPattern.getId(), updatedPattern);
});
- transitModel.index();
+ timetableRepository.index();
}
}
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java b/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java
index 744260ba784..238ddc5dc67 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/TripPatternNamer.java
@@ -12,24 +12,24 @@
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.timetable.TripTimes;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TripPatternNamer implements GraphBuilderModule {
private static final Logger LOG = LoggerFactory.getLogger(TripPatternNamer.class);
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
@Inject
- public TripPatternNamer(TransitModel transitModel) {
- this.transitModel = transitModel;
+ public TripPatternNamer(TimetableRepository timetableRepository) {
+ this.timetableRepository = timetableRepository;
}
@Override
public void buildGraph() {
/* Generate unique human-readable names for all the TableTripPatterns. */
- generateUniqueNames(transitModel.getAllTripPatterns());
+ generateUniqueNames(timetableRepository.getAllTripPatterns());
}
/**
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderFactory.java b/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderFactory.java
index 21b125b1188..d0d359cea3e 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderFactory.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderFactory.java
@@ -33,7 +33,7 @@
import org.opentripplanner.service.worldenvelope.WorldEnvelopeRepository;
import org.opentripplanner.standalone.config.BuildConfig;
import org.opentripplanner.street.model.StreetLimitationParameters;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
@Singleton
@Component(modules = { GraphBuilderModules.class })
@@ -77,7 +77,7 @@ interface Builder {
Builder graph(Graph graph);
@BindsInstance
- Builder transitModel(TransitModel transitModel);
+ Builder timetableRepository(TimetableRepository timetableRepository);
@BindsInstance
Builder worldEnvelopeRepository(WorldEnvelopeRepository worldEnvelopeRepository);
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java b/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java
index 85b34b5704b..080d69c571e 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/configure/GraphBuilderModules.java
@@ -45,7 +45,7 @@
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.standalone.config.BuildConfig;
import org.opentripplanner.street.model.StreetLimitationParameters;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* Configure all modules which is not simple enough to be injected.
@@ -95,7 +95,7 @@ static GtfsModule provideGtfsModule(
GraphBuilderDataSources dataSources,
BuildConfig config,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore
) {
List gtfsBundles = new ArrayList<>();
@@ -108,7 +108,7 @@ static GtfsModule provideGtfsModule(
}
return new GtfsModule(
gtfsBundles,
- transitModel,
+ timetableRepository,
graph,
issueStore,
config.getTransitServicePeriod(),
@@ -138,13 +138,13 @@ static NetexModule provideNetexModule(
GraphBuilderDataSources dataSources,
BuildConfig config,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore
) {
return new NetexConfigure(config)
.createNetexModule(
dataSources.getNetexConfiguredDatasource(),
- transitModel,
+ timetableRepository,
graph,
issueStore
);
@@ -155,10 +155,10 @@ static NetexModule provideNetexModule(
static StreetLinkerModule provideStreetLinkerModule(
BuildConfig config,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore
) {
- return new StreetLinkerModule(graph, transitModel, issueStore, config.areaVisibility);
+ return new StreetLinkerModule(graph, timetableRepository, issueStore, config.areaVisibility);
}
@Provides
@@ -166,14 +166,14 @@ static StreetLinkerModule provideStreetLinkerModule(
static PruneIslands providePruneIslands(
BuildConfig config,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore
) {
PruneIslands pruneIslands = new PruneIslands(
graph,
- transitModel,
+ timetableRepository,
issueStore,
- new StreetLinkerModule(graph, transitModel, issueStore, config.areaVisibility)
+ new StreetLinkerModule(graph, timetableRepository, issueStore, config.areaVisibility)
);
pruneIslands.setPruningThresholdIslandWithoutStops(
config.islandPruning.pruningThresholdIslandWithoutStops
@@ -229,12 +229,12 @@ static List provideElevationModules(
static DirectTransferGenerator provideDirectTransferGenerator(
BuildConfig config,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore
) {
return new DirectTransferGenerator(
graph,
- transitModel,
+ timetableRepository,
issueStore,
config.maxTransferDuration,
config.transferRequests
@@ -246,12 +246,12 @@ static DirectTransferGenerator provideDirectTransferGenerator(
static DirectTransferAnalyzer provideDirectTransferAnalyzer(
BuildConfig config,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore
) {
return new DirectTransferAnalyzer(
graph,
- transitModel,
+ timetableRepository,
issueStore,
config.maxTransferDuration.toSeconds() * WalkPreferences.DEFAULT.speed()
);
@@ -293,13 +293,13 @@ static DataImportIssueSummary providesDataImportIssueSummary(DataImportIssueStor
@Singleton
@Nullable
static StopConsolidationModule providesStopConsolidationModule(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
@Nullable StopConsolidationRepository repo,
GraphBuilderDataSources dataSources
) {
return dataSources
.stopConsolidation()
- .map(ds -> StopConsolidationModule.of(transitModel, repo, ds))
+ .map(ds -> StopConsolidationModule.of(timetableRepository, repo, ds))
.orElse(null);
}
@@ -309,12 +309,12 @@ static StopConsolidationModule providesStopConsolidationModule(
static RouteToCentroidStationIdsValidator routeToCentroidStationIdValidator(
DataImportIssueStore issueStore,
BuildConfig config,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
var ids = config.transitRouteToStationCentroid();
return ids.isEmpty()
? null
- : new RouteToCentroidStationIdsValidator(issueStore, ids, transitModel);
+ : new RouteToCentroidStationIdsValidator(issueStore, ids, timetableRepository);
}
/* private methods */
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/CalculateWorldEnvelopeModule.java b/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/CalculateWorldEnvelopeModule.java
index adcfe525414..e114eb612e3 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/CalculateWorldEnvelopeModule.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/geometry/CalculateWorldEnvelopeModule.java
@@ -9,7 +9,7 @@
import org.opentripplanner.service.worldenvelope.model.WorldEnvelope;
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,24 +28,24 @@ public class CalculateWorldEnvelopeModule implements GraphBuilderModule {
private static final int LOG_EVERY_N_COORDINATE = 1_000_000;
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final WorldEnvelopeRepository worldEnvelopeRepository;
@Inject
public CalculateWorldEnvelopeModule(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
WorldEnvelopeRepository worldEnvelopeRepository
) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.worldEnvelopeRepository = worldEnvelopeRepository;
}
@Override
public void buildGraph() {
var vertices = graph.getVertices();
- var stops = transitModel.getStopModel().listStopLocations();
+ var stops = timetableRepository.getSiteRepository().listStopLocations();
WorldEnvelope envelope = build(vertices, stops);
worldEnvelopeRepository.saveEnvelope(envelope);
}
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java b/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java
index 26349c0d803..8bb3b3fbcd5 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/islandpruning/PruneIslands.java
@@ -32,7 +32,7 @@
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.street.search.request.StreetSearchRequest;
import org.opentripplanner.street.search.state.State;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +48,7 @@ public class PruneIslands implements GraphBuilderModule {
private static final Logger LOG = LoggerFactory.getLogger(PruneIslands.class);
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final DataImportIssueStore issueStore;
private final StreetLinkerModule streetLinkerModule;
private int pruningThresholdWithoutStops;
@@ -60,12 +60,12 @@ public class PruneIslands implements GraphBuilderModule {
public PruneIslands(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore,
StreetLinkerModule streetLinkerModule
) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.issueStore = issueStore;
this.streetLinkerModule = streetLinkerModule;
}
@@ -81,8 +81,8 @@ public void buildGraph() {
adaptivePruningDistance
);
- this.vertexLinker = graph.getLinkerSafe(transitModel.getStopModel());
- this.streetIndex = graph.getStreetIndexSafe(transitModel.getStopModel());
+ this.vertexLinker = graph.getLinkerSafe(timetableRepository.getSiteRepository());
+ this.streetIndex = graph.getStreetIndexSafe(timetableRepository.getSiteRepository());
pruneIslands(TraverseMode.BICYCLE);
pruneIslands(TraverseMode.WALK);
@@ -91,7 +91,7 @@ public void buildGraph() {
// reconnect stops that got disconnected
if (streetLinkerModule != null) {
LOG.info("Reconnecting stops");
- streetLinkerModule.linkTransitStops(graph, transitModel);
+ streetLinkerModule.linkTransitStops(graph, timetableRepository);
int isolated = 0;
for (TransitStopVertex tStop : graph.getVerticesOfType(TransitStopVertex.class)) {
if (tStop.getDegreeOut() + tStop.getDegreeIn() == 0) {
diff --git a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java
index 88b1fe9f7da..e6727190b54 100644
--- a/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java
+++ b/application/src/main/java/org/opentripplanner/graph_builder/module/osm/OsmDatabase.java
@@ -253,11 +253,7 @@ public void addWay(OsmWay way) {
applyLevelsForWay(way);
- /* An area can be specified as such, or be one by default as an amenity */
- if (
- (way.isArea() || way.isParkAndRide() || way.isBikeParking() || way.isBoardingArea()) &&
- way.getNodeRefs().size() > 2
- ) {
+ if (way.isRoutableArea()) {
// this is an area that's a simple polygon. So we can just add it straight
// to the areas, if it's not part of a relation.
if (!areaWayIds.contains(wayId)) {
diff --git a/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java b/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java
index 2f7feb5993e..39f88f13281 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/graphbuilder/GtfsModule.java
@@ -35,7 +35,7 @@
import org.opentripplanner.framework.application.OTPFeature;
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
-import org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph;
+import org.opentripplanner.graph_builder.module.AddTransitEntitiesToGraph;
import org.opentripplanner.graph_builder.module.GtfsFeedId;
import org.opentripplanner.graph_builder.module.ValidateAndInterpolateStopTimesForEachTrip;
import org.opentripplanner.graph_builder.module.geometry.GeometryProcessor;
@@ -51,7 +51,7 @@
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.standalone.config.BuildConfig;
import org.opentripplanner.transit.model.framework.FeedScopedId;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -77,21 +77,21 @@ public class GtfsModule implements GraphBuilderModule {
private final List gtfsBundles;
private final FareServiceFactory fareServiceFactory;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final Graph graph;
private final DataImportIssueStore issueStore;
private int nextAgencyId = 1; // used for generating agency IDs to resolve ID conflicts
public GtfsModule(
List bundles,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
Graph graph,
DataImportIssueStore issueStore,
ServiceDateInterval transitPeriodLimit,
FareServiceFactory fareServiceFactory
) {
this.gtfsBundles = bundles;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.graph = graph;
this.issueStore = issueStore;
this.transitPeriodLimit = transitPeriodLimit;
@@ -100,13 +100,13 @@ public GtfsModule(
public GtfsModule(
List bundles,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
Graph graph,
ServiceDateInterval transitPeriodLimit
) {
this(
bundles,
- transitModel,
+ timetableRepository,
graph,
DataImportIssueStore.NOOP,
transitPeriodLimit,
@@ -132,7 +132,7 @@ public void buildGraph() {
feedIdsEncountered.put(feedId, gtfsBundle);
GTFSToOtpTransitServiceMapper mapper = new GTFSToOtpTransitServiceMapper(
- new OtpTransitServiceBuilder(transitModel.getStopModel(), issueStore),
+ new OtpTransitServiceBuilder(timetableRepository.getSiteRepository(), issueStore),
feedId,
issueStore,
gtfsBundle.discardMinTransferTimes(),
@@ -170,7 +170,7 @@ public void buildGraph() {
// NB! The calls below have side effects - the builder state is updated!
createTripPatterns(
graph,
- transitModel,
+ timetableRepository,
builder,
calendarServiceData.getServiceIds(),
geometryProcessor,
@@ -182,11 +182,11 @@ public void buildGraph() {
// if this or previously processed gtfs bundle has transit that has not been filtered out
hasTransit = hasTransit || otpTransitService.hasActiveTransit();
- addTransitModelToGraph(graph, transitModel, gtfsBundle, otpTransitService);
+ addTimetableRepositoryToGraph(graph, timetableRepository, gtfsBundle, otpTransitService);
if (gtfsBundle.blockBasedInterlining()) {
new InterlineProcessor(
- transitModel.getTransferService(),
+ timetableRepository.getTransferService(),
builder.getStaySeatedNotAllowed(),
gtfsBundle.maxInterlineDistance(),
issueStore,
@@ -206,9 +206,9 @@ public void buildGraph() {
gtfsBundles.forEach(GtfsBundle::close);
}
- transitModel.validateTimeZones();
+ timetableRepository.validateTimeZones();
- transitModel.updateCalendarServiceData(hasTransit, calendarServiceData, issueStore);
+ timetableRepository.updateCalendarServiceData(hasTransit, calendarServiceData, issueStore);
}
/**
@@ -268,7 +268,7 @@ private void validateAndInterpolateStopTimesForEachTrip(
*/
private void createTripPatterns(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
OtpTransitServiceBuilder builder,
Set calServiceIds,
GeometryProcessor geometryProcessor,
@@ -282,25 +282,25 @@ private void createTripPatterns(
geometryProcessor
);
buildTPOp.run();
- transitModel.setHasFrequencyService(
- transitModel.hasFrequencyService() || buildTPOp.hasFrequencyBasedTrips()
+ timetableRepository.setHasFrequencyService(
+ timetableRepository.hasFrequencyService() || buildTPOp.hasFrequencyBasedTrips()
);
- transitModel.setHasScheduledService(
- transitModel.hasScheduledService() || buildTPOp.hasScheduledTrips()
+ timetableRepository.setHasScheduledService(
+ timetableRepository.hasScheduledService() || buildTPOp.hasScheduledTrips()
);
}
- private void addTransitModelToGraph(
+ private void addTimetableRepositoryToGraph(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
GtfsBundle gtfsBundle,
OtpTransitService otpTransitService
) {
- AddTransitModelEntitiesToGraph.addToGraph(
+ AddTransitEntitiesToGraph.addToGraph(
otpTransitService,
gtfsBundle.subwayAccessTime,
graph,
- transitModel
+ timetableRepository
);
}
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java
index f57a9db8684..e72b3ae584b 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/AgencyMapper.java
@@ -36,7 +36,6 @@ private Agency doMap(org.onebusaway.gtfs.model.Agency rhs) {
.withLang(rhs.getLang())
.withPhone(rhs.getPhone())
.withFareUrl(rhs.getFareUrl())
- .withBrandingUrl(rhs.getBrandingUrl())
.build();
}
}
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/BrandingMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/BrandingMapper.java
deleted file mode 100644
index 5e370335d4e..00000000000
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/BrandingMapper.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.opentripplanner.gtfs.mapping;
-
-import javax.annotation.Nullable;
-import org.onebusaway.gtfs.model.Route;
-import org.opentripplanner.transit.model.framework.FeedScopedId;
-import org.opentripplanner.transit.model.organization.Branding;
-
-/** Responsible for mapping GTFS Route into the OTP Branding model. */
-public class BrandingMapper {
-
- /**
- * Convert GTFS Route entity into OTP Branding model.
- *
- * @param route GTFS Route entity
- * @return OTP branding model. Null if route branding url is not present.
- */
- @Nullable
- public Branding map(Route route) {
- if (route.getBrandingUrl() == null) {
- return null;
- }
- // Make an id from the url, the id is required
- var id = new FeedScopedId(route.getId().getAgencyId(), route.getBrandingUrl());
- return Branding.of(id).withUrl(route.getBrandingUrl()).build();
- }
-}
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/CarAccessMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/CarAccessMapper.java
new file mode 100644
index 00000000000..4034814462b
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/CarAccessMapper.java
@@ -0,0 +1,19 @@
+package org.opentripplanner.gtfs.mapping;
+
+import org.onebusaway.gtfs.model.Trip;
+import org.opentripplanner.transit.model.network.CarAccess;
+
+/**
+ * Model car access for GTFS trips.
+ */
+class CarAccessMapper {
+
+ public static CarAccess mapForTrip(Trip rhs) {
+ int carsAllowed = rhs.getCarsAllowed();
+ return switch (carsAllowed) {
+ case 1 -> CarAccess.ALLOWED;
+ case 2 -> CarAccess.NOT_ALLOWED;
+ default -> CarAccess.UNKNOWN;
+ };
+ }
+}
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java
index b7aea1c2e2f..8e3718be4c6 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/GTFSToOtpTransitServiceMapper.java
@@ -105,12 +105,13 @@ public GTFSToOtpTransitServiceMapper(
feedInfoMapper = new FeedInfoMapper(feedId);
agencyMapper = new AgencyMapper(feedId);
stationMapper = new StationMapper(translationHelper, stationTransferPreference);
- stopMapper = new StopMapper(translationHelper, stationLookup, builder.stopModel());
+ stopMapper = new StopMapper(translationHelper, stationLookup, builder.siteRepository());
entranceMapper = new EntranceMapper(translationHelper, stationLookup);
pathwayNodeMapper = new PathwayNodeMapper(translationHelper, stationLookup);
boardingAreaMapper = new BoardingAreaMapper(translationHelper, stopLookup);
- locationMapper = new LocationMapper(builder.stopModel(), issueStore);
- locationGroupMapper = new LocationGroupMapper(stopMapper, locationMapper, builder.stopModel());
+ locationMapper = new LocationMapper(builder.siteRepository(), issueStore);
+ locationGroupMapper =
+ new LocationGroupMapper(stopMapper, locationMapper, builder.siteRepository());
pathwayMapper =
new PathwayMapper(stopMapper, entranceMapper, pathwayNodeMapper, boardingAreaMapper);
routeMapper = new RouteMapper(agencyMapper, issueStore, translationHelper);
@@ -142,7 +143,7 @@ public FareRulesData getFareRulesService() {
}
public void mapStopTripAndRouteDataIntoBuilder() {
- var stopModel = builder.stopModel();
+ var siteRepository = builder.siteRepository();
translationHelper.importTranslations(data.getAllTranslations(), data.getAllFeedInfos());
builder.getAgenciesById().addAll(agencyMapper.map(data.getAllAgencies()));
@@ -159,8 +160,8 @@ public void mapStopTripAndRouteDataIntoBuilder() {
if (OTPFeature.FlexRouting.isOn()) {
// Stop areas and Stop groups are only used in FLEX routes
- builder.stopModel().withAreaStops(locationMapper.map(data.getAllLocations()));
- builder.stopModel().withGroupStops(locationGroupMapper.map(data.getAllLocationGroups()));
+ builder.siteRepository().withAreaStops(locationMapper.map(data.getAllLocations()));
+ builder.siteRepository().withGroupStops(locationGroupMapper.map(data.getAllLocationGroups()));
}
builder.getPathways().addAll(pathwayMapper.map(data.getAllPathways()));
@@ -184,14 +185,14 @@ private void mapGtfsStopsToOtpTypes(Collection s
// Map station first, so we can link to them
for (org.onebusaway.gtfs.model.Stop it : stops) {
if (it.getLocationType() == LOCATION_TYPE_STATION) {
- builder.stopModel().withStation(stationMapper.map(it));
+ builder.siteRepository().withStation(stationMapper.map(it));
}
}
// Map Stop, Entrance and PathwayNode, link to station
for (org.onebusaway.gtfs.model.Stop it : stops) {
if (it.getLocationType() == LOCATION_TYPE_STOP) {
- builder.stopModel().withRegularStop(stopMapper.map(it));
+ builder.siteRepository().withRegularStop(stopMapper.map(it));
} else if (it.getLocationType() == LOCATION_TYPE_ENTRANCE_EXIT) {
builder.getEntrances().add(entranceMapper.map(it));
} else if (it.getLocationType() == LOCATION_TYPE_NODE) {
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationGroupMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationGroupMapper.java
index 591a59c492e..b4ba6d3cc27 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationGroupMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationGroupMapper.java
@@ -13,24 +13,24 @@
import org.opentripplanner.framework.i18n.NonLocalizedString;
import org.opentripplanner.transit.model.site.GroupStop;
import org.opentripplanner.transit.model.site.GroupStopBuilder;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
public class LocationGroupMapper {
private final StopMapper stopMapper;
private final LocationMapper locationMapper;
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
private final Map mappedLocationGroups = new HashMap<>();
public LocationGroupMapper(
StopMapper stopMapper,
LocationMapper locationMapper,
- StopModelBuilder stopModelBuilder
+ SiteRepositoryBuilder siteRepositoryBuilder
) {
this.stopMapper = stopMapper;
this.locationMapper = locationMapper;
- this.stopModelBuilder = stopModelBuilder;
+ this.siteRepositoryBuilder = siteRepositoryBuilder;
}
Collection map(Collection allLocationGroups) {
@@ -43,7 +43,7 @@ GroupStop map(LocationGroup original) {
}
private GroupStop doMap(LocationGroup element) {
- GroupStopBuilder groupStopBuilder = stopModelBuilder
+ GroupStopBuilder groupStopBuilder = siteRepositoryBuilder
.groupStop(mapAgencyAndId(element.getId()))
.withName(new NonLocalizedString(element.getName()));
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationMapper.java
index 79a28ac0f61..5a845b8bfe8 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/LocationMapper.java
@@ -15,17 +15,20 @@
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.graph_builder.issue.api.Issue;
import org.opentripplanner.transit.model.site.AreaStop;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
/** Responsible for mapping GTFS Location into the OTP model. */
public class LocationMapper {
private final Map mappedLocations = new HashMap<>();
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
private final DataImportIssueStore issueStore;
- public LocationMapper(StopModelBuilder stopModelBuilder, DataImportIssueStore issueStore) {
- this.stopModelBuilder = stopModelBuilder;
+ public LocationMapper(
+ SiteRepositoryBuilder siteRepositoryBuilder,
+ DataImportIssueStore issueStore
+ ) {
+ this.siteRepositoryBuilder = siteRepositoryBuilder;
this.issueStore = issueStore;
}
@@ -57,7 +60,7 @@ private AreaStop doMap(Location gtfsLocation) {
)
);
}
- return stopModelBuilder
+ return siteRepositoryBuilder
.areaStop(id)
.withName(name)
.withUrl(NonLocalizedString.ofNullable(gtfsLocation.getUrl()))
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java
index 0c668f64b92..776a829f6b7 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/RouteMapper.java
@@ -15,7 +15,6 @@
class RouteMapper {
private final AgencyMapper agencyMapper;
- private final BrandingMapper brandingMapper;
private final DataImportIssueStore issueStore;
@@ -30,7 +29,6 @@ class RouteMapper {
) {
this.agencyMapper = agencyMapper;
this.issueStore = issueStore;
- this.brandingMapper = new BrandingMapper();
this.translationHelper = helper;
}
@@ -82,7 +80,6 @@ private Route doMap(org.onebusaway.gtfs.model.Route rhs) {
lhs.withColor(rhs.getColor());
lhs.withTextColor(rhs.getTextColor());
lhs.withBikesAllowed(BikeAccessMapper.mapForRoute(rhs));
- lhs.withBranding(brandingMapper.map(rhs));
if (rhs.getNetworkId() != null) {
var networkId = GroupOfRoutes
.of(new FeedScopedId(rhs.getId().getAgencyId(), rhs.getNetworkId()))
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/StopMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/StopMapper.java
index 2f7aef34312..4cbe252d68f 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/StopMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/StopMapper.java
@@ -12,24 +12,24 @@
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.RegularStopBuilder;
import org.opentripplanner.transit.model.site.Station;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
/** Responsible for mapping GTFS Stop into the OTP model. */
class StopMapper {
private final Map mappedStops = new HashMap<>();
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
private final TranslationHelper translationHelper;
private final Function stationLookUp;
StopMapper(
TranslationHelper translationHelper,
Function stationLookUp,
- StopModelBuilder stopModelBuilder
+ SiteRepositoryBuilder siteRepositoryBuilder
) {
this.translationHelper = translationHelper;
this.stationLookUp = stationLookUp;
- this.stopModelBuilder = stopModelBuilder;
+ this.siteRepositoryBuilder = siteRepositoryBuilder;
}
Collection map(Collection allStops) {
@@ -44,7 +44,7 @@ RegularStop map(org.onebusaway.gtfs.model.Stop original) {
private RegularStop doMap(org.onebusaway.gtfs.model.Stop gtfsStop) {
assertLocationTypeIsStop(gtfsStop);
StopMappingWrapper base = new StopMappingWrapper(gtfsStop);
- RegularStopBuilder builder = stopModelBuilder
+ RegularStopBuilder builder = siteRepositoryBuilder
.regularStop(base.getId())
.withCode(base.getCode())
.withCoordinate(base.getCoordinate())
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/TransitModeMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/TransitModeMapper.java
index 608ff6ba2d3..0640011bb3b 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/TransitModeMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/TransitModeMapper.java
@@ -16,7 +16,8 @@ public static TransitMode mapMode(int routeType) {
}
/* TPEG Extension https://groups.google.com/d/msg/gtfs-changes/keT5rTPS7Y0/71uMz2l6ke0J */
- if (routeType >= 100 && routeType < 200) { // Railway Service
+ if (routeType >= 100 && routeType < 200) {
+ // Railway Service
return TransitMode.RAIL;
} else if (routeType >= 200 && routeType < 300) { //Coach Service
return TransitMode.BUS;
@@ -28,24 +29,32 @@ public static TransitMode mapMode(int routeType) {
return TransitMode.MONORAIL;
}
return TransitMode.RAIL;
- } else if (routeType >= 500 && routeType < 700) { //Metro Service and Underground Service
+ } else if (routeType >= 500 && routeType < 700) {
+ // Metro Service and Underground Service
return TransitMode.SUBWAY;
- } else if (routeType >= 700 && routeType < 900) { //Bus Service and Trolleybus service
- if (routeType == 800) {
- return TransitMode.TROLLEYBUS;
- }
+ } else if (routeType >= 700 && routeType < 800) {
+ // Bus Service
return TransitMode.BUS;
- } else if (routeType >= 900 && routeType < 1000) { //Tram service
+ } else if (routeType >= 800 && routeType < 900) {
+ // Trolleybus Service
+ return TransitMode.TROLLEYBUS;
+ } else if (routeType >= 900 && routeType < 1000) {
+ // Tram service
return TransitMode.TRAM;
- } else if (routeType >= 1000 && routeType < 1100) { //Water Transport Service
+ } else if (routeType >= 1000 && routeType < 1100) {
+ // Water Transport Service
return TransitMode.FERRY;
- } else if (routeType >= 1100 && routeType < 1200) { //Air Service
+ } else if (routeType >= 1100 && routeType < 1200) {
+ // Air Service
return TransitMode.AIRPLANE;
- } else if (routeType >= 1200 && routeType < 1300) { //Ferry Service
+ } else if (routeType >= 1200 && routeType < 1300) {
+ // Ferry Service
return TransitMode.FERRY;
- } else if (routeType >= 1300 && routeType < 1400) { //Telecabin Service
+ } else if (routeType >= 1300 && routeType < 1400) {
+ // Telecabin Service
return TransitMode.GONDOLA;
- } else if (routeType >= 1400 && routeType < 1500) { //Funicular Service
+ } else if (routeType >= 1400 && routeType < 1500) {
+ // Funicular Service
return TransitMode.FUNICULAR;
} else if (routeType >= 1551 && routeType < 1561) {
// Carpooling, not defined anywhere, so we've chosen this number space
@@ -53,11 +62,13 @@ public static TransitMode mapMode(int routeType) {
// standardise
return TransitMode.CARPOOL;
} else if (routeType >= 1500 && routeType < 1599) {
- //Taxi Service
+ // Taxi Service
return TransitMode.TAXI;
- } else if (routeType >= 1600 && routeType < 1700) { //Self drive
+ } else if (routeType >= 1600 && routeType < 1700) {
+ // Self drive
return TransitMode.BUS;
- } else if (routeType >= 1700 && routeType < 1800) { //Miscellaneous Service
+ } else if (routeType >= 1700 && routeType < 1800) {
+ // Miscellaneous Service
return null;
}
/* Original GTFS route types. Should these be checked before TPEG types? */
diff --git a/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java b/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java
index fdef2bb4e0c..4e805d6d1df 100644
--- a/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java
+++ b/application/src/main/java/org/opentripplanner/gtfs/mapping/TripMapper.java
@@ -71,6 +71,7 @@ private Trip doMap(org.onebusaway.gtfs.model.Trip rhs) {
lhs.withShapeId(AgencyAndIdMapper.mapAgencyAndId(rhs.getShapeId()));
lhs.withWheelchairBoarding(WheelchairAccessibilityMapper.map(rhs.getWheelchairAccessible()));
lhs.withBikesAllowed(BikeAccessMapper.mapForTrip(rhs));
+ lhs.withCarsAllowed(CarAccessMapper.mapForTrip(rhs));
var trip = lhs.build();
mapSafeTimePenalty(rhs).ifPresent(f -> flexSafeTimePenalties.put(trip, f));
diff --git a/application/src/main/java/org/opentripplanner/model/OtpTransitService.java b/application/src/main/java/org/opentripplanner/model/OtpTransitService.java
index 91351af383d..748c44fa788 100644
--- a/application/src/main/java/org/opentripplanner/model/OtpTransitService.java
+++ b/application/src/main/java/org/opentripplanner/model/OtpTransitService.java
@@ -16,7 +16,7 @@
import org.opentripplanner.transit.model.site.Pathway;
import org.opentripplanner.transit.model.site.PathwayNode;
import org.opentripplanner.transit.model.timetable.Trip;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
/**
* Methods for accessing imported entities.
@@ -35,7 +35,7 @@ public interface OtpTransitService {
Collection getAllFeedInfos();
- StopModel stopModel();
+ SiteRepository siteRepository();
/**
* This is equivalent to a Transmodel Notice Assignments. The map key may reference entity ids of
diff --git a/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java b/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java
index bb02695122e..fa8bb2e55e0 100644
--- a/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java
+++ b/application/src/main/java/org/opentripplanner/model/TimetableSnapshot.java
@@ -132,7 +132,7 @@ public class TimetableSnapshot {
/**
* The realTimeAdded* maps are indexes on the trips created at runtime (extra-journey), and the
* Route, TripPattern, TripOnServiceDate they refer to.
- * They are meant to override the corresponding indexes in TransitModelIndex.
+ * They are meant to override the corresponding indexes in TimetableRepositoryIndex.
*/
private final Map realtimeAddedRoutes;
private final Map realTimeAddedTrips;
@@ -406,8 +406,13 @@ public void clear(String feedId) {
boolean newTripPatternsForModifiedTripsWereCleared = clearNewTripPatternsForModifiedTrips(
feedId
);
+ boolean addedTripPatternsWereCleared = clearEntriesForRealtimeAddedTrips(feedId);
// If this snapshot was modified, it will be dirty after the clear actions.
- if (timetablesWereCleared || newTripPatternsForModifiedTripsWereCleared) {
+ if (
+ timetablesWereCleared ||
+ newTripPatternsForModifiedTripsWereCleared ||
+ addedTripPatternsWereCleared
+ ) {
dirty = true;
}
}
@@ -552,7 +557,7 @@ private boolean clearTimetables(String feedId) {
}
/**
- * Clear all realtime added trip patterns matching the provided feed id.
+ * Clear new trip patterns for modified trips matching the provided feed id.
*
* @param feedId feed id to clear out
* @return true if the newTripPatternForModifiedTrip changed as a result of the call
@@ -563,6 +568,28 @@ private boolean clearNewTripPatternsForModifiedTrips(String feedId) {
.removeIf(tripIdAndServiceDate -> feedId.equals(tripIdAndServiceDate.tripId().getFeedId()));
}
+ /**
+ * Clear all realtime added routes, trip patterns and trips matching the provided feed id.
+ *
+ * */
+ private boolean clearEntriesForRealtimeAddedTrips(String feedId) {
+ // it is sufficient to test for the removal of added trips, since other indexed entities are
+ // added only if a new trip is added.
+ boolean removedEntry = realTimeAddedTrips
+ .keySet()
+ .removeIf(id -> feedId.equals(id.getFeedId()));
+ realTimeAddedPatternForTrip.keySet().removeIf(trip -> feedId.equals(trip.getId().getFeedId()));
+ realTimeAddedTripOnServiceDateForTripAndDay
+ .keySet()
+ .removeIf(tripOnServiceDate -> feedId.equals(tripOnServiceDate.tripId().getFeedId()));
+ realTimeAddedTripOnServiceDateById.keySet().removeIf(id -> feedId.equals(id.getFeedId()));
+ realTimeAddedPatternsForRoute
+ .keySet()
+ .removeIf(route -> feedId.equals(route.getId().getFeedId()));
+ realtimeAddedRoutes.keySet().removeIf(id -> feedId.equals(id.getFeedId()));
+ return removedEntry;
+ }
+
/**
* Add the patterns to the stop index, only if they come from a modified pattern
*/
diff --git a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java
index d62d0331a34..3dd4a3db992 100644
--- a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java
+++ b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceBuilder.java
@@ -54,8 +54,8 @@
import org.opentripplanner.transit.model.timetable.Trip;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
import org.opentripplanner.transit.model.timetable.TripTimes;
-import org.opentripplanner.transit.service.StopModel;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepository;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -78,7 +78,7 @@ public class OtpTransitServiceBuilder {
private final List frequencies = new ArrayList<>();
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
private final Multimap noticeAssignments = ArrayListMultimap.create();
@@ -124,8 +124,8 @@ public class OtpTransitServiceBuilder {
private final DataImportIssueStore issueStore;
- public OtpTransitServiceBuilder(StopModel stopModel, DataImportIssueStore issueStore) {
- this.stopModelBuilder = stopModel.withContext();
+ public OtpTransitServiceBuilder(SiteRepository siteRepository, DataImportIssueStore issueStore) {
+ this.siteRepositoryBuilder = siteRepository.withContext();
this.issueStore = issueStore;
}
@@ -151,16 +151,16 @@ public List getFrequencies() {
return frequencies;
}
- public StopModelBuilder stopModel() {
- return stopModelBuilder;
+ public SiteRepositoryBuilder siteRepository() {
+ return siteRepositoryBuilder;
}
public ImmutableEntityById getGroupsOfStationsById() {
- return stopModelBuilder.groupOfStationById();
+ return siteRepositoryBuilder.groupOfStationById();
}
public ImmutableEntityById getMultiModalStationsById() {
- return stopModelBuilder.multiModalStationById();
+ return siteRepositoryBuilder.multiModalStationById();
}
/**
@@ -188,11 +188,11 @@ public Multimap getShapePoints() {
}
public ImmutableEntityById getStations() {
- return stopModelBuilder.stationById();
+ return siteRepositoryBuilder.stationById();
}
public ImmutableEntityById getStops() {
- return stopModelBuilder.regularStopsById();
+ return siteRepositoryBuilder.regularStopsById();
}
public EntityById getEntrances() {
@@ -208,11 +208,11 @@ public EntityById getBoardingAreas() {
}
public ImmutableEntityById getAreaStops() {
- return stopModelBuilder.areaStopById();
+ return siteRepositoryBuilder.areaStopById();
}
public ImmutableEntityById getGroupStops() {
- return stopModelBuilder.groupStopById();
+ return siteRepositoryBuilder.groupStopById();
}
public TripStopTimes getStopTimesSortedByTrip() {
diff --git a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java
index 9ca549f1631..2f735f36435 100644
--- a/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java
+++ b/application/src/main/java/org/opentripplanner/model/impl/OtpTransitServiceImpl.java
@@ -26,7 +26,7 @@
import org.opentripplanner.transit.model.site.Pathway;
import org.opentripplanner.transit.model.site.PathwayNode;
import org.opentripplanner.transit.model.timetable.Trip;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
/**
* A in-memory implementation of {@link OtpTransitService}. It's super fast for most methods, but
@@ -45,7 +45,7 @@ class OtpTransitServiceImpl implements OtpTransitService {
private final Collection feedInfos;
- private final StopModel stopModel;
+ private final SiteRepository siteRepository;
private final ImmutableListMultimap noticeAssignments;
@@ -77,7 +77,7 @@ class OtpTransitServiceImpl implements OtpTransitService {
OtpTransitServiceImpl(OtpTransitServiceBuilder builder) {
this.agencies = immutableList(builder.getAgenciesById().values());
this.feedInfos = immutableList(builder.getFeedInfos());
- this.stopModel = builder.stopModel().build();
+ this.siteRepository = builder.siteRepository().build();
this.noticeAssignments = ImmutableListMultimap.copyOf(builder.getNoticeAssignments());
this.operators = immutableList(builder.getOperatorsById().values());
this.pathways = immutableList(builder.getPathways());
@@ -109,8 +109,8 @@ public Collection getAllFeedInfos() {
}
@Override
- public StopModel stopModel() {
- return stopModel;
+ public SiteRepository siteRepository() {
+ return siteRepository;
}
/**
diff --git a/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java b/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java
index c3d8513c2f1..18055690b6e 100644
--- a/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java
+++ b/application/src/main/java/org/opentripplanner/model/plan/Itinerary.java
@@ -232,7 +232,7 @@ public void removeDeletionFlags(Set removeTags) {
}
public boolean isFlaggedForDeletion() {
- return !getSystemNotices().isEmpty();
+ return !systemNotices.isEmpty();
}
/**
diff --git a/application/src/main/java/org/opentripplanner/model/plan/Leg.java b/application/src/main/java/org/opentripplanner/model/plan/Leg.java
index d9e3a4589d8..174fdf70452 100644
--- a/application/src/main/java/org/opentripplanner/model/plan/Leg.java
+++ b/application/src/main/java/org/opentripplanner/model/plan/Leg.java
@@ -161,6 +161,7 @@ default boolean overlapInTime(Leg other) {
/**
* For transit legs, the route agency. For non-transit legs {@code null}.
*/
+ @Nullable
default Agency getAgency() {
return null;
}
@@ -171,6 +172,7 @@ default Agency getAgency() {
*
* @see Trip#getOperator()
*/
+ @Nullable
default Operator getOperator() {
return null;
}
@@ -178,6 +180,7 @@ default Operator getOperator() {
/**
* For transit legs, the route. For non-transit legs, null.
*/
+ @Nullable
default Route getRoute() {
return null;
}
@@ -198,6 +201,7 @@ default TripOnServiceDate getTripOnServiceDate() {
return null;
}
+ @Nullable
default Accessibility getTripWheelchairAccessibility() {
return null;
}
@@ -245,6 +249,7 @@ default boolean getRealTime() {
return false;
}
+ @Nullable
default RealTimeState getRealTimeState() {
return null;
}
@@ -261,6 +266,7 @@ default boolean isFlexibleTrip() {
/**
* Is this a frequency-based trip with non-strict departure times?
*/
+ @Nullable
default Boolean getNonExactFrequency() {
return null;
}
@@ -270,6 +276,7 @@ default Boolean getNonExactFrequency() {
* non-strict frequency trips, but could become important for real-time trips, strict frequency
* trips, and scheduled trips with empirical headways.
*/
+ @Nullable
default Integer getHeadway() {
return null;
}
@@ -289,10 +296,11 @@ default int getAgencyTimeZoneOffset() {
/**
* For transit legs, the type of the route. Non transit -1 When 0-7: 0 Tram, 1 Subway, 2 Train, 3
- * Bus, 4 Ferry, 5 Cable Car, 6 Gondola, 7 Funicular When equal or highter than 100, it is coded
+ * Bus, 4 Ferry, 5 Cable Tram, 6 Gondola, 7 Funicular When equal or highter than 100, it is coded
* using the Hierarchical Vehicle Type (HVT) codes from the European TPEG standard Also see
* http://groups.google.com/group/gtfs-changes/msg/ed917a69cf8c5bef
*/
+ @Nullable
default Integer getRouteType() {
return null;
}
@@ -300,6 +308,7 @@ default Integer getRouteType() {
/**
* For transit legs, the headsign of the bus or train being used. For non-transit legs, null.
*/
+ @Nullable
default I18NString getHeadsign() {
return null;
}
@@ -312,6 +321,7 @@ default I18NString getHeadsign() {
* for a given trip may happen at service date March 25th and service time 25:00, which in local
* time would be Mach 26th 01:00.
*/
+ @Nullable
default LocalDate getServiceDate() {
return null;
}
@@ -319,6 +329,7 @@ default LocalDate getServiceDate() {
/**
* For transit leg, the route's branding URL (if one exists). For non-transit legs, null.
*/
+ @Nullable
default String getRouteBrandingUrl() {
return null;
}
@@ -337,6 +348,7 @@ default String getRouteBrandingUrl() {
* For transit legs, intermediate stops between the Place where the leg originates and the Place
* where the leg ends. For non-transit legs, {@code null}.
*/
+ @Nullable
default List getIntermediateStops() {
return null;
}
@@ -344,6 +356,7 @@ default List getIntermediateStops() {
/**
* The leg's geometry.
*/
+ @Nullable
LineString getLegGeometry();
/**
@@ -352,6 +365,7 @@ default List getIntermediateStops() {
* The elevation profile as a comma-separated list of x,y values. x is the distance from the start
* of the leg, y is the elevation at this distance.
*/
+ @Nullable
default ElevationProfile getElevationProfile() {
return null;
}
@@ -364,49 +378,59 @@ default List getWalkSteps() {
}
default Set getStreetNotes() {
- return null;
+ return Set.of();
}
default Set getTransitAlerts() {
return Set.of();
}
+ @Nullable
default PickDrop getBoardRule() {
return null;
}
+ @Nullable
default PickDrop getAlightRule() {
return null;
}
+ @Nullable
default BookingInfo getDropOffBookingInfo() {
return null;
}
+ @Nullable
default BookingInfo getPickupBookingInfo() {
return null;
}
+ @Nullable
default ConstrainedTransfer getTransferFromPrevLeg() {
return null;
}
+ @Nullable
default ConstrainedTransfer getTransferToNextLeg() {
return null;
}
+ @Nullable
default Integer getBoardStopPosInPattern() {
return null;
}
+ @Nullable
default Integer getAlightStopPosInPattern() {
return null;
}
+ @Nullable
default Integer getBoardingGtfsStopSequence() {
return null;
}
+ @Nullable
default Integer getAlightGtfsStopSequence() {
return null;
}
@@ -414,6 +438,7 @@ default Integer getAlightGtfsStopSequence() {
/**
* Is this leg walking with a bike?
*/
+ @Nullable
default Boolean getWalkingBike() {
return null;
}
@@ -435,10 +460,12 @@ default Float accessibilityScore() {
return null;
}
+ @Nullable
default Boolean getRentedVehicle() {
return null;
}
+ @Nullable
default String getVehicleRentalNetwork() {
return null;
}
@@ -453,6 +480,7 @@ default String getVehicleRentalNetwork() {
*/
int getGeneralizedCost();
+ @Nullable
default LegReference getLegReference() {
return null;
}
diff --git a/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java b/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java
index 7af091531e0..9949d83cdfe 100644
--- a/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java
+++ b/application/src/main/java/org/opentripplanner/model/plan/ScheduledTransitLeg.java
@@ -96,10 +96,7 @@ protected ScheduledTransitLeg(ScheduledTransitLegBuilder> builder) {
setDistanceMeters(getDistanceFromCoordinates(transitLegCoordinates));
this.directDistanceMeters =
getDistanceFromCoordinates(
- List.of(
- transitLegCoordinates.get(0),
- transitLegCoordinates.get(transitLegCoordinates.size() - 1)
- )
+ List.of(transitLegCoordinates.getFirst(), transitLegCoordinates.getLast())
);
}
@@ -139,22 +136,23 @@ public Boolean isInterlinedWithPreviousLeg() {
@Override
public Agency getAgency() {
- return getTrip().getRoute().getAgency();
+ return trip().getRoute().getAgency();
}
@Override
+ @Nullable
public Operator getOperator() {
- return getTrip().getOperator();
+ return trip().getOperator();
}
@Override
public Route getRoute() {
- return getTrip().getRoute();
+ return trip().getRoute();
}
@Override
public Trip getTrip() {
- return tripTimes.getTrip();
+ return trip();
}
@Override
@@ -182,7 +180,7 @@ public LegTime end() {
@Override
public TransitMode getMode() {
- return getTrip().getMode();
+ return trip().getMode();
}
@Override
@@ -247,7 +245,7 @@ public double getDirectDistanceMeters() {
@Override
public Integer getRouteType() {
- return getTrip().getRoute().getGtfsType();
+ return trip().getRoute().getGtfsType();
}
@Override
@@ -300,6 +298,7 @@ public Set getTransitAlerts() {
}
@Override
+ @Nullable
public PickDrop getBoardRule() {
if (transferFromPrevLeg != null && transferFromPrevLeg.getTransferConstraint().isStaySeated()) {
return null;
@@ -308,6 +307,7 @@ public PickDrop getBoardRule() {
}
@Override
+ @Nullable
public PickDrop getAlightRule() {
if (transferToNextLeg != null && transferToNextLeg.getTransferConstraint().isStaySeated()) {
return null;
@@ -434,6 +434,13 @@ public String toString() {
.toString();
}
+ /**
+ * Non-null getter for trip
+ */
+ private Trip trip() {
+ return tripTimes.getTrip();
+ }
+
private List extractTransitLegCoordinates(
TripPattern tripPattern,
int boardStopIndexInPattern,
diff --git a/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java b/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java
index df43bbcb411..76179a8ee7c 100644
--- a/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java
+++ b/application/src/main/java/org/opentripplanner/model/plan/UnknownTransitPathLeg.java
@@ -4,6 +4,7 @@
import java.time.ZonedDateTime;
import java.util.List;
+import javax.annotation.Nullable;
import org.locationtech.jts.geom.LineString;
import org.opentripplanner.framework.time.DurationUtils;
import org.opentripplanner.framework.tostring.ToStringBuilder;
@@ -84,6 +85,7 @@ public double getDistanceMeters() {
}
@Override
+ @Nullable
public LineString getLegGeometry() {
return null;
}
diff --git a/application/src/main/java/org/opentripplanner/netex/NetexBundle.java b/application/src/main/java/org/opentripplanner/netex/NetexBundle.java
index a0e0aae8500..b061c9e9352 100644
--- a/application/src/main/java/org/opentripplanner/netex/NetexBundle.java
+++ b/application/src/main/java/org/opentripplanner/netex/NetexBundle.java
@@ -125,19 +125,19 @@ public void close() throws IOException {
/** Load all files entries in the bundle */
private void loadFileEntries() {
// Load global shared files
- loadFilesThenMapToOtpTransitModel("shared file", hierarchy.sharedEntries());
+ loadFilesThenMapToTimetableRepository("shared file", hierarchy.sharedEntries());
for (GroupEntries group : hierarchy.groups()) {
LOG.info("reading group {}", group.name());
scopeInputData(() -> {
// Load shared group files
- loadFilesThenMapToOtpTransitModel("shared group file", group.sharedEntries());
+ loadFilesThenMapToTimetableRepository("shared group file", group.sharedEntries());
for (DataSource entry : group.independentEntries()) {
scopeInputData(() -> {
// Load each independent file in group
- loadFilesThenMapToOtpTransitModel("group file", List.of(entry));
+ loadFilesThenMapToTimetableRepository("group file", List.of(entry));
});
}
});
@@ -164,7 +164,7 @@ private void scopeInputData(Runnable task) {
* when read, would lead to missing references, since the order entries are read is not enforced
* in any way.
*/
- private void loadFilesThenMapToOtpTransitModel(
+ private void loadFilesThenMapToTimetableRepository(
String fileDescription,
Iterable entries
) {
diff --git a/application/src/main/java/org/opentripplanner/netex/NetexModule.java b/application/src/main/java/org/opentripplanner/netex/NetexModule.java
index 92ee25dbab2..4c45131389f 100644
--- a/application/src/main/java/org/opentripplanner/netex/NetexModule.java
+++ b/application/src/main/java/org/opentripplanner/netex/NetexModule.java
@@ -5,7 +5,7 @@
import org.opentripplanner.framework.application.OTPFeature;
import org.opentripplanner.graph_builder.issue.api.DataImportIssueStore;
import org.opentripplanner.graph_builder.model.GraphBuilderModule;
-import org.opentripplanner.graph_builder.module.AddTransitModelEntitiesToGraph;
+import org.opentripplanner.graph_builder.module.AddTransitEntitiesToGraph;
import org.opentripplanner.graph_builder.module.ValidateAndInterpolateStopTimesForEachTrip;
import org.opentripplanner.model.OtpTransitService;
import org.opentripplanner.model.TripStopTimes;
@@ -15,7 +15,7 @@
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingHelper;
import org.opentripplanner.standalone.config.BuildConfig;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* This module is used for importing the NeTEx CEN Technical Standard for exchanging Public
@@ -28,7 +28,7 @@ public class NetexModule implements GraphBuilderModule {
private final int subwayAccessTime;
private final Graph graph;
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private final DataImportIssueStore issueStore;
/**
@@ -41,14 +41,14 @@ public class NetexModule implements GraphBuilderModule {
public NetexModule(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
DataImportIssueStore issueStore,
int subwayAccessTime,
ServiceDateInterval transitPeriodLimit,
List netexBundles
) {
this.graph = graph;
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.issueStore = issueStore;
this.subwayAccessTime = subwayAccessTime;
this.transitPeriodLimit = transitPeriodLimit;
@@ -70,7 +70,7 @@ public void buildGraph() {
);
transitBuilder.limitServiceDays(transitPeriodLimit);
for (var tripOnServiceDate : transitBuilder.getTripOnServiceDates().values()) {
- transitModel.addTripOnServiceDate(tripOnServiceDate);
+ timetableRepository.addTripOnServiceDate(tripOnServiceDate);
}
calendarServiceData.add(transitBuilder.buildCalendarServiceData());
@@ -87,20 +87,20 @@ public void buildGraph() {
// if this or previously processed netex bundle has transit that has not been filtered out
hasActiveTransit = hasActiveTransit || otpService.hasActiveTransit();
- // TODO OTP2 - Move this into the AddTransitModelEntitiesToGraph
+ // TODO OTP2 - Move this into the AddTransitEntitiesToGraph
// - and make sure they also work with GTFS feeds - GTFS do no
// - have operators and notice assignments.
- transitModel.addOperators(otpService.getAllOperators());
- transitModel.addNoticeAssignments(otpService.getNoticeAssignments());
+ timetableRepository.addOperators(otpService.getAllOperators());
+ timetableRepository.addNoticeAssignments(otpService.getNoticeAssignments());
- AddTransitModelEntitiesToGraph.addToGraph(
+ AddTransitEntitiesToGraph.addToGraph(
otpService,
subwayAccessTime,
graph,
- transitModel
+ timetableRepository
);
- transitModel.validateTimeZones();
+ timetableRepository.validateTimeZones();
var lots = transitBuilder.vehicleParkings();
graph.getVehicleParkingService().updateVehicleParking(lots, List.of());
@@ -108,7 +108,11 @@ public void buildGraph() {
lots.forEach(linker::linkVehicleParkingToGraph);
}
- transitModel.updateCalendarServiceData(hasActiveTransit, calendarServiceData, issueStore);
+ timetableRepository.updateCalendarServiceData(
+ hasActiveTransit,
+ calendarServiceData,
+ issueStore
+ );
} catch (Exception e) {
throw new RuntimeException(e);
}
diff --git a/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java b/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java
index 5f4b665e362..9ca6dc27b04 100644
--- a/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java
+++ b/application/src/main/java/org/opentripplanner/netex/configure/NetexConfigure.java
@@ -12,7 +12,7 @@
import org.opentripplanner.netex.loader.NetexDataSourceHierarchy;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.standalone.config.BuildConfig;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* Responsible for dependency injection and creating main NeTEx module objects. This decouple the
@@ -35,7 +35,7 @@ public NetexConfigure(BuildConfig builderParams) {
public NetexModule createNetexModule(
Iterable> netexSources,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
Graph graph,
DataImportIssueStore issueStore
) {
@@ -43,7 +43,7 @@ public NetexModule createNetexModule(
for (ConfiguredDataSource it : netexSources) {
var transitServiceBuilder = new OtpTransitServiceBuilder(
- transitModel.getStopModel(),
+ timetableRepository.getSiteRepository(),
issueStore
);
netexBundles.add(netexBundle(transitServiceBuilder, it));
@@ -51,7 +51,7 @@ public NetexModule createNetexModule(
return new NetexModule(
graph,
- transitModel,
+ timetableRepository,
issueStore,
buildParams.getSubwayAccessTimeSeconds(),
buildParams.getTransitServicePeriod(),
diff --git a/application/src/main/java/org/opentripplanner/netex/loader/parser/package-info.java b/application/src/main/java/org/opentripplanner/netex/loader/parser/package-info.java
deleted file mode 100644
index a0b9cd00721..00000000000
--- a/application/src/main/java/org/opentripplanner/netex/loader/parser/package-info.java
+++ /dev/null
@@ -1,2 +0,0 @@
-package org.opentripplanner.netex.loader.parser;
-// TODO OTP2 - This package need Unit tests
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java
index 7e06db882f1..1bbe76c0e7c 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/FlexStopsMapper.java
@@ -15,7 +15,7 @@
import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
import org.rutebanken.netex.model.FlexibleArea;
import org.rutebanken.netex.model.FlexibleStopPlace;
import org.rutebanken.netex.model.KeyListStructure;
@@ -34,14 +34,14 @@ class FlexStopsMapper {
"UnrestrictedPublicTransportAreas";
private final FeedScopedIdFactory idFactory;
private final HashGridSpatialIndex stopsSpatialIndex;
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
private final DataImportIssueStore issueStore;
private final TransportModeMapper transportModeMapper = new TransportModeMapper();
FlexStopsMapper(
FeedScopedIdFactory idFactory,
Collection stops,
- StopModelBuilder stopModelBuilder,
+ SiteRepositoryBuilder siteRepositoryBuilder,
DataImportIssueStore issueStore
) {
this.idFactory = idFactory;
@@ -50,7 +50,7 @@ class FlexStopsMapper {
Envelope env = new Envelope(stop.getCoordinate().asJtsCoordinate());
this.stopsSpatialIndex.insert(env, stop);
}
- this.stopModelBuilder = stopModelBuilder;
+ this.siteRepositoryBuilder = siteRepositoryBuilder;
this.issueStore = issueStore;
}
@@ -100,7 +100,7 @@ StopLocation map(FlexibleStopPlace flexibleStopPlace) {
} else {
// We create a new GroupStop, even if the stop place consists of a single area, in order to
// get the ids for the area and stop place correct
- var builder = stopModelBuilder
+ var builder = siteRepositoryBuilder
.groupStop(idFactory.createId(flexibleStopPlace.getId()))
.withName(new NonLocalizedString(flexibleStopPlace.getName().getValue()))
.withEncompassingAreaGeometries(areaGeometries);
@@ -118,7 +118,7 @@ AreaStop mapFlexArea(FlexibleArea area, Geometry geometry, String backupName) {
}
var areaName = area.getName();
- return stopModelBuilder
+ return siteRepositoryBuilder
.areaStop(idFactory.createId(area.getId()))
.withName(new NonLocalizedString(areaName != null ? areaName.getValue() : backupName))
.withGeometry(geometry)
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
index 909d7b1c69f..c8d4f80af63 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
@@ -309,7 +309,7 @@ private void mapStopPlaceAndQuays(TariffZoneMapper tariffZoneMapper) {
idFactory,
currentNetexIndex.getQuayById(),
tariffZoneMapper,
- transitBuilder.stopModel(),
+ transitBuilder.siteRepository(),
zoneId,
issueStore,
noTransfersOnIsolatedStops,
@@ -321,8 +321,8 @@ private void mapStopPlaceAndQuays(TariffZoneMapper tariffZoneMapper) {
.lookup(stopPlaceId);
stopMapper.mapParentAndChildStops(stopPlaceAllVersions);
}
- transitBuilder.stopModel().withRegularStops(stopMapper.resultStops);
- transitBuilder.stopModel().withStations(stopMapper.resultStations);
+ transitBuilder.siteRepository().withRegularStops(stopMapper.resultStops);
+ transitBuilder.siteRepository().withStations(stopMapper.resultStations);
currentMapperIndexes.addStationByMultiModalStationRfs(
stopMapper.resultStationByMultiModalStationRfs
);
@@ -339,7 +339,7 @@ private void mapMultiModalStopPlaces() {
.get(multiModalStopPlace.getId());
var multiModalStation = mapper.map(multiModalStopPlace, stations);
if (multiModalStation != null) {
- transitBuilder.stopModel().withMultiModalStation(multiModalStation);
+ transitBuilder.siteRepository().withMultiModalStation(multiModalStation);
}
}
}
@@ -354,7 +354,9 @@ private void mapGroupsOfStopPlaces() {
for (GroupOfStopPlaces groupOfStopPlaces : currentNetexIndex
.getGroupOfStopPlacesById()
.localValues()) {
- transitBuilder.stopModel().withGroupOfStation(groupOfStationsMapper.map(groupOfStopPlaces));
+ transitBuilder
+ .siteRepository()
+ .withGroupOfStation(groupOfStationsMapper.map(groupOfStopPlaces));
}
}
@@ -371,19 +373,19 @@ private void mapFlexibleStopPlaces() {
FlexStopsMapper flexStopsMapper = new FlexStopsMapper(
idFactory,
transitBuilder.getStops().values(),
- transitBuilder.stopModel(),
+ transitBuilder.siteRepository(),
issueStore
);
for (FlexibleStopPlace flexibleStopPlace : flexibleStopPlaces) {
StopLocation stopLocation = flexStopsMapper.map(flexibleStopPlace);
if (stopLocation instanceof AreaStop areaStop) {
- transitBuilder.stopModel().withAreaStop(areaStop);
+ transitBuilder.siteRepository().withAreaStop(areaStop);
} else if (stopLocation instanceof GroupStop groupStop) {
- transitBuilder.stopModel().withGroupStop(groupStop);
+ transitBuilder.siteRepository().withGroupStop(groupStop);
for (var child : groupStop.getChildLocations()) {
if (child instanceof AreaStop areaStop) {
- transitBuilder.stopModel().withAreaStop(areaStop);
+ transitBuilder.siteRepository().withAreaStop(areaStop);
}
}
}
@@ -444,9 +446,9 @@ private void mapTripPatterns(Map serviceIds) {
issueStore,
idFactory,
transitBuilder.getOperatorsById(),
- transitBuilder.stopModel().regularStopsById(),
- transitBuilder.stopModel().areaStopById(),
- transitBuilder.stopModel().groupStopById(),
+ transitBuilder.siteRepository().regularStopsById(),
+ transitBuilder.siteRepository().areaStopById(),
+ transitBuilder.siteRepository().groupStopById(),
transitBuilder.getRoutes(),
currentNetexIndex.getRouteById(),
currentNetexIndex.getJourneyPatternsById(),
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java
index a304ca32f72..db67941e323 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/QuayMapper.java
@@ -11,7 +11,7 @@
import org.opentripplanner.transit.model.site.FareZone;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.Station;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
import org.rutebanken.netex.model.MultilingualString;
import org.rutebanken.netex.model.Quay;
@@ -21,16 +21,16 @@ class QuayMapper {
private final FeedScopedIdFactory idFactory;
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
QuayMapper(
FeedScopedIdFactory idFactory,
DataImportIssueStore issueStore,
- StopModelBuilder stopModelBuilder
+ SiteRepositoryBuilder siteRepositoryBuilder
) {
this.idFactory = idFactory;
this.issueStore = issueStore;
- this.stopModelBuilder = stopModelBuilder;
+ this.siteRepositoryBuilder = siteRepositoryBuilder;
}
/**
@@ -45,7 +45,7 @@ RegularStop mapQuayToStop(
Accessibility wheelchair
) {
var id = idFactory.createId(quay.getId());
- return stopModelBuilder.computeRegularStopIfAbsent(
+ return siteRepositoryBuilder.computeRegularStopIfAbsent(
id,
it -> map(it, quay, parentStation, fareZones, transitMode, wheelchair)
);
@@ -70,7 +70,7 @@ private RegularStop map(
return null;
}
- var builder = stopModelBuilder
+ var builder = siteRepositoryBuilder
.regularStop(id)
.withParentStation(parentStation)
.withName(parentStation.getName())
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java
index 2b2152be4e0..090f475e22e 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/ServiceLinkMapper.java
@@ -3,6 +3,7 @@
import jakarta.xml.bind.JAXBElement;
import java.util.Arrays;
import java.util.List;
+import javax.annotation.Nullable;
import net.opengis.gml._3.LineStringType;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.CoordinateSequence;
@@ -116,6 +117,7 @@ private LineString[] generateGeometriesFromServiceLinks(
return geometries;
}
+ @Nullable
private LineString mapServiceLink(
ServiceLink serviceLink,
StopPattern stopPattern,
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java
index 8840f7e4bdf..27773a9f66c 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/StationMapper.java
@@ -17,7 +17,7 @@
import org.opentripplanner.netex.support.JAXBUtils;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.site.Station;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
import org.rutebanken.netex.model.LimitedUseTypeEnumeration;
import org.rutebanken.netex.model.LocaleStructure;
import org.rutebanken.netex.model.MultilingualString;
@@ -38,7 +38,7 @@ class StationMapper {
private final Set routeToCentroidStopPlaceIds;
- private final StopModelBuilder stopModelBuilder;
+ private final SiteRepositoryBuilder siteRepositoryBuilder;
StationMapper(
DataImportIssueStore issueStore,
@@ -46,19 +46,22 @@ class StationMapper {
ZoneId defaultTimeZone,
boolean noTransfersOnIsolatedStops,
Set routeToCentroidStopPlaceIds,
- StopModelBuilder stopModelBuilder
+ SiteRepositoryBuilder siteRepositoryBuilder
) {
this.issueStore = issueStore;
this.idFactory = idFactory;
this.defaultTimeZone = defaultTimeZone;
this.noTransfersOnIsolatedStops = noTransfersOnIsolatedStops;
this.routeToCentroidStopPlaceIds = routeToCentroidStopPlaceIds;
- this.stopModelBuilder = stopModelBuilder;
+ this.siteRepositoryBuilder = siteRepositoryBuilder;
}
Station map(StopPlace stopPlace) {
var id = idFactory.createId(stopPlace.getId());
- return stopModelBuilder.computeStationIfAbsent(id, it -> mapStopPlaceToStation(it, stopPlace));
+ return siteRepositoryBuilder.computeStationIfAbsent(
+ id,
+ it -> mapStopPlaceToStation(it, stopPlace)
+ );
}
Station mapStopPlaceToStation(FeedScopedId id, StopPlace stopPlace) {
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java
index c5618a03a1a..0a5ab4ba16c 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/StopAndStationMapper.java
@@ -26,7 +26,7 @@
import org.opentripplanner.transit.model.site.FareZone;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.Station;
-import org.opentripplanner.transit.service.StopModelBuilder;
+import org.opentripplanner.transit.service.SiteRepositoryBuilder;
import org.rutebanken.netex.model.Quay;
import org.rutebanken.netex.model.Quays_RelStructure;
import org.rutebanken.netex.model.StopPlace;
@@ -68,7 +68,7 @@ class StopAndStationMapper {
FeedScopedIdFactory idFactory,
ReadOnlyHierarchicalVersionMapById quayIndex,
TariffZoneMapper tariffZoneMapper,
- StopModelBuilder stopModelBuilder,
+ SiteRepositoryBuilder siteRepositoryBuilder,
ZoneId defaultTimeZone,
DataImportIssueStore issueStore,
boolean noTransfersOnIsolatedStops,
@@ -81,9 +81,9 @@ class StopAndStationMapper {
defaultTimeZone,
noTransfersOnIsolatedStops,
routeToCentroidStopPlaceIds,
- stopModelBuilder
+ siteRepositoryBuilder
);
- this.quayMapper = new QuayMapper(idFactory, issueStore, stopModelBuilder);
+ this.quayMapper = new QuayMapper(idFactory, issueStore, siteRepositoryBuilder);
this.tariffZoneMapper = tariffZoneMapper;
this.quayIndex = quayIndex;
this.issueStore = issueStore;
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/StopPlaceTypeMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/StopPlaceTypeMapper.java
index 22fbb1fca1c..b98ce0fd39f 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/StopPlaceTypeMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/StopPlaceTypeMapper.java
@@ -29,7 +29,7 @@ private TransitMode mapVehicleMode(StopPlace stopPlace) {
case AIR -> TransitMode.AIRPLANE;
case BUS -> TransitMode.BUS;
case TROLLEY_BUS -> TransitMode.TROLLEYBUS;
- case CABLEWAY -> TransitMode.CABLE_CAR;
+ case CABLEWAY -> TransitMode.GONDOLA;
case COACH -> TransitMode.COACH;
case FUNICULAR -> TransitMode.FUNICULAR;
case METRO -> TransitMode.SUBWAY;
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/TransportModeMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/TransportModeMapper.java
index 82a5f99c9c7..5db45f93c8d 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/TransportModeMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/TransportModeMapper.java
@@ -32,7 +32,7 @@ public TransitMode mapAllVehicleModesOfTransport(AllVehicleModesOfTransportEnume
return switch (mode) {
case AIR -> TransitMode.AIRPLANE;
case BUS -> TransitMode.BUS;
- case CABLEWAY -> TransitMode.CABLE_CAR;
+ case CABLEWAY -> TransitMode.GONDOLA;
case COACH -> TransitMode.COACH;
case FUNICULAR -> TransitMode.FUNICULAR;
case METRO -> TransitMode.SUBWAY;
diff --git a/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java b/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java
index 30b87d248a0..02b5de80bb3 100644
--- a/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java
+++ b/application/src/main/java/org/opentripplanner/netex/mapping/TripMapper.java
@@ -137,7 +137,7 @@ Trip mapServiceJourney(ServiceJourney serviceJourney, Supplier headsign)
);
// TODO RTM - Instead of getting the first headsign from the StopTime this could be the
- // - default behaviour of the TransitModel - So, in the NeTEx mapper we would just
+ // - default behaviour of the TimetableRepository - So, in the NeTEx mapper we would just
// - ignore setting the headsign on the Trip.
builder.withHeadsign(new NonLocalizedString(headsign.get()));
diff --git a/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java b/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java
index 7f102b27c5a..7b5fbe56748 100644
--- a/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java
+++ b/application/src/main/java/org/opentripplanner/osm/model/OsmWay.java
@@ -14,6 +14,7 @@ public class OsmWay extends OsmWithTags {
"backward",
"reversible"
);
+
private final TLongList nodes = new TLongArrayList();
public void addNodeRef(long nodeRef) {
@@ -137,8 +138,23 @@ public boolean isBackwardEscalator() {
return isEscalator() && "backward".equals(this.getTag("conveying"));
}
- public boolean isArea() {
- return isTag("area", "yes");
+ /**
+ * Returns true if the way is considered an area.
+ *
+ * An area can be specified as such, or be one by default as an amenity.
+ */
+ public boolean isRoutableArea() {
+ return (
+ !isTag("area", "no") &&
+ (
+ isTag("area", "yes") ||
+ isParking() ||
+ isBikeParking() ||
+ isBoardingArea() ||
+ isIndoorRoutable()
+ ) &&
+ getNodeRefs().size() > 2
+ );
}
/**
diff --git a/application/src/main/java/org/opentripplanner/osm/model/OsmWithTags.java b/application/src/main/java/org/opentripplanner/osm/model/OsmWithTags.java
index 1cd08d9fcd5..cbaf4652b34 100644
--- a/application/src/main/java/org/opentripplanner/osm/model/OsmWithTags.java
+++ b/application/src/main/java/org/opentripplanner/osm/model/OsmWithTags.java
@@ -45,6 +45,8 @@ public class OsmWithTags {
"escape"
);
+ private static final Set INDOOR_ROUTABLE_VALUES = Set.of("corridor", "area");
+
private static final Set LEVEL_TAGS = Set.of("level", "layer");
private static final Set DEFAULT_LEVEL = Set.of("0");
@@ -413,6 +415,13 @@ public boolean isPedestrianExplicitlyAllowed() {
return doesTagAllowAccess("foot");
}
+ /**
+ * @return True if this node / area is a parking.
+ */
+ public boolean isParking() {
+ return isTag("amenity", "parking");
+ }
+
/**
* @return True if this node / area is a park and ride.
*/
@@ -420,7 +429,7 @@ public boolean isParkAndRide() {
String parkingType = getTag("parking");
String parkAndRide = getTag("park_ride");
return (
- isTag("amenity", "parking") &&
+ isParking() &&
(
(parkingType != null && parkingType.contains("park_and_ride")) ||
(parkAndRide != null && !parkAndRide.equalsIgnoreCase("no"))
@@ -532,7 +541,7 @@ public void setOsmProvider(OsmProvider provider) {
public boolean isRoutable() {
if (isOneOfTags("highway", NON_ROUTABLE_HIGHWAYS)) {
return false;
- } else if (hasTag("highway") || isPlatform()) {
+ } else if (hasTag("highway") || isPlatform() || isIndoorRoutable()) {
if (isGeneralAccessDenied()) {
// There are exceptions.
return (
@@ -549,6 +558,10 @@ public boolean isRoutable() {
return false;
}
+ public boolean isIndoorRoutable() {
+ return isOneOfTags("indoor", INDOOR_ROUTABLE_VALUES);
+ }
+
/**
* Is this a link to another road, like a highway ramp.
*/
diff --git a/application/src/main/java/org/opentripplanner/osm/tagmapping/UKMapper.java b/application/src/main/java/org/opentripplanner/osm/tagmapping/UKMapper.java
index bef0be4101b..08531ce051d 100644
--- a/application/src/main/java/org/opentripplanner/osm/tagmapping/UKMapper.java
+++ b/application/src/main/java/org/opentripplanner/osm/tagmapping/UKMapper.java
@@ -2,7 +2,9 @@
import static org.opentripplanner.osm.wayproperty.WayPropertiesBuilder.withModes;
import static org.opentripplanner.street.model.StreetTraversalPermission.ALL;
+import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN;
+import org.opentripplanner.osm.wayproperty.WayProperties;
import org.opentripplanner.osm.wayproperty.WayPropertySet;
/**
@@ -73,6 +75,10 @@ public void populateProperties(WayPropertySet props) {
props.setCarSpeed("highway=secondary_link", 13.4f); // ~= 30mph
props.setCarSpeed("highway=tertiary", 15.7f); // ~= 35mph
+ WayProperties pedestrianWayProperties = withModes(PEDESTRIAN).build();
+ props.setProperties("indoor=area", pedestrianWayProperties);
+ props.setProperties("indoor=corridor", pedestrianWayProperties);
+
// Read the rest from the default set
new DefaultMapper().populateProperties(props);
}
diff --git a/application/src/main/java/org/opentripplanner/raptor/api/request/DynamicSearchWindowCoefficients.java b/application/src/main/java/org/opentripplanner/raptor/api/request/DynamicSearchWindowCoefficients.java
index 27ebb62c870..4cc74c34c66 100644
--- a/application/src/main/java/org/opentripplanner/raptor/api/request/DynamicSearchWindowCoefficients.java
+++ b/application/src/main/java/org/opentripplanner/raptor/api/request/DynamicSearchWindowCoefficients.java
@@ -60,11 +60,10 @@ default Duration minWindow() {
/**
* Set an upper limit to the calculation of the dynamic search window to prevent exceptionable
- * cases to cause very long search windows. Long search windows consumes a lot of resources and
+ * cases to cause very long search windows. Long search windows consume a lot of resources and
* may take a long time. Use this parameter to tune the desired maximum search time.
*
- * This is the parameter that affect the response time most, the downside is that a search is only
- * guaranteed to be pareto-optimal within a search-window.
+ * This is the parameter that affects the response time the most.
*
* The default is 3 hours. The unit is minutes.
*/
diff --git a/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorEnvironment.java b/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorEnvironment.java
new file mode 100644
index 00000000000..30e3abb5b27
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorEnvironment.java
@@ -0,0 +1,41 @@
+package org.opentripplanner.raptor.api.request;
+
+import java.util.concurrent.ExecutorService;
+import javax.annotation.Nullable;
+
+/**
+ * The raptor environment provides a few hooks and integration points to the caller. The default
+ * implementation will work just fine, override to adjust Raptor to the calling application.
+ */
+public interface RaptorEnvironment {
+ Runnable NOOP = () -> {};
+
+ /**
+ * Use the timeout-hook to register a callback from Raptor. The hook is called periodically to
+ * check if a time-out is reached. The hook should then exit with an exception handled by the
+ * caller. Raptor does not have blocking method calls so just calling {@link Thread#interrupt()}
+ * will not terminate the Raptor search.
+ */
+ default Runnable timeoutHook() {
+ return NOOP;
+ }
+
+ /**
+ * Raptor has support for running a few things in parallel. If Raptor catches an
+ * {@link InterruptedException}, Raptor will convert the checked exception to an unchecked
+ * exception. The default is {@link RuntimeException}. Override this method to map
+ * {@link InterruptedException} to your prefered runtime exception.
+ */
+ default RuntimeException mapInterruptedException(InterruptedException e) {
+ return new RuntimeException(e);
+ }
+
+ /**
+ * Inject a thread pool into Raptor to run part of the raptor search in parallel. If no
+ * thread pool is provided, then Raptor runs everything in the caller thread.
+ */
+ @Nullable
+ default ExecutorService threadPool() {
+ return null;
+ }
+}
diff --git a/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorTuningParameters.java b/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorTuningParameters.java
index d80c50ed7f5..a85fc3069f6 100644
--- a/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorTuningParameters.java
+++ b/application/src/main/java/org/opentripplanner/raptor/api/request/RaptorTuningParameters.java
@@ -20,11 +20,6 @@ default int iterationDepartureStepInSeconds() {
return 60;
}
- /** see {@link org.opentripplanner.standalone.config.routerconfig.TransitRoutingConfig} **/
- default int searchThreadPoolSize() {
- return 0;
- }
-
/**
* Coefficients used to calculate raptor-search-window parameters dynamically from heuristics.
*/
diff --git a/application/src/main/java/org/opentripplanner/raptor/api/view/ArrivalView.java b/application/src/main/java/org/opentripplanner/raptor/api/view/ArrivalView.java
index 862f7f17fb6..2dffbbe5733 100644
--- a/application/src/main/java/org/opentripplanner/raptor/api/view/ArrivalView.java
+++ b/application/src/main/java/org/opentripplanner/raptor/api/view/ArrivalView.java
@@ -10,7 +10,6 @@
import org.opentripplanner.raptor.api.model.RaptorValueFormatter;
import org.opentripplanner.raptor.api.model.TransitArrival;
import org.opentripplanner.raptor.spi.RaptorCostCalculator;
-import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.DefaultCostCalculator;
/**
* The purpose of the stop-arrival-view is to provide a common interface for stop-arrivals for
@@ -157,7 +156,7 @@ default String asString() {
String arrival =
"[" +
TimeUtils.timeToStrCompact(arrivalTime()) +
- cost(c1(), DefaultCostCalculator.ZERO_COST, RaptorValueFormatter::formatC1) +
+ cost(c1(), RaptorCostCalculator.ZERO_COST, RaptorValueFormatter::formatC1) +
cost(c2(), RaptorConstants.NOT_SET, RaptorValueFormatter::formatC2) +
"]";
return switch (arrivedBy()) {
diff --git a/application/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java b/application/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java
index cc488448304..380f9fe3ba5 100644
--- a/application/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java
+++ b/application/src/main/java/org/opentripplanner/raptor/configure/RaptorConfig.java
@@ -1,10 +1,8 @@
package org.opentripplanner.raptor.configure;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.annotation.Nullable;
-import org.opentripplanner.framework.concurrent.OtpRequestThreadFactory;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
+import org.opentripplanner.raptor.api.request.RaptorEnvironment;
import org.opentripplanner.raptor.api.request.RaptorRequest;
import org.opentripplanner.raptor.api.request.RaptorTuningParameters;
import org.opentripplanner.raptor.rangeraptor.DefaultRangeRaptorWorker;
@@ -27,26 +25,26 @@
/**
* This class is responsible for creating a new search and holding application scoped Raptor state.
*
- * This class should have APPLICATION scope. It manage a threadPool, and hold a reference to the
- * application tuning parameters.
+ * This class should have APPLICATION scope. It keeps a reference to the environment and the
+ * tuning parameters. The environment has a thread-pool, which should be APPLICATION scope.
*
* @param The TripSchedule type defined by the user of the raptor API.
*/
public class RaptorConfig {
- private final ExecutorService threadPool;
+ private final RaptorEnvironment environment;
private final RaptorTuningParameters tuningParameters;
/** The service is not final, because it depends on the request. */
private PassThroughPointsService passThroughPointsService = null;
- public RaptorConfig(RaptorTuningParameters tuningParameters) {
+ public RaptorConfig(RaptorTuningParameters tuningParameters, RaptorEnvironment environment) {
this.tuningParameters = tuningParameters;
- this.threadPool = createNewThreadPool(tuningParameters.searchThreadPoolSize());
+ this.environment = environment;
}
public static RaptorConfig defaultConfigForTest() {
- return new RaptorConfig<>(new RaptorTuningParameters() {});
+ return new RaptorConfig<>(new RaptorTuningParameters() {}, new RaptorEnvironment() {});
}
public SearchContext context(RaptorTransitDataProvider transit, RaptorRequest request) {
@@ -114,19 +112,23 @@ public Heuristics createHeuristic(
}
public boolean isMultiThreaded() {
- return threadPool != null;
+ return threadPool() != null;
}
public ExecutorService threadPool() {
- return threadPool;
+ return environment.threadPool();
}
public void shutdown() {
- if (threadPool != null) {
- threadPool.shutdown();
+ if (threadPool() != null) {
+ threadPool().shutdown();
}
}
+ public RuntimeException mapInterruptedException(InterruptedException e) {
+ return environment.mapInterruptedException(e);
+ }
+
public RaptorSearchWindowCalculator searchWindowCalculator() {
return new RaptorSearchWindowCalculator(tuningParameters.dynamicSearchWindowCoefficients());
}
@@ -164,14 +166,8 @@ private RangeRaptor createRangeRaptor(SearchContext ctx, RangeRaptorWorker
ctx.roundTracker(),
ctx.calculator(),
ctx.createLifeCyclePublisher(),
- ctx.performanceTimers()
+ ctx.performanceTimers(),
+ environment.timeoutHook()
);
}
-
- @Nullable
- private ExecutorService createNewThreadPool(int size) {
- return size > 0
- ? Executors.newFixedThreadPool(size, OtpRequestThreadFactory.of("raptor-%d"))
- : null;
- }
}
diff --git a/application/src/main/java/org/opentripplanner/raptor/rangeraptor/RangeRaptor.java b/application/src/main/java/org/opentripplanner/raptor/rangeraptor/RangeRaptor.java
index 02c39f9e52c..02fb2a627e9 100644
--- a/application/src/main/java/org/opentripplanner/raptor/rangeraptor/RangeRaptor.java
+++ b/application/src/main/java/org/opentripplanner/raptor/rangeraptor/RangeRaptor.java
@@ -2,7 +2,6 @@
import static java.util.Objects.requireNonNull;
-import org.opentripplanner.framework.application.OTPRequestTimeoutException;
import org.opentripplanner.raptor.api.debug.RaptorTimers;
import org.opentripplanner.raptor.api.model.RaptorConstants;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
@@ -66,6 +65,8 @@ public final class RangeRaptor implements RaptorRo
private final LifeCycleEventPublisher lifeCycle;
+ private final Runnable timeoutHook;
+
private final int minNumberOfRounds;
public RangeRaptor(
@@ -75,7 +76,8 @@ public RangeRaptor(
RoundTracker roundTracker,
RaptorTransitCalculator calculator,
LifeCycleEventPublisher lifeCyclePublisher,
- RaptorTimers timers
+ RaptorTimers timers,
+ Runnable timeoutHook
) {
this.worker = requireNonNull(worker);
this.transitData = requireNonNull(transitData);
@@ -85,6 +87,7 @@ public RangeRaptor(
this.minNumberOfRounds = accessPaths.calculateMaxNumberOfRides();
this.roundTracker = requireNonNull(roundTracker);
this.lifeCycle = requireNonNull(lifeCyclePublisher);
+ this.timeoutHook = requireNonNull(timeoutHook);
}
public RaptorRouterResult route() {
@@ -165,7 +168,7 @@ private int round() {
* Run the raptor search for this particular iteration departure time
*/
private void setupIteration(int iterationDepartureTime) {
- OTPRequestTimeoutException.checkForTimeout();
+ timeoutHook.run();
roundTracker.setupIteration();
lifeCycle.prepareForNextRound(round());
lifeCycle.setupIteration(iterationDepartureTime);
diff --git a/application/src/main/java/org/opentripplanner/raptor/rangeraptor/support/TimeBasedBoardingSupport.java b/application/src/main/java/org/opentripplanner/raptor/rangeraptor/support/TimeBasedBoardingSupport.java
index 9ecd2bbf100..2b5c4694409 100644
--- a/application/src/main/java/org/opentripplanner/raptor/rangeraptor/support/TimeBasedBoardingSupport.java
+++ b/application/src/main/java/org/opentripplanner/raptor/rangeraptor/support/TimeBasedBoardingSupport.java
@@ -13,7 +13,6 @@
import org.opentripplanner.raptor.spi.RaptorConstrainedBoardingSearch;
import org.opentripplanner.raptor.spi.RaptorTimeTable;
import org.opentripplanner.raptor.spi.RaptorTripScheduleSearch;
-import org.opentripplanner.routing.algorithm.raptoradapter.transit.request.TripScheduleBoardSearch;
/**
* This class contains code which is shared by all time-dependent {@link RoutingStrategy}s.
@@ -119,9 +118,6 @@ private int earliestBoardTime(int prevArrivalTime, int boardSlack) {
return calculator.plusDuration(prevArrivalTime, boardSlack);
}
- /**
- * Create a trip search using {@link TripScheduleBoardSearch}.
- */
private RaptorTripScheduleSearch createTripSearch(RaptorTimeTable timeTable) {
if (!inFirstIteration && isFirstRound(round) && !hasTimeDependentAccess) {
// For the first round of every iteration(except the first) we restrict the first
diff --git a/application/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java b/application/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java
index 5353804f414..c2a174d646a 100644
--- a/application/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java
+++ b/application/src/main/java/org/opentripplanner/raptor/service/RangeRaptorDynamicSearch.java
@@ -11,7 +11,6 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
-import org.opentripplanner.framework.application.OTPRequestTimeoutException;
import org.opentripplanner.raptor.RaptorService;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
import org.opentripplanner.raptor.api.request.RaptorRequest;
@@ -182,10 +181,10 @@ private void runHeuristicsInParallel() {
Thread.currentThread().interrupt();
// propagate interruption to the running task.
asyncResult.cancel(true);
- throw new OTPRequestTimeoutException();
+ throw config.mapInterruptedException(e);
} catch (ExecutionException e) {
- if (e.getCause() instanceof DestinationNotReachedException) {
- throw new DestinationNotReachedException();
+ if (e.getCause() instanceof DestinationNotReachedException dnr) {
+ throw dnr;
}
LOG.error(e.getMessage() + ". Request: " + originalRequest, e);
throw new IllegalStateException(
diff --git a/application/src/main/java/org/opentripplanner/raptor/service/ViaRangeRaptorDynamicSearch.java b/application/src/main/java/org/opentripplanner/raptor/service/ViaRangeRaptorDynamicSearch.java
index 4476e40464f..cfd12f65b3a 100644
--- a/application/src/main/java/org/opentripplanner/raptor/service/ViaRangeRaptorDynamicSearch.java
+++ b/application/src/main/java/org/opentripplanner/raptor/service/ViaRangeRaptorDynamicSearch.java
@@ -11,7 +11,6 @@
import java.util.concurrent.Future;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
-import org.opentripplanner.framework.application.OTPRequestTimeoutException;
import org.opentripplanner.raptor.RaptorService;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
import org.opentripplanner.raptor.api.request.RaptorRequest;
@@ -182,7 +181,7 @@ private void runHeuristicsInParallel() {
Thread.currentThread().interrupt();
// propagate interruption to the running task.
asyncResult.cancel(true);
- throw new OTPRequestTimeoutException();
+ throw config.mapInterruptedException(e);
} catch (ExecutionException e) {
if (e.getCause() instanceof DestinationNotReachedException) {
throw new DestinationNotReachedException();
diff --git a/application/src/main/java/org/opentripplanner/raptor/spi/BoardAndAlightTime.java b/application/src/main/java/org/opentripplanner/raptor/spi/BoardAndAlightTime.java
index 94744f4bd61..9c0f8264511 100644
--- a/application/src/main/java/org/opentripplanner/raptor/spi/BoardAndAlightTime.java
+++ b/application/src/main/java/org/opentripplanner/raptor/spi/BoardAndAlightTime.java
@@ -1,7 +1,8 @@
package org.opentripplanner.raptor.spi;
import java.util.Objects;
-import org.opentripplanner.framework.tostring.ValueObjectToStringBuilder;
+import org.opentripplanner.framework.time.DurationUtils;
+import org.opentripplanner.framework.time.TimeUtils;
import org.opentripplanner.raptor.api.model.RaptorTripSchedule;
/**
@@ -68,19 +69,18 @@ public boolean equals(Object o) {
@Override
public String toString() {
- return ValueObjectToStringBuilder
- .of()
- .addText("[")
- .addObj(trip.pattern().stopIndex(boardStopPos))
- .addText(" ~ ")
- .addServiceTime(boardTime())
- .addText(" ")
- .addServiceTime(alightTime())
- .addText("(")
- .addDurationSec(alightTime() - boardTime())
- .addText(") ~ ")
- .addObj(trip.pattern().stopIndex(alightStopPos))
- .addText("]")
- .toString();
+ return (
+ "[" +
+ trip.pattern().stopIndex(boardStopPos) +
+ " ~ " +
+ TimeUtils.timeToStrCompact(boardTime()) +
+ " " +
+ TimeUtils.timeToStrCompact(alightTime()) +
+ "(" +
+ DurationUtils.durationToStr(alightTime() - boardTime()) +
+ ") ~ " +
+ trip.pattern().stopIndex(alightStopPos) +
+ "]"
+ );
}
}
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/PagingServiceFactory.java b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/PagingServiceFactory.java
index ec58d444914..97dbda4bb68 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/PagingServiceFactory.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/mapping/PagingServiceFactory.java
@@ -24,8 +24,10 @@ public static PagingService createPagingService(
) {
return new PagingService(
transitTuningParameters.pagingSearchWindowAdjustments(),
+ // The dynamic search-window is not the same as requested search-window, but in lack
+ // of a something else we use the raptor dynamic min here.
raptorTuningParameters.dynamicSearchWindowCoefficients().minWindow(),
- raptorTuningParameters.dynamicSearchWindowCoefficients().maxWindow(),
+ transitTuningParameters.maxSearchWindow(),
searchWindowOf(raptorSearchParamsUsed),
edt(searchStartTime, raptorSearchParamsUsed),
lat(searchStartTime, raptorSearchParamsUsed),
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java
index e72d8ee1427..8040c16d800 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/router/TransitRouter.java
@@ -288,11 +288,10 @@ private Collection extends RoutingAccessEgress> fetchAccessEgresses(AccessEgre
}
/**
- * Given a list of {@code results} shift the access ones which contain driving
- * so that they only start at the time when the ride hailing vehicle can actually be there
- * to pick up passengers.
+ * Given a list of {@code results} shift the access ones that contain driving so that they only
+ * start at the time when the ride hailing vehicle can actually be there to pick up passengers.
*
- * If there are accesses/egresses with only walking then they remain unchanged.
+ * If there are accesses/egresses with only walking, then they remain unchanged.
*
* This method is a good candidate to be moved to the access/egress filter chain when that has
* been added.
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TransitLayer.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TransitLayer.java
index e5f0544f584..c7d6a7809ed 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TransitLayer.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/TransitLayer.java
@@ -14,18 +14,18 @@
import org.opentripplanner.routing.algorithm.raptoradapter.transit.request.RaptorRequestTransferCache;
import org.opentripplanner.routing.api.request.RouteRequest;
import org.opentripplanner.transit.model.site.StopLocation;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
/**
- * This is a replica of public transportation data already present in TransitModel, but rearranged
+ * This is a replica of public transportation data already present in TimetableRepository, but rearranged
* and indexed differently for efficient use by the Raptor router. Patterns and trips are split out
* by days, retaining only the services actually running on any particular day.
*
* TODO RT_AB: this name may reflect usage in R5, where the TransportNetwork encompasses two
* sub-aggregates (one for the streets and one for the public transit data). Here, the TransitLayer
- * seems to just be an indexed and rearranged copy of the main TransitModel instance. TG has
+ * seems to just be an indexed and rearranged copy of the main TimetableRepository instance. TG has
* indicated that "layer" should be restricted in its standard OO meaning, and this class should
- * really be merged into TransitModel.
+ * really be merged into TimetableRepository.
*/
public class TransitLayer {
@@ -48,7 +48,7 @@ public class TransitLayer {
*/
private final TransferService transferService;
- private final StopModel stopModel;
+ private final SiteRepository siteRepository;
private final RaptorRequestTransferCache transferCache;
@@ -69,7 +69,7 @@ public TransitLayer(TransitLayer transitLayer) {
transitLayer.tripPatternsRunningOnDate,
transitLayer.transfersByStopIndex,
transitLayer.transferService,
- transitLayer.stopModel,
+ transitLayer.siteRepository,
transitLayer.transferCache,
transitLayer.constrainedTransfers,
transitLayer.transferIndexGenerator,
@@ -81,7 +81,7 @@ public TransitLayer(
Map> tripPatternsRunningOnDate,
List> transfersByStopIndex,
TransferService transferService,
- StopModel stopModel,
+ SiteRepository siteRepository,
RaptorRequestTransferCache transferCache,
ConstrainedTransfersForPatterns constrainedTransfers,
TransferIndexGenerator transferIndexGenerator,
@@ -90,7 +90,7 @@ public TransitLayer(
this.tripPatternsRunningOnDate = new HashMap<>(tripPatternsRunningOnDate);
this.transfersByStopIndex = transfersByStopIndex;
this.transferService = transferService;
- this.stopModel = stopModel;
+ this.siteRepository = siteRepository;
this.transferCache = transferCache;
this.constrainedTransfers = constrainedTransfers;
this.transferIndexGenerator = transferIndexGenerator;
@@ -99,7 +99,7 @@ public TransitLayer(
@Nullable
public StopLocation getStopByIndex(int stop) {
- return stop == -1 ? null : this.stopModel.stopByIndex(stop);
+ return stop == -1 ? null : this.siteRepository.stopByIndex(stop);
}
/**
@@ -112,7 +112,7 @@ public Collection getTripPatternsForRunningDate(LocalDate da
}
public int getStopCount() {
- return stopModel.stopIndexSize();
+ return siteRepository.stopIndexSize();
}
/**
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/frequency/TripFrequencyAlightSearch.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/frequency/TripFrequencyAlightSearch.java
index 2f020e22cf5..ff97fd9bdaa 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/frequency/TripFrequencyAlightSearch.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/frequency/TripFrequencyAlightSearch.java
@@ -60,6 +60,6 @@ public RaptorBoardOrAlightEvent search(
}
}
}
- return null;
+ return RaptorBoardOrAlightEvent.empty(earliestBoardTime);
}
}
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java
index c7e9ea05320..5f4e40708ef 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransfersMapper.java
@@ -5,7 +5,7 @@
import org.opentripplanner.model.PathTransfer;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.Transfer;
import org.opentripplanner.transit.model.site.RegularStop;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TransitService;
class TransfersMapper {
@@ -14,11 +14,14 @@ class TransfersMapper {
* Copy pre-calculated transfers from the original graph
* @return a list where each element is a list of transfers for the corresponding stop index
*/
- static List> mapTransfers(StopModel stopModel, TransitService transitService) {
+ static List> mapTransfers(
+ SiteRepository siteRepository,
+ TransitService transitService
+ ) {
List> transferByStopIndex = new ArrayList<>();
- for (int i = 0; i < stopModel.stopIndexSize(); ++i) {
- var stop = stopModel.stopByIndex(i);
+ for (int i = 0; i < siteRepository.stopIndexSize(); ++i) {
+ var stop = siteRepository.stopByIndex(i);
if (stop == null) {
continue;
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java
index 13f8facef3d..b0d2b009a0f 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerMapper.java
@@ -24,14 +24,14 @@
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.site.StopTransferPriority;
import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.StopModel;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.SiteRepository;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.transit.service.TransitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Maps the TransitLayer object from the TransitModel object. The ServiceDay hierarchy is reversed,
+ * Maps the TransitLayer object from the TimetableRepository object. The ServiceDay hierarchy is reversed,
* with service days at the top level, which contains TripPatternForDate objects that contain only
* TripSchedules running on that particular date. This makes it faster to filter out TripSchedules
* when doing Range Raptor searches.
@@ -46,18 +46,18 @@ public class TransitLayerMapper {
private static final Logger LOG = LoggerFactory.getLogger(TransitLayerMapper.class);
private final TransitService transitService;
- private final StopModel stopModel;
+ private final SiteRepository siteRepository;
- private TransitLayerMapper(TransitModel transitModel) {
- this.transitService = new DefaultTransitService(transitModel);
- this.stopModel = transitModel.getStopModel();
+ private TransitLayerMapper(TimetableRepository timetableRepository) {
+ this.transitService = new DefaultTransitService(timetableRepository);
+ this.siteRepository = timetableRepository.getSiteRepository();
}
public static TransitLayer map(
TransitTuningParameters tuningParameters,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
- return new TransitLayerMapper(transitModel).map(tuningParameters);
+ return new TransitLayerMapper(timetableRepository).map(tuningParameters);
}
private TransitLayer map(TransitTuningParameters tuningParameters) {
@@ -65,13 +65,13 @@ private TransitLayer map(TransitTuningParameters tuningParameters) {
List> transferByStopIndex;
ConstrainedTransfersForPatterns constrainedTransfers = null;
- LOG.info("Mapping transitLayer from TransitModel...");
+ LOG.info("Mapping transitLayer from TimetableRepository...");
Collection allTripPatterns = transitService.getAllTripPatterns();
tripPatternsByStopByDate = mapTripPatterns(allTripPatterns);
- transferByStopIndex = mapTransfers(stopModel, transitService);
+ transferByStopIndex = mapTransfers(siteRepository, transitService);
TransferIndexGenerator transferIndexGenerator = null;
if (OTPFeature.TransferConstraints.isOn()) {
@@ -88,11 +88,11 @@ private TransitLayer map(TransitTuningParameters tuningParameters) {
tripPatternsByStopByDate,
transferByStopIndex,
transitService.getTransferService(),
- stopModel,
+ siteRepository,
transferCache,
constrainedTransfers,
transferIndexGenerator,
- createStopBoardAlightTransferCosts(stopModel, tuningParameters)
+ createStopBoardAlightTransferCosts(siteRepository, tuningParameters)
);
}
@@ -169,7 +169,7 @@ private HashMap> keyByRunningPeriodDates(
*/
@Nullable
static int[] createStopBoardAlightTransferCosts(
- StopModel stops,
+ SiteRepository stops,
TransitTuningParameters tuningParams
) {
if (!tuningParams.enableStopTransferPriority()) {
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerUpdater.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerUpdater.java
index d3e6cd07d60..8b307321ca8 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerUpdater.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/mappers/TransitLayerUpdater.java
@@ -30,7 +30,7 @@
* the updated copy in an atomic operation. This ensures that any TransitLayer that is referenced
* from the Graph is never changed.
*
- * This is a way of keeping the TransitLayer up to date (in sync with the TransitModel plus its most
+ * This is a way of keeping the TransitLayer up to date (in sync with the TimetableRepository plus its most
* recent TimetableSnapshot) without repeatedly deriving it from scratch every few seconds. The same
* incremental changes are applied to both the TimetableSnapshot and the TransitLayer and they are
* published together.
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilter.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilter.java
index 44d9f3cdb3d..514a5b56f9a 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilter.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/RouteRequestTransitDataProviderFilter.java
@@ -12,6 +12,7 @@
import org.opentripplanner.transit.model.basic.Accessibility;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.BikeAccess;
+import org.opentripplanner.transit.model.network.CarAccess;
import org.opentripplanner.transit.model.network.RoutingTripPattern;
import org.opentripplanner.transit.model.timetable.Trip;
import org.opentripplanner.transit.model.timetable.TripTimes;
@@ -20,6 +21,8 @@ public class RouteRequestTransitDataProviderFilter implements TransitDataProvide
private final boolean requireBikesAllowed;
+ private final boolean requireCarsAllowed;
+
private final boolean wheelchairEnabled;
private final WheelchairPreferences wheelchairPreferences;
@@ -41,6 +44,7 @@ public class RouteRequestTransitDataProviderFilter implements TransitDataProvide
public RouteRequestTransitDataProviderFilter(RouteRequest request) {
this(
request.journey().transfer().mode() == StreetMode.BIKE,
+ request.journey().transfer().mode() == StreetMode.CAR,
request.wheelchair(),
request.preferences().wheelchair(),
request.preferences().transit().includePlannedCancellations(),
@@ -53,6 +57,7 @@ public RouteRequestTransitDataProviderFilter(RouteRequest request) {
// This constructor is used only for testing
public RouteRequestTransitDataProviderFilter(
boolean requireBikesAllowed,
+ boolean requireCarsAllowed,
boolean wheelchairEnabled,
WheelchairPreferences wheelchairPreferences,
boolean includePlannedCancellations,
@@ -61,6 +66,7 @@ public RouteRequestTransitDataProviderFilter(
List filters
) {
this.requireBikesAllowed = requireBikesAllowed;
+ this.requireCarsAllowed = requireCarsAllowed;
this.wheelchairEnabled = wheelchairEnabled;
this.wheelchairPreferences = wheelchairPreferences;
this.includePlannedCancellations = includePlannedCancellations;
@@ -97,10 +103,12 @@ public boolean tripPatternPredicate(TripPatternForDate tripPatternForDate) {
public boolean tripTimesPredicate(TripTimes tripTimes, boolean withFilters) {
final Trip trip = tripTimes.getTrip();
- if (requireBikesAllowed) {
- if (bikeAccessForTrip(trip) != BikeAccess.ALLOWED) {
- return false;
- }
+ if (requireBikesAllowed && bikeAccessForTrip(trip) != BikeAccess.ALLOWED) {
+ return false;
+ }
+
+ if (requireCarsAllowed && trip.getCarsAllowed() != CarAccess.ALLOWED) {
+ return false;
}
if (wheelchairEnabled) {
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java
index db08dd2dada..4ec306f84b3 100644
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java
+++ b/application/src/main/java/org/opentripplanner/routing/algorithm/raptoradapter/transit/request/TripScheduleBoardSearch.java
@@ -15,7 +15,7 @@
* trips are ordered after the FIRST stop boarding times. We also assume that trips do not pass each
* other; Hence trips IN SERVICE on a given day will be in order for all other stops too.
*
- * The search use a binary search if the number of trip schedules is above a given threshold. A
+ * The search uses a binary search if the number of trip schedules is above a given threshold. A
* linear search is slow when the number of schedules is very large, let say more than 300 trip
* schedules.
*
diff --git a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package-info.java b/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package-info.java
deleted file mode 100644
index 22163201b6e..00000000000
--- a/application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Package documentation
- */
-package org.opentripplanner.routing.algorithm.transferoptimization;
diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java
index 56ba39d8431..27ecc777050 100644
--- a/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java
+++ b/application/src/main/java/org/opentripplanner/routing/api/request/RouteRequest.java
@@ -11,9 +11,11 @@
import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import org.opentripplanner.framework.collection.ListSection;
+import org.opentripplanner.framework.lang.ObjectUtils;
import org.opentripplanner.framework.time.DateUtils;
import org.opentripplanner.framework.tostring.ToStringBuilder;
import org.opentripplanner.model.GenericLocation;
@@ -26,6 +28,7 @@
import org.opentripplanner.routing.api.response.RoutingError;
import org.opentripplanner.routing.api.response.RoutingErrorCode;
import org.opentripplanner.routing.error.RoutingValidationException;
+import org.opentripplanner.standalone.config.routerconfig.TransitRoutingConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -332,12 +335,25 @@ private boolean hasMaxSearchWindow() {
return maxSearchWindow != null;
}
+ /**
+ * For testing only. Use {@link TransitRoutingConfig#maxSearchWindow()} instead.
+ * @see #initMaxSearchWindow(Duration)
+ */
public Duration maxSearchWindow() {
return maxSearchWindow;
}
- public void setMaxSearchWindow(@Nullable Duration maxSearchWindow) {
- this.maxSearchWindow = maxSearchWindow;
+ /**
+ * Initialize the maxSearchWindow from the transit config. This is necessary because the
+ * default route request is configured before the {@link TransitRoutingConfig}.
+ */
+ public void initMaxSearchWindow(Duration maxSearchWindow) {
+ this.maxSearchWindow =
+ ObjectUtils.requireNotInitialized(
+ "maxSearchWindow",
+ this.maxSearchWindow,
+ Objects.requireNonNull(maxSearchWindow)
+ );
}
public Locale locale() {
diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java b/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java
index 56e716d9d62..cbc2764f030 100644
--- a/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java
+++ b/application/src/main/java/org/opentripplanner/routing/api/request/StreetMode.java
@@ -36,10 +36,8 @@ public enum StreetMode implements DocumentedEnum {
SCOOTER_RENTAL(Feature.ACCESS, Feature.EGRESS, Feature.WALKING, Feature.SCOOTER, Feature.RENTING),
/**
* Car only
- *
- * Direct mode only.
*/
- CAR(Feature.ACCESS, Feature.DRIVING),
+ CAR(Feature.ACCESS, Feature.TRANSFER, Feature.EGRESS, Feature.DRIVING),
/**
* Start in the car, drive to a parking area, and walk the rest of the way.
*
diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java
index 1116031cec6..aa75a634004 100644
--- a/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java
+++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/PassThroughViaLocation.java
@@ -16,7 +16,8 @@ public PassThroughViaLocation(@Nullable String label, Collection s
super(label, stopLocationIds);
if (stopLocationIds.isEmpty()) {
throw new IllegalArgumentException(
- "A pass through via location must have at least one stop location. Label: " + label
+ "A pass through via location must have at least one stop location." +
+ (label == null ? "" : " Label: " + label)
);
}
}
diff --git a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java
index 2b59a749a1d..096fbfabc0b 100644
--- a/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java
+++ b/application/src/main/java/org/opentripplanner/routing/api/request/via/VisitViaLocation.java
@@ -41,7 +41,8 @@ public VisitViaLocation(
if (stopLocationIds().isEmpty() && coordinates().isEmpty()) {
throw new IllegalArgumentException(
- "A via location must have at least one stop location or a coordinate. Label: " + label
+ "A via location must have at least one stop location or a coordinate." +
+ (label == null ? "" : " Label: " + label)
);
}
}
diff --git a/application/src/main/java/org/opentripplanner/routing/graph/Graph.java b/application/src/main/java/org/opentripplanner/routing/graph/Graph.java
index 1fbea77e759..04266476ae5 100644
--- a/application/src/main/java/org/opentripplanner/routing/graph/Graph.java
+++ b/application/src/main/java/org/opentripplanner/routing/graph/Graph.java
@@ -30,7 +30,7 @@
import org.opentripplanner.street.model.vertex.VertexLabel;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.FeedScopedId;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,10 +43,10 @@
* In OTP1, the Graph contained vertices and edges representing the entire transportation network,
* including edges representing both street segments and public transit lines connecting stops. In
* OTP2, the Graph edges now represent only the street network. Transit routing is performed on
- * other data structures suited to the Raptor algorithm (the TransitModel). Some transit-related
+ * other data structures suited to the Raptor algorithm (the TimetableRepository). Some transit-related
* vertices are still present in the Graph, specifically those representing transit stops,
* entrances, and elevators. Their presence in the street graph creates a connection between the two
- * routable data structures (identifying where stops in the TransitModel are located relative to
+ * routable data structures (identifying where stops in the TimetableRepository are located relative to
* roads).
*
* Other data structures related to street routing, such as elevation data and vehicle parking
@@ -284,9 +284,9 @@ public int countEdges() {
* - graph. This allows a module to index the streetIndex BEFORE another module add
* - something that should go into the index; Hence, inconsistent data.
*/
- public void index(StopModel stopModel) {
+ public void index(SiteRepository siteRepository) {
LOG.info("Index street model...");
- streetIndex = new StreetIndex(this, stopModel);
+ streetIndex = new StreetIndex(this, siteRepository);
LOG.info("Index street model complete.");
}
@@ -297,7 +297,7 @@ public OpeningHoursCalendarService getOpeningHoursCalendarService() {
/**
* Get streetIndex, safe to use while routing, but do not use during graph build.
- * @see #getStreetIndexSafe(StopModel)
+ * @see #getStreetIndexSafe(SiteRepository)
*/
public StreetIndex getStreetIndex() {
return this.streetIndex;
@@ -307,14 +307,14 @@ public StreetIndex getStreetIndex() {
* Get streetIndex during graph build, both OSM street data and transit data must be loaded
* before calling this.
*/
- public StreetIndex getStreetIndexSafe(StopModel stopModel) {
- indexIfNotIndexed(stopModel);
+ public StreetIndex getStreetIndexSafe(SiteRepository siteRepository) {
+ indexIfNotIndexed(siteRepository);
return this.streetIndex;
}
/**
* Get VertexLinker, safe to use while routing, but do not use during graph build.
- * @see #getLinkerSafe(StopModel)
+ * @see #getLinkerSafe(SiteRepository)
*/
public VertexLinker getLinker() {
return streetIndex.getVertexLinker();
@@ -324,8 +324,8 @@ public VertexLinker getLinker() {
* Get VertexLinker during graph build, both OSM street data and transit data must be loaded
* before calling this.
*/
- public VertexLinker getLinkerSafe(StopModel stopModel) {
- indexIfNotIndexed(stopModel);
+ public VertexLinker getLinkerSafe(SiteRepository siteRepository) {
+ indexIfNotIndexed(siteRepository);
return streetIndex.getVertexLinker();
}
@@ -374,9 +374,9 @@ public void setFareService(FareService fareService) {
this.fareService = fareService;
}
- private void indexIfNotIndexed(StopModel stopModel) {
+ private void indexIfNotIndexed(SiteRepository siteRepository) {
if (streetIndex == null) {
- index(stopModel);
+ index(siteRepository);
}
}
}
diff --git a/application/src/main/java/org/opentripplanner/routing/graph/SerializedGraphObject.java b/application/src/main/java/org/opentripplanner/routing/graph/SerializedGraphObject.java
index b2404adc5d1..e7e0c3248e8 100644
--- a/application/src/main/java/org/opentripplanner/routing/graph/SerializedGraphObject.java
+++ b/application/src/main/java/org/opentripplanner/routing/graph/SerializedGraphObject.java
@@ -35,7 +35,7 @@
import org.opentripplanner.street.model.vertex.Vertex;
import org.opentripplanner.transit.model.basic.SubMode;
import org.opentripplanner.transit.model.network.RoutingTripPattern;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,7 +55,7 @@ public class SerializedGraphObject implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(SerializedGraphObject.class);
public final Graph graph;
- public final TransitModel transitModel;
+ public final TimetableRepository timetableRepository;
public final WorldEnvelopeRepository worldEnvelopeRepository;
private final Collection edges;
@@ -82,7 +82,7 @@ public class SerializedGraphObject implements Serializable {
public SerializedGraphObject(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
WorldEnvelopeRepository worldEnvelopeRepository,
BuildConfig buildConfig,
RouterConfig routerConfig,
@@ -93,7 +93,7 @@ public SerializedGraphObject(
) {
this.graph = graph;
this.edges = graph.getEdges();
- this.transitModel = transitModel;
+ this.timetableRepository = timetableRepository;
this.worldEnvelopeRepository = worldEnvelopeRepository;
this.buildConfig = buildConfig;
this.routerConfig = routerConfig;
@@ -184,9 +184,9 @@ private static SerializedGraphObject load(InputStream inputStream, String source
);
LOG.debug("Graph read.");
serObj.reconstructEdgeLists();
- serObj.transitModel.getStopModel().reindexAfterDeserialization();
- serObj.transitModel.index();
- logSerializationCompleteStatus(serObj.graph, serObj.transitModel);
+ serObj.timetableRepository.getSiteRepository().reindexAfterDeserialization();
+ serObj.timetableRepository.index();
+ logSerializationCompleteStatus(serObj.graph, serObj.timetableRepository);
return serObj;
} catch (IOException e) {
LOG.error("IO exception while loading graph: {}", e.getLocalizedMessage(), e);
@@ -256,11 +256,14 @@ private void save(OutputStream outputStream, String graphName, long size) {
// ((InstanceCountingClassResolver) kryo.getClassResolver()).summarize();
}
- private static void logSerializationCompleteStatus(Graph graph, TransitModel transitModel) {
+ private static void logSerializationCompleteStatus(
+ Graph graph,
+ TimetableRepository timetableRepository
+ ) {
var f = new OtpNumberFormat();
- var nStops = f.formatNumber(transitModel.getStopModel().stopIndexSize());
- var nTransfers = f.formatNumber(transitModel.getTransferService().listAll().size());
- var nPatterns = f.formatNumber(transitModel.getAllTripPatterns().size());
+ var nStops = f.formatNumber(timetableRepository.getSiteRepository().stopIndexSize());
+ var nTransfers = f.formatNumber(timetableRepository.getTransferService().listAll().size());
+ var nPatterns = f.formatNumber(timetableRepository.getAllTripPatterns().size());
var nVertices = f.formatNumber(graph.countVertices());
var nEdges = f.formatNumber(graph.countEdges());
diff --git a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java
index 362c87bff7d..90294d554cc 100644
--- a/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java
+++ b/application/src/main/java/org/opentripplanner/routing/graph/index/StreetIndex.java
@@ -41,7 +41,7 @@
import org.opentripplanner.street.search.TraverseModeSet;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.site.RegularStop;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,7 +57,7 @@ public class StreetIndex {
private static final Logger LOG = LoggerFactory.getLogger(StreetIndex.class);
- private final StopModel stopModel;
+ private final SiteRepository siteRepository;
private final VertexLinker vertexLinker;
@@ -74,11 +74,11 @@ public class StreetIndex {
/**
* Should only be called by the graph.
*/
- public StreetIndex(Graph graph, StopModel stopModel) {
- this.stopModel = stopModel;
+ public StreetIndex(Graph graph, SiteRepository siteRepository) {
+ this.siteRepository = siteRepository;
this.edgeSpatialIndex = new EdgeSpatialIndex();
this.verticesTree = new HashGridSpatialIndex<>();
- this.vertexLinker = new VertexLinker(graph, stopModel, edgeSpatialIndex);
+ this.vertexLinker = new VertexLinker(graph, siteRepository, edgeSpatialIndex);
this.transitStopVertices = toImmutableMap(graph.getVerticesOfType(TransitStopVertex.class));
this.stationCentroidVertices = createStationCentroidVertexMap(graph);
postSetup(graph.getVertices());
@@ -195,7 +195,7 @@ public Set getStreetVerticesForLocation(
if (nonTransitMode.isInCar()) {
// Fetch coordinate from stop, if not given in request
if (location.stopId != null && location.getCoordinate() == null) {
- var coordinate = stopModel.getCoordinateById(location.stopId);
+ var coordinate = siteRepository.getCoordinateById(location.stopId);
if (coordinate != null) {
location =
new GenericLocation(
@@ -262,7 +262,7 @@ public Vertex createVertexForCoordinateForTest(
* @return The associated TransitStopVertex or all underlying TransitStopVertices
*/
public Set getStopOrChildStopsVertices(FeedScopedId id) {
- return stopModel
+ return siteRepository
.findStopOrChildStops(id)
.stream()
.filter(RegularStop.class::isInstance)
diff --git a/application/src/main/java/org/opentripplanner/routing/impl/DelegatingTransitAlertServiceImpl.java b/application/src/main/java/org/opentripplanner/routing/impl/DelegatingTransitAlertServiceImpl.java
index 8da6fc21aa7..e63894b1a2c 100644
--- a/application/src/main/java/org/opentripplanner/routing/impl/DelegatingTransitAlertServiceImpl.java
+++ b/application/src/main/java/org/opentripplanner/routing/impl/DelegatingTransitAlertServiceImpl.java
@@ -11,7 +11,7 @@
import org.opentripplanner.routing.services.TransitAlertService;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.timetable.Direction;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.updater.alert.TransitAlertProvider;
/**
@@ -30,14 +30,14 @@ public class DelegatingTransitAlertServiceImpl implements TransitAlertService {
private final ArrayList transitAlertServices = new ArrayList<>();
/**
- * Constructor which scans over all existing GraphUpdaters associated with a TransitModel
+ * Constructor which scans over all existing GraphUpdaters associated with a TimetableRepository
* instance and retains references to all their TransitAlertService instances.
* This implies that these instances are expected to remain in use indefinitely (not be replaced
* with new instances or taken out of service over time).
*/
- public DelegatingTransitAlertServiceImpl(TransitModel transitModel) {
- if (transitModel.getUpdaterManager() != null) {
- transitModel
+ public DelegatingTransitAlertServiceImpl(TimetableRepository timetableRepository) {
+ if (timetableRepository.getUpdaterManager() != null) {
+ timetableRepository
.getUpdaterManager()
.getUpdaterList()
.stream()
diff --git a/application/src/main/java/org/opentripplanner/routing/impl/TransitAlertServiceImpl.java b/application/src/main/java/org/opentripplanner/routing/impl/TransitAlertServiceImpl.java
index 0cc24c691e9..04b58d050ee 100644
--- a/application/src/main/java/org/opentripplanner/routing/impl/TransitAlertServiceImpl.java
+++ b/application/src/main/java/org/opentripplanner/routing/impl/TransitAlertServiceImpl.java
@@ -13,7 +13,7 @@
import org.opentripplanner.routing.services.TransitAlertService;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.timetable.Direction;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* This is the primary implementation of TransitAlertService, which actually retains its own set
@@ -32,12 +32,12 @@
*/
public class TransitAlertServiceImpl implements TransitAlertService {
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
private Multimap alerts = HashMultimap.create();
- public TransitAlertServiceImpl(TransitModel transitModel) {
- this.transitModel = transitModel;
+ public TransitAlertServiceImpl(TimetableRepository timetableRepository) {
+ this.timetableRepository = timetableRepository;
}
@Override
@@ -85,8 +85,8 @@ public Collection getStopAlerts(
}
if (result.isEmpty()) {
// Search for alerts on parent-stop
- if (transitModel != null) {
- var quay = transitModel.getStopModel().getRegularStop(stopId);
+ if (timetableRepository != null) {
+ var quay = timetableRepository.getSiteRepository().getRegularStop(stopId);
if (quay != null) {
// TODO - SIRI: Add alerts from parent- and multimodal-stops
/*
diff --git a/application/src/main/java/org/opentripplanner/routing/linking/FlexLocationAdder.java b/application/src/main/java/org/opentripplanner/routing/linking/FlexLocationAdder.java
index 047e44f229a..e9d29f596c7 100644
--- a/application/src/main/java/org/opentripplanner/routing/linking/FlexLocationAdder.java
+++ b/application/src/main/java/org/opentripplanner/routing/linking/FlexLocationAdder.java
@@ -8,15 +8,19 @@
import org.opentripplanner.street.model.edge.StreetEdge;
import org.opentripplanner.street.model.vertex.IntersectionVertex;
import org.opentripplanner.transit.model.site.AreaStop;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
class FlexLocationAdder {
- static void addFlexLocations(StreetEdge edge, IntersectionVertex v0, StopModel stopModel) {
+ static void addFlexLocations(
+ StreetEdge edge,
+ IntersectionVertex v0,
+ SiteRepository siteRepository
+ ) {
if (edge.getPermission().allows(StreetTraversalPermission.PEDESTRIAN_AND_CAR)) {
Point p = GeometryUtils.getGeometryFactory().createPoint(v0.getCoordinate());
Envelope env = p.getEnvelopeInternal();
- for (AreaStop areaStop : stopModel.findAreaStops(env)) {
+ for (AreaStop areaStop : siteRepository.findAreaStops(env)) {
if (!areaStop.getGeometry().disjoint(p)) {
v0.addAreaStops(Set.of(areaStop));
}
diff --git a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java
index 9616fbab792..48f5ff997c8 100644
--- a/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java
+++ b/application/src/main/java/org/opentripplanner/routing/linking/VertexLinker.java
@@ -34,7 +34,7 @@
import org.opentripplanner.street.model.vertex.VertexFactory;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.street.search.TraverseModeSet;
-import org.opentripplanner.transit.service.StopModel;
+import org.opentripplanner.transit.service.SiteRepository;
/**
* This class links transit stops to streets by splitting the streets (unless the stop is extremely
@@ -71,7 +71,7 @@ public class VertexLinker {
private final Graph graph;
- private final StopModel stopModel;
+ private final SiteRepository siteRepository;
private final VertexFactory vertexFactory;
// TODO Temporary code until we refactor WalkableAreaBuilder (#3152)
@@ -81,11 +81,15 @@ public class VertexLinker {
* Construct a new VertexLinker. NOTE: Only one VertexLinker should be active on a graph at any
* given time.
*/
- public VertexLinker(Graph graph, StopModel stopModel, EdgeSpatialIndex edgeSpatialIndex) {
+ public VertexLinker(
+ Graph graph,
+ SiteRepository siteRepository,
+ EdgeSpatialIndex edgeSpatialIndex
+ ) {
this.edgeSpatialIndex = edgeSpatialIndex;
this.graph = graph;
this.vertexFactory = new VertexFactory(graph);
- this.stopModel = stopModel;
+ this.siteRepository = siteRepository;
}
public void linkVertexPermanently(
@@ -397,7 +401,7 @@ else if (
}
// TODO Consider moving this code
if (OTPFeature.FlexRouting.isOn()) {
- FlexLocationAdder.addFlexLocations(edge, start, stopModel);
+ FlexLocationAdder.addFlexLocations(edge, start, siteRepository);
}
return start;
diff --git a/application/src/main/java/org/opentripplanner/standalone/OTPMain.java b/application/src/main/java/org/opentripplanner/standalone/OTPMain.java
index d865f8fa28c..a8096d806ba 100644
--- a/application/src/main/java/org/opentripplanner/standalone/OTPMain.java
+++ b/application/src/main/java/org/opentripplanner/standalone/OTPMain.java
@@ -17,7 +17,7 @@
import org.opentripplanner.standalone.configure.ConstructApplication;
import org.opentripplanner.standalone.configure.LoadApplication;
import org.opentripplanner.standalone.server.GrizzlyServer;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.updater.configure.UpdaterConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -150,7 +150,7 @@ private static void startOTPServer(CommandLineParameters cli) {
// with using the embedded router config.
new SerializedGraphObject(
app.graph(),
- app.transitModel(),
+ app.timetableRepository(),
app.worldEnvelopeRepository(),
config.buildConfig(),
config.routerConfig(),
@@ -187,8 +187,8 @@ private static void detectUnusedConfigParams(CommandLineParameters cli, ConfigMo
private static void startOtpWebServer(CommandLineParameters params, ConstructApplication app) {
// Index graph for travel search
- app.transitModel().index();
- app.graph().index(app.transitModel().getStopModel());
+ app.timetableRepository().index();
+ app.graph().index(app.timetableRepository().getSiteRepository());
// publishing the config version info make it available to the APIs
setOtpConfigVersionsOnServerInfo(app);
@@ -205,7 +205,7 @@ private static void startOtpWebServer(CommandLineParameters params, ConstructApp
if (params.doServe()) {
GrizzlyServer grizzlyServer = app.createGrizzlyServer();
- registerShutdownHookToGracefullyShutDownServer(app.transitModel(), app.raptorConfig());
+ registerShutdownHookToGracefullyShutDownServer(app.timetableRepository(), app.raptorConfig());
// Loop to restart server on uncaught fatal exceptions.
while (true) {
@@ -232,14 +232,14 @@ private static void startOtpWebServer(CommandLineParameters params, ConstructApp
*
*/
private static void registerShutdownHookToGracefullyShutDownServer(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
RaptorConfig> raptorConfig
) {
ApplicationShutdownSupport.addShutdownHook(
"server-shutdown",
() -> {
LOG.info("OTP shutdown started...");
- UpdaterConfigurator.shutdownGraph(transitModel);
+ UpdaterConfigurator.shutdownGraph(timetableRepository);
raptorConfig.shutdown();
WeakCollectionCleaner.DEFAULT.exit();
DeferredAuthorityFactory.exit();
diff --git a/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java
index 55128af5659..cb00428284b 100644
--- a/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java
+++ b/application/src/main/java/org/opentripplanner/standalone/config/RouterConfig.java
@@ -69,7 +69,7 @@ public RouterConfig(JsonNode node, String source, boolean logUnusedParams) {
this.transmodelApi = new TransmodelAPIConfig("transmodelApi", root);
this.routingRequestDefaults = mapDefaultRouteRequest("routingDefaults", root);
this.transitConfig = new TransitRoutingConfig("transit", root, routingRequestDefaults);
- this.routingRequestDefaults.setMaxSearchWindow(transitConfig.maxSearchWindow());
+ this.routingRequestDefaults.initMaxSearchWindow(transitConfig.maxSearchWindow());
this.updatersParameters = new UpdatersConfig(root);
this.rideHailingConfig = new RideHailingServicesConfig(root);
this.vectorTileConfig = VectorTileConfig.mapVectorTilesParameters(root, "vectorTiles");
diff --git a/application/src/main/java/org/opentripplanner/standalone/config/configure/ConfigModule.java b/application/src/main/java/org/opentripplanner/standalone/config/configure/ConfigModule.java
index b7d7084f7ba..4f75f3984d5 100644
--- a/application/src/main/java/org/opentripplanner/standalone/config/configure/ConfigModule.java
+++ b/application/src/main/java/org/opentripplanner/standalone/config/configure/ConfigModule.java
@@ -3,12 +3,14 @@
import dagger.Module;
import dagger.Provides;
import jakarta.inject.Singleton;
+import org.opentripplanner.raptor.api.request.RaptorEnvironment;
import org.opentripplanner.raptor.configure.RaptorConfig;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule;
import org.opentripplanner.standalone.config.BuildConfig;
import org.opentripplanner.standalone.config.ConfigModel;
import org.opentripplanner.standalone.config.OtpConfig;
import org.opentripplanner.standalone.config.RouterConfig;
+import org.opentripplanner.standalone.config.routerconfig.RaptorEnvironmentFactory;
/**
* Map {@link ConfigModel} into more specific types like {@link BuildConfig} to simplify
@@ -34,7 +36,17 @@ static RouterConfig provideRouterConfig(ConfigModel model) {
@Provides
@Singleton
- static RaptorConfig providesRaptorConfig(ConfigModel config) {
- return new RaptorConfig<>(config.routerConfig().transitTuningConfig());
+ static RaptorConfig providesRaptorConfig(
+ RouterConfig routerConfig,
+ RaptorEnvironment environment
+ ) {
+ return new RaptorConfig<>(routerConfig.transitTuningConfig(), environment);
+ }
+
+ @Provides
+ @Singleton
+ static RaptorEnvironment providesRaptorEnvironment(RouterConfig routerConfig) {
+ int searchThreadPoolSize = routerConfig.transitTuningConfig().searchThreadPoolSize();
+ return RaptorEnvironmentFactory.create(searchThreadPoolSize);
}
}
diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/RaptorEnvironmentFactory.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/RaptorEnvironmentFactory.java
new file mode 100644
index 00000000000..e2cd5d6dee7
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/RaptorEnvironmentFactory.java
@@ -0,0 +1,41 @@
+package org.opentripplanner.standalone.config.routerconfig;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import javax.annotation.Nullable;
+import org.opentripplanner.framework.application.OTPRequestTimeoutException;
+import org.opentripplanner.framework.concurrent.OtpRequestThreadFactory;
+import org.opentripplanner.raptor.api.request.RaptorEnvironment;
+
+/**
+ * Create {@link RaptorEnvironment} from config and adapt it to the OTP application.
+ */
+public class RaptorEnvironmentFactory {
+
+ public static RaptorEnvironment create(final int threadPoolSize) {
+ return new RaptorEnvironment() {
+ @Override
+ public Runnable timeoutHook() {
+ return OTPRequestTimeoutException::checkForTimeout;
+ }
+
+ /**
+ * OTP web server will interrupt all request threads in case of a timeout. In OTP
+ * such events should be mapped to {@link OTPRequestTimeoutException}, witch will
+ * later be mapped to the right API response.
+ */
+ @Override
+ public RuntimeException mapInterruptedException(InterruptedException e) {
+ return new OTPRequestTimeoutException();
+ }
+
+ @Nullable
+ @Override
+ public ExecutorService threadPool() {
+ return threadPoolSize > 0
+ ? Executors.newFixedThreadPool(threadPoolSize, OtpRequestThreadFactory.of("raptor-%d"))
+ : null;
+ }
+ };
+ }
+}
diff --git a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java
index 34465cff27a..e6602a188f4 100644
--- a/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java
+++ b/application/src/main/java/org/opentripplanner/standalone/config/routerconfig/TransitRoutingConfig.java
@@ -62,8 +62,8 @@ public TransitRoutingConfig(
.summary("This parameter is used to allocate enough memory space for Raptor.")
.description(
"""
-Set it to the maximum number of transfers for any given itinerary expected to be found within the
-entire transit network. The memory overhead of setting this higher than the maximum number of
+Set it to the maximum number of transfers for any given itinerary expected to be found within the
+entire transit network. The memory overhead of setting this higher than the maximum number of
transfers is very little so it is better to set it too high than to low.
"""
)
@@ -78,8 +78,8 @@ public TransitRoutingConfig(
.description(
"""
This reduce the number of trips departure time lookups and comparisons. When testing with data from
-Entur and all of Norway as a Graph, the optimal value was about 50. If you calculate the departure
-time every time or want to fine tune the performance, changing this may improve the performance a
+Entur and all of Norway as a Graph, the optimal value was about 50. If you calculate the departure
+time every time or want to fine tune the performance, changing this may improve the performance a
few percents.
"""
)
@@ -108,11 +108,11 @@ public TransitRoutingConfig(
.description(
"""
Use this parameter to set the total number of executable threads available across all searches.
-Multiple searches can run in parallel - this parameter have no effect with regard to that. If 0,
+Multiple searches can run in parallel - this parameter has no effect with regard to that. If 0,
no extra threads are started and the search is done in one thread.
"""
)
- .asInt(dft.searchThreadPoolSize());
+ .asInt(0);
// Dynamic Search Window
this.stopBoardAlightDuringTransferCost =
c
@@ -142,7 +142,7 @@ public TransitRoutingConfig(
| `recommended` | Use a small cost penalty like `60`. | int |
| `preferred` | The best place to do transfers. Should be set to `0`(zero). | int |
-Use values in a range from `0` to `100 000`. **All key/value pairs are required if the
+Use values in a range from `0` to `100 000`. **All key/value pairs are required if the
`stopBoardAlightDuringTransferCost` is listed.**
"""
)
@@ -166,7 +166,7 @@ public TransitRoutingConfig(
.summary("Routing requests to use for pre-filling the stop-to-stop transfer cache.")
.description(
"""
-If not set, the default behavior is to cache stop-to-stop transfers using the default route request
+If not set, the default behavior is to cache stop-to-stop transfers using the default route request
(`routingDefaults`). Use this to change the default or specify more than one `RouteRequest`.
**Example**
@@ -175,7 +175,7 @@ public TransitRoutingConfig(
// router-config.json
{
"transit": {
- "transferCacheRequests": [
+ "transferCacheRequests": [
{ "modes": "WALK" },
{ "modes": "WALK", "wheelchairAccessibility": { "enabled": true } }
]
@@ -201,7 +201,7 @@ public TransitRoutingConfig(
"""
The search window is expanded when the current page return few options. If ZERO result is returned
the first duration in the list is used, if ONE result is returned then the second duration is used
-and so on. The duration is added to the existing search-window and inserted into the next and
+and so on. The duration is added to the existing search-window and inserted into the next and
previous page cursor. See JavaDoc for [TransitTuningParameters#pagingSearchWindowAdjustments](https://github.com/opentripplanner/OpenTripPlanner/blob/dev-2.x/src/main/java/org/opentripplanner/routing/algorithm/raptor/transit/TransitTuningParameters.java)" +
for more info."
"""
@@ -244,7 +244,6 @@ public int iterationDepartureStepInSeconds() {
return iterationDepartureStepInSeconds;
}
- @Override
public int searchThreadPoolSize() {
return searchThreadPoolSize;
}
@@ -367,7 +366,7 @@ heuristics perform a Raptor search (one-iteration) to find a trip which we use t
.summary("Upper limit for the search-window calculation.")
.description(
"""
-Long search windows consumes a lot of resources and may take a long time. Use this parameter to
+Long search windows consume a lot of resources and may take a long time. Use this parameter to
tune the desired maximum search time.
This is the parameter that affects the response time most, the downside is that a search is only
@@ -382,12 +381,12 @@ heuristics perform a Raptor search (one-iteration) to find a trip which we use t
.summary("Used to set the steps the search-window is rounded to.")
.description(
"""
-The search window is rounded off to the closest multiplication of `stepMinutes`. If `stepMinutes` =
+The search window is rounded off to the closest multiplication of `stepMinutes`. If `stepMinutes` =
10 minutes, the search-window can be 10, 20, 30 ... minutes. It the computed search-window is 5
minutes and 17 seconds it will be rounded up to 10 minutes.
-Use a value between `1` and `60`. This should be less than the `min-raptor-search-window`
+Use a value between `1` and `60`. This should be less than the `min-raptor-search-window`
coefficient.
"""
)
diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java
index 52f7970ccd7..979467299cd 100644
--- a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java
+++ b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplication.java
@@ -33,7 +33,7 @@
import org.opentripplanner.street.model.StreetLimitationParameters;
import org.opentripplanner.street.model.elevation.ElevationUtils;
import org.opentripplanner.transit.service.DefaultTransitService;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.updater.configure.UpdaterConfigurator;
import org.opentripplanner.visualizer.GraphVisualizer;
import org.slf4j.Logger;
@@ -69,7 +69,7 @@ public class ConstructApplication {
ConstructApplication(
CommandLineParameters cli,
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
WorldEnvelopeRepository worldEnvelopeRepository,
ConfigModel config,
GraphBuilderDataSources graphBuilderDataSources,
@@ -90,7 +90,7 @@ public class ConstructApplication {
.builder()
.configModel(config)
.graph(graph)
- .transitModel(transitModel)
+ .timetableRepository(timetableRepository)
.graphVisualizer(graphVisualizer)
.worldEnvelopeRepository(worldEnvelopeRepository)
.emissionsDataModel(emissionsDataModel)
@@ -125,7 +125,7 @@ public GraphBuilder createGraphBuilder() {
buildConfig(),
graphBuilderDataSources,
graph(),
- transitModel(),
+ timetableRepository(),
factory.worldEnvelopeRepository(),
factory.emissionsDataModel(),
factory.stopConsolidationRepository(),
@@ -156,26 +156,27 @@ private void setupTransitRoutingServer() {
enableRequestTraceLogging();
createMetricsLogging();
- creatTransitLayerForRaptor(transitModel(), routerConfig().transitTuningConfig());
+ creatTransitLayerForRaptor(timetableRepository(), routerConfig().transitTuningConfig());
/* Create updater modules from JSON config. */
UpdaterConfigurator.configure(
graph(),
realtimeVehicleRepository(),
vehicleRentalRepository(),
- transitModel(),
+ timetableRepository(),
routerConfig().updaterConfig()
);
initEllipsoidToGeoidDifference();
- initializeTransferCache(routerConfig().transitTuningConfig(), transitModel());
+ initializeTransferCache(routerConfig().transitTuningConfig(), timetableRepository());
if (OTPFeature.TransmodelGraphQlApi.isOn()) {
TransmodelAPI.setUp(
routerConfig().transmodelApi(),
- transitModel(),
- routerConfig().routingRequestDefaults()
+ timetableRepository(),
+ routerConfig().routingRequestDefaults(),
+ routerConfig().transitTuningConfig()
);
}
@@ -200,25 +201,29 @@ private void initEllipsoidToGeoidDifference() {
* Create transit layer for Raptor routing. Here we map the scheduled timetables.
*/
public static void creatTransitLayerForRaptor(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
TransitTuningParameters tuningParameters
) {
- if (!transitModel.hasTransit() || !transitModel.isIndexed()) {
+ if (!timetableRepository.hasTransit() || !timetableRepository.isIndexed()) {
LOG.warn(
"Cannot create Raptor data, that requires the graph to have transit data and be indexed."
);
}
LOG.info("Creating transit layer for Raptor routing.");
- transitModel.setTransitLayer(TransitLayerMapper.map(tuningParameters, transitModel));
- transitModel.setRealtimeTransitLayer(new TransitLayer(transitModel.getTransitLayer()));
- transitModel.setTransitLayerUpdater(
- new TransitLayerUpdater(new DefaultTransitService(transitModel))
+ timetableRepository.setTransitLayer(
+ TransitLayerMapper.map(tuningParameters, timetableRepository)
+ );
+ timetableRepository.setRealtimeTransitLayer(
+ new TransitLayer(timetableRepository.getTransitLayer())
+ );
+ timetableRepository.setTransitLayerUpdater(
+ new TransitLayerUpdater(new DefaultTransitService(timetableRepository))
);
}
public static void initializeTransferCache(
TransitTuningParameters transitTuningConfig,
- TransitModel transitModel
+ TimetableRepository timetableRepository
) {
var transferCacheRequests = transitTuningConfig.transferCacheRequests();
if (!transferCacheRequests.isEmpty()) {
@@ -231,7 +236,7 @@ public static void initializeTransferCache(
LOG.info(progress.startMessage());
transferCacheRequests.forEach(request -> {
- transitModel.getTransitLayer().initTransferCacheForRequest(request);
+ timetableRepository.getTransitLayer().initTransferCacheForRequest(request);
//noinspection Convert2MethodRef
progress.step(s -> LOG.info(s));
@@ -241,8 +246,8 @@ public static void initializeTransferCache(
}
}
- public TransitModel transitModel() {
- return factory.transitModel();
+ public TimetableRepository timetableRepository() {
+ return factory.timetableRepository();
}
public DataImportIssueSummary dataImportIssueSummary() {
diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java
index b307776ef52..e828406a35e 100644
--- a/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java
+++ b/application/src/main/java/org/opentripplanner/standalone/configure/ConstructApplicationFactory.java
@@ -34,7 +34,7 @@
import org.opentripplanner.street.model.StreetLimitationParameters;
import org.opentripplanner.street.service.StreetLimitationParametersServiceModule;
import org.opentripplanner.transit.configure.TransitModule;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
import org.opentripplanner.transit.service.TransitService;
import org.opentripplanner.visualizer.GraphVisualizer;
@@ -65,7 +65,7 @@ public interface ConstructApplicationFactory {
ConfigModel config();
RaptorConfig raptorConfig();
Graph graph();
- TransitModel transitModel();
+ TimetableRepository timetableRepository();
WorldEnvelopeRepository worldEnvelopeRepository();
WorldEnvelopeService worldEnvelopeService();
RealtimeVehicleRepository realtimeVehicleRepository();
@@ -102,7 +102,7 @@ interface Builder {
Builder graph(Graph graph);
@BindsInstance
- Builder transitModel(TransitModel transitModel);
+ Builder timetableRepository(TimetableRepository timetableRepository);
@BindsInstance
Builder graphVisualizer(@Nullable GraphVisualizer graphVisualizer);
diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplication.java b/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplication.java
index 19415e489b4..300eb24f997 100644
--- a/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplication.java
+++ b/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplication.java
@@ -12,7 +12,7 @@
import org.opentripplanner.standalone.config.CommandLineParameters;
import org.opentripplanner.standalone.config.ConfigModel;
import org.opentripplanner.street.model.StreetLimitationParameters;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* This class is responsible for loading configuration and setting up the OTP data store.
@@ -54,7 +54,7 @@ public DataSource getInputGraphDataStore() {
public ConstructApplication appConstruction(SerializedGraphObject obj) {
return createAppConstruction(
obj.graph,
- obj.transitModel,
+ obj.timetableRepository,
obj.worldEnvelopeRepository,
obj.issueSummary,
obj.emissionsDataModel,
@@ -67,7 +67,7 @@ public ConstructApplication appConstruction(SerializedGraphObject obj) {
public ConstructApplication appConstruction() {
return createAppConstruction(
factory.emptyGraph(),
- factory.emptyTransitModel(),
+ factory.emptyTimetableRepository(),
factory.emptyWorldEnvelopeRepository(),
DataImportIssueSummary.empty(),
factory.emptyEmissionsDataModel(),
@@ -89,7 +89,7 @@ public ConfigModel config() {
private ConstructApplication createAppConstruction(
Graph graph,
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
WorldEnvelopeRepository worldEnvelopeRepository,
DataImportIssueSummary issueSummary,
@Nullable EmissionsDataModel emissionsDataModel,
@@ -99,7 +99,7 @@ private ConstructApplication createAppConstruction(
return new ConstructApplication(
cli,
graph,
- transitModel,
+ timetableRepository,
worldEnvelopeRepository,
config(),
graphBuilderDataSources(),
diff --git a/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplicationFactory.java b/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplicationFactory.java
index aacb42c4336..8d11d645c48 100644
--- a/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplicationFactory.java
+++ b/application/src/main/java/org/opentripplanner/standalone/configure/LoadApplicationFactory.java
@@ -17,7 +17,7 @@
import org.opentripplanner.standalone.config.ConfigModel;
import org.opentripplanner.standalone.config.configure.LoadConfigModule;
import org.opentripplanner.street.model.StreetLimitationParameters;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* Dagger dependency injection Factory to create components for the OTP load application phase.
@@ -41,7 +41,7 @@ public interface LoadApplicationFactory {
Graph emptyGraph();
@Singleton
- TransitModel emptyTransitModel();
+ TimetableRepository emptyTimetableRepository();
@Singleton
WorldEnvelopeRepository emptyWorldEnvelopeRepository();
diff --git a/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java b/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java
index 0e81193d787..6dc3d27ce69 100644
--- a/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java
+++ b/application/src/main/java/org/opentripplanner/standalone/server/DefaultServerRequestContext.java
@@ -33,7 +33,6 @@
public class DefaultServerRequestContext implements OtpServerRequestContext {
private final List rideHailingServices;
- private RouteRequest routeRequest = null;
private final Graph graph;
private final TransitService transitService;
private final TransitRoutingConfig transitRoutingConfig;
@@ -52,6 +51,8 @@ public class DefaultServerRequestContext implements OtpServerRequestContext {
private final StreetLimitationParametersService streetLimitationParametersService;
private final LuceneIndex luceneIndex;
+ private RouteRequest defaultRouteRequestWithTimeSet = null;
+
/**
* Make sure all mutable components are copied/cloned before calling this constructor.
*/
@@ -142,10 +143,10 @@ public static DefaultServerRequestContext create(
@Override
public RouteRequest defaultRouteRequest() {
// Lazy initialize request-scoped request to avoid doing this when not needed
- if (routeRequest == null) {
- routeRequest = routeRequestDefaults.copyWithDateTimeNow();
+ if (defaultRouteRequestWithTimeSet == null) {
+ defaultRouteRequestWithTimeSet = routeRequestDefaults.copyWithDateTimeNow();
}
- return routeRequest;
+ return defaultRouteRequestWithTimeSet;
}
/**
diff --git a/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java b/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java
index 3ed5685015b..c9161c7588a 100644
--- a/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java
+++ b/application/src/main/java/org/opentripplanner/standalone/server/MetricsLogging.java
@@ -22,7 +22,7 @@
import org.opentripplanner.graph_builder.issue.api.DataImportIssueSummary;
import org.opentripplanner.raptor.configure.RaptorConfig;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule;
-import org.opentripplanner.transit.service.TransitModel;
+import org.opentripplanner.transit.service.TimetableRepository;
/**
* This class is responsible for wiring up various metrics to micrometer, which we use for
@@ -32,7 +32,7 @@ public class MetricsLogging {
@Inject
public MetricsLogging(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
RaptorConfig raptorConfig,
DataImportIssueSummary issueSummary
) {
@@ -48,9 +48,9 @@ public MetricsLogging(
new ProcessorMetrics().bindTo(Metrics.globalRegistry);
new UptimeMetrics().bindTo(Metrics.globalRegistry);
- if (transitModel.getTransitLayer() != null) {
+ if (timetableRepository.getTransitLayer() != null) {
new GuavaCacheMetrics(
- transitModel.getTransitLayer().getTransferCache().getTransferCache(),
+ timetableRepository.getTransitLayer().getTransferCache().getTransferCache(),
"raptorTransfersCache",
List.of(Tag.of("cache", "raptorTransfers"))
)
@@ -63,23 +63,23 @@ public MetricsLogging(
)
.bindTo(Metrics.globalRegistry);
- if (transitModel.getUpdaterManager() != null) {
+ if (timetableRepository.getUpdaterManager() != null) {
new ExecutorServiceMetrics(
- transitModel.getUpdaterManager().getPollingUpdaterPool(),
+ timetableRepository.getUpdaterManager().getPollingUpdaterPool(),
"pollingGraphUpdaters",
List.of(Tag.of("pool", "pollingGraphUpdaters"))
)
.bindTo(Metrics.globalRegistry);
new ExecutorServiceMetrics(
- transitModel.getUpdaterManager().getNonPollingUpdaterPool(),
+ timetableRepository.getUpdaterManager().getNonPollingUpdaterPool(),
"nonPollingGraphUpdaters",
List.of(Tag.of("pool", "nonPollingGraphUpdaters"))
)
.bindTo(Metrics.globalRegistry);
new ExecutorServiceMetrics(
- transitModel.getUpdaterManager().getScheduler(),
+ timetableRepository.getUpdaterManager().getScheduler(),
"graphUpdateScheduler",
List.of(Tag.of("pool", "graphUpdateScheduler"))
)
diff --git a/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java b/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java
index e25cb435887..507b033f645 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/basic/TransitMode.java
@@ -69,7 +69,7 @@ public String enumValueDescription() {
case TRAM -> "Tram, streetcar or light rail. Used for any light rail or street level system within a metropolitan area.";
case FERRY -> "Used for short- and long-distance boat service.";
case AIRPLANE -> "Taking an airplane";
- case CABLE_CAR -> "Used for street-level cable cars where the cable runs beneath the car.";
+ case CABLE_CAR -> "Used for street-level rail cars where the cable runs beneath the vehicle.";
case GONDOLA -> "Gondola or suspended cable car. Typically used for aerial cable cars where the car is suspended from the cable.";
case FUNICULAR -> "Used for any rail system that moves on steep inclines with a cable traction system.";
case TROLLEYBUS -> "Used for trolleybus systems which draw power from overhead wires using poles on the roof of the vehicle.";
diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/BikeAccess.java b/application/src/main/java/org/opentripplanner/transit/model/network/BikeAccess.java
index 536a01a9b14..c0d850e9ce7 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/network/BikeAccess.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/network/BikeAccess.java
@@ -1,6 +1,8 @@
package org.opentripplanner.transit.model.network;
/**
+ * This represents the state of whether bikes are allowed on board trips (or routes).
+ *
* GTFS codes:
* 0 = unknown / unspecified, 1 = bikes allowed, 2 = bikes NOT allowed
*/
diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/CarAccess.java b/application/src/main/java/org/opentripplanner/transit/model/network/CarAccess.java
new file mode 100644
index 00000000000..2fca43cfb32
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/transit/model/network/CarAccess.java
@@ -0,0 +1,13 @@
+package org.opentripplanner.transit.model.network;
+
+/**
+ * This represents the state of whether cars are allowed on board trips.
+ *
+ * GTFS codes:
+ * 0 = unknown / unspecified, 1 = cars allowed, 2 = cars NOT allowed
+ */
+public enum CarAccess {
+ UNKNOWN,
+ NOT_ALLOWED,
+ ALLOWED,
+}
diff --git a/application/src/main/java/org/opentripplanner/transit/model/network/Route.java b/application/src/main/java/org/opentripplanner/transit/model/network/Route.java
index 206e65f7af9..bd868fba10d 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/network/Route.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/network/Route.java
@@ -156,6 +156,9 @@ public Integer getGtfsSortOrder() {
return gtfsSortOrder;
}
+ /**
+ * Returns the NeTEx submode for the route. Will return UNKNOWN by default.
+ */
public SubMode getNetexSubmode() {
return netexSubmode;
}
diff --git a/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java b/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java
index 4d82ab05e57..0953f65559d 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/organization/Agency.java
@@ -21,7 +21,6 @@ public final class Agency extends AbstractTransitEntity i
private final String lang;
private final String phone;
private final String fareUrl;
- private final String brandingUrl;
Agency(AgencyBuilder builder) {
super(builder.getId());
@@ -43,7 +42,6 @@ public final class Agency extends AbstractTransitEntity i
this.lang = builder.getLang();
this.phone = builder.getPhone();
this.fareUrl = builder.getFareUrl();
- this.brandingUrl = builder.getBrandingUrl();
}
public static AgencyBuilder of(FeedScopedId id) {
@@ -78,11 +76,6 @@ public String getFareUrl() {
return fareUrl;
}
- @Nullable
- public String getBrandingUrl() {
- return brandingUrl;
- }
-
@Override
public AgencyBuilder copy() {
return new AgencyBuilder(this);
@@ -102,8 +95,7 @@ public boolean sameAs(Agency other) {
Objects.equals(url, other.url) &&
Objects.equals(lang, other.lang) &&
Objects.equals(phone, other.phone) &&
- Objects.equals(fareUrl, other.fareUrl) &&
- Objects.equals(brandingUrl, other.brandingUrl)
+ Objects.equals(fareUrl, other.fareUrl)
);
}
}
diff --git a/application/src/main/java/org/opentripplanner/transit/model/organization/AgencyBuilder.java b/application/src/main/java/org/opentripplanner/transit/model/organization/AgencyBuilder.java
index 3cf24523c5d..f985a953d9e 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/organization/AgencyBuilder.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/organization/AgencyBuilder.java
@@ -11,7 +11,6 @@ public class AgencyBuilder extends AbstractEntityBuilder
private String lang;
private String phone;
private String fareUrl;
- private String brandingUrl;
AgencyBuilder(FeedScopedId id) {
super(id);
@@ -25,7 +24,6 @@ public class AgencyBuilder extends AbstractEntityBuilder
this.lang = original.getLang();
this.phone = original.getPhone();
this.fareUrl = original.getFareUrl();
- this.brandingUrl = original.getBrandingUrl();
}
public String getName() {
@@ -82,15 +80,6 @@ public AgencyBuilder withFareUrl(String fareUrl) {
return this;
}
- public String getBrandingUrl() {
- return brandingUrl;
- }
-
- public AgencyBuilder withBrandingUrl(String brandingUrl) {
- this.brandingUrl = brandingUrl;
- return this;
- }
-
@Override
protected Agency buildFromValues() {
return new Agency(this);
diff --git a/application/src/main/java/org/opentripplanner/transit/model/package.md b/application/src/main/java/org/opentripplanner/transit/model/package.md
index 9c10c88828c..26ed7facde3 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/package.md
+++ b/application/src/main/java/org/opentripplanner/transit/model/package.md
@@ -23,10 +23,9 @@ All transit entities must have an ID. Transit entities ar "root" level are consi
roots_.
-#### @Nonnull and @Nullable entity fields
+#### Non-null and nullable entity fields
-All fields getters(except primitive types) should be annotated with `@Nullable` or `@Nonnull`. None
-null field should be enforced in the Entity constructor by using `Objects.requireNonNull`,
+Non-nullability of fields should be enforced in the Entity constructor by using `Objects.requireNonNull`,
`Objects.requireNonNullElse` or `ObjectUtils.ifNotNull`. We should enforce this for all fields
required in both GTFS and in the Nordic NeTEx Profile. For enumeration types using a special value
like `UNKNOWN` is preferred over making the field optional.
diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java
index 53ec7207adc..7cca32c4a90 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/Trip.java
@@ -16,6 +16,7 @@
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.framework.LogInfo;
import org.opentripplanner.transit.model.network.BikeAccess;
+import org.opentripplanner.transit.model.network.CarAccess;
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Operator;
@@ -34,23 +35,36 @@
*/
public final class Trip extends AbstractTransitEntity implements LogInfo {
- private final Operator operator;
private final Route route;
- private final FeedScopedId serviceId;
- private final String shortName;
private final TransitMode mode;
- private final SubMode netexSubmode;
- private final I18NString headsign;
- private final FeedScopedId shapeId;
-
private final Direction direction;
private final BikeAccess bikesAllowed;
+ private final CarAccess carsAllowed;
private final Accessibility wheelchairBoarding;
+ private final SubMode netexSubmode;
+ private final TripAlteration netexAlteration;
+
+ @Nullable
+ private final Operator operator;
+
+ @Nullable
+ private final FeedScopedId serviceId;
+
+ @Nullable
+ private final String shortName;
+
+ @Nullable
+ private final I18NString headsign;
+
+ @Nullable
+ private final FeedScopedId shapeId;
+
+ @Nullable
private final String gtfsBlockId;
+ @Nullable
private final String netexInternalPlanningCode;
- private final TripAlteration netexAlteration;
Trip(TripBuilder builder) {
super(builder.getId());
@@ -64,6 +78,7 @@ public final class Trip extends AbstractTransitEntity impleme
: route.getNetexSubmode();
this.direction = requireNonNullElse(builder.getDirection(), Direction.UNKNOWN);
this.bikesAllowed = requireNonNullElse(builder.getBikesAllowed(), route.getBikesAllowed());
+ this.carsAllowed = requireNonNullElse(builder.getCarsAllowed(), CarAccess.UNKNOWN);
this.wheelchairBoarding =
requireNonNullElse(builder.getWheelchairBoarding(), Accessibility.NO_INFORMATION);
this.netexAlteration = requireNonNullElse(builder.getNetexAlteration(), TripAlteration.PLANNED);
@@ -144,6 +159,10 @@ public BikeAccess getBikesAllowed() {
return bikesAllowed;
}
+ public CarAccess getCarsAllowed() {
+ return carsAllowed;
+ }
+
public Accessibility getWheelchairBoarding() {
return wheelchairBoarding;
}
@@ -205,6 +224,7 @@ public boolean sameAs(Trip other) {
Objects.equals(this.shapeId, other.shapeId) &&
Objects.equals(this.direction, other.direction) &&
Objects.equals(this.bikesAllowed, other.bikesAllowed) &&
+ Objects.equals(this.carsAllowed, other.carsAllowed) &&
Objects.equals(this.wheelchairBoarding, other.wheelchairBoarding) &&
Objects.equals(this.netexAlteration, other.netexAlteration)
);
diff --git a/application/src/main/java/org/opentripplanner/transit/model/timetable/TripBuilder.java b/application/src/main/java/org/opentripplanner/transit/model/timetable/TripBuilder.java
index 063dfe10da2..5ed0616831d 100644
--- a/application/src/main/java/org/opentripplanner/transit/model/timetable/TripBuilder.java
+++ b/application/src/main/java/org/opentripplanner/transit/model/timetable/TripBuilder.java
@@ -6,6 +6,7 @@
import org.opentripplanner.transit.model.framework.AbstractEntityBuilder;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.model.network.BikeAccess;
+import org.opentripplanner.transit.model.network.CarAccess;
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Operator;
@@ -21,6 +22,7 @@ public class TripBuilder extends AbstractEntityBuilder {
private FeedScopedId shapeId;
private Direction direction;
private BikeAccess bikesAllowed;
+ private CarAccess carsAllowed;
private Accessibility wheelchairBoarding;
private String gtfsBlockId;
private String netexInternalPlanningCode;
@@ -44,6 +46,7 @@ public class TripBuilder extends AbstractEntityBuilder {
this.shapeId = original.getShapeId();
this.direction = original.getDirection();
this.bikesAllowed = original.getBikesAllowed();
+ this.carsAllowed = original.getCarsAllowed();
this.wheelchairBoarding = original.getWheelchairBoarding();
this.netexInternalPlanningCode = original.getNetexInternalPlanningCode();
}
@@ -151,11 +154,20 @@ public BikeAccess getBikesAllowed() {
return bikesAllowed;
}
+ public CarAccess getCarsAllowed() {
+ return carsAllowed;
+ }
+
public TripBuilder withBikesAllowed(BikeAccess bikesAllowed) {
this.bikesAllowed = bikesAllowed;
return this;
}
+ public TripBuilder withCarsAllowed(CarAccess carsAllowed) {
+ this.carsAllowed = carsAllowed;
+ return this;
+ }
+
public Accessibility getWheelchairBoarding() {
return wheelchairBoarding;
}
diff --git a/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java b/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java
index ce2d3aa0ad2..2ce99e7809b 100644
--- a/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java
+++ b/application/src/main/java/org/opentripplanner/transit/service/DefaultTransitService.java
@@ -68,9 +68,9 @@
*/
public class DefaultTransitService implements TransitEditorService {
- private final TransitModel transitModel;
+ private final TimetableRepository timetableRepository;
- private final TransitModelIndex transitModelIndex;
+ private final TimetableRepositoryIndex timetableRepositoryIndex;
/**
* This should only be accessed through the getTimetableSnapshot method.
@@ -78,113 +78,113 @@ public class DefaultTransitService implements TransitEditorService {
private TimetableSnapshot timetableSnapshot;
@Inject
- public DefaultTransitService(TransitModel transitModel) {
- this.transitModel = transitModel;
- this.transitModelIndex = transitModel.getTransitModelIndex();
+ public DefaultTransitService(TimetableRepository timetableRepository) {
+ this.timetableRepository = timetableRepository;
+ this.timetableRepositoryIndex = timetableRepository.getTimetableRepositoryIndex();
}
public DefaultTransitService(
- TransitModel transitModel,
+ TimetableRepository timetableRepository,
TimetableSnapshot timetableSnapshotBuffer
) {
- this(transitModel);
+ this(timetableRepository);
this.timetableSnapshot = timetableSnapshotBuffer;
}
@Override
public Collection getFeedIds() {
- return this.transitModel.getFeedIds();
+ return this.timetableRepository.getFeedIds();
}
@Override
public Collection getAgencies() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getAgencies();
+ return this.timetableRepository.getAgencies();
}
@Override
public Optional findAgencyById(FeedScopedId id) {
- return this.transitModel.findAgencyById(id);
+ return this.timetableRepository.findAgencyById(id);
}
@Override
public FeedInfo getFeedInfo(String feedId) {
- return this.transitModel.getFeedInfo(feedId);
+ return this.timetableRepository.getFeedInfo(feedId);
}
@Override
public void addAgency(Agency agency) {
- this.transitModel.addAgency(agency);
+ this.timetableRepository.addAgency(agency);
}
@Override
public void addFeedInfo(FeedInfo info) {
- this.transitModel.addFeedInfo(info);
+ this.timetableRepository.addFeedInfo(info);
}
@Override
public Collection getNoticesByEntity(AbstractTransitEntity, ?> entity) {
- return this.transitModel.getNoticesByElement().get(entity);
+ return this.timetableRepository.getNoticesByElement().get(entity);
}
@Override
public TripPattern getTripPatternForId(FeedScopedId id) {
- return this.transitModel.getTripPatternForId(id);
+ return this.timetableRepository.getTripPatternForId(id);
}
@Override
public Collection getAllTripPatterns() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getAllTripPatterns();
+ return this.timetableRepository.getAllTripPatterns();
}
@Override
public Collection getNotices() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getNoticesByElement().values();
+ return this.timetableRepository.getNoticesByElement().values();
}
@Override
public Station getStationById(FeedScopedId id) {
- return this.transitModel.getStopModel().getStationById(id);
+ return this.timetableRepository.getSiteRepository().getStationById(id);
}
@Override
public MultiModalStation getMultiModalStation(FeedScopedId id) {
- return this.transitModel.getStopModel().getMultiModalStation(id);
+ return this.timetableRepository.getSiteRepository().getMultiModalStation(id);
}
@Override
public Collection getStations() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getStopModel().listStations();
+ return this.timetableRepository.getSiteRepository().listStations();
}
@Override
public Integer getServiceCodeForId(FeedScopedId id) {
- return this.transitModel.getServiceCodes().get(id);
+ return this.timetableRepository.getServiceCodes().get(id);
}
@Override
public TIntSet getServiceCodesRunningForDate(LocalDate serviceDate) {
- return transitModelIndex
+ return timetableRepositoryIndex
.getServiceCodesRunningForDate()
.getOrDefault(serviceDate, new TIntHashSet());
}
@Override
public AreaStop getAreaStop(FeedScopedId id) {
- return this.transitModel.getStopModel().getAreaStop(id);
+ return this.timetableRepository.getSiteRepository().getAreaStop(id);
}
@Override
public Agency getAgencyForId(FeedScopedId id) {
- return this.transitModelIndex.getAgencyForId(id);
+ return this.timetableRepositoryIndex.getAgencyForId(id);
}
@Override
public RegularStop getRegularStop(FeedScopedId id) {
- return this.transitModel.getStopModel().getRegularStop(id);
+ return this.timetableRepository.getSiteRepository().getRegularStop(id);
}
@Override
@@ -196,7 +196,7 @@ public Route getRouteForId(FeedScopedId id) {
return realtimeAddedRoute;
}
}
- return transitModelIndex.getRouteForId(id);
+ return timetableRepositoryIndex.getRouteForId(id);
}
/**
@@ -205,75 +205,75 @@ public Route getRouteForId(FeedScopedId id) {
*/
@Override
public void addRoutes(Route route) {
- this.transitModelIndex.addRoutes(route);
+ this.timetableRepositoryIndex.addRoutes(route);
}
@Override
public Set getRoutesForStop(StopLocation stop) {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModelIndex.getRoutesForStop(stop);
+ return this.timetableRepositoryIndex.getRoutesForStop(stop);
}
@Override
public Collection getPatternsForStop(StopLocation stop) {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModelIndex.getPatternsForStop(stop);
+ return this.timetableRepositoryIndex.getPatternsForStop(stop);
}
@Override
public Collection getTripsForStop(StopLocation stop) {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModelIndex.getTripsForStop(stop);
+ return this.timetableRepositoryIndex.getTripsForStop(stop);
}
@Override
public Collection getAllOperators() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getOperators();
+ return this.timetableRepository.getOperators();
}
@Override
public Operator getOperatorForId(FeedScopedId id) {
- return this.transitModelIndex.getOperatorForId(id);
+ return this.timetableRepositoryIndex.getOperatorForId(id);
}
@Override
public Collection listStopLocations() {
OTPRequestTimeoutException.checkForTimeout();
- return transitModel.getStopModel().listStopLocations();
+ return timetableRepository.getSiteRepository().listStopLocations();
}
@Override
public Collection listRegularStops() {
OTPRequestTimeoutException.checkForTimeout();
- return transitModel.getStopModel().listRegularStops();
+ return timetableRepository.getSiteRepository().listRegularStops();
}
@Override
public Collection listGroupStops() {
OTPRequestTimeoutException.checkForTimeout();
- return transitModel.getStopModel().listGroupStops();
+ return timetableRepository.getSiteRepository().listGroupStops();
}
@Override
public StopLocation getStopLocation(FeedScopedId id) {
- return transitModel.getStopModel().getStopLocation(id);
+ return timetableRepository.getSiteRepository().getStopLocation(id);
}
@Override
public Collection getStopOrChildStops(FeedScopedId id) {
- return transitModel.getStopModel().findStopOrChildStops(id);
+ return timetableRepository.getSiteRepository().findStopOrChildStops(id);
}
@Override
public Collection listStopLocationGroups() {
OTPRequestTimeoutException.checkForTimeout();
- return transitModel.getStopModel().listStopLocationGroups();
+ return timetableRepository.getSiteRepository().listStopLocationGroups();
}
@Override
public StopLocationsGroup getStopLocationsGroup(FeedScopedId id) {
- return transitModel.getStopModel().getStopLocationsGroup(id);
+ return timetableRepository.getSiteRepository().getStopLocationsGroup(id);
}
@Override
@@ -291,7 +291,7 @@ public Trip getTripForId(FeedScopedId id) {
@Nullable
@Override
public Trip getScheduledTripForId(FeedScopedId id) {
- return this.transitModelIndex.getTripForId(id);
+ return this.timetableRepositoryIndex.getTripForId(id);
}
@Override
@@ -300,11 +300,11 @@ public Collection getAllTrips() {
TimetableSnapshot currentSnapshot = lazyGetTimeTableSnapShot();
if (currentSnapshot != null) {
return new CollectionsView<>(
- transitModelIndex.getAllTrips(),
+ timetableRepositoryIndex.getAllTrips(),
currentSnapshot.listRealTimeAddedTrips()
);
}
- return Collections.unmodifiableCollection(transitModelIndex.getAllTrips());
+ return Collections.unmodifiableCollection(timetableRepositoryIndex.getAllTrips());
}
@Override
@@ -313,11 +313,11 @@ public Collection getAllRoutes() {
TimetableSnapshot currentSnapshot = lazyGetTimeTableSnapShot();
if (currentSnapshot != null) {
return new CollectionsView<>(
- transitModelIndex.getAllRoutes(),
+ timetableRepositoryIndex.getAllRoutes(),
currentSnapshot.listRealTimeAddedRoutes()
);
}
- return transitModelIndex.getAllRoutes();
+ return timetableRepositoryIndex.getAllRoutes();
}
@Override
@@ -329,7 +329,7 @@ public TripPattern getPatternForTrip(Trip trip) {
return realtimeAddedTripPattern;
}
}
- return this.transitModelIndex.getPatternForTrip(trip);
+ return this.timetableRepositoryIndex.getPatternForTrip(trip);
}
@Override
@@ -345,7 +345,7 @@ public TripPattern getPatternForTrip(Trip trip, LocalDate serviceDate) {
public Collection getPatternsForRoute(Route route) {
OTPRequestTimeoutException.checkForTimeout();
Collection tripPatterns = new HashSet<>(
- transitModelIndex.getPatternsForRoute(route)
+ timetableRepositoryIndex.getPatternsForRoute(route)
);
TimetableSnapshot currentSnapshot = lazyGetTimeTableSnapShot();
if (currentSnapshot != null) {
@@ -359,7 +359,7 @@ public Collection getPatternsForRoute(Route route) {
@Override
public MultiModalStation getMultiModalStationForStation(Station station) {
- return this.transitModel.getStopModel().getMultiModalStationForStation(station);
+ return this.timetableRepository.getSiteRepository().getMultiModalStationForStation(station);
}
/**
@@ -465,7 +465,7 @@ public List stopTimesForPatternAtStop(
* Returns all the patterns for a specific stop. If includeRealtimeUpdates is set, new patterns
* added by realtime updates are added to the collection.
* A set is used here because trip patterns
- * that were updated by realtime data is both part of the TransitModelIndex and the TimetableSnapshot
+ * that were updated by realtime data is both part of the TimetableRepositoryIndex and the TimetableSnapshot
*/
@Override
public Collection getPatternsForStop(
@@ -486,18 +486,18 @@ public Collection getPatternsForStop(
@Override
public Collection getGroupsOfRoutes() {
OTPRequestTimeoutException.checkForTimeout();
- return transitModelIndex.getAllGroupOfRoutes();
+ return timetableRepositoryIndex.getAllGroupOfRoutes();
}
@Override
public Collection getRoutesForGroupOfRoutes(GroupOfRoutes groupOfRoutes) {
OTPRequestTimeoutException.checkForTimeout();
- return transitModelIndex.getRoutesForGroupOfRoutes(groupOfRoutes);
+ return timetableRepositoryIndex.getRoutesForGroupOfRoutes(groupOfRoutes);
}
@Override
public GroupOfRoutes getGroupOfRoutesForId(FeedScopedId id) {
- return transitModelIndex.getGroupOfRoutesForId(id);
+ return timetableRepositoryIndex.getGroupOfRoutesForId(id);
}
/**
@@ -540,7 +540,7 @@ public boolean hasNewTripPatternsForModifiedTrips() {
@Nullable
private TimetableSnapshot lazyGetTimeTableSnapShot() {
if (this.timetableSnapshot == null) {
- timetableSnapshot = transitModel.getTimetableSnapshot();
+ timetableSnapshot = timetableRepository.getTimetableSnapshot();
}
return this.timetableSnapshot;
}
@@ -556,7 +556,7 @@ public TripOnServiceDate getTripOnServiceDateById(FeedScopedId tripOnServiceDate
return tripOnServiceDate;
}
}
- return transitModel.getTripOnServiceDateById(tripOnServiceDateId);
+ return timetableRepository.getTripOnServiceDateById(tripOnServiceDateId);
}
@Override
@@ -564,11 +564,11 @@ public Collection getAllTripOnServiceDates() {
TimetableSnapshot currentSnapshot = lazyGetTimeTableSnapShot();
if (currentSnapshot != null) {
return new CollectionsView<>(
- transitModel.getAllTripsOnServiceDates(),
+ timetableRepository.getAllTripsOnServiceDates(),
currentSnapshot.listRealTimeAddedTripOnServiceDate()
);
}
- return transitModel.getAllTripsOnServiceDates();
+ return timetableRepository.getAllTripsOnServiceDates();
}
@Override
@@ -584,7 +584,7 @@ public TripOnServiceDate getTripOnServiceDateForTripAndDay(
return tripOnServiceDate;
}
}
- return transitModelIndex.getTripOnServiceDateForTripAndDay(tripIdAndServiceDate);
+ return timetableRepositoryIndex.getTripOnServiceDateForTripAndDay(tripIdAndServiceDate);
}
/**
@@ -605,96 +605,96 @@ public List getTripOnServiceDates(TripOnServiceDateRequest re
*/
@Override
public FeedScopedId getOrCreateServiceIdForDate(LocalDate serviceDate) {
- return transitModel.getOrCreateServiceIdForDate(serviceDate);
+ return timetableRepository.getOrCreateServiceIdForDate(serviceDate);
}
@Override
public void addTransitMode(TransitMode mode) {
- this.transitModel.addTransitMode(mode);
+ this.timetableRepository.addTransitMode(mode);
}
@Override
public Set getTransitModes() {
- return this.transitModel.getTransitModes();
+ return this.timetableRepository.getTransitModes();
}
@Override
public Collection getTransfersByStop(StopLocation stop) {
- return this.transitModel.getTransfersByStop(stop);
+ return this.timetableRepository.getTransfersByStop(stop);
}
@Override
public TransitLayer getTransitLayer() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getTransitLayer();
+ return this.timetableRepository.getTransitLayer();
}
@Override
public TransitLayer getRealtimeTransitLayer() {
OTPRequestTimeoutException.checkForTimeout();
- return this.transitModel.getRealtimeTransitLayer();
+ return this.timetableRepository.getRealtimeTransitLayer();
}
@Override
public void setTransitLayer(TransitLayer transitLayer) {
- this.transitModel.setTransitLayer(transitLayer);
+ this.timetableRepository.setTransitLayer(transitLayer);
}
@Override
public void setRealtimeTransitLayer(TransitLayer realtimeTransitLayer) {
- transitModel.setRealtimeTransitLayer(realtimeTransitLayer);
+ timetableRepository.setRealtimeTransitLayer(realtimeTransitLayer);
}
@Override
public boolean hasRealtimeTransitLayer() {
- return transitModel.hasRealtimeTransitLayer();
+ return timetableRepository.hasRealtimeTransitLayer();
}
@Override
public CalendarService getCalendarService() {
- return this.transitModel.getCalendarService();
+ return this.timetableRepository.getCalendarService();
}
@Override
public ZoneId getTimeZone() {
- return this.transitModel.getTimeZone();
+ return this.timetableRepository.getTimeZone();
}
@Override
public TransitAlertService getTransitAlertService() {
- return this.transitModel.getTransitAlertService();
+ return this.timetableRepository.getTransitAlertService();
}
@Override
public FlexIndex getFlexIndex() {
- return this.transitModelIndex.getFlexIndex();
+ return this.timetableRepositoryIndex.getFlexIndex();
}
@Override
public ZonedDateTime getTransitServiceEnds() {
- return transitModel.getTransitServiceEnds();
+ return timetableRepository.getTransitServiceEnds();
}
@Override
public ZonedDateTime getTransitServiceStarts() {
- return transitModel.getTransitServiceStarts();
+ return timetableRepository.getTransitServiceStarts();
}
@Override
public Collection findRegularStops(Envelope envelope) {
OTPRequestTimeoutException.checkForTimeout();
- return transitModel.getStopModel().findRegularStops(envelope);
+ return timetableRepository.getSiteRepository().findRegularStops(envelope);
}
@Override
public Collection findAreaStops(Envelope envelope) {
OTPRequestTimeoutException.checkForTimeout();
- return transitModel.getStopModel().findAreaStops(envelope);
+ return timetableRepository.getSiteRepository().findAreaStops(envelope);
}
@Override
public GraphUpdaterStatus getUpdaterStatus() {
- return transitModel.getUpdaterManager();
+ return timetableRepository.getUpdaterManager();
}
@Override
@@ -712,17 +712,19 @@ public List getModesOfStopLocation(StopLocation stop) {
@Override
public Deduplicator getDeduplicator() {
- return transitModel.getDeduplicator();
+ return timetableRepository.getDeduplicator();
}
@Override
public Set getAllServiceCodes() {
- return Collections.unmodifiableSet(transitModelIndex.getServiceCodesRunningForDate().keySet());
+ return Collections.unmodifiableSet(
+ timetableRepositoryIndex.getServiceCodesRunningForDate().keySet()
+ );
}
@Override
public Map getServiceCodesRunningForDate() {
- return Collections.unmodifiableMap(transitModelIndex.getServiceCodesRunningForDate());
+ return Collections.unmodifiableMap(timetableRepositoryIndex.getServiceCodesRunningForDate());
}
/**
@@ -738,12 +740,12 @@ private Stream getPatternModesOfStop(StopLocation stop) {
@Override
public TransferService getTransferService() {
- return transitModel.getTransferService();
+ return timetableRepository.getTransferService();
}
@Override
public boolean transitFeedCovers(Instant dateTime) {
- return transitModel.transitFeedCovers(dateTime);
+ return timetableRepository.transitFeedCovers(dateTime);
}
/**
diff --git a/application/src/main/java/org/opentripplanner/transit/service/StopModel.java b/application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java
similarity index 88%
rename from application/src/main/java/org/opentripplanner/transit/service/StopModel.java
rename to application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java
index 4f55ca25b5b..6c9d591933a 100644
--- a/application/src/main/java/org/opentripplanner/transit/service/StopModel.java
+++ b/application/src/main/java/org/opentripplanner/transit/service/SiteRepository.java
@@ -26,9 +26,9 @@
/**
* Repository for Stop entities.
*/
-public class StopModel implements Serializable {
+public class SiteRepository implements Serializable {
- private static final Logger LOG = LoggerFactory.getLogger(StopModel.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SiteRepository.class);
private final AtomicInteger stopIndexCounter;
private final Map regularStopById;
@@ -37,10 +37,10 @@ public class StopModel implements Serializable {
private final Map groupOfStationsById;
private final Map areaStopById;
private final Map groupStopById;
- private transient StopModelIndex index;
+ private transient SiteRepositoryIndex index;
@Inject
- public StopModel() {
+ public SiteRepository() {
this.stopIndexCounter = new AtomicInteger(0);
this.regularStopById = Map.of();
this.stationById = Map.of();
@@ -51,7 +51,7 @@ public StopModel() {
this.index = createIndex();
}
- StopModel(StopModelBuilder builder) {
+ SiteRepository(SiteRepositoryBuilder builder) {
this.stopIndexCounter = builder.stopIndexCounter();
this.regularStopById = builder.regularStopsById().asImmutableMap();
this.stationById = builder.stationById().asImmutableMap();
@@ -67,7 +67,7 @@ public StopModel() {
* method, if not this method will fail! If a duplicate key exist, then child value is kept -
* this feature is normally not allowed, but not enforced here.
*/
- private StopModel(StopModel main, StopModel child) {
+ private SiteRepository(SiteRepository main, SiteRepository child) {
this.stopIndexCounter = assertSameStopIndexCounterIsUsedToCreateBothModels(main, child);
this.areaStopById = MapUtils.combine(main.areaStopById, child.areaStopById);
this.regularStopById = MapUtils.combine(main.regularStopById, child.regularStopById);
@@ -83,28 +83,28 @@ private StopModel(StopModel main, StopModel child) {
/**
* Create a new builder based on an empty model. This is useful in unit-tests, but should
* NOT be used in the main code. It is not possible to merge the result with another
- * {@link StopModel}, because they do not share the same context(stopIndexCounter).
+ * {@link SiteRepository}, because they do not share the same context(stopIndexCounter).
*
* In the application code the correct way is to retrieve a model instance and then use the
* {@link #withContext()} method to create a builder.
*/
- public static StopModelBuilder of() {
- return new StopModelBuilder(new AtomicInteger(0));
+ public static SiteRepositoryBuilder of() {
+ return new SiteRepositoryBuilder(new AtomicInteger(0));
}
/**
* Create a new builder attached to the existing model. The entities of the existing model are
* NOT copied into the builder, but the builder has access to the model - allowing it to check
* for duplicates and injecting information from the model(indexing). The changes in the
- * StopModelBuilder can then be merged into the original model - this is for now left to the
+ * SiteRepositoryBuilder can then be merged into the original model - this is for now left to the
* caller.
*
* USE THIS TO CREATE A SAFE BUILDER IN PRODUCTION CODE. You MAY use this method in unit-tests,
* the alternative is the {@link #of()} method. This method should be used if the test have a
- * StopModel and the {@link #of()} method should be used if a stop-model in not needed.
+ * SiteRepository and the {@link #of()} method should be used if a stop-model in not needed.
*/
- public StopModelBuilder withContext() {
- return new StopModelBuilder(this.stopIndexCounter);
+ public SiteRepositoryBuilder withContext() {
+ return new SiteRepositoryBuilder(this.stopIndexCounter);
}
/**
@@ -282,24 +282,24 @@ public Collection findStopOrChildStops(FeedScopedId id) {
}
/**
- * Call this method after deserializing this class. This will reindex the StopModel.
+ * Call this method after deserializing this class. This will reindex the SiteRepository.
*/
public void reindexAfterDeserialization() {
reindex();
}
- public StopModel merge(StopModel child) {
- return new StopModel(this, child);
+ public SiteRepository merge(SiteRepository child) {
+ return new SiteRepository(this, child);
}
private void reindex() {
- LOG.info("Index stop model...");
+ LOG.info("Index site repository...");
index = createIndex();
- LOG.info("Index stop model complete.");
+ LOG.info("Index site repository complete.");
}
- private StopModelIndex createIndex() {
- return new StopModelIndex(
+ private SiteRepositoryIndex createIndex() {
+ return new SiteRepositoryIndex(
regularStopById.values(),
areaStopById.values(),
groupStopById.values(),
@@ -328,13 +328,13 @@ private static V getById(FeedScopedId id, Map...
*/
@SuppressWarnings("NumberEquality")
private static AtomicInteger assertSameStopIndexCounterIsUsedToCreateBothModels(
- StopModel main,
- StopModel child
+ SiteRepository main,
+ SiteRepository child
) {
if (main.stopIndexCounter != child.stopIndexCounter) {
throw new IllegalArgumentException(
- "Two Stop models can only be merged if they are created with the same stopIndexCounter. " +
- "This is archived by using the 'StopModel.withContext()' method. We do this to avoid " +
+ "Two Stop repositories can only be merged if they are created with the same stopIndexCounter. " +
+ "This is archived by using the 'SiteRepository.withContext()' method. We do this to avoid " +
"duplicates/gaps in the stopIndex."
);
}
diff --git a/application/src/main/java/org/opentripplanner/transit/service/StopModelBuilder.java b/application/src/main/java/org/opentripplanner/transit/service/SiteRepositoryBuilder.java
similarity index 78%
rename from application/src/main/java/org/opentripplanner/transit/service/StopModelBuilder.java
rename to application/src/main/java/org/opentripplanner/transit/service/SiteRepositoryBuilder.java
index 52ac778c559..a5c89c2a741 100644
--- a/application/src/main/java/org/opentripplanner/transit/service/StopModelBuilder.java
+++ b/application/src/main/java/org/opentripplanner/transit/service/SiteRepositoryBuilder.java
@@ -17,7 +17,7 @@
import org.opentripplanner.transit.model.site.RegularStopBuilder;
import org.opentripplanner.transit.model.site.Station;
-public class StopModelBuilder {
+public class SiteRepositoryBuilder {
private final AtomicInteger stopIndexCounter;
@@ -28,7 +28,7 @@ public class StopModelBuilder {
private final EntityById multiModalStationById = new DefaultEntityById<>();
private final EntityById groupOfStationById = new DefaultEntityById<>();
- StopModelBuilder(AtomicInteger stopIndexCounter) {
+ SiteRepositoryBuilder(AtomicInteger stopIndexCounter) {
this.stopIndexCounter = stopIndexCounter;
}
@@ -47,12 +47,12 @@ public RegularStop computeRegularStopIfAbsent(
return regularStopById.computeIfAbsent(id, factory);
}
- public StopModelBuilder withRegularStop(RegularStop stop) {
+ public SiteRepositoryBuilder withRegularStop(RegularStop stop) {
regularStopById.add(stop);
return this;
}
- public StopModelBuilder withRegularStops(Collection stops) {
+ public SiteRepositoryBuilder withRegularStops(Collection stops) {
regularStopById.addAll(stops);
return this;
}
@@ -61,7 +61,7 @@ public ImmutableEntityById stationById() {
return stationById;
}
- public StopModelBuilder withStation(Station station) {
+ public SiteRepositoryBuilder withStation(Station station) {
stationById.add(station);
return this;
}
@@ -70,7 +70,7 @@ public Station computeStationIfAbsent(FeedScopedId id, Function stations) {
+ public SiteRepositoryBuilder withStations(Collection stations) {
stationById.addAll(stations);
return this;
}
@@ -79,7 +79,7 @@ public ImmutableEntityById multiModalStationById() {
return multiModalStationById;
}
- public StopModelBuilder withMultiModalStation(MultiModalStation station) {
+ public SiteRepositoryBuilder withMultiModalStation(MultiModalStation station) {
multiModalStationById.add(station);
return this;
}
@@ -88,7 +88,7 @@ public ImmutableEntityById groupOfStationById() {
return groupOfStationById;
}
- public StopModelBuilder withGroupOfStation(GroupOfStations station) {
+ public SiteRepositoryBuilder withGroupOfStation(GroupOfStations station) {
groupOfStationById.add(station);
return this;
}
@@ -101,12 +101,12 @@ public ImmutableEntityById areaStopById() {
return areaStopById;
}
- public StopModelBuilder withAreaStop(AreaStop stop) {
+ public SiteRepositoryBuilder withAreaStop(AreaStop stop) {
areaStopById.add(stop);
return this;
}
- public StopModelBuilder withAreaStops(Collection stops) {
+ public SiteRepositoryBuilder withAreaStops(Collection stops) {
areaStopById.addAll(stops);
return this;
}
@@ -119,21 +119,21 @@ public ImmutableEntityById groupStopById() {
return groupStopById;
}
- public StopModelBuilder withGroupStop(GroupStop group) {
+ public SiteRepositoryBuilder withGroupStop(GroupStop group) {
groupStopById.add(group);
return this;
}
- public StopModelBuilder withGroupStops(Collection groups) {
+ public SiteRepositoryBuilder withGroupStops(Collection groups) {
groupStopById.addAll(groups);
return this;
}
/**
- * Add the content of another stop model. There are no collision check, entities in the given
+ * Add the content of another site repository. There are no collision check, entities in the given
* {@code other} model, will replace existing entities.
*/
- public StopModelBuilder addAll(StopModel other) {
+ public SiteRepositoryBuilder addAll(SiteRepository other) {
regularStopById.addAll(other.listRegularStops());
stationById.addAll(other.listStations());
multiModalStationById.addAll(other.listMultiModalStations());
@@ -143,8 +143,8 @@ public StopModelBuilder addAll(StopModel other) {
return this;
}
- public StopModel build() {
- return new StopModel(this);
+ public SiteRepository build() {
+ return new SiteRepository(this);
}
AtomicInteger stopIndexCounter() {
diff --git a/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java b/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java
index c12c6f715f7..48048101b3d 100644
--- a/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java
+++ b/application/src/main/java/org/opentripplanner/transit/service/StopModelIndex.java
@@ -24,9 +24,9 @@
* For performance reasons these indexes are not part of the serialized state of the graph.
* They are rebuilt at runtime after graph deserialization.
*/
-class StopModelIndex {
+class SiteRepositoryIndex {
- private static final Logger LOG = LoggerFactory.getLogger(StopModelIndex.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SiteRepositoryIndex.class);
private final HashGridSpatialIndex regularStopSpatialIndex = new HashGridSpatialIndex<>();
private final Map multiModalStationForStations = new HashMap<>();
@@ -36,7 +36,7 @@ class StopModelIndex {
/**
* @param stops All stops including regular transit and flex
*/
- StopModelIndex(
+ SiteRepositoryIndex(
Collection stops,
Collection flexStops,
Collection groupStops,
diff --git a/application/src/main/java/org/opentripplanner/transit/service/TransitModel.java b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java
similarity index 86%
rename from application/src/main/java/org/opentripplanner/transit/service/TransitModel.java
rename to application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java
index 91c5ba8e5d9..798da10a7c6 100644
--- a/application/src/main/java/org/opentripplanner/transit/service/TransitModel.java
+++ b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepository.java
@@ -20,6 +20,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.opentripplanner.ext.flex.trip.FlexTrip;
import org.opentripplanner.framework.lang.ObjectUtils;
@@ -44,9 +45,12 @@
import org.opentripplanner.transit.model.framework.AbstractTransitEntity;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.FeedScopedId;
+import org.opentripplanner.transit.model.network.CarAccess;
import org.opentripplanner.transit.model.network.TripPattern;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.organization.Operator;
+import org.opentripplanner.transit.model.site.GroupStop;
+import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.model.site.StopLocation;
import org.opentripplanner.transit.model.timetable.TripOnServiceDate;
import org.opentripplanner.updater.GraphUpdaterManager;
@@ -55,32 +59,32 @@
import org.slf4j.LoggerFactory;
/**
- * The TransitModel groups together all instances making up OTP's primary internal representation
+ * The TimetableRepository groups together all instances making up OTP's primary internal representation
* of the public transportation network. Although the names of many entities are derived from
* GTFS concepts, these are actually independent of the data source from which they are loaded.
* Both GTFS and NeTEx entities are mapped to these same internal OTP entities. If a concept exists
* in both GTFS and NeTEx, the GTFS name is used in the internal model. For concepts that exist
* only in NeTEx, the NeTEx name is used in the internal model.
*
- * A TransitModel instance also includes references to some transient indexes of its contents, to
+ * A TimetableRepository instance also includes references to some transient indexes of its contents, to
* the TransitLayer derived from it, and to some other services and utilities that operate upon
* its contents.
*
- * The TransitModel stands in opposition to two other aggregates: the Graph (representing the
- * street network) and the TransitLayer (representing many of the same things in the TransitModel
+ * The TimetableRepository stands in opposition to two other aggregates: the Graph (representing the
+ * street network) and the TransitLayer (representing many of the same things in the TimetableRepository
* but rearranged to be more efficient for Raptor routing).
*
- * At this point the TransitModel is not often read directly. Many requests will look at the
- * TransitLayer rather than the TransitModel it's derived from. Both are often accessed via the
- * TransitService rather than directly reading the fields of TransitModel or TransitLayer.
+ * At this point the TimetableRepository is not often read directly. Many requests will look at the
+ * TransitLayer rather than the TimetableRepository it's derived from. Both are often accessed via the
+ * TransitService rather than directly reading the fields of TimetableRepository or TransitLayer.
*
* TODO RT_AB: consider renaming. By some definitions this is not really the model, but a top-level
* object grouping together instances of model classes with things that operate on and map those
* instances.
*/
-public class TransitModel implements Serializable {
+public class TimetableRepository implements Serializable {
- private static final Logger LOG = LoggerFactory.getLogger(TransitModel.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TimetableRepository.class);
private final Collection agencies = new ArrayList<>();
private final Collection operators = new ArrayList<>();
@@ -96,27 +100,27 @@ public class TransitModel implements Serializable {
private final Multimap transfersByStop = HashMultimap.create();
- private StopModel stopModel;
+ private SiteRepository siteRepository;
private ZonedDateTime transitServiceStarts = LocalDate.MAX.atStartOfDay(ZoneId.systemDefault());
private ZonedDateTime transitServiceEnds = LocalDate.MIN.atStartOfDay(ZoneId.systemDefault());
/**
- * The TransitLayer representation (optimized and rearranged for Raptor) of this TransitModel's
+ * The TransitLayer representation (optimized and rearranged for Raptor) of this TimetableRepository's
* scheduled (non-realtime) contents.
*/
private transient TransitLayer transitLayer;
/**
* This updater applies realtime changes queued up for the next TimetableSnapshot such that
- * this TransitModel.realtimeSnapshot remains aligned with the service represented in
- * (this TransitModel instance + that next TimetableSnapshot). This is a way of keeping the
+ * this TimetableRepository.realtimeSnapshot remains aligned with the service represented in
+ * (this TimetableRepository instance + that next TimetableSnapshot). This is a way of keeping the
* TransitLayer up to date without repeatedly deriving it from scratch every few seconds. The
* same incremental changes are applied to both sets of data and they are published together.
*/
private transient TransitLayerUpdater transitLayerUpdater;
/**
- * An optionally present second TransitLayer representing the contents of this TransitModel plus
+ * An optionally present second TransitLayer representing the contents of this TimetableRepository plus
* the results of realtime updates in the latest TimetableSnapshot.
*/
private final transient ConcurrentPublished realtimeTransitLayer = new ConcurrentPublished<>();
@@ -125,7 +129,7 @@ public class TransitModel implements Serializable {
private final CalendarServiceData calendarServiceData = new CalendarServiceData();
- private transient TransitModelIndex index;
+ private transient TimetableRepositoryIndex index;
private transient TimetableSnapshotProvider timetableSnapshotProvider = null;
private ZoneId timeZone = null;
private boolean timeZoneExplicitlySet = false;
@@ -145,14 +149,14 @@ public class TransitModel implements Serializable {
private transient TransitAlertService transitAlertService;
@Inject
- public TransitModel(StopModel stopModel, Deduplicator deduplicator) {
- this.stopModel = Objects.requireNonNull(stopModel);
+ public TimetableRepository(SiteRepository siteRepository, Deduplicator deduplicator) {
+ this.siteRepository = Objects.requireNonNull(siteRepository);
this.deduplicator = deduplicator;
}
/** No-argument constructor, required for deserialization. */
- public TransitModel() {
- this(new StopModel(), new Deduplicator());
+ public TimetableRepository() {
+ this(new SiteRepository(), new Deduplicator());
}
/**
@@ -163,8 +167,8 @@ public TransitModel() {
public void index() {
if (index == null) {
LOG.info("Index transit model...");
- // the transit model indexing updates the stop model index (flex stops added to the stop index)
- this.index = new TransitModelIndex(this);
+ // the transit model indexing updates the site repository index (flex stops added to the stop index)
+ this.index = new TimetableRepositoryIndex(this);
LOG.info("Index transit model complete.");
}
}
@@ -430,8 +434,8 @@ public Collection getTransfersByStop(StopLocation stop) {
return transfersByStop.get(stop);
}
- public StopModel getStopModel() {
- return stopModel;
+ public SiteRepository getSiteRepository() {
+ return siteRepository;
}
public void addTripPattern(FeedScopedId id, TripPattern tripPattern) {
@@ -499,11 +503,11 @@ public void setTransitLayerUpdater(TransitLayerUpdater transitLayerUpdater) {
}
/**
- * Updating the stop model is only allowed during graph build
+ * Updating the site repository is only allowed during graph build
*/
- public void mergeStopModels(StopModel childStopModel) {
+ public void mergeSiteRepositories(SiteRepository childSiteRepository) {
invalidateIndex();
- this.stopModel = this.stopModel.merge(childStopModel);
+ this.siteRepository = this.siteRepository.merge(childSiteRepository);
}
public void addFlexTrip(FeedScopedId id, FlexTrip, ?> flexTrip) {
@@ -548,7 +552,7 @@ public void setHasScheduledService(boolean hasScheduledService) {
* possibility that the index is not initialized (during graph build).
*/
@Nullable
- TransitModelIndex getTransitModelIndex() {
+ TimetableRepositoryIndex getTimetableRepositoryIndex() {
return index;
}
@@ -564,6 +568,36 @@ public FlexTrip getFlexTrip(FeedScopedId tripId) {
return flexTripsById.get(tripId);
}
+ /**
+ * The stops that are used by transit capable of transporting cars need to be
+ * connected to the road network (e.g. car ferries). This method returns the
+ * stops that are used by trips that allow cars.
+ * @return set of stop locations that are used for trips that allow cars
+ */
+ public Set getStopLocationsUsedForCarsAllowedTrips() {
+ Set stopLocations = getAllTripPatterns()
+ .stream()
+ .filter(t ->
+ t
+ .getScheduledTimetable()
+ .getTripTimes()
+ .stream()
+ .anyMatch(tt -> tt.getTrip().getCarsAllowed() == CarAccess.ALLOWED)
+ )
+ .flatMap(t -> t.getStops().stream())
+ .collect(Collectors.toSet());
+
+ stopLocations.addAll(
+ stopLocations
+ .stream()
+ .filter(GroupStop.class::isInstance)
+ .map(GroupStop.class::cast)
+ .flatMap(g -> g.getChildLocations().stream().filter(RegularStop.class::isInstance))
+ .toList()
+ );
+ return stopLocations;
+ }
+
private void invalidateIndex() {
this.index = null;
}
diff --git a/application/src/main/java/org/opentripplanner/transit/service/TransitModelIndex.java b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java
similarity index 90%
rename from application/src/main/java/org/opentripplanner/transit/service/TransitModelIndex.java
rename to application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java
index 7f44854eb9a..dc618b0943f 100644
--- a/application/src/main/java/org/opentripplanner/transit/service/TransitModelIndex.java
+++ b/application/src/main/java/org/opentripplanner/transit/service/TimetableRepositoryIndex.java
@@ -35,9 +35,9 @@
* For performance reasons these indexes are not part of the serialized state of the graph.
* They are rebuilt at runtime after graph deserialization.
*/
-class TransitModelIndex {
+class TimetableRepositoryIndex {
- private static final Logger LOG = LoggerFactory.getLogger(TransitModelIndex.class);
+ private static final Logger LOG = LoggerFactory.getLogger(TimetableRepositoryIndex.class);
// TODO: consistently key on model object or id string
private final Map