route.getId().setAgencyId(reader.getDefaultAgencyId()); generateRouteColor(route);
private Route doMap(org.onebusaway.gtfs.model.Route rhs) { Route lhs = new Route(); lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())); lhs.setAgency(agencyMapper.map(rhs.getAgency())); lhs.setShortName(rhs.getShortName()); lhs.setLongName(rhs.getLongName()); lhs.setType(rhs.getType()); lhs.setDesc(rhs.getDesc()); lhs.setUrl(rhs.getUrl()); lhs.setColor(rhs.getColor()); lhs.setTextColor(rhs.getTextColor()); lhs.setRouteBikesAllowed(rhs.getRouteBikesAllowed()); lhs.setBikesAllowed(rhs.getBikesAllowed()); lhs.setSortOrder(rhs.getSortOrder()); lhs.setBrandingUrl(rhs.getBrandingUrl()); return lhs; } }
@Override @SuppressWarnings("unchecked") public RouteCollection getRouteCollectionForRoute(Route route) { List<Route> routes = Arrays.asList(route); List<RouteCollection> routeCollections = _template.findByNamedQueryAndNamedParam( "routeCollectionsForRoutes", "routes", routes); if (routeCollections.isEmpty()) return null; if (routeCollections.size() > 1) _log.warn("multiple route collections for route id=" + route.getId()); return routeCollections.get(0); }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
private String getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); if (id == null || id.length() == 0) id = trim(route.getLongName()); if (id == null || id.length() == 0) throw new IllegalStateException("no short or long name for route " + route.getId()); id = id.replace('/', '_'); id = id.replace('\\', '_'); return id; }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
public void validateEntity(CsvEntityContext context, Map<String, Object> csvValues, BeanWrapper object) { Route route = object.getWrappedInstance(Route.class); String shortName = route.getShortName(); String longName = route.getLongName(); if ((shortName == null || shortName.length() == 0) && (longName == null || longName.length() == 0)) throw new RouteNameException(route.getId()); } }
public void validateEntity(CsvEntityContext context, Map<String, Object> csvValues, BeanWrapper object) { Route route = object.getWrappedInstance(Route.class); String shortName = route.getShortName(); String longName = route.getLongName(); if ((shortName == null || shortName.length() == 0) && (longName == null || longName.length() == 0)) throw new RouteNameException(route.getId()); } }
private RouteEntryImpl processRoute(TransitGraphImpl graph, Route route) { RouteEntryImpl routeEntry = new RouteEntryImpl(); routeEntry.setId(unique(route.getId())); graph.putRouteEntry(routeEntry); return routeEntry; }
@Transactional public void run() { Collection<Route> routes = _gtfsDao.getAllRoutes(); Map<AgencyAndId, List<Route>> routesByKey = new HashMap<AgencyAndId, List<Route>>(); Counter<Route> tripCounts = new Counter<Route>(); for (Route route : routes) { String id = getRouteCollectionIdForRoute(route); AgencyAndId key = new AgencyAndId(route.getId().getAgencyId(), id); List<Route> forKey = routesByKey.get(key); if (forKey == null) { forKey = new ArrayList<Route>(); routesByKey.put(key, forKey); } forKey.add(route); List<Trip> trips = _gtfsDao.getTripsForRoute(route); tripCounts.increment(route, trips.size()); } for (Map.Entry<AgencyAndId, List<Route>> entry : routesByKey.entrySet()) { AgencyAndId key = entry.getKey(); List<Route> routesForKey = entry.getValue(); RouteCollection routeCollection = new RouteCollection(); routeCollection.setId(key); setPropertiesOfRouteCollectionFromRoutes(routesForKey, tripCounts, routeCollection); routeCollection.setRoutes(routesForKey); _transitDataFederationMutableDao.save(routeCollection); } // _whereMutableDao.flush(); _refreshService.refresh(RefreshableResources.ROUTE_COLLECTIONS_DATA); }
private Pattern getPatternForTrip(GtfsMutableRelationalDao dao, Trip trip) { List<StopTime> stopTimes = dao.getStopTimesForTrip(trip); int n = stopTimes.size(); AgencyAndId[] stopIds = new AgencyAndId[n]; int[] arrivalTimes = new int[n]; int[] departureTimes = new int[n]; for (int i = 0; i < n; i++) { StopTime stopTime = stopTimes.get(i); stopIds[i] = stopTime.getStop().getId(); arrivalTimes[i] = stopTime.getArrivalTime(); departureTimes[i] = stopTime.getDepartureTime(); } return new Pattern(trip.getRoute().getId(), trip.getServiceId(), stopIds, arrivalTimes, departureTimes); }
private Route getShuttleRoute(GtfsMutableRelationalDao dao, Route orig) { Route shuttleRoute = new Route(orig); AgencyAndId id = new AgencyAndId(shuttleRoute.getId().getAgencyId(), shuttleRoute.getId().getId() + SHUTTLE_ID_SUFFIX); shuttleRoute.setId(id); shuttleRoute.setShortName(shuttleRoute.getShortName() + SHUTTLE_ID_SUFFIX); shuttleRoute.setLongName(shuttleRoute.getLongName() + SHUTTLE_NAME_SUFFIX); shuttleRoute.setType(SHUTTLE_ROUTE_TYPE); dao.saveEntity(shuttleRoute); return shuttleRoute; } }
/** * Checks rule E030 - "GTFS-rt alert trip_id does not belong to GTFS-rt alert route_id in GTFS trips.txt" and adds * any errors that are found to the provided errors list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector that has both a routeId and a tripDescriptor * @param gtfsMetadata metadata for the static GTFS data * @param errors list to add any errors for E030 to */ private void checkE030(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { String routeId = entitySelector.getRouteId(); GtfsRealtime.TripDescriptor tripDescriptor = entitySelector.getTrip(); if (tripDescriptor.hasTripId()) { Trip gtfsTrip = gtfsMetadata.getTrips().get(tripDescriptor.getTripId()); if (gtfsTrip != null && !routeId.equals(gtfsTrip.getRoute().getId().getId())) { String prefix = "alert ID " + entity.getId() + " informed_entity.trip.trip_id " + tripDescriptor.getTripId() + " does not belong to informed_entity.route_id " + routeId + " (GTFS says it belongs to route_id " + gtfsTrip.getRoute().getId().getId() + ")"; RuleUtils.addOccurrence(E030, prefix, errors, _log); } } }
private RouteEntryImpl processRoute(TransitGraphImpl graph, Route route) { RouteEntryImpl routeEntry = new RouteEntryImpl(); routeEntry.setId(unique(route.getId())); routeEntry.setType(route.getType()); graph.putRouteEntry(routeEntry); return routeEntry; }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); HashMap<String, Route> referenceRoutes = new HashMap<>(); for (Route route : reference.getAllRoutes()) { referenceRoutes.put(route.getId().getId(), route); } for (Route route: dao.getAllRoutes()) { String identifier = route.getId().getId(); if (identifier.length() > 2) { identifier = identifier.substring(0,2); } Route refRoute = referenceRoutes.get(identifier); if (refRoute != null) { route.setShortName(refRoute.getShortName()); route.setLongName(refRoute.getLongName()); route.setType(refRoute.getType()); route.setDesc(refRoute.getDesc()); route.setUrl(refRoute.getUrl()); route.setColor(refRoute.getColor()); route.setTextColor(refRoute.getTextColor()); route.setId(refRoute.getId()); } } } }
public TraverseResult traverse(State state0, TraverseOptions wo) { State state1 = state0.clone(); state1.incrementTimeInSeconds(elapsed); state1.setZoneAndRoute(getEndStop().getZoneId(), start.getTrip().getRoute().getId(), fareContext); return new TraverseResult(elapsed, state1); }
public TraverseResult traverseBack(State state0, TraverseOptions wo) { State state1 = state0.clone(); state1.incrementTimeInSeconds(-elapsed); state1.setZoneAndRoute(getStartStop().getZoneId(), start.getTrip().getRoute().getId(), fareContext); return new TraverseResult(elapsed, state1); }
public TraverseResult traverse(State state0, TraverseOptions wo) { State state1 = state0.clone(); int runningTime = pattern.getRunningTime(stopIndex, state0.getTrip()); state1.incrementTimeInSeconds(runningTime); state1.setZoneAndRoute(getEndStop().getZoneId(), pattern.getExemplar().getRoute().getId(), context); return new TraverseResult(runningTime, state1); }
public TraverseResult traverseBack(State state0, TraverseOptions wo) { State state1 = state0.clone(); int runningTime = pattern.getRunningTime(stopIndex, state0.getTrip()); state1.incrementTimeInSeconds(-runningTime); state1.setZoneAndRoute(getStartStop().getZoneId(), pattern.getExemplar().getRoute().getId(), context); return new TraverseResult(runningTime, state1); }
private void setLTDRoute(Route daoRoute, Route refRoute) { daoRoute.setShortName(refRoute.getShortName()); daoRoute.setLongName(refRoute.getLongName()); daoRoute.setType(refRoute.getType()); daoRoute.setDesc(refRoute.getDesc()); daoRoute.setUrl(refRoute.getUrl()); daoRoute.setColor(refRoute.getColor()); daoRoute.setTextColor(refRoute.getTextColor()); //set the id to also be the same daoRoute.setId(refRoute.getId()); } }