Skip to content

Commit

Permalink
Merge pull request #240 from ibi-group/upstream-merge-2024-12-04
Browse files Browse the repository at this point in the history
Upstream merge 2024-12-04
  • Loading branch information
miles-grant-ibigroup authored Dec 4, 2024
2 parents 5f776ef + 3495393 commit ac90804
Show file tree
Hide file tree
Showing 28 changed files with 453 additions and 3,750 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 @@ -462,81 +462,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 @@ -84,7 +84,7 @@ private Optional<TimePenalty> mapSafeTimePenalty(org.onebusaway.gtfs.model.Trip
} else {
var offset = rhs.getSafeDurationOffset() == null
? Duration.ZERO
: Duration.ofMinutes(rhs.getSafeDurationOffset().longValue());
: Duration.ofSeconds(rhs.getSafeDurationOffset().longValue());
var factor = rhs.getSafeDurationFactor() == null
? 1d
: rhs.getSafeDurationFactor().doubleValue();
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 @@ -150,8 +150,8 @@ void testFlexFactorAndOffset(

private static Stream<Arguments> provideOffsetAndFactor() {
return Stream.of(
Arguments.of(1.5d, 60d, 1.5d, Duration.ofHours(1)),
Arguments.of(null, 120d, 1d, Duration.ofHours(2)),
Arguments.of(1.5d, 60d, 1.5d, Duration.ofMinutes(1)),
Arguments.of(null, 120d, 1d, Duration.ofMinutes(2)),
Arguments.of(1.5d, null, 1.5d, Duration.ZERO)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.opentripplanner.street.model.StreetTraversalPermission.ALL;
import static org.opentripplanner.street.model.StreetTraversalPermission.CAR;
import static org.opentripplanner.street.model.StreetTraversalPermission.NONE;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN;
import static org.opentripplanner.street.model.StreetTraversalPermission.PEDESTRIAN_AND_BICYCLE;
Expand All @@ -12,15 +14,16 @@
import org.opentripplanner.osm.model.OsmWithTags;
import org.opentripplanner.osm.wayproperty.WayProperties;
import org.opentripplanner.osm.wayproperty.WayPropertySet;
import org.opentripplanner.osm.wayproperty.specifier.WayTestData;

public class FinlandMapperTest {
class FinlandMapperTest {

private WayPropertySet wps;
private OsmTagMapper mapper;
static float epsilon = 0.01f;

@BeforeEach
public void setup() {
void setup() {
this.wps = new WayPropertySet();
this.mapper = new FinlandMapper();
this.mapper.populateProperties(this.wps);
Expand All @@ -30,7 +33,7 @@ public void setup() {
* Test that bike and walk safety factors are calculated accurately
*/
@Test
public void testSafety() {
void testSafety() {
OsmWithTags primaryWay = new OsmWithTags();
primaryWay.addTag("highway", "primary");
primaryWay.addTag("oneway", "no");
Expand Down Expand Up @@ -141,7 +144,7 @@ public void testSafety() {
}

@Test
public void testSafetyWithMixins() {
void testSafetyWithMixins() {
OsmWithTags wayWithMixins = new OsmWithTags();
// highway=service has no custom bicycle or walk safety
wayWithMixins.addTag("highway", "unclassified");
Expand Down Expand Up @@ -179,7 +182,7 @@ public void testSafetyWithMixins() {
}

@Test
public void testTagMapping() {
void testTagMapping() {
OsmWithTags way;
WayProperties wayData;

Expand All @@ -206,7 +209,7 @@ public void testTagMapping() {
* Test that biking is not allowed in footway areas and transit platforms
*/
@Test
public void testArea() {
void testArea() {
OsmWithTags way;
WayProperties wayData;

Expand All @@ -227,10 +230,21 @@ public void testArea() {
}

@Test
public void serviceNoThroughTraffic() {
void serviceNoThroughTraffic() {
var way = new OsmWay();
way.addTag("highway", "residential");
way.addTag("service", "driveway");
assertTrue(mapper.isMotorVehicleThroughTrafficExplicitlyDisallowed(way));
}

@Test
void motorroad() {
OsmTagMapper osmTagMapper = new FinlandMapper();
WayPropertySet wps = new WayPropertySet();
osmTagMapper.populateProperties(wps);
var way = WayTestData.carTunnel();
assertEquals(ALL, wps.getDataForWay(way).getPermission());
way.addTag("motorroad", "yes");
assertEquals(CAR, wps.getDataForWay(way).getPermission());
}
}
Loading

0 comments on commit ac90804

Please sign in to comment.