Skip to content

Commit

Permalink
Merge branch 'dev-2.x' into fix-departureArrivalStopTime-npe
Browse files Browse the repository at this point in the history
# Conflicts:
#	application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/TripImpl.java
#	application/src/main/java/org/opentripplanner/apis/transmodel/model/timetable/ServiceJourneyType.java
#	application/src/main/java/org/opentripplanner/routing/TripTimeOnDateHelper.java
#	application/src/main/java/org/opentripplanner/transit/service/TransitService.java
  • Loading branch information
miklcct committed Dec 4, 2024
2 parents 4b50129 + 2050217 commit 512f30b
Show file tree
Hide file tree
Showing 240 changed files with 3,770 additions and 5,309 deletions.
6 changes: 3 additions & 3 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Used to import NeTEx transit data files.

### Transit Routing

#### [Raptor transit routing](application/src/main/java/org/opentripplanner/raptor/package.md)
#### [Raptor transit routing](raptor/src/main/java/org/opentripplanner/raptor/package.md)

This is the OTP2 new transit routing engine implemented using the Raptor algorithm. It explains how
Raptor works, the important concepts and the design. It might be worth reading even if you are not a
Expand All @@ -71,9 +71,9 @@ implementation is highly critical code, hence we set the bar higher with respect
OTP provides transit data to Raptor by implementing the _raptor/spi_. The
[RoutingService](application/src/main/java/org/opentripplanner/routing/service/DefaultRoutingService.java)
is responsible for mapping from the OTP context to a
[RaptorRequest](application/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java)
[RaptorRequest](raptor/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java)
and then map the
result, [Raptor Path](application/src/main/java/org/opentripplanner/raptor/api/path/RaptorPath.java), back to
result, [Raptor Path](raptor/src/main/java/org/opentripplanner/raptor/api/path/RaptorPath.java), back to
the OTP internal domain. This might seem like a lot of unnecessary mapping, but mapping is simple -
routing is not.

Expand Down
6 changes: 6 additions & 0 deletions DEVELOPMENT_DECISION_RECORDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Use established terminology from GTFS, NeTEx or the existing OTP code. Make sure
to read and understand. [Follow naming conventions](doc/dev/decisionrecords/NamingConventions.md#naming-conventions) .


## Do Analysis-and-design if needed

Be prepared to provide [analyses and/or design documentation](doc/dev/decisionrecords/AnalysesAndDesign.md)
if a task is complex, changes the core model and/or the main APIs.


## Write-Code-Documentation - Use JavaDoc

Document the business intention and decisions in the relevant code. Do not repeat the logic
Expand Down
81 changes: 3 additions & 78 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>otp-root</artifactId>
<version>2.7.0-SNAPSHOT</version>
</parent>
<artifactId>otp</artifactId>
<artifactId>application</artifactId>
<name>OpenTripPlanner - Application</name>

<dependencies>
Expand All @@ -20,12 +20,12 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>otp-utils</artifactId>
<artifactId>utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>otp-raptor</artifactId>
<artifactId>raptor</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down Expand Up @@ -456,81 +456,6 @@
</execution>
</executions>
</plugin>
<!--
There used to be a dependency-plugin:copy-dependencies plugin entry here, but the
shade-plugin will explode the dependencies even if they aren't manually copied in.
-->
<plugin>
<!-- We want to create a standalone jar that can be run on the command
line. Java does not really allow this - you cannot place jars inside of jars.
You must either provide all the dependency jars to the user (usually lib/
under the directory containing the runnable jar) or explode all the jars
and repackage them into a single jar. The problem is that while class files
are nicely organized into the package namespace and should not collide, the
META-INF directories of the jars will collide. Maven's standard assembly
plugin does not account for this and will just clobber metadata. This then
causes runtime errors, particularly with Spring. Instead, we use the shade
plugin which has transformers that will for example append files of the same
name rather than overwrite them in the combined JAR. NB: Don't use a version
of the shade plugin older than 1.3.2, as it fixed MSHADE-76 (files not merged
properly if some input files are missing a terminating newline) -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<!-- exclude signatures from merged JAR to avoid invalid signature messages -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<!-- The shaded JAR will not be the main artifact for the project, it will be attached
for deployment in the way source and docs are. -->
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>shaded</shadedClassifierName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<!-- MinimizeJar removes unused classes, (classes not imported explicitly by name).
We have eliminated most Jersey auto-scanning, but there is still some need for include
filters to force-include classes that are dynamically loaded by name/auto-scanned. -->
<!-- This roughly halves the size of the OTP JAR, bringing it down to around 20 MB.
<minimizeJar>true</minimizeJar>
<filters> <filter> <artifact>com.sun.jersey:*</artifact> <includes> <include>**</include>
</includes> </filter> <filter> <artifact>org.opentripplanner:*</artifact>
<includes> <include>**</include> </includes> </filter> </filters> -->
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.opentripplanner.standalone.OTPMain</Main-Class>
<!-- The ImageIO lines allow some image reader plugins to work
https://stackoverflow.com/questions/7051603/jai-vendorname-null#18495658 -->
<Specification-Title>Java Advanced Imaging Image I/O
Tools
</Specification-Title>
<Specification-Version>1.1</Specification-Version>
<Specification-Vendor>Sun Microsystems, Inc.</Specification-Vendor>
<Implementation-Title>com.sun.media.imageio</Implementation-Title>
<Implementation-Version>1.1</Implementation-Version>
<Implementation-Vendor>Sun Microsystems, Inc.</Implementation-Vendor>
<Extension-Name>com.sun.media.imageio</Extension-Name>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.bohnman</groupId>
<artifactId>package-info-maven-plugin</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions application/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug Client</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-22T08:29/assets/index-CwmtYnAr.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-22T08:29/assets/index-CaBThmWm.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/12/2024-12-04T08:22/assets/index-D5kxjVzr.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/12/2024-12-04T08:22/assets/index-CaBThmWm.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static void setup() {
.build();

@Override
public List<TransitMode> getModesOfStopLocation(StopLocation stop) {
public List<TransitMode> findTransitModes(StopLocation stop) {
if (stop.getVehicleType() != null) {
return List.of(stop.getVehicleType());
} else {
Expand All @@ -144,15 +144,15 @@ public List<TransitMode> getModesOfStopLocation(StopLocation stop) {
}

@Override
public Agency getAgencyForId(FeedScopedId id) {
public Agency getAgency(FeedScopedId id) {
if (id.equals(BVG.getId())) {
return BVG;
}
return null;
}

@Override
public Set<Route> getRoutesForStop(StopLocation stop) {
public Set<Route> findRoutes(StopLocation stop) {
return Set.of(TimetableRepositoryForTest.route("route1").withAgency(BVG).build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public TestTransitService(TimetableRepository timetableRepository) {
}

@Override
public Set<Route> getRoutesForStop(StopLocation stop) {
public Set<Route> findRoutes(StopLocation stop) {
return Set.of(
TimetableRepositoryForTest.route("1").withMode(TransitMode.RAIL).withGtfsType(100).build()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
import org.opentripplanner.framework.i18n.TranslatedString;
import org.opentripplanner.inspector.vector.KeyValue;
import org.opentripplanner.inspector.vector.LayerParameters;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingGroup;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingRepository;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingGroup;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.standalone.config.routerconfig.VectorTileConfig;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand Down Expand Up @@ -90,9 +91,8 @@ public void setUp() {

@Test
public void vehicleParkingGroupGeometryTest() {
Graph graph = new Graph();
VehicleParkingService service = graph.getVehicleParkingService();
service.updateVehicleParking(List.of(vehicleParking), List.of());
var repository = new DefaultVehicleParkingRepository();
repository.updateVehicleParking(List.of(vehicleParking), List.of());

var config =
"""
Expand All @@ -116,7 +116,7 @@ public void vehicleParkingGroupGeometryTest() {
var tiles = VectorTileConfig.mapVectorTilesParameters(nodeAdapter, "vectorTiles");
assertEquals(1, tiles.layers().size());
var builder = new VehicleParkingGroupsLayerBuilderWithPublicGeometry(
graph,
new DefaultVehicleParkingService(repository),
tiles.layers().get(0),
Locale.US
);
Expand Down Expand Up @@ -171,11 +171,11 @@ private static class VehicleParkingGroupsLayerBuilderWithPublicGeometry
extends VehicleParkingGroupsLayerBuilder {

public VehicleParkingGroupsLayerBuilderWithPublicGeometry(
Graph graph,
VehicleParkingService service,
LayerParameters<VectorTilesResource.LayerType> layerParameters,
Locale locale
) {
super(graph, layerParameters, locale);
super(service, layerParameters, locale);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.opentripplanner.framework.geometry.WgsCoordinate;
import org.opentripplanner.framework.i18n.TranslatedString;
import org.opentripplanner.model.calendar.openinghours.OpeningHoursCalendarService;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingSpaces;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingRepository;
import org.opentripplanner.service.vehicleparking.internal.DefaultVehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingSpaces;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.standalone.config.routerconfig.VectorTileConfig;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
Expand Down Expand Up @@ -86,9 +86,8 @@ public void setUp() {

@Test
public void vehicleParkingGeometryTest() {
Graph graph = new Graph();
VehicleParkingService service = graph.getVehicleParkingService();
service.updateVehicleParking(List.of(vehicleParking), List.of());
var repo = new DefaultVehicleParkingRepository();
repo.updateVehicleParking(List.of(vehicleParking), List.of());

var config =
"""
Expand All @@ -111,7 +110,7 @@ public void vehicleParkingGeometryTest() {
var nodeAdapter = newNodeAdapterForTest(config);
var tiles = VectorTileConfig.mapVectorTilesParameters(nodeAdapter, "vectorTiles");
assertEquals(1, tiles.layers().size());
var builder = new VehicleParkingsLayerBuilder(graph, tiles.layers().getFirst(), Locale.US);
var builder = new VehicleParkingsLayerBuilder(new DefaultVehicleParkingService(repo), tiles.layers().getFirst(), Locale.US);

List<Geometry> geometries = builder.getGeometries(new Envelope(0.99, 1.01, 1.99, 2.01));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.time.Duration;
import java.util.Locale;
import org.junit.jupiter.api.Test;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.transit.model.basic.Locales;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.opentripplanner._support.time.ZoneIds;
import org.opentripplanner.model.calendar.openinghours.OpeningHoursCalendarService;
import org.opentripplanner.model.calendar.openinghours.OsmOpeningHoursSupport;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingState;
import org.opentripplanner.service.vehicleparking.model.VehicleParkingState;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.transit.model.framework.Deduplicator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public TransitStopVertex getStopVertexForStopId(FeedScopedId stopId) {

@Override
public Collection<PathTransfer> getTransfersFromStop(StopLocation stop) {
return transitService.getTransfersByStop(stop);
return transitService.findPathTransfers(stop);
}

@Override
Expand All @@ -207,7 +207,7 @@ public Collection<PathTransfer> getTransfersToStop(StopLocation stop) {

@Override
public boolean isDateActive(FlexServiceDate date, FlexTrip<?, ?> trip) {
int serviceCode = transitService.getServiceCodeForId(trip.getTrip().getServiceId());
int serviceCode = transitService.getServiceCode(trip.getTrip().getServiceId());
return date.isTripServiceRunning(serviceCode);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private static Optional<LuceneStopCluster> map(List<StopLocation> stopLocations)
}

private List<Agency> agenciesForStopLocation(StopLocation stop) {
return transitService.getRoutesForStop(stop).stream().map(Route::getAgency).distinct().toList();
return transitService.findRoutes(stop).stream().map(Route::getAgency).distinct().toList();
}

private List<Agency> agenciesForStopLocationsGroup(StopLocationsGroup group) {
Expand All @@ -190,7 +190,7 @@ StopCluster.Location toLocation(FeedScopedId id) {
var loc = transitService.getStopLocation(id);
if (loc != null) {
var feedPublisher = toFeedPublisher(transitService.getFeedInfo(id.getFeedId()));
var modes = transitService.getModesOfStopLocation(loc).stream().map(Enum::name).toList();
var modes = transitService.findTransitModes(loc).stream().map(Enum::name).toList();
var agencies = agenciesForStopLocation(loc)
.stream()
.map(StopClusterMapper::toAgency)
Expand All @@ -209,7 +209,7 @@ StopCluster.Location toLocation(FeedScopedId id) {
var group = transitService.getStopLocationsGroup(id);
var feedPublisher = toFeedPublisher(transitService.getFeedInfo(id.getFeedId()));
var modes = transitService
.getModesOfStopLocationsGroup(group)
.findTransitModes(group)
.stream()
.map(Enum::name)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.routing.graphfinder.DirectGraphFinder;
import org.opentripplanner.routing.graphfinder.GraphFinder;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.VehicleParkingService;
import org.opentripplanner.service.vehicleparking.model.VehicleParking;
import org.opentripplanner.standalone.api.OtpServerRequestContext;

/**
Expand All @@ -36,7 +36,7 @@ public ParkAndRideResource(
*/
@Deprecated @PathParam("ignoreRouterId") String ignoreRouterId
) {
this.vehicleParkingService = serverContext.graph().getVehicleParkingService();
this.vehicleParkingService = serverContext.vehicleParkingService();

// TODO OTP2 - Why are we using the DirectGraphFinder here, not just
// - serverContext.graphFinder(). This needs at least a comment!
Expand Down Expand Up @@ -73,7 +73,8 @@ public Response getParkAndRide(
}

var prs = vehicleParkingService
.getCarParks()
.listCarParks()
.stream()
.filter(lot -> envelope.contains(lot.getCoordinate().asJtsCoordinate()))
.filter(lot -> hasTransitStopsNearby(maxTransitDistance, lot))
.map(ParkAndRideInfo::ofVehicleParking)
Expand Down
Loading

0 comments on commit 512f30b

Please sign in to comment.