use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class RoutingContextTest method testSetServiceDays.
@Test
public void testSetServiceDays() throws Exception {
String feedId = "FEED";
String agencyId = "AGENCY";
Agency agency = new Agency();
agency.setId(agencyId);
Graph graph = mock(Graph.class);
RoutingRequest routingRequest = mock(RoutingRequest.class);
CalendarService calendarService = mock(CalendarService.class);
// You're probably not supposed to do this to mocks (access their fields directly)
// But I know of no other way to do this since the mock object has only action-free stub methods.
routingRequest.modes = new TraverseModeSet("WALK,TRANSIT");
when(graph.getTimeZone()).thenReturn(TimeZone.getTimeZone("Europe/Budapest"));
when(graph.getCalendarService()).thenReturn(calendarService);
when(graph.getFeedIds()).thenReturn(Collections.singletonList("FEED"));
when(graph.getAgencies(feedId)).thenReturn(Collections.singletonList(agency));
when(calendarService.getTimeZoneForAgencyId(agencyId)).thenReturn(TimeZone.getTimeZone("Europe/Budapest"));
when(routingRequest.getSecondsSinceEpoch()).thenReturn(1393750800L, 1396126800L, /* 2014-03-29T22:00:00+01:00 */
1396132200L, /* 2014-03-29T23:30:00+01:00 */
1396135800L, 1401696000L, 1414272600L, /* 2014-10-25T23:30:00+02:00 */
1414276200L, /* 2014-10-26T00:30:00+02:00 */
1414279800L);
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 3, 1), new ServiceDate(2014, 3, 2), new ServiceDate(2014, 3, 3));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 3, 28), new ServiceDate(2014, 3, 29), new ServiceDate(2014, 3, 30));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 3, 28), new ServiceDate(2014, 3, 29), new ServiceDate(2014, 3, 30));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 3, 29), new ServiceDate(2014, 3, 30), new ServiceDate(2014, 3, 31));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 6, 1), new ServiceDate(2014, 6, 2), new ServiceDate(2014, 6, 3));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 10, 24), new ServiceDate(2014, 10, 25), new ServiceDate(2014, 10, 26));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 10, 25), new ServiceDate(2014, 10, 26), new ServiceDate(2014, 10, 27));
verifyServiceDays(routingRequest, graph, new ServiceDate(2014, 10, 25), new ServiceDate(2014, 10, 26), new ServiceDate(2014, 10, 27));
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class SimpleTraversalCostModelTest method before.
@Before
public void before() {
_graph = new Graph();
costModel = new SimpleIntersectionTraversalCostModel();
// Initialize the routing request.
options = new RoutingRequest();
options.carSpeed = 1.0;
options.walkSpeed = 1.0;
options.carDecelerationSpeed = (2.0);
options.carAccelerationSpeed = (2.0);
options.setModes(TraverseModeSet.allModes());
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestGraph method testGetEdgesMultiple.
public void testGetEdgesMultiple() {
Graph g = new Graph();
Vertex a = new IntersectionVertex(g, "A", 5, 5);
Vertex b = new IntersectionVertex(g, "B", 6, 6);
Vertex c = new IntersectionVertex(g, "C", 3, 2);
Set<Edge> expectedEdges = new HashSet<Edge>(4);
expectedEdges.add(new FreeEdge(a, b));
expectedEdges.add(new FreeEdge(b, c));
expectedEdges.add(new FreeEdge(c, b));
expectedEdges.add(new FreeEdge(c, a));
Set<Edge> edges = new HashSet<Edge>(g.getEdges());
assertEquals(4, edges.size());
assertEquals(expectedEdges, edges);
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestOnBoardRouting method setUp.
public void setUp() throws Exception {
GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
graph = new Graph();
GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
factory.run(graph);
graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestPatternHopFactory method setUp.
public void setUp() throws Exception {
context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
graph = new Graph();
feedId = context.getFeedId().getId();
GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
factory.run(graph);
graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
String[] stops = { feedId + ":A", feedId + ":B", feedId + ":C", feedId + ":D", feedId + ":E", feedId + ":entrance_a", feedId + ":entrance_b" };
for (int i = 0; i < stops.length; ++i) {
TransitStop stop = (TransitStop) (graph.getVertex(stops[i]));
IntersectionVertex front = new IntersectionVertex(graph, "near_1_" + stop.getStopId(), stop.getX() + 0.0001, stop.getY() + 0.0001);
IntersectionVertex back = new IntersectionVertex(graph, "near_2_" + stop.getStopId(), stop.getX() - 0.0001, stop.getY() - 0.0001);
StreetEdge street1 = new StreetEdge(front, back, GeometryUtils.makeLineString(stop.getX() + 0.0001, stop.getY() + 0.0001, stop.getX() - 0.0001, stop.getY() - 0.0001), "street", 100, StreetTraversalPermission.ALL, false);
StreetEdge street2 = new StreetEdge(back, front, GeometryUtils.makeLineString(stop.getX() - 0.0001, stop.getY() - 0.0001, stop.getX() + 0.0001, stop.getY() + 0.0001), "street", 100, StreetTraversalPermission.ALL, true);
}
StreetLinkerModule ttsnm = new StreetLinkerModule();
// Linkers aren't run otherwise
graph.hasStreets = true;
graph.hasTransit = true;
ttsnm.buildGraph(graph, new HashMap<Class<?>, Object>());
}
Aggregations