Search in sources :

Example 1 with MockGtfs

use of org.opentripplanner.gtfs.MockGtfs in project OpenTripPlanner by opentripplanner.

the class GtfsGraphBuilderModuleTest method testBikesByDefault.

@Test
public void testBikesByDefault() throws IOException {
    // We configure two trip: one with unknown bikes_allowed and the second with no bikes
    // allowed.
    MockGtfs gtfs = getSimpleGtfs();
    gtfs.putTrips(2, "r0", "sid0", "bikes_allowed=0,2");
    gtfs.putStopTimes("t0,t1", "s0,s1");
    List<GtfsBundle> bundleList = getGtfsAsBundleList(gtfs);
    bundleList.get(0).setDefaultBikesAllowed(true);
    builder = new GtfsModule(bundleList, ServiceDateInterval.unbounded());
    Graph graph = new Graph();
    builder.buildGraph(graph, _extra);
    graph.index();
    // Feed id is used instead of the agency id for OBA entities.
    GtfsBundle gtfsBundle = bundleList.get(0);
    GtfsFeedId feedId = gtfsBundle.getFeedId();
    Trip trip = graph.index.getTripForId().get(new FeedScopedId(feedId.getId(), "t0"));
    TripPattern pattern = graph.index.getPatternForTrip().get(trip);
    List<Trip> trips = pattern.getTrips();
    assertEquals(BikeAccess.ALLOWED, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t0"))));
    assertEquals(BikeAccess.NOT_ALLOWED, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t1"))));
}
Also used : Trip(org.opentripplanner.model.Trip) Graph(org.opentripplanner.routing.graph.Graph) GtfsBundle(org.opentripplanner.graph_builder.model.GtfsBundle) MockGtfs(org.opentripplanner.gtfs.MockGtfs) FeedScopedId(org.opentripplanner.model.FeedScopedId) TripPattern(org.opentripplanner.model.TripPattern) Test(org.junit.Test)

Example 2 with MockGtfs

use of org.opentripplanner.gtfs.MockGtfs in project OpenTripPlanner by opentripplanner.

the class GtfsGraphBuilderModuleTest method getSimpleGtfs.

private MockGtfs getSimpleGtfs() throws IOException {
    MockGtfs gtfs = MockGtfs.create();
    gtfs.putAgencies(1);
    gtfs.putRoutes(1);
    gtfs.putStops(2);
    gtfs.putCalendars(1);
    gtfs.putTrips(1, "r0", "sid0");
    gtfs.putStopTimes("t0", "s0,s1");
    return gtfs;
}
Also used : MockGtfs(org.opentripplanner.gtfs.MockGtfs)

Example 3 with MockGtfs

use of org.opentripplanner.gtfs.MockGtfs in project OpenTripPlanner by opentripplanner.

the class GeometryAndBlockProcessorTest 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();
    Graph graph = new Graph();
    GtfsContext context = new GtfsContextBuilder(feedId, gtfs.read()).withIssueStoreAndDeduplicator(graph).build();
    GeometryAndBlockProcessor factory = new GeometryAndBlockProcessor(context);
    factory.run(graph);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) GtfsFeedId(org.opentripplanner.graph_builder.module.GtfsFeedId) GtfsContext(org.opentripplanner.gtfs.GtfsContext) MockGtfs(org.opentripplanner.gtfs.MockGtfs) GtfsContextBuilder(org.opentripplanner.gtfs.GtfsContextBuilder) GtfsContextBuilder(org.opentripplanner.gtfs.GtfsContextBuilder) Test(org.junit.Test)

Example 4 with MockGtfs

use of org.opentripplanner.gtfs.MockGtfs in project OpenTripPlanner by opentripplanner.

the class GtfsGraphBuilderModuleTest method testNoBikesByDefault.

@Test
public void testNoBikesByDefault() throws IOException {
    // We configure two trip: one with unknown bikes_allowed and the second with bikes
    // allowed.
    MockGtfs gtfs = getSimpleGtfs();
    gtfs.putTrips(2, "r0", "sid0", "bikes_allowed=0,1");
    gtfs.putStopTimes("t0,t1", "s0,s1");
    List<GtfsBundle> bundleList = getGtfsAsBundleList(gtfs);
    bundleList.get(0).setDefaultBikesAllowed(false);
    builder = new GtfsModule(bundleList, ServiceDateInterval.unbounded());
    Graph graph = new Graph();
    builder.buildGraph(graph, _extra);
    graph.index();
    // Feed id is used instead of the agency id for OBA entities.
    GtfsBundle gtfsBundle = bundleList.get(0);
    GtfsFeedId feedId = gtfsBundle.getFeedId();
    Trip trip = graph.index.getTripForId().get(new FeedScopedId(feedId.getId(), "t0"));
    TripPattern pattern = graph.index.getPatternForTrip().get(trip);
    List<Trip> trips = pattern.getTrips();
    assertEquals(BikeAccess.UNKNOWN, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t0"))));
    assertEquals(BikeAccess.ALLOWED, BikeAccess.fromTrip(withId(trips, new FeedScopedId(feedId.getId(), "t1"))));
}
Also used : Trip(org.opentripplanner.model.Trip) Graph(org.opentripplanner.routing.graph.Graph) GtfsBundle(org.opentripplanner.graph_builder.model.GtfsBundle) MockGtfs(org.opentripplanner.gtfs.MockGtfs) FeedScopedId(org.opentripplanner.model.FeedScopedId) TripPattern(org.opentripplanner.model.TripPattern) Test(org.junit.Test)

Aggregations

MockGtfs (org.opentripplanner.gtfs.MockGtfs)4 Test (org.junit.Test)3 Graph (org.opentripplanner.routing.graph.Graph)3 GtfsBundle (org.opentripplanner.graph_builder.model.GtfsBundle)2 FeedScopedId (org.opentripplanner.model.FeedScopedId)2 Trip (org.opentripplanner.model.Trip)2 TripPattern (org.opentripplanner.model.TripPattern)2 GtfsFeedId (org.opentripplanner.graph_builder.module.GtfsFeedId)1 GtfsContext (org.opentripplanner.gtfs.GtfsContext)1 GtfsContextBuilder (org.opentripplanner.gtfs.GtfsContextBuilder)1