Search in sources :

Example 6 with GTFSPatternHopFactory

use of org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory in project OpenTripPlanner by opentripplanner.

the class TestFares method testBasic.

public void testBasic() throws Exception {
    Graph gg = new Graph();
    GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.CALTRAIN_GTFS));
    GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
    factory.run(gg);
    gg.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
    RoutingRequest options = new RoutingRequest();
    String feedId = gg.getFeedIds().iterator().next();
    long startTime = TestUtils.dateInSeconds("America/Los_Angeles", 2009, 8, 7, 12, 0, 0);
    options.dateTime = startTime;
    options.setRoutingContext(gg, feedId + ":Millbrae Caltrain", feedId + ":Mountain View Caltrain");
    ShortestPathTree spt;
    GraphPath path = null;
    spt = aStar.getShortestPathTree(options);
    path = spt.getPath(gg.getVertex(feedId + ":Mountain View Caltrain"), true);
    FareService fareService = gg.getService(FareService.class);
    Fare cost = fareService.getCost(path);
    assertEquals(cost.getFare(FareType.regular), new Money(new WrappedCurrency("USD"), 425));
}
Also used : GtfsContext(org.opentripplanner.gtfs.GtfsContext) GraphPath(org.opentripplanner.routing.spt.GraphPath) WrappedCurrency(org.opentripplanner.routing.core.WrappedCurrency) GTFSPatternHopFactory(org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory) FareService(org.opentripplanner.routing.services.FareService) Fare(org.opentripplanner.routing.core.Fare) Money(org.opentripplanner.routing.core.Money) Graph(org.opentripplanner.routing.graph.Graph) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) File(java.io.File)

Example 7 with GTFSPatternHopFactory

use of org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory in project OpenTripPlanner by opentripplanner.

the class TestGraphPath method setUp.

public void setUp() throws Exception {
    GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
    graph = new Graph();
    GTFSPatternHopFactory hl = new GTFSPatternHopFactory(context);
    hl.run(graph);
    graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) GtfsContext(org.opentripplanner.gtfs.GtfsContext) GTFSPatternHopFactory(org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory) File(java.io.File)

Example 8 with GTFSPatternHopFactory

use of org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory in project OpenTripPlanner by opentripplanner.

the class ConstantsForTests method buildGraph.

public static Graph buildGraph(String path) {
    GtfsContext context;
    try {
        context = GtfsLibrary.readGtfs(new File(path));
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }
    Graph graph = new Graph();
    GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
    factory.run(graph);
    graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
    return graph;
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) GtfsContext(org.opentripplanner.gtfs.GtfsContext) IOException(java.io.IOException) GTFSPatternHopFactory(org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory) File(java.io.File)

Example 9 with GTFSPatternHopFactory

use of org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory in project OpenTripPlanner by opentripplanner.

the class ConstantsForTests method setupPortland.

private void setupPortland() {
    try {
        portlandContext = GtfsLibrary.readGtfs(new File(ConstantsForTests.PORTLAND_GTFS));
        portlandGraph = new Graph();
        GTFSPatternHopFactory factory = new GTFSPatternHopFactory(portlandContext);
        factory.run(portlandGraph);
        TransferGraphLinker linker = new TransferGraphLinker(portlandGraph);
        linker.run();
        // TODO: eliminate GTFSContext
        // this is now making a duplicate calendarservicedata but it's oh so practical
        portlandGraph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(portlandContext.getDao()));
    } catch (Exception e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    }
    StreetLinkerModule ttsnm = new StreetLinkerModule();
    ttsnm.buildGraph(portlandGraph, new HashMap<Class<?>, Object>());
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) TransferGraphLinker(org.opentripplanner.routing.edgetype.factory.TransferGraphLinker) GTFSPatternHopFactory(org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory) File(java.io.File) StreetLinkerModule(org.opentripplanner.graph_builder.module.StreetLinkerModule) IOException(java.io.IOException)

Example 10 with GTFSPatternHopFactory

use of org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory in project OpenTripPlanner by opentripplanner.

the class AlertPatchTest method setUp.

public void setUp() throws Exception {
    aStar = new AStar();
    GtfsContext context = GtfsLibrary.readGtfs(new File(ConstantsForTests.FAKE_GTFS));
    options = new RoutingRequest();
    graph = new Graph();
    GTFSPatternHopFactory factory = new GTFSPatternHopFactory(context);
    factory.run(graph);
    graph.putService(CalendarServiceData.class, GtfsLibrary.createCalendarServiceData(context.getDao()));
    graph.index(new DefaultStreetVertexIndexFactory());
    feedId = context.getFeedId().getId();
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) GtfsContext(org.opentripplanner.gtfs.GtfsContext) AStar(org.opentripplanner.routing.algorithm.AStar) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) GTFSPatternHopFactory(org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory) DefaultStreetVertexIndexFactory(org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory) File(java.io.File)

Aggregations

GTFSPatternHopFactory (org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory)15 File (java.io.File)14 Graph (org.opentripplanner.routing.graph.Graph)13 GtfsContext (org.opentripplanner.gtfs.GtfsContext)10 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)5 GraphPath (org.opentripplanner.routing.spt.GraphPath)4 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)4 IOException (java.io.IOException)3 BeforeClass (org.junit.BeforeClass)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)3 Fare (org.opentripplanner.routing.core.Fare)3 Money (org.opentripplanner.routing.core.Money)3 WrappedCurrency (org.opentripplanner.routing.core.WrappedCurrency)3 FareService (org.opentripplanner.routing.services.FareService)3 Trip (org.onebusaway.gtfs.model.Trip)2 StreetLinkerModule (org.opentripplanner.graph_builder.module.StreetLinkerModule)2 DefaultStreetVertexIndexFactory (org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory)2 TransitStopDepart (org.opentripplanner.routing.vertextype.TransitStopDepart)2 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)1 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)1