use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class TestGeometryAndBlockProcessor method testTimelessStops.
public void testTimelessStops() throws Exception {
Vertex stop_d = graph.getVertex(feedId + ":D");
Vertex stop_c = graph.getVertex(feedId + ":C");
RoutingRequest options = new RoutingRequest();
options.setDateTime(TestUtils.dateInstant("America/New_York", 2009, 8, 1, 10, 0, 0));
options.setRoutingContext(graph, stop_d, stop_c);
ShortestPathTree spt = aStar.getShortestPathTree(options);
GraphPath path = spt.getPath(stop_c, false);
assertNotNull(path);
assertEquals(TestUtils.dateInSeconds("America/New_York", 2009, 8, 1, 11, 0, 0), path.getEndTime());
}
use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class TestGeometryAndBlockProcessor method testWheelchairAccessible.
public void testWheelchairAccessible() throws Exception {
Vertex near_a = graph.getVertex("near_1_" + feedId + "_entrance_a");
Vertex near_b = graph.getVertex("near_1_" + feedId + "_entrance_b");
Vertex near_c = graph.getVertex("near_1_" + feedId + "_C");
Vertex near_e = graph.getVertex("near_1_" + feedId + "_E");
Vertex stop_d = graph.getVertex(feedId + ":D");
Vertex split_d = null;
for (StreetTransitStopLink e : Iterables.filter(stop_d.getOutgoing(), StreetTransitStopLink.class)) {
split_d = e.getToVertex();
}
RoutingRequest options = new RoutingRequest();
options.wheelchairAccessible = true;
options.setDateTime(TestUtils.dateInstant("America/New_York", 2009, 8, 18, 0, 0, 0));
ShortestPathTree spt;
GraphPath path;
// stop B is accessible, so there should be a path.
options.setRoutingContext(graph, near_a, near_b);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(near_b, false);
assertNotNull(path);
// stop C is not accessible, so there should be no path.
options.setRoutingContext(graph, near_a, near_c);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(near_c, false);
assertNull(path);
// stop E has no accessibility information, but we should still be able to route to it.
options.setRoutingContext(graph, near_a, near_e);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(near_e, false);
assertNotNull(path);
// from stop A to stop D would normally be trip 1.1 to trip 2.1, arriving at 00:30. But trip
// 2 is not accessible, so we'll do 1.1 to 3.1, arriving at 01:00
GregorianCalendar time = new GregorianCalendar(2009, 8, 18, 0, 0, 0);
time.setTimeZone(TimeZone.getTimeZone("America/New_York"));
options.setDateTime(time.toInstant());
options.setRoutingContext(graph, near_a, split_d);
spt = aStar.getShortestPathTree(options);
time.add(Calendar.HOUR, 1);
// for the StreetTransitLink
time.add(Calendar.SECOND, 1);
path = spt.getPath(split_d, false);
assertNotNull(path);
assertEquals(TestUtils.toSeconds(time), path.getEndTime());
}
use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class TestGeometryAndBlockProcessor method testRunForTrain.
public void testRunForTrain() {
/**
* This is the notorious Byrd bug: we're going from Q to T at 8:30.
* There's a trip from S to T at 8:50 and a second one at 9:50.
* To get to S by 8:50, we need to take trip 12.1 from Q to R, and 13.1
* from R to S. If we take the direct-but-slower 11.1, we'll miss
* the 8:50 and have to catch the 9:50.
*/
Vertex destination = graph.getVertex(feedId + ":T");
RoutingRequest options = new RoutingRequest();
// test is designed such that transfers must be instantaneous
options.transferSlack = 0;
GregorianCalendar startTime = new GregorianCalendar(2009, 11, 2, 8, 30, 0);
startTime.setTimeZone(TimeZone.getTimeZone("America/New_York"));
options.setDateTime(startTime.toInstant());
options.setRoutingContext(graph, feedId + ":Q", destination.getLabel());
ShortestPathTree spt = aStar.getShortestPathTree(options);
GraphPath path = spt.getPath(destination, false);
long endTime = path.getEndTime();
Calendar c = new GregorianCalendar();
c.setTimeInMillis(endTime * 1000L);
assertTrue(endTime - TestUtils.toSeconds(startTime) < 7200);
}
use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class TestHopFactory method testRouting.
public void testRouting() throws Exception {
Vertex stop_a = graph.getVertex(feedId + ":A");
Vertex stop_b = graph.getVertex(feedId + ":B");
Vertex stop_c = graph.getVertex(feedId + ":C");
Vertex stop_d = graph.getVertex(feedId + ":D");
Vertex stop_e = graph.getVertex(feedId + ":E");
RoutingRequest options = new RoutingRequest();
options.setDateTime(ZonedDateTime.of(2009, 8, 7, 0, 0, 0, 0, zoneId).toInstant());
ShortestPathTree spt;
GraphPath path;
// A to B
options.setRoutingContext(graph, stop_a, stop_b);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(stop_b, false);
assertNotNull(path);
assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_b));
// A to C
options.setRoutingContext(graph, stop_a, stop_c);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(stop_c, false);
assertNotNull(path);
assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c));
// A to D
options.setRoutingContext(graph, stop_a, stop_d);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(stop_d, false);
assertNotNull(path);
assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c, stop_d));
long endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0) + 40 * 60;
assertEquals(endTime, path.getEndTime());
// A to E
options.setRoutingContext(graph, stop_a, stop_e);
spt = aStar.getShortestPathTree(options);
path = spt.getPath(stop_e, false);
assertNotNull(path);
assertEquals(extractStopVertices(path), Lists.newArrayList(stop_a, stop_c, stop_e));
endTime = TestUtils.dateInSeconds("America/New_York", 2009, 8, 7, 0, 0, 0) + 70 * 60;
assertEquals(endTime, path.getEndTime());
}
use of org.opentripplanner.routing.api.request.RoutingRequest in project OpenTripPlanner by opentripplanner.
the class TestHopFactory method testDwell.
public void testDwell() {
Vertex stop_a = graph.getVertex(feedId + ":A_depart");
Vertex stop_c = graph.getVertex(feedId + ":C_arrive");
RoutingRequest options = new RoutingRequest();
options.setDateTime(ZonedDateTime.of(2009, 8, 7, 8, 0, 0, 0, zoneId).toInstant());
options.setRoutingContext(graph, stop_a, stop_c);
ShortestPathTree spt = aStar.getShortestPathTree(options);
GraphPath path = spt.getPath(stop_c, false);
assertNotNull(path);
assertEquals(6, path.states.size());
long endTime = ZonedDateTime.of(2009, 8, 7, 8, 30, 0, 0, zoneId).toInstant().getEpochSecond();
assertEquals(endTime, path.getEndTime());
}
Aggregations