Package org.onebusaway.gtfs.model

Examples of org.onebusaway.gtfs.model.Route


    @SuppressWarnings("deprecation")
    @Test
    public void testBikesAllowedOverridesTripBikesAllowed() {
        Trip trip = new Trip();
        Route route = new Route();
        trip.setRoute(route);

        trip.setBikesAllowed(1);
        trip.setTripBikesAllowed(1);
        assertEquals(BikeAccess.ALLOWED, BikeAccess.fromTrip(trip));
View Full Code Here


    r2.setTrips(Arrays.asList(t2, t3));

    Mockito.when(_transitGraphDao.getAllRouteCollections()).thenReturn(
        Arrays.asList((RouteCollectionEntry) rc));

    Route route1 = new Route();
    route1.setId(r1.getId());
    route1.setBikesAllowed(0);
    route1.setColor("#000000");
    route1.setDesc("Route One Desc");
    route1.setLongName("Route One");
    route1.setShortName("One");
    route1.setTextColor("#ff0000");
    route1.setType(3);
    route1.setUrl("http://agency.gov/route-one");

    Route route2 = new Route();
    route2.setId(r2.getId());
    route2.setBikesAllowed(1);
    route2.setColor("#0000ff");
    route2.setDesc("Route Two Desc");
    route2.setLongName("Route Two");
    route2.setShortName("Two");
    route2.setTextColor("#000000");
    route2.setType(3);
    route2.setUrl("http://agency.gov/route-two");

    Mockito.when(_gtfsDao.getRouteForId(r1.getId())).thenReturn(route1);
    Mockito.when(_gtfsDao.getRouteForId(r2.getId())).thenReturn(route2);

    _task.generateRouteNarratives(_provider);

    RouteCollectionNarrative narrative = _provider.getNarrativeForRouteCollectionId(rc.getId());
    assertEquals(route2.getColor(), narrative.getColor());
    assertEquals(route2.getDesc(), narrative.getDescription());
    assertEquals(route2.getLongName(), narrative.getLongName());
    assertEquals(route2.getShortName(), narrative.getShortName());
    assertEquals(route2.getTextColor(), narrative.getTextColor());
    assertEquals(route2.getType(), narrative.getType());
    assertEquals(route2.getUrl(), narrative.getUrl());
  }
View Full Code Here

    routeB.setId(new AgencyAndId("A", "routeB"));
    graph.putRouteEntry(routeB);

    GtfsRelationalDao gtfsDao = Mockito.mock(GtfsRelationalDao.class);

    Route rA = new Route();
    rA.setId(routeA.getId());
    rA.setShortName("10");
    Mockito.when(gtfsDao.getRouteForId(routeA.getId())).thenReturn(rA);

    Route rB = new Route();
    rB.setId(routeB.getId());
    rB.setShortName("10");
    Mockito.when(gtfsDao.getRouteForId(routeB.getId())).thenReturn(rB);

    RouteCollectionEntriesFactory factory = new RouteCollectionEntriesFactory();
    factory.setGroupRoutesByShortName(true);
View Full Code Here

    Agency agency = new Agency();
    agency.setId("1");
    agency.setTimezone("America/Los_Angeles");
    // gtfsDao.saveEntity(agency);

    Route route = new Route();
    route.setId(new AgencyAndId("1", "routeA"));
    route.setAgency(agency);
    Mockito.when(gtfsDao.getAllRoutes()).thenReturn(Arrays.asList(route));

    AgencyAndId shapeId = new AgencyAndId("1", "shapeId");

    Trip trip = new Trip();
    trip.setId(new AgencyAndId("1", "tripA"));
    trip.setRoute(route);
    trip.setServiceId(new AgencyAndId("1", "serviceId"));
    trip.setShapeId(shapeId);
    Mockito.when(gtfsDao.getTripsForRoute(route)).thenReturn(
        Arrays.asList(trip));

    Stop stopA = new Stop();
    stopA.setId(aid("stopA"));

    StopTime stA = new StopTime();
    stA.setId(100);
    stA.setArrivalTime(time(9, 00));
    stA.setDepartureTime(time(9, 05));
    stA.setStopSequence(100);
    stA.setStop(stopA);
    stA.setTrip(trip);

    Stop stopB = new Stop();
    stopB.setId(aid("stopB"));

    StopTime stB = new StopTime();
    stB.setId(101);
    stB.setArrivalTime(time(10, 00));
    stB.setDepartureTime(time(10, 05));
    stB.setStopSequence(102);
    stB.setStop(stopB);
    stB.setTrip(trip);

    Mockito.when(gtfsDao.getStopTimesForTrip(trip)).thenReturn(
        Arrays.asList(stA, stB));

    TransitGraphImpl graph = new TransitGraphImpl();

    graph.putStopEntry(stop("stopA", 47.672207391799056, -122.387855896286));

    graph.putStopEntry(stop("stopB", 47.66852277218285, -122.3853882639923));

    RouteEntryImpl routeEntry = route("routeA");
    graph.putRouteEntry(routeEntry);

    graph.initialize();

    ShapePointsFactory shapePointsFactory = new ShapePointsFactory();
    shapePointsFactory.addPoint(47.673840100841396, -122.38756621771239);
    shapePointsFactory.addPoint(47.668667271970484, -122.38756621771239);
    shapePointsFactory.addPoint(47.66868172192725, -122.3661729186096);
    ShapePoints shapePoints = shapePointsFactory.create();

    ShapePointHelper shapePointHelper = Mockito.mock(ShapePointHelper.class);
    Mockito.when(shapePointHelper.getShapePointsForShapeId(shapeId)).thenReturn(
        shapePoints);

    TripEntriesFactory factory = new TripEntriesFactory();
    factory.setGtfsDao(gtfsDao);
    factory.setShapePointHelper(shapePointHelper);
    factory.setUniqueService(new UniqueServiceImpl());

    StopTimeEntriesFactory stopTimeEntriesFactory = new StopTimeEntriesFactory();
    stopTimeEntriesFactory.setDistanceAlongShapeLibrary(new DistanceAlongShapeLibrary());

    factory.setStopTimeEntriesFactory(stopTimeEntriesFactory);

    factory.processTrips(graph);

    TripEntryImpl entry = graph.getTripEntryForId(trip.getId());
    assertEquals(trip.getId(), entry.getId());
    assertEquals(route.getId(), entry.getRoute().getId());
    assertEquals(lsid("serviceId"), entry.getServiceId());
    assertEquals(trip.getShapeId(), entry.getShapeId());
    assertEquals(2177.1, entry.getTotalTripDistance(), 0.1);

    List<StopTimeEntry> stopTimes = entry.getStopTimes();
