Search in sources :

Example 56 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId 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 57 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class LocationStringParserTest method testWithId.

@Test
public void testWithId() {
    GenericLocation loc = LocationStringParser.fromOldStyleString("name::aFeed:A1B2C3");
    assertEquals("name", loc.label);
    assertEquals(loc.stopId, new FeedScopedId("aFeed", "A1B2C3"));
    assertNull(loc.lat);
    assertNull(loc.lng);
    assertNull(loc.getCoordinate());
    loc = LocationStringParser.fromOldStyleString("feed:4321");
    assertNull(loc.label);
    assertEquals(loc.stopId, new FeedScopedId("feed", "4321"));
    assertNull(loc.lat);
    assertNull(loc.lng);
    assertNull(loc.getCoordinate());
}
Also used : GenericLocation(org.opentripplanner.model.GenericLocation) FeedScopedId(org.opentripplanner.model.FeedScopedId) Test(org.junit.Test)

Example 58 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class FeedScopedIdMapperTest method testMapAgencyAndId.

@Test
public void testMapAgencyAndId() throws Exception {
    org.onebusaway.gtfs.model.AgencyAndId inputId = new org.onebusaway.gtfs.model.AgencyAndId("A", "1");
    FeedScopedId mappedId = mapAgencyAndId(inputId);
    assertEquals("A", mappedId.getFeedId());
    assertEquals("1", mappedId.getId());
}
Also used : AgencyAndIdMapper.mapAgencyAndId(org.opentripplanner.gtfs.mapping.AgencyAndIdMapper.mapAgencyAndId) FeedScopedId(org.opentripplanner.model.FeedScopedId) Test(org.junit.Test)

Example 59 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class TestBanning method getTestRoutes.

private Collection<Route> getTestRoutes() {
    Route route1 = new Route();
    route1.setId(new FeedScopedId("RB", "RUT:Route:1"));
    route1.setLongName("");
    Route route2 = new Route();
    route2.setId(new FeedScopedId("RB", "RUT:Route:2"));
    route2.setLongName("");
    Route route3 = new Route();
    route3.setId(new FeedScopedId("RB", "RUT:Route:3"));
    route3.setLongName("");
    Agency agency1 = new Agency(new FeedScopedId("RB", "RUT:Agency:1"), "A", "Europe/Paris");
    Agency agency2 = new Agency(new FeedScopedId("RB", "RUT:Agency:2"), "B", "Europe/Paris");
    route1.setAgency(agency1);
    route2.setAgency(agency1);
    route3.setAgency(agency2);
    return Arrays.asList(route1, route2, route3);
}
Also used : Agency(org.opentripplanner.model.Agency) FeedScopedId(org.opentripplanner.model.FeedScopedId) Route(org.opentripplanner.model.Route)

Example 60 with FeedScopedId

use of org.opentripplanner.model.FeedScopedId in project OpenTripPlanner by opentripplanner.

the class TestBanning method testSetBannedOnRequest.

@Test
public void testSetBannedOnRequest() {
    Collection<Route> routes = getTestRoutes();
    RoutingRequest routingRequest = new RoutingRequest();
    routingRequest.setBannedRoutesFromSting("RB__RUT:Route:1");
    routingRequest.setBannedAgenciesFromSting("RB:RUT:Agency:2");
    Collection<FeedScopedId> bannedRoutes = routingRequest.getBannedRoutes(routes);
    Assert.assertEquals(2, bannedRoutes.size());
    Assert.assertTrue(bannedRoutes.contains(new FeedScopedId("RB", "RUT:Route:1")));
    Assert.assertTrue(bannedRoutes.contains(new FeedScopedId("RB", "RUT:Route:3")));
}
Also used : FeedScopedId(org.opentripplanner.model.FeedScopedId) RoutingRequest(org.opentripplanner.routing.api.request.RoutingRequest) Route(org.opentripplanner.model.Route) Test(org.junit.Test)

Aggregations

FeedScopedId (org.opentripplanner.model.FeedScopedId)117 Trip (org.opentripplanner.model.Trip)32 Test (org.junit.Test)29 Stop (org.opentripplanner.model.Stop)25 TripPattern (org.opentripplanner.model.TripPattern)25 ServiceDate (org.opentripplanner.model.calendar.ServiceDate)21 ArrayList (java.util.ArrayList)20 Route (org.opentripplanner.model.Route)15 HashSet (java.util.HashSet)11 List (java.util.List)11 Agency (org.opentripplanner.model.Agency)11 Collection (java.util.Collection)9 Map (java.util.Map)9 Collectors (java.util.stream.Collectors)9 ZonedDateTime (java.time.ZonedDateTime)8 TransitEntity (org.opentripplanner.model.TransitEntity)8 RoutingService (org.opentripplanner.routing.RoutingService)8 TripTimes (org.opentripplanner.routing.trippattern.TripTimes)8 Notice (org.opentripplanner.model.Notice)7 Station (org.opentripplanner.model.Station)7