Search in sources :

Example 1 with RouterInfo

use of org.opentripplanner.api.model.RouterInfo in project OpenTripPlanner by opentripplanner.

the class RoutersTest method getRouterInfoReturnsFirstAndLastValidDateForGraph.

@Test
public void getRouterInfoReturnsFirstAndLastValidDateForGraph() {
    final CalendarServiceData calendarService = new CalendarServiceData();
    final List<ServiceDate> serviceDates = new ArrayList<ServiceDate>() {

        {
            add(new ServiceDate(2015, 10, 1));
            add(new ServiceDate(2015, 11, 1));
        }
    };
    calendarService.putServiceDatesForServiceId(new AgencyAndId("NA", "1"), serviceDates);
    final Graph graph = new Graph();
    graph.updateTransitFeedValidity(calendarService);
    graph.expandToInclude(0, 100);
    OTPServer otpServer = new OTPServer(new CommandLineParameters(), new GraphService());
    otpServer.getGraphService().registerGraph("A", new MemoryGraphSource("A", graph));
    Routers routerApi = new Routers();
    routerApi.otpServer = otpServer;
    RouterInfo info = routerApi.getGraphId("A");
    assertNotNull(info.transitServiceStarts);
    assertNotNull(info.transitServiceEnds);
    assertTrue(info.transitServiceStarts < info.transitServiceEnds);
}
Also used : CalendarServiceData(org.onebusaway.gtfs.model.calendar.CalendarServiceData) GraphService(org.opentripplanner.routing.services.GraphService) ServiceDate(org.onebusaway.gtfs.model.calendar.ServiceDate) CommandLineParameters(org.opentripplanner.standalone.CommandLineParameters) Graph(org.opentripplanner.routing.graph.Graph) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) OTPServer(org.opentripplanner.standalone.OTPServer) MemoryGraphSource(org.opentripplanner.routing.impl.MemoryGraphSource) RouterInfo(org.opentripplanner.api.model.RouterInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with RouterInfo

use of org.opentripplanner.api.model.RouterInfo in project OpenTripPlanner by opentripplanner.

the class RoutersTest method testRouters.

@Test
public void testRouters() {
    OTPServer otpServer = new OTPServer(new CommandLineParameters(), new GraphService());
    otpServer.getGraphService().registerGraph("", new MemoryGraphSource(null, new Graph()));
    otpServer.getGraphService().registerGraph("A", new MemoryGraphSource("", new Graph()));
    otpServer.getGraphService().getRouter("A").graph.addVertex(new ExitVertex(null, "A", 0, 0, 0));
    otpServer.getGraphService().getRouter("A").graph.addVertex(new ExitVertex(null, "B", 0, 1, 0));
    otpServer.getGraphService().getRouter("A").graph.addVertex(new ExitVertex(null, "C", 1, 1, 0));
    // this needs to be added since convex hull isn't lazy loaded anymore
    otpServer.getGraphService().getRouter("A").graph.calculateConvexHull();
    otpServer.getGraphService().getRouter("").graph.calculateConvexHull();
    // this needs to be added since it is otherwise calculated during OSM/Transit loading
    // which doesn't happen in this test
    otpServer.getGraphService().getRouter("A").graph.calculateEnvelope();
    otpServer.getGraphService().getRouter("").graph.calculateEnvelope();
    Routers routerApi = new Routers();
    routerApi.otpServer = otpServer;
    RouterList routers = routerApi.getRouterIds();
    assertEquals(2, routers.routerInfo.size());
    RouterInfo router0 = routers.routerInfo.get(0);
    RouterInfo router1 = routers.routerInfo.get(1);
    RouterInfo otherRouter;
    RouterInfo defaultRouter;
    if (router0.routerId.equals("")) {
        defaultRouter = router0;
        otherRouter = router1;
    } else {
        defaultRouter = router1;
        otherRouter = router0;
    }
    assertEquals("", defaultRouter.routerId);
    assertEquals("A", otherRouter.routerId);
    assertTrue(otherRouter.polygon.getArea() > 0);
}
Also used : GraphService(org.opentripplanner.routing.services.GraphService) ExitVertex(org.opentripplanner.routing.vertextype.ExitVertex) CommandLineParameters(org.opentripplanner.standalone.CommandLineParameters) Graph(org.opentripplanner.routing.graph.Graph) OTPServer(org.opentripplanner.standalone.OTPServer) MemoryGraphSource(org.opentripplanner.routing.impl.MemoryGraphSource) RouterList(org.opentripplanner.api.model.RouterList) RouterInfo(org.opentripplanner.api.model.RouterInfo) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RouterInfo (org.opentripplanner.api.model.RouterInfo)2 Graph (org.opentripplanner.routing.graph.Graph)2 MemoryGraphSource (org.opentripplanner.routing.impl.MemoryGraphSource)2 GraphService (org.opentripplanner.routing.services.GraphService)2 CommandLineParameters (org.opentripplanner.standalone.CommandLineParameters)2 OTPServer (org.opentripplanner.standalone.OTPServer)2 ArrayList (java.util.ArrayList)1 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)1 CalendarServiceData (org.onebusaway.gtfs.model.calendar.CalendarServiceData)1 ServiceDate (org.onebusaway.gtfs.model.calendar.ServiceDate)1 RouterList (org.opentripplanner.api.model.RouterList)1 ExitVertex (org.opentripplanner.routing.vertextype.ExitVertex)1