View Full Code Here

    Agency agency = new Agency();
    agency.setId("1");
    agency.setTimezone("America/Los_Angeles");

    Route route = new Route();
    route.setAgency(agency);

    Trip trip = new Trip();
    trip.setRoute(route);
    trip.setServiceId(aid("serviceId"));
View Full Code Here

    Agency agency = new Agency();
    agency.setId("1");
    agency.setTimezone("America/Los_Angeles");

    Route route = new Route();
    route.setAgency(agency);

    Trip trip = new Trip();
    trip.setRoute(route);
    trip.setServiceId(aid("serviceId"));
View Full Code Here

    Agency agency = new Agency();
    agency.setId("1");
    agency.setTimezone("America/Los_Angeles");

    Route route = new Route();
    route.setAgency(agency);

    Trip trip = new Trip();
    trip.setRoute(route);
    trip.setServiceId(aid("serviceId"));
View Full Code Here

    _dao = Mockito.mock(GtfsRelationalDao.class);
    _factory.setGtfsDao(_dao);

    _graph = new TransitGraphImpl();

    _route = new Route();
    _route.setId(aid("route"));
    _routeEntry = UnitTestingSupport.route("route");
   
    Mockito.when(_dao.getAllRoutes()).thenReturn(Arrays.asList(_route));
  }
View Full Code Here

    GtfsRelationalDao gtfsDao = Mockito.mock(GtfsRelationalDao.class);

    Agency agency = new Agency();
    agency.setId("A");

    Route routeA = new Route();
    routeA.setAgency(agency);
    routeA.setId(new AgencyAndId("A", "routeA"));

    Route routeB = new Route();
    routeB.setAgency(agency);
    routeB.setId(new AgencyAndId("A", "routeB"));

    Mockito.when(gtfsDao.getAllRoutes()).thenReturn(
        Arrays.asList(routeA, routeB));

    TransitGraphImpl graph = new TransitGraphImpl();

    RouteEntriesFactory factory = new RouteEntriesFactory();
    factory.setGtfsDao(gtfsDao);
    factory.setUniqueService(new UniqueServiceImpl());
    factory.processRoutes(graph);

    RouteEntryImpl routeEntryA = graph.getRouteForId(routeA.getId());

    RouteEntryImpl routeEntryB = graph.getRouteForId(routeB.getId());

    List<RouteEntry> routes = graph.getAllRoutes();
    assertEquals(2, routes.size());
    assertTrue(routes.contains(routeEntryA));
    assertTrue(routes.contains(routeEntryB));
View Full Code Here

  private void createRouteShortNameRouteCollectionMapping(TransitGraphImpl graph) {

    Map<AgencyAndId, List<RouteEntryImpl>> routesByKey = new HashMap<AgencyAndId, List<RouteEntryImpl>>();

    for (RouteEntryImpl routeEntry : graph.getRoutes()) {
      Route route = _gtfsDao.getRouteForId(routeEntry.getId());
      AgencyAndId key = getRouteCollectionIdForRoute(route);
      List<RouteEntryImpl> forKey = routesByKey.get(key);
      if (forKey == null) {
        forKey = new ArrayList<RouteEntryImpl>();
        routesByKey.put(key, forKey);
      }
      forKey.add(routeEntry);
    }

    for (Map.Entry<AgencyAndId, List<RouteEntryImpl>> entry : routesByKey.entrySet()) {
      AgencyAndId key = entry.getKey();
      List<RouteEntryImpl> routesForKey = entry.getValue();

      ArrayList<RouteEntry> children = new ArrayList<RouteEntry>();
      children.addAll(routesForKey);
      children.trimToSize();

      key = _uniqueService.unique(key);

      RouteCollectionEntryImpl routeCollectionEntry = new RouteCollectionEntryImpl();
      routeCollectionEntry.setId(key);
      routeCollectionEntry.setChildren(children);
      graph.putRouteCollectionEntry(routeCollectionEntry);

      for (RouteEntryImpl route : routesForKey)
        route.setParent(routeCollectionEntry);
    }
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.gtfs.model.Route

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.