Skip to content

Commit

Permalink
Merge branch 'remove-duplicates-alternative-legs' into dev-2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
optionsome committed Mar 16, 2023
2 parents 2faf20d + a4fa84c commit d822282
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
package org.opentripplanner.ext.legacygraphqlapi.generated;

import graphql.relay.Connection;
import graphql.relay.Connection;
import graphql.relay.Edge;
import graphql.relay.Edge;
import graphql.schema.DataFetcher;
import graphql.schema.TypeResolver;
import java.util.Map;
import java.util.Map;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.api.resource.DebugOutput;
Expand All @@ -21,10 +18,6 @@
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLRelativeDirection;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLRoutingErrorCode;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLTypes.LegacyGraphQLTransitMode;
import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLRouteTypeModel;
import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLStopOnRouteModel;
import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLStopOnTripModel;
import org.opentripplanner.ext.legacygraphqlapi.model.LegacyGraphQLUnknownModel;
import org.opentripplanner.model.StopTimesInPattern;
import org.opentripplanner.model.SystemNotice;
import org.opentripplanner.model.TripTimeOnDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void testGetAllFrequencies() {
public void testGetRoutes() {
Collection<Route> routes = subject.getRoutes().values();

assertEquals(18, routes.size());
assertEquals(19, routes.size());
assertEquals("Route{agency:1 BUS 1}", first(routes).toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testGetAllStations() {
public void testGetAllStops() {
Collection<RegularStop> stops = subject.stopModel().listRegularStops();

assertEquals(22, stops.size());
assertEquals(25, stops.size());
assertEquals("RegularStop{F:A A}", first(stops).toString());
}

Expand All @@ -115,7 +115,7 @@ public void testGetAllStopTimes() {
stopTimes.addAll(subject.getStopTimesForTrip(trip));
}

assertEquals(80, stopTimes.size());
assertEquals(85, stopTimes.size());
assertEquals(
"StopTime(seq=1 stop=F:A trip=agency:1.1 times=00:00:00-00:00:00)",
first(stopTimes).toString()
Expand All @@ -126,7 +126,7 @@ public void testGetAllStopTimes() {
public void testGetAllTrips() {
Collection<Trip> trips = subject.getAllTrips();

assertEquals(33, trips.size());
assertEquals(34, trips.size());
assertEquals("Trip{agency:1.1 1}", first(trips).toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,35 @@ void testNextLegs() throws Exception {

assertEquals(expectd, legs);
}

@Test
void testCircularRoutes() {
var transitService = new DefaultTransitService(transitModel);

var originalLeg = new ScheduledTransitLegReference(
new FeedScopedId(this.feedId.getId(), "19.1"),
LocalDate.parse("2022-04-02"),
0,
1
)
.getLeg(transitService);

final List<ScheduledTransitLeg> alternativeLegs = AlternativeLegs.getAlternativeLegs(
originalLeg,
2,
transitService,
false,
AlternativeLegsFilter.NO_FILTER
);
var legs = Itinerary.toStr(
alternativeLegs.stream().map(Leg.class::cast).map(List::of).map(Itinerary::new).toList()
);

var expected = String.join(
", ",
List.of("X ~ BUS 19 10:30 10:40 ~ Y [$-1]", "X ~ BUS 19 10:00 10:10 ~ Y [$-1]")
);

assertEquals(expected, legs);
}
}
1 change: 1 addition & 0 deletions src/test/resources/testagency/routes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ route_id,route_short_name,route_long_name,route_type,route_bikes_allowed
16,16,16,2,
17,17,17,2,
18,18,18,2,
19,19,19,3,
5 changes: 5 additions & 0 deletions src/test/resources/testagency/stop_times.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,8 @@ trip_id,arrival_time,departure_time,stop_id,stop_sequence,shape_dist_traveled,pi
18.1back,16:25:00,16:25:00,E,2,,0,0
18.bogus,23:20:00,23:20:00,D,1,,0,0
18.bogus,00:25:00,00:25:00,E,2,,0,0
19.1,10:00:00,10:00:00,X,1,,0,0
19.1,10:10:00,10:10:00,Y,2,,0,0
19.1,10:20:00,10:20:00,Z,3,,0,0
19.1,10:30:00,10:30:00,X,4,,0,0
19.1,10:40:00,10:40:00,Y,5,,0,0
4 changes: 4 additions & 0 deletions src/test/resources/testagency/stops.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ S,S,42.03,-73,0,0,
T,T,42.04,-73,0,0,
U,U,13,13,0,0,
V,V,16,16,0,0,
X,X,17,0,0,
Y,Y,18,0,0,
Z,Z,19,0,0,

1 change: 1 addition & 0 deletions src/test/resources/testagency/trips.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ route_id,service_id,trip_id,shape_id,block_id,wheelchair_accessible,trip_bikes_a
18,alldays,18.1,,,,,N,foo
18,alldays,18.1back,,,1,,S,foo
18,alldays,18.bogus,,,,,,foo
19,alldays,19.1,,,,,,

0 comments on commit d822282

Please sign in to comment.