Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
Browse files Browse the repository at this point in the history
…023-10-20
  • Loading branch information
leonardehrenfried committed Oct 20, 2023
2 parents 2539af7 + ec0c0fc commit 3867083
Show file tree
Hide file tree
Showing 22 changed files with 538 additions and 299 deletions.
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ based on merged pull requests. Search GitHub issues and pull requests for smalle
- Add validation for missing calls in SIRI update [#5403](https://github.com/opentripplanner/OpenTripPlanner/pull/5403)
- Import Occupancy Status from GTFS-RT Vehicle Positions [#5372](https://github.com/opentripplanner/OpenTripPlanner/pull/5372)
- Add Roadmap epic template [#5413](https://github.com/opentripplanner/OpenTripPlanner/pull/5413)
- Allow multiple zones in an unscheduled flex trip [#5376](https://github.com/opentripplanner/OpenTripPlanner/pull/5376)
[](AUTOMATIC_CHANGELOG_PLACEHOLDER_DO_NOT_REMOVE)

## 2.4.0 (2023-09-13)
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@


<properties>
<otp.serialization.version.id>121</otp.serialization.version.id>
<otp.serialization.version.id>122</otp.serialization.version.id>
<!-- Lib versions - keep list sorted on property name -->
<geotools.version>29.2</geotools.version>
<geotools.version>30.0</geotools.version>
<google.dagger.version>2.48.1</google.dagger.version>
<jackson.version>2.15.3</jackson.version>
<jersey.version>3.1.3</jersey.version>
Expand Down Expand Up @@ -648,7 +648,7 @@
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-opengis</artifactId>
<artifactId>gt-api</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
Expand Down
98 changes: 98 additions & 0 deletions src/ext-test/java/org/opentripplanner/ext/flex/GtfsFlexTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.opentripplanner.ext.flex;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.opentripplanner.TestOtpModel;
import org.opentripplanner.ext.flex.trip.FlexTrip;
import org.opentripplanner.ext.flex.trip.UnscheduledTrip;
import org.opentripplanner.routing.graphfinder.NearbyStop;
import org.opentripplanner.standalone.config.sandbox.FlexConfig;
import org.opentripplanner.transit.model.framework.FeedScopedId;
import org.opentripplanner.transit.service.TransitModel;

/**
* This test makes sure that one of the example feeds in the GTFS-Flex repo works. It's the City of
* Aspen Downtown taxi service which is a completely unscheduled trip that takes you door-to-door in
* the city.
* <p>
* It only contains a single stop time which in GTFS static would not work but is valid in GTFS
* Flex.
*/
public class GtfsFlexTest extends FlexTest {

private static TransitModel transitModel;

@BeforeAll
static void setup() {
TestOtpModel model = FlexTest.buildFlexGraph(ASPEN_GTFS);
transitModel = model.transitModel();
}

@Test
void parseAspenTaxiAsUnscheduledTrip() {
var flexTrips = transitModel.getAllFlexTrips();
assertFalse(flexTrips.isEmpty());
assertEquals(
Set.of("t_1289262_b_29084_tn_0", "t_1289257_b_28352_tn_0"),
flexTrips.stream().map(FlexTrip::getId).map(FeedScopedId::getId).collect(Collectors.toSet())
);

assertEquals(
Set.of(UnscheduledTrip.class),
flexTrips.stream().map(FlexTrip::getClass).collect(Collectors.toSet())
);
}

@Test
void calculateAccessTemplate() {
var trip = getFlexTrip();
var nearbyStop = getNearbyStop(trip);

var accesses = trip
.getFlexAccessTemplates(nearbyStop, flexDate, calculator, FlexConfig.DEFAULT)
.toList();

assertEquals(1, accesses.size());

var access = accesses.get(0);
assertEquals(0, access.fromStopIndex);
assertEquals(0, access.toStopIndex);
}

@Test
void calculateEgressTemplate() {
var trip = getFlexTrip();
var nearbyStop = getNearbyStop(trip);
var egresses = trip
.getFlexEgressTemplates(nearbyStop, flexDate, calculator, FlexConfig.DEFAULT)
.toList();

assertEquals(1, egresses.size());

var egress = egresses.get(0);
assertEquals(0, egress.fromStopIndex);
assertEquals(0, egress.toStopIndex);
}

@Test
void shouldGeneratePatternForFlexTripWithSingleStop() {
assertFalse(transitModel.getAllTripPatterns().isEmpty());
}

private static NearbyStop getNearbyStop(FlexTrip<?, ?> trip) {
assertEquals(1, trip.getStops().size());
var stopLocation = trip.getStops().iterator().next();
return new NearbyStop(stopLocation, 0, List.of(), null);
}

private static FlexTrip<?, ?> getFlexTrip() {
var flexTrips = transitModel.getAllFlexTrips();
return flexTrips.iterator().next();
}
}
Loading

0 comments on commit 3867083

Please sign in to comment.