Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into background-tiles
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Dec 4, 2024
2 parents a83afac + 27b18bd commit 9230aa3
Show file tree
Hide file tree
Showing 31 changed files with 511 additions and 3,759 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-27T19:19/assets/index-csysh7Fh.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-27T19:19/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 @@ -27,8 +27,8 @@ private static ApiBookingInfo mapBookingInfo(BookingInfo info, boolean isPickup)
BookingMethodMapper.mapBookingMethods(info.bookingMethods()),
BookingTimeMapper.mapBookingTime(info.getEarliestBookingTime()),
BookingTimeMapper.mapBookingTime(info.getLatestBookingTime()),
info.getMinimumBookingNotice(),
info.getMaximumBookingNotice(),
info.getMinimumBookingNotice().orElse(null),
info.getMaximumBookingNotice().orElse(null),
info.getMessage(),
isPickup ? info.getPickupMessage() : null,
!isPickup ? info.getDropOffMessage() : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import java.time.Duration;
import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers;
import org.opentripplanner.transit.model.organization.ContactInfo;
import org.opentripplanner.transit.model.timetable.booking.BookingInfo;
Expand Down Expand Up @@ -31,7 +32,8 @@ public DataFetcher<BookingTime> latestBookingTime() {

@Override
public DataFetcher<Long> maximumBookingNoticeSeconds() {
return environment -> getSource(environment).getMaximumBookingNotice().toSeconds();
return environment ->
getSource(environment).getMaximumBookingNotice().map(Duration::toSeconds).orElse(null);
}

@Override
Expand All @@ -41,7 +43,8 @@ public DataFetcher<String> message() {

@Override
public DataFetcher<Long> minimumBookingNoticeSeconds() {
return environment -> getSource(environment).getMinimumBookingNotice().toSeconds();
return environment ->
getSource(environment).getMinimumBookingNotice().map(Duration::toSeconds).orElse(null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ else if (speedLimit <= 16.65f) {
// Don't recommend walking in trunk road tunnels
props.setProperties("highway=trunk;tunnel=yes", withModes(CAR).bicycleSafety(7.47));

// Do not walk on "moottoriliikennetie"
props.setProperties("motorroad=yes", withModes(CAR).bicycleSafety(7.47));

// Remove informal and private roads
props.setProperties("highway=*;informal=yes", withModes(NONE));
props.setProperties("highway=service;access=private", withModes(NONE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.opentripplanner.osm.wayproperty.WayProperties;
import org.opentripplanner.osm.wayproperty.WayPropertySet;
import org.opentripplanner.osm.wayproperty.specifier.BestMatchSpecifier;
import org.opentripplanner.osm.wayproperty.specifier.Condition;
import org.opentripplanner.osm.wayproperty.specifier.ExactMatchSpecifier;
import org.opentripplanner.osm.wayproperty.specifier.LogicalOrSpecifier;
import org.opentripplanner.routing.services.notes.StreetNotesService;
Expand Down Expand Up @@ -104,6 +103,10 @@ public void populateProperties(WayPropertySet props) {
props.setProperties("highway=trunk", withModes(CAR).bicycleSafety(7.47));
props.setProperties("highway=motorway", withModes(CAR).bicycleSafety(8));

// Do not walk on "moottoriliikennetie"/"Kraftfahrstrasse"/"Limited access road"
// https://en.wikipedia.org/wiki/Limited-access_road
props.setProperties(new ExactMatchSpecifier("motorroad=yes"), withModes(CAR));

/* cycleway=lane */
props.setProperties(
"highway=*;cycleway=lane",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.Serializable;
import java.time.Duration;
import java.util.EnumSet;
import java.util.Optional;
import javax.annotation.Nullable;
import org.opentripplanner.transit.model.organization.ContactInfo;
import org.opentripplanner.utils.tostring.ToStringBuilder;
Expand Down Expand Up @@ -99,14 +100,12 @@ public BookingTime getLatestBookingTime() {
return latestBookingTime;
}

@Nullable
public Duration getMinimumBookingNotice() {
return minimumBookingNotice;
public Optional<Duration> getMinimumBookingNotice() {
return Optional.ofNullable(minimumBookingNotice);
}

@Nullable
public Duration getMaximumBookingNotice() {
return maximumBookingNotice;
public Optional<Duration> getMaximumBookingNotice() {
return Optional.ofNullable(maximumBookingNotice);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,17 @@ Builder withBookingInfo(@Nullable BookingInfo bookingInfo) {
return this;
}
withLatestBookingTime(bookingInfo.getLatestBookingTime());
withMinimumBookingNotice(bookingInfo.getMinimumBookingNotice());
withMinimumBookingNotice(bookingInfo.getMinimumBookingNotice().orElse(null));
return this;
}

public Builder withLatestBookingTime(BookingTime latestBookingTime) {
public Builder withLatestBookingTime(@Nullable BookingTime latestBookingTime) {
this.latestBookingTime =
latestBookingTime == null ? NOT_SET : latestBookingTime.relativeTimeSeconds();
return this;
}

public Builder withMinimumBookingNotice(Duration minimumBookingNotice) {
public Builder withMinimumBookingNotice(@Nullable Duration minimumBookingNotice) {
this.minimumBookingNotice =
minimumBookingNotice == null ? NOT_SET : (int) minimumBookingNotice.toSeconds();
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.opentripplanner.apis.gtfs.datafetchers;

import static graphql.execution.ExecutionContextBuilder.newExecutionContextBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import graphql.execution.ExecutionId;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.DataFetchingEnvironmentImpl;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.opentripplanner.transit.model.timetable.booking.BookingInfo;

class BookingInfoImplTest {

private static final BookingInfoImpl SUBJECT = new BookingInfoImpl();
private static final Duration TEN_MINUTES = Duration.ofMinutes(10);

@Test
void emptyDurations() throws Exception {
var env = dataFetchingEnvironment(BookingInfo.of().build());
assertNull(SUBJECT.minimumBookingNoticeSeconds().get(env));
assertNull(SUBJECT.maximumBookingNoticeSeconds().get(env));
}

@Test
void durations() throws Exception {
var env = dataFetchingEnvironment(
BookingInfo
.of()
.withMinimumBookingNotice(TEN_MINUTES)
.withMaximumBookingNotice(TEN_MINUTES)
.build()
);
assertEquals(600, SUBJECT.minimumBookingNoticeSeconds().get(env));
assertEquals(600, SUBJECT.maximumBookingNoticeSeconds().get(env));
}

private DataFetchingEnvironment dataFetchingEnvironment(BookingInfo bookingInfo) {
var executionContext = newExecutionContextBuilder()
.executionId(ExecutionId.from(this.getClass().getName()))
.build();
return DataFetchingEnvironmentImpl
.newDataFetchingEnvironment(executionContext)
.source(bookingInfo)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ void testMapMinimumBookingNotice() {

BookingInfo bookingInfo = subject.map(stopPoint, null, null);

assertEquals(THIRTY_MINUTES, bookingInfo.getMinimumBookingNotice());
assertEquals(THIRTY_MINUTES, bookingInfo.getMinimumBookingNotice().get());
}
}
Loading

0 comments on commit 9230aa3

Please sign in to comment.