Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into coach_gtfs_import
Browse files Browse the repository at this point in the history
# Conflicts:
#	application/src/test/java/org/opentripplanner/gtfs/mapping/TransitModeMapperTest.java
  • Loading branch information
miklcct committed Oct 29, 2024
2 parents 5cee140 + 8f5af3a commit 44c94d1
Show file tree
Hide file tree
Showing 214 changed files with 2,249 additions and 2,438 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,23 @@ jobs:
- name: Run speed test
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
working-directory: application
env:
PERFORMANCE_INFLUX_DB_PASSWORD: ${{ secrets.PERFORMANCE_INFLUX_DB_PASSWORD }}
SPEEDTEST_LOCATION: ${{ matrix.location }}
MAVEN_OPTS: "-Xmx50g -XX:StartFlightRecording=delay=${{ matrix.jfr-delay }},duration=30m,filename=${{ matrix.location}}-speed-test.jfr -Dmaven.repo.local=/home/lenni/.m2/repository/"
run: |
mvn exec:java -Dexec.mainClass="org.opentripplanner.transit.speed_test.SpeedTest" -Dexec.classpathScope=test -Dexec.args="--dir=../test/performance/${{ matrix.location }} -p md -n ${{ matrix.iterations }} -i 3 -0" -P prettierSkip
mvn exec:java -Dexec.mainClass="org.opentripplanner.transit.speed_test.SpeedTest" -Dexec.classpathScope=test -Dexec.args="--dir=test/performance/${{ matrix.location }} -p md -n ${{ matrix.iterations }} -i 3 -0" -P prettierSkip -pl application -am
- name: Archive travel results file
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.location }}-travelSearch-results.csv
path: test/performance/${{ matrix.location }}/travelSearch-results.csv
path: test/performance/${{ matrix.location }}/travelSearch-results-md.csv

- name: Archive Flight Recorder instrumentation file
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.location }}-flight-recorder
path: ${{ matrix.location}}-speed-test.jfr
path: application/${{ matrix.location }}-speed-test.jfr
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ o_o_standalone_config_IncludeFileDirectiveTest_part.json
.venv/
_site/
build/
!/application/src/build/
dist/
doc/user/_build/
gen-java/
Expand Down
30 changes: 15 additions & 15 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ examples. The Transit model is more complex than the VehiclePosition model.
Below is a list of documented components in OTP. Not every component is documented at a high level,
but this is a start and we would like to expand this list in the future.

### [OTP Configuration design](src/main/java/org/opentripplanner/standalone/config/package.md)
### [OTP Configuration design](application/src/main/java/org/opentripplanner/standalone/config/package.md)

The Configuration module is responsible for loading and parsing OTP configuration files and map them
into Plan Old Java Objects (POJOs). These POJOs are injected into the other components.

### [GTFS import module](src/main/java/org/opentripplanner/gtfs/package.md)
### [GTFS import module](application/src/main/java/org/opentripplanner/gtfs/package.md)

Used to import GTFS transit data files.

### [NeTEx import module](src/main/java/org/opentripplanner/netex/package.md)
### [NeTEx import module](application/src/main/java/org/opentripplanner/netex/package.md)

Used to import NeTEx transit data files.

### Transit Routing

#### [Raptor transit routing](src/main/java/org/opentripplanner/raptor/package.md)
#### [Raptor transit routing](application/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 @@ -68,35 +68,35 @@ dependencies from Raptor to other parts of OTP code, only to utility classes not
Also, the code follows a stricter object-oriented design, than most other parts of OTP. The Raptor
implementation is highly critical code, hence we set the bar higher with respect to code quality.

OTP provides transit data to Raptor by implementing the _raptor/api/transit_ model. The
[RoutingService](src/main/java/org/opentripplanner/routing/RoutingService.java)
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](src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java)
[RaptorRequest](application/src/main/java/org/opentripplanner/raptor/api/request/RaptorRequest.java)
and then map the
result, [Raptor Path](src/main/java/org/opentripplanner/raptor/api/path/Path.java), back to
result, [Raptor Path](application/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.

The performance of Raptor is important, and we care about every millisecond. All changes to the
existing Raptor coded should be tested with the
[SpeedTest](src/test/java/org/opentripplanner/transit/raptor/speed_test/package.md) and compared
[SpeedTest](application/src/test/java/org/opentripplanner/transit/speed_test/package.md) and compared
with an earlier version of the code to make sure the performance is NOT degraded.

#### [Transfer path optimization](src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package.md)
#### [Transfer path optimization](application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/package.md)

Describes the transfer functionality, the design and the implementation. The logic for finding the
best transfer is distributed to the Raptor and
the [OptimizeTransferService](src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/OptimizeTransferService.java)
the [OptimizeTransferService](application/src/main/java/org/opentripplanner/routing/algorithm/transferoptimization/OptimizeTransferService.java)
.

#### [Itinerary list filter chain](src/main/java/org/opentripplanner/routing/algorithm/filterchain/package.md)
#### [Itinerary list filter chain](application/src/main/java/org/opentripplanner/routing/algorithm/filterchain/package.md)

Describes the itinerary list filter chain, used to post-process the itineraries returned from the
routers in [RoutingWorker](src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java),
routers in [RoutingWorker](application/src/main/java/org/opentripplanner/routing/algorithm/RoutingWorker.java),
in order to sort and reduce the number of returned itineraries. It can also be used to decorate the
returned itineraries, especially if it requires more complex calculations, which would be unfeasible
to do during the routing process.

### [Service](src/main/java/org/opentripplanner/service/package.md)
### [Service](application/src/main/java/org/opentripplanner/service/package.md)
The service package contains small services usually specific to one or a few use-cases. In contrast
to a domain model they may use one or many domain models and other services.
to a domain model they may use one or many domain models and other services.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@ We run a speed test (included in the code) to measure the performance for every

## Repository layout

The main Java server code is in `src/main/`. OTP also includes a Javascript client based on the
Leaflet mapping library in `src/client/`. This client is now primarily used for testing, with most
major deployments building custom clients from reusable components. The Maven build produces a
unified ("shaded") JAR file at `target/otp-VERSION.jar` containing all necessary code and
dependencies to run OpenTripPlanner.
The main Java server code is in `application/src/main/`. OTP also includes a Javascript client based on the
MapLibre mapping library in `client/src/`. This client is now used for testing, with most major
deployments building custom clients from reusable components. The Maven build produces a unified ("shaded")
JAR file at `application/target/otp-VERSION.jar` containing all necessary code and dependencies to run OpenTripPlanner.

Additional information and instructions are available in
the [main documentation](http://docs.opentripplanner.org/en/dev-2.x/), including a
Expand Down
31 changes: 31 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<name>OpenTripPlanner - Application</name>

<dependencies>
<!-- project dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>gtfs-realtime-protobuf</artifactId>
<version>${project.version}</version>
</dependency>

<!-- 3rd party dependencies -->
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
Expand Down Expand Up @@ -513,6 +521,29 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.bohnman</groupId>
<artifactId>package-info-maven-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<!-- Couldn't get this to work for main and ext code at the same time. -->
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<outputDirectory>${project.basedir}/target/generated-sources</outputDirectory>
<packages>
<package>
<pattern>**</pattern>
<template>${project.basedir}/src/build/templates/package-info-template.java</template>
</package>
</packages>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4 changes: 4 additions & 0 deletions application/src/build/templates/package-info-template.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@ParametersAreNonnullByDefault
package org.opentripplanner;

import javax.annotation.ParametersAreNonnullByDefault;
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/10/2024-10-17T07:45/assets/index-CZI6LO02.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-17T07:45/assets/index-BqgnKsMX.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-17T19:27/assets/index-czfEIRbh.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-17T19:27/assets/index-BqgnKsMX.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

public class AtlantaFareServiceTest implements PlanTestConstants {

Expand Down Expand Up @@ -262,20 +262,20 @@ private static Leg createLeg(String agencyId, String shortName, long startTimeMi
}

private static Itinerary createItinerary(String agencyId, String shortName, long startTimeMins) {
var stopModelBuilder = StopModel.of();
var siteRepositoryBuilder = SiteRepository.of();
Agency agency = Agency
.of(new FeedScopedId(FEED_ID, agencyId))
.withName(agencyId)
.withTimezone(ZoneIds.NEW_YORK.getId())
.build();

// Set up stops
RegularStop firstStop = stopModelBuilder
RegularStop firstStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(FEED_ID, "1"))
.withCoordinate(new WgsCoordinate(1, 1))
.withName(new NonLocalizedString("first stop"))
.build();
RegularStop lastStop = stopModelBuilder
RegularStop lastStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(FEED_ID, "2"))
.withCoordinate(new WgsCoordinate(1, 2))
.withName(new NonLocalizedString("last stop"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.site.FareZone;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.StopModelBuilder;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.SiteRepositoryBuilder;

public class FareModelForTest {

Expand All @@ -25,40 +25,40 @@ public class FareModelForTest {
.of(FeedScopedId.ofNullable("F2", "other-feed-zone"))
.build();

private static final StopModelBuilder STOP_MODEL_BUILDER = StopModel.of();
private static final SiteRepositoryBuilder SITE_REPOSITORY_BUILDER = SiteRepository.of();

static final RegularStop AIRPORT_STOP = STOP_MODEL_BUILDER
static final RegularStop AIRPORT_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("airport"))
.withCoordinate(new WgsCoordinate(1, 1))
.addFareZones(AIRPORT_ZONE)
.withName(I18NString.of("Airport"))
.build();

static final RegularStop CITY_CENTER_A_STOP = STOP_MODEL_BUILDER
static final RegularStop CITY_CENTER_A_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("city-center-a"))
.withCoordinate(new WgsCoordinate(1, 2))
.addFareZones(CITY_CENTER_ZONE)
.withName(I18NString.of("City center: stop A"))
.build();
static final RegularStop CITY_CENTER_B_STOP = STOP_MODEL_BUILDER
static final RegularStop CITY_CENTER_B_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("city-center-b"))
.withCoordinate(new WgsCoordinate(1, 3))
.addFareZones(CITY_CENTER_ZONE)
.withName(I18NString.of("City center: stop B"))
.build();
static final RegularStop CITY_CENTER_C_STOP = STOP_MODEL_BUILDER
static final RegularStop CITY_CENTER_C_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("city-center-c"))
.withCoordinate(new WgsCoordinate(1, 4))
.addFareZones(CITY_CENTER_ZONE)
.withName(I18NString.of("City center: stop C"))
.build();
static final RegularStop SUBURB_STOP = STOP_MODEL_BUILDER
static final RegularStop SUBURB_STOP = SITE_REPOSITORY_BUILDER
.regularStop(id("suburb"))
.withCoordinate(new WgsCoordinate(1, 4))
.withName(I18NString.of("Suburb"))
.build();

static final RegularStop OTHER_FEED_STOP = STOP_MODEL_BUILDER
static final RegularStop OTHER_FEED_STOP = SITE_REPOSITORY_BUILDER
.regularStop(FeedScopedId.ofNullable("F2", "other-feed-stop"))
.withCoordinate(new WgsCoordinate(1, 5))
.withName(I18NString.of("Other feed stop"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.opentripplanner.transit.model.network.Route;
import org.opentripplanner.transit.model.organization.Agency;
import org.opentripplanner.transit.model.site.RegularStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

public class OrcaFareServiceTest {

Expand Down Expand Up @@ -662,15 +662,15 @@ private static Itinerary createItinerary(
.withTimezone(ZoneIds.NEW_YORK.getId())
.build();

var stopModelBuilder = StopModel.of();
var siteRepositoryBuilder = SiteRepository.of();

// Set up stops
RegularStop firstStop = stopModelBuilder
RegularStop firstStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(agencyId, "1"))
.withCoordinate(new WgsCoordinate(1, 1))
.withName(new NonLocalizedString(firstStopName))
.build();
RegularStop lastStop = stopModelBuilder
RegularStop lastStop = siteRepositoryBuilder
.regularStop(new FeedScopedId(agencyId, "2"))
.withCoordinate(new WgsCoordinate(1, 2))
.withName(new NonLocalizedString(lastStopName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.site.AreaStop;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

class AreaStopsToVerticesMapperTest {
Expand All @@ -33,13 +33,13 @@ class AreaStopsToVerticesMapperTest {
.areaStop("berlin")
.withGeometry(Polygons.BERLIN)
.build();
public static final StopModel STOP_MODEL = TEST_MODEL
.stopModelBuilder()
public static final SiteRepository SITE_REPOSITORY = TEST_MODEL
.siteRepositoryBuilder()
.withAreaStop(AreaStopsToVerticesMapperTest.BERLIN_AREA_STOP)
.build();

public static final TimetableRepository TRANSIT_MODEL = new TimetableRepository(
STOP_MODEL,
SITE_REPOSITORY,
new Deduplicator()
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static void addGtfsToGraph(
.buildGraph();

timetableRepository.index();
graph.index(timetableRepository.getStopModel());
graph.index(timetableRepository.getSiteRepository());
}

private Itinerary getItinerary(GenericLocation from, GenericLocation to, int index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.test.support.ResourceLoader;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;
import org.opentripplanner.transit.service.TimetableRepository;

public final class FlexIntegrationTestData {
Expand Down Expand Up @@ -43,7 +43,7 @@ public static TestOtpModel cobbOsm() {
private static TestOtpModel buildFlexGraph(File file) {
var deduplicator = new Deduplicator();
var graph = new Graph(deduplicator);
var timetableRepository = new TimetableRepository(new StopModel(), deduplicator);
var timetableRepository = new TimetableRepository(new SiteRepository(), deduplicator);
GtfsBundle gtfsBundle = new GtfsBundle(file);
GtfsModule module = new GtfsModule(
List.of(gtfsBundle),
Expand All @@ -54,7 +54,7 @@ private static TestOtpModel buildFlexGraph(File file) {
OTPFeature.enableFeatures(Map.of(OTPFeature.FlexRouting, true));
module.buildGraph();
timetableRepository.index();
graph.index(timetableRepository.getStopModel());
graph.index(timetableRepository.getSiteRepository());
OTPFeature.enableFeatures(Map.of(OTPFeature.FlexRouting, false));
assertTrue(timetableRepository.hasFlexTrips());
return new TestOtpModel(graph, timetableRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.opentripplanner.model.StopTime;
import org.opentripplanner.model.impl.OtpTransitServiceBuilder;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.service.StopModel;
import org.opentripplanner.transit.service.SiteRepository;

class FlexTripsMapperTest {

@Test
void defaultTimePenalty() {
var builder = new OtpTransitServiceBuilder(StopModel.of().build(), NOOP);
var builder = new OtpTransitServiceBuilder(SiteRepository.of().build(), NOOP);
var stopTimes = List.of(stopTime(0), stopTime(1));
builder.getStopTimesSortedByTrip().addAll(stopTimes);
var trips = FlexTripsMapper.createFlexTrips(builder, NOOP);
Expand Down
Loading

0 comments on commit 44c94d1

Please sign in to comment.