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