Search in sources :

Example 1 with GtfsFeedId

use of org.opentripplanner.graph_builder.module.GtfsFeedId in project OpenTripPlanner by opentripplanner.

the class GTFSPatternHopFactoryTest method testBikesAllowed.

@Test
public void testBikesAllowed() throws IOException {
    MockGtfs gtfs = MockGtfs.create();
    gtfs.putAgencies(1);
    gtfs.putRoutes(1);
    gtfs.putStops(2);
    gtfs.putCalendars(1);
    gtfs.putTrips(1, "r0", "sid0", "bikes_allowed=1");
    gtfs.putStopTimes("t0", "s0,s1");
    gtfs.putLines("frequencies.txt", "trip_id,start_time,end_time,headway_secs", "t0,09:00:00,17:00:00,300");
    GtfsFeedId feedId = new GtfsFeedId.Builder().id("FEED").build();
    GTFSPatternHopFactory factory = new GTFSPatternHopFactory(GtfsLibrary.createContext(feedId, gtfs.read()));
    Graph graph = new Graph();
    factory.run(graph);
    for (Edge edge : graph.getEdges()) {
        if (edge instanceof TransitBoardAlight) {
            TripPattern pattern = ((TransitBoardAlight) edge).getPattern();
        // TODO assertTrue(pattern.getBikesAllowed());
        }
    }
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) TransitBoardAlight(org.opentripplanner.routing.edgetype.TransitBoardAlight) MockGtfs(org.onebusaway.gtfs.services.MockGtfs) Edge(org.opentripplanner.routing.graph.Edge) TripPattern(org.opentripplanner.routing.edgetype.TripPattern) Test(org.junit.Test)

Example 2 with GtfsFeedId

use of org.opentripplanner.graph_builder.module.GtfsFeedId in project OpenTripPlanner by opentripplanner.

the class GtfsLibrary method readGtfs.

public static GtfsContext readGtfs(File path) throws IOException {
    GtfsRelationalDaoImpl dao = new GtfsRelationalDaoImpl();
    GtfsReader reader = new GtfsReader();
    reader.setInputLocation(path);
    reader.setEntityStore(dao);
    GtfsFeedId feedId = new GtfsFeedId.Builder().fromGtfsFeed(reader.getInputSource()).build();
    reader.setDefaultAgencyId(feedId.getId());
    reader.run();
    CalendarService calendarService = createCalendarService(dao);
    return new GtfsContextImpl(feedId, dao, calendarService);
}
Also used : GtfsReader(org.onebusaway.gtfs.serialization.GtfsReader) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) GtfsRelationalDaoImpl(org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl) CalendarService(org.onebusaway.gtfs.services.calendar.CalendarService)

Aggregations

GtfsFeedId (org.opentripplanner.graph_builder.module.GtfsFeedId)2 Test (org.junit.Test)1 GtfsRelationalDaoImpl (org.onebusaway.gtfs.impl.GtfsRelationalDaoImpl)1 GtfsReader (org.onebusaway.gtfs.serialization.GtfsReader)1 MockGtfs (org.onebusaway.gtfs.services.MockGtfs)1 CalendarService (org.onebusaway.gtfs.services.calendar.CalendarService)1 TransitBoardAlight (org.opentripplanner.routing.edgetype.TransitBoardAlight)1 TripPattern (org.opentripplanner.routing.edgetype.TripPattern)1 Edge (org.opentripplanner.routing.graph.Edge)1 Graph (org.opentripplanner.routing.graph.Graph)1