Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into feature/layer-gr…
Browse files Browse the repository at this point in the history
…oups
  • Loading branch information
flaktack committed Nov 7, 2024
2 parents 336fb13 + 55cce3f commit f6c04e0
Show file tree
Hide file tree
Showing 1,188 changed files with 9,956 additions and 5,423 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ on:
- master
- dev-1.x
- dev-2.x
env:
# Since version 3.9.0 of Maven it will automatically understand this environment variable.
# However, as of 2024-11 the latest versions of Ubuntu and Debian were on 3.8.8 so it will take some
# time until we can remove the $MAVEN_ARGS below.
MAVEN_ARGS: "--no-transfer-progress -Dstyle.color=always"

jobs:
build-linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,22 +52,29 @@ jobs:
# https://github.com/actions/runner-images/issues/1499
# we set nodePath and npmPath to skip downloading the node binary, which frequently times out
run: |
mvn --batch-mode jacoco:prepare-agent test jacoco:report -P prettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
mvn --batch-mode package -Dmaven.test.skip -P prettierSkip
mvn $MAVEN_ARGS jacoco:prepare-agent test jacoco:report -P prettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
mvn $MAVEN_ARGS package -Dmaven.test.skip -P prettierSkip
- name: Send coverage data to codecov.io
if: github.repository_owner == 'opentripplanner'
uses: codecov/codecov-action@v4
with:
files: target/site/jacoco/jacoco.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

- name: Upload test results to Codecov
# always upload test results, even when failed
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "*TEST-*.xml"

- name: Deploy to Github Package Registry
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev-1.x' || github.ref == 'refs/heads/dev-2.x')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --batch-mode deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierSkip -P deployGitHub
run: mvn $MAVEN_ARGS deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierSkip -P deployGitHub

build-windows:
timeout-minutes: 20
Expand All @@ -79,7 +92,7 @@ jobs:
- name: Configure Windows Pagefile
uses: al-cheb/[email protected]
- name: Run tests
run: mvn --batch-mode test -P prettierSkip
run: mvn $MAVEN_ARGS test -P prettierSkip

docs:
if: github.repository_owner == 'opentripplanner'
Expand Down Expand Up @@ -192,7 +205,7 @@ jobs:
distribution: temurin
cache: maven
- name: Compile Java code
run: mvn --batch-mode compile -DskipTests -P prettierSkip
run: mvn $MAVEN_ARGS compile -DskipTests -P prettierSkip

container-image:
if: github.repository_owner == 'opentripplanner' && github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -235,4 +248,6 @@ jobs:
echo "Maven version ${version_with_snapshot} contains SNAPSHOT, adding date to container image tag"
fi
mvn --batch-mode -P prettierSkip compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_version
MAVEN_SKIP_ARGS="-P prettierSkip -Dmaven.test.skip=true -Dmaven.source.skip=true"
mvn $MAVEN_ARGS $MAVEN_SKIP_ARGS package com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_version
9 changes: 4 additions & 5 deletions .github/workflows/performance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
env:
MAVEN_OPTS: "-Dmaven.repo.local=/home/lenni/.m2/repository/"
run: mvn -DskipTests --batch-mode package -P prettierSkip
run: mvn -DskipTests --batch-mode install -P prettierSkip

- name: Build graph
if: matrix.profile == 'core' || github.ref == 'refs/heads/dev-2.x'
Expand All @@ -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 --projects application 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"
- 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
2 changes: 1 addition & 1 deletion .github/workflows/prune-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ jobs:
run: |
# remove all snapshot container images that have not been pulled for over a year
# --keep-semver makes sure that any image with a x.y.z version scheme is unaffected by this
pip install prune-container-repo==0.0.4 --break-system-packages
pip install prune-container-repo==0.0.4
prune-container-repo -u ${CONTAINER_REGISTRY_USER} -r ${CONTAINER_REPO} --days=365 --keep-semver --activate
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
43 changes: 42 additions & 1 deletion application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,24 @@
<name>OpenTripPlanner - Application</name>

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

<!-- 3rd party dependencies -->
<dependency>
<groupId>net.sf.trove4j</groupId>
<artifactId>trove4j</artifactId>
Expand Down Expand Up @@ -317,7 +335,7 @@
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.4</version>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down Expand Up @@ -513,6 +531,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:37/assets/index-QusXf0JY.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/10/2024-10-17T07:37/assets/index-DOoQNd6K.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-04T12:49/assets/index-DPdUtdaa.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-04T12:49/assets/index-CaBThmWm.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
Loading

0 comments on commit f6c04e0

Please sign in to comment.