private Trip doMap(org.onebusaway.gtfs.model.Trip rhs) { Trip lhs = new Trip(); lhs.setId(AgencyAndIdMapper.mapAgencyAndId(rhs.getId())); lhs.setRoute(routeMapper.map(rhs.getRoute())); lhs.setServiceId(AgencyAndIdMapper.mapAgencyAndId(rhs.getServiceId())); lhs.setTripShortName(rhs.getTripShortName()); lhs.setTripHeadsign(rhs.getTripHeadsign()); lhs.setRouteShortName(rhs.getRouteShortName()); lhs.setDirectionId(rhs.getDirectionId()); lhs.setBlockId(rhs.getBlockId()); lhs.setShapeId(AgencyAndIdMapper.mapAgencyAndId(rhs.getShapeId())); lhs.setWheelchairAccessible(rhs.getWheelchairAccessible()); lhs.setTripBikesAllowed(rhs.getTripBikesAllowed()); lhs.setBikesAllowed(rhs.getBikesAllowed()); lhs.setFareId(rhs.getFareId()); return lhs; }
private void warnOnMissingTrips() { for (Trip t : _gtfsMutableRelationalDao.getAllTrips()) { String blockId = t.getBlockId(); if (blockId == null || blockId.equals("")) { _log.warn("When matching GTFS to STIF, failed to find block in STIF for " + t.getId()); } } }
/** * Checks E047 - "VehiclePosition and TripUpdate ID pairing mismatch" for VehiclePositions, and adds a found error to the provided error list. * * @param vehicle A map entry of a vehicle_id to a trip_id that represents a vehicle in VehiclePositions and the trip_id that the vehicle contains * @param tripUpdatesInverse An inverse map of a TripUpdates feed, with keys that represent the vehicle_ids that each TripUpdate contains, and the value being the TripUpdate trip_id that contains the vehicle.id * @param errors the list to add the errors to */ private void checkE047VehiclePositions(Map.Entry<String, String> vehicle, HashMap<String, String> tripUpdatesInverse, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { String tripUpdatesTripId = tripUpdatesInverse.get(vehicle.getKey()); String vehiclePositionsTripId = vehicle.getValue(); if (!StringUtils.isEmpty(tripUpdatesTripId)) { if (!vehiclePositionsTripId.equals(tripUpdatesTripId)) { // Log E047 if either trip_id is missing from GTFS, if the block_id is missing for either trip (block_id is an optional field) or if the two trips aren't in the same block Trip tripA = gtfsMetadata.getTrips().get(vehiclePositionsTripId); Trip tripB = gtfsMetadata.getTrips().get(tripUpdatesTripId); if (tripA == null || tripB == null || StringUtils.isEmpty(tripA.getBlockId()) || StringUtils.isEmpty(tripB.getBlockId()) || !tripA.getBlockId().equals(tripB.getBlockId())) { // E047 - "VehiclePosition and TripUpdate ID pairing mismatch" for VehiclePositions RuleUtils.addOccurrence(E047, "trip_id " + vehicle.getValue() + " and vehicle_id " + vehicle.getKey() + " pairing in VehiclePositions does not match trip_id " + tripUpdatesTripId + " and vehicle_id " + vehicle.getKey() + " pairing in TripUpdates feed and trip block_ids aren't the same", errors, _log); } } } } }
@Override public List<Trip> getTripsForBlockId(AgencyAndId blockId) { if (_tripsByBlockId == null) { _tripsByBlockId = new HashMap<AgencyAndId, List<Trip>>(); for (Trip trip : getAllTrips()) { if (trip.getBlockId() != null) { AgencyAndId bid = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId()); List<Trip> trips = _tripsByBlockId.get(bid); if (trips == null) { trips = new ArrayList<Trip>(); _tripsByBlockId.put(bid, trips); } trips.add(trip); } } } return list(_tripsByBlockId.get(blockId)); }
private void loadStifBlocks(StifTripLoader loader) { Map<Trip, RawRunData> rawData = loader.getRawRunDataByTrip(); for (Map.Entry<Trip, RawRunData> entry : rawData.entrySet()) { Trip trip = entry.getKey(); if (trip.getBlockId() == null || trip.getBlockId().length() == 0) { RawRunData data = entry.getValue(); trip.setBlockId(trip.getServiceId().getId() + "_STIF_" + data.getDepotCode() + "_" + data.getBlock()); _gtfsMutableRelationalDao.updateEntity(trip); } } }
@Override public List<Trip> getTripsForBlockId(AgencyAndId blockId) { if (_tripsByBlockId == null) { _tripsByBlockId = new HashMap<AgencyAndId, List<Trip>>(); for (Trip trip : getAllTrips()) { if (trip.getBlockId() != null) { AgencyAndId bid = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId()); List<Trip> trips = _tripsByBlockId.get(bid); if (trips == null) { trips = new ArrayList<Trip>(); _tripsByBlockId.put(bid, trips); } trips.add(trip); } } } return list(_tripsByBlockId.get(blockId)); }
String blockId = trip.getBlockId();
private Map<AgencyAndId, List<TripEntryImpl>> getTripsByBlockId( TransitGraphImpl graph) { Collection<Route> routes = _gtfsDao.getAllRoutes(); int routeIndex = 0; Map<AgencyAndId, List<TripEntryImpl>> tripsByBlockId = new FactoryMap<AgencyAndId, List<TripEntryImpl>>( new ArrayList<TripEntryImpl>()); for (Route route : routes) { _log.info("routes: " + (routeIndex++) + "/" + routes.size()); List<Trip> trips = _gtfsDao.getTripsForRoute(route); for (Trip trip : trips) { TripEntryImpl tripEntry = graph.getTripEntryForId(trip.getId()); // If null, probably indicates no stop times, or some other reason to // prune the trip if (tripEntry == null) continue; AgencyAndId blockId = trip.getId(); if (trip.getBlockId() != null) { blockId = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId()); } tripsByBlockId.get(blockId).add(tripEntry); } } return tripsByBlockId; }
private Map<AgencyAndId, List<TripEntryImpl>> getTripsByBlockId( TransitGraphImpl graph) { Collection<Route> routes = _gtfsDao.getAllRoutes(); int routeIndex = 0; Map<AgencyAndId, List<TripEntryImpl>> tripsByBlockId = new FactoryMap<AgencyAndId, List<TripEntryImpl>>( new ArrayList<TripEntryImpl>()); for (Route route : routes) { _log.info("routes: " + (routeIndex++) + "/" + routes.size()); List<Trip> trips = _gtfsDao.getTripsForRoute(route); for (Trip trip : trips) { TripEntryImpl tripEntry = graph.getTripEntryForId(trip.getId()); // If null, probably indicates no stop times, or some other reason to // prune the trip if (tripEntry == null) continue; AgencyAndId blockId = trip.getId(); if (trip.getBlockId() != null) { blockId = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId()); } tripsByBlockId.get(blockId).add(tripEntry); } } return tripsByBlockId; }
if (trip.getBlockId() != null) { trip.getBlockId());
return new TripIdentifier(routeName, startTime, endTime, startStop, run, trip.getBlockId());
private void retainTrip(Trip trip, boolean retainUp) { if (retainUp) { for (StopTime stopTime : _dao.getStopTimesForTrip(trip)) retainUp(stopTime); if (_retainBlocks && trip.getBlockId() != null) { AgencyAndId blockId = new AgencyAndId(trip.getId().getAgencyId(), trip.getBlockId()); retainUp(new BlockIdKey(blockId)); } for (Frequency frequency : _dao.getFrequenciesForTrip(trip)) retainUp(frequency); } else { retainDown(trip.getRoute()); retainDown(new ServiceIdKey(trip.getServiceId())); AgencyAndId shapeId = trip.getShapeId(); if (shapeId != null && shapeId.hasValues()) retainDown(new ShapeIdKey(shapeId)); } }
String blockId = trip.getBlockId();