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));
}
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()));
}
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;
}
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>());
}
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();
}
Aggregations