Skip to content

Commit

Permalink
Merge branch 'dev-2.x' into graphql-previousLegs
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Oct 22, 2024
2 parents 1f0cceb + 559fac5 commit ccd001d
Show file tree
Hide file tree
Showing 403 changed files with 5,129 additions and 4,379 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

# reorder and reformat GTFS GraphQL API schema file with graphql-java
14051fab312a67cae9a460aaf0bbc77223bec624

# Make OTP a multi-module project
ead33ffe280dd7caf72cae5ff7a41542e8427636
4 changes: 2 additions & 2 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
if: github.event_name == 'pull_request'

- name: Install Python dependencies
run: pip install --break-system-packages -r doc/user/requirements.txt
run: pip install -r doc/user/requirements.txt


- name: Build main documentation
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 22
- name: Run code generator
working-directory: application/src/main/java/org/opentripplanner/apis/gtfs/generated
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ jobs:
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
25 changes: 24 additions & 1 deletion application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.13.0</version>
<version>5.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -513,6 +513,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-09T18:54/assets/index-C6b5LCY-.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-09T18:54/assets/index-BcsxnGE8.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 @@ -3,7 +3,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.opentripplanner.model.plan.Itinerary.createScheduledTransitItinerary;
import static org.opentripplanner.transit.model._data.TransitModelForTest.id;
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id;

import java.time.OffsetDateTime;
import java.time.ZonedDateTime;
Expand All @@ -21,7 +21,7 @@
import org.opentripplanner.model.plan.ScheduledTransitLegBuilder;
import org.opentripplanner.model.plan.StreetLeg;
import org.opentripplanner.street.search.TraverseMode;
import org.opentripplanner.transit.model._data.TransitModelForTest;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.basic.TransitMode;
import org.opentripplanner.transit.model.framework.Deduplicator;
import org.opentripplanner.transit.model.framework.FeedScopedId;
Expand All @@ -46,9 +46,13 @@ class EmissionsTest {
.withEndTime(TIME.plusHours(1))
.build();

private static final Route ROUTE_WITH_EMISSIONS = TransitModelForTest.route(id("1")).build();
private static final Route ROUTE_WITH_ZERO_EMISSIONS = TransitModelForTest.route(id("2")).build();
private static final Route ROUTE_WITHOUT_EMISSIONS_CONFIGURED = TransitModelForTest
private static final Route ROUTE_WITH_EMISSIONS = TimetableRepositoryForTest
.route(id("1"))
.build();
private static final Route ROUTE_WITH_ZERO_EMISSIONS = TimetableRepositoryForTest
.route(id("2"))
.build();
private static final Route ROUTE_WITHOUT_EMISSIONS_CONFIGURED = TimetableRepositoryForTest
.route(id("3"))
.build();

Expand Down Expand Up @@ -119,12 +123,15 @@ private ScheduledTransitLeg createTransitLeg(Route route) {
var stoptime = new StopTime();
var stopTimes = new ArrayList<StopTime>();
stopTimes.add(stoptime);
var testModel = TransitModelForTest.of();
var testModel = TimetableRepositoryForTest.of();
var stopOne = testModel.stop("1:stop1", 60, 25).build();
var stopTwo = testModel.stop("1:stop1", 61, 25).build();
var stopThree = testModel.stop("1:stop1", 62, 25).build();
var stopPattern = TransitModelForTest.stopPattern(stopOne, stopTwo, stopThree);
var pattern = TransitModelForTest.tripPattern("1", route).withStopPattern(stopPattern).build();
var stopPattern = TimetableRepositoryForTest.stopPattern(stopOne, stopTwo, stopThree);
var pattern = TimetableRepositoryForTest
.tripPattern("1", route)
.withStopPattern(stopPattern)
.build();
var trip = Trip
.of(FeedScopedId.parse("FOO:BAR"))
.withMode(TransitMode.BUS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.opentripplanner.model.plan.TestItineraryBuilder.newItinerary;
import static org.opentripplanner.transit.model._data.TransitModelForTest.id;
import static org.opentripplanner.transit.model._data.TimetableRepositoryForTest.id;

import java.util.List;
import org.junit.jupiter.api.Test;
Expand All @@ -13,12 +13,12 @@
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.PlanTestConstants;
import org.opentripplanner.routing.fares.FareService;
import org.opentripplanner.transit.model._data.TransitModelForTest;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.basic.Money;

public class FaresFilterTest implements PlanTestConstants {

private final TransitModelForTest testModel = TransitModelForTest.of();
private final TimetableRepositoryForTest testModel = TimetableRepositoryForTest.of();

@Test
void shouldAddFare() {
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 @@ -22,13 +22,13 @@
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.PlanTestConstants;
import org.opentripplanner.routing.core.FareType;
import org.opentripplanner.transit.model._data.TransitModelForTest;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.basic.Money;
import org.opentripplanner.transit.model.network.Route;

class CombinedInterlinedLegsFareServiceTest implements PlanTestConstants {

static final Route route = TransitModelForTest.route("route-1").build();
static final Route route = TimetableRepositoryForTest.route("route-1").build();
static final Itinerary interlinedWithDifferentRoute = newItinerary(
Place.forStop(AIRPORT_STOP),
T11_00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.opentripplanner.model.plan.Place;
import org.opentripplanner.model.plan.PlanTestConstants;
import org.opentripplanner.routing.core.FareType;
import org.opentripplanner.transit.model._data.TransitModelForTest;
import org.opentripplanner.transit.model._data.TimetableRepositoryForTest;
import org.opentripplanner.transit.model.basic.Money;

class DefaultFareServiceTest implements PlanTestConstants {
Expand Down Expand Up @@ -116,7 +116,7 @@ void shouldNotCombineInterlinedLegs() {
var itin = newItinerary(Place.forStop(AIRPORT_STOP), T11_00)
.bus(1, T11_05, T11_12, Place.forStop(CITY_CENTER_A_STOP))
.staySeatedBus(
TransitModelForTest.route("123").build(),
TimetableRepositoryForTest.route("123").build(),
2,
T11_12,
T11_16,
Expand Down
Loading

0 comments on commit ccd001d

Please sign in to comment.