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; }
switch (gtfsTrip.getBikesAllowed()) { case 1: return ALLOWED; return NOT_ALLOWED; switch (gtfsTrip.getTripBikesAllowed()) { case 1: return NOT_ALLOWED; return ALLOWED; org.onebusaway.gtfs.model.Route route = gtfsTrip.getRoute(); switch (route.getBikesAllowed()) { case 1:
if (trip.getShapeId() != null) shapePoints = _shapePointsHelper.getShapePointsForShapeId(trip.getShapeId()); Agency agency = trip.getRoute().getAgency(); TimeZone tz = TimeZone.getTimeZone(agency.getTimezone()); LocalizedServiceId lsid = new LocalizedServiceId(trip.getServiceId(), tz); tripEntry.setId(trip.getId()); tripEntry.setDirectionId(unique(trip.getDirectionId())); tripEntry.setServiceId(unique(lsid)); tripEntry.setShapeId(unique(trip.getShapeId())); _log.error("trip " + trip.getId() + " missing stops!"); return null;
private Trip createTrip(GtfsMutableRelationalDao dao, Trip referenceTrip, Trip atisTrip) { Trip trip = new Trip(); trip.setRoute(atisTrip.getRoute()); trip.setId(referenceTrip.getId()); trip.setTripHeadsign(atisTrip.getTripHeadsign()); trip.setDirectionId(atisTrip.getDirectionId()); trip.setShapeId(atisTrip.getShapeId()); trip.setPeakOffpeak(atisTrip.getPeakOffpeak()); trip.setMtaTripId(referenceTrip.getId().getId()); dao.saveOrUpdateEntity(trip); //_log.info("Created new trip: {}", trip.getId().getId()); return trip; }
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()); } } }
trip.getId().setAgencyId(reader.getDefaultAgencyId());
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)); } }
Trip newTrip = new Trip(trip); String id = newTrip.getId().getId(); if (preIndex != null) { id += "-" + operation.getToStopId(); newTrip.setId(new AgencyAndId(trip.getId().getAgencyId(), id)); Set<AgencyAndId> shapeIds = new HashSet<AgencyAndId>(dao.getAllShapeIds()); for (Trip trip : dao.getAllTrips()) { shapeIds.remove(trip.getShapeId());
private TripNarrative getTripNarrative(Trip trip) { String headsign = trip.getTripHeadsign(); if (headsign == null) { Route route = trip.getRoute(); headsign = route.getLongName(); } TripNarrative.Builder builder = TripNarrative.builder(); builder.setRouteShortName(deduplicate(trip.getRouteShortName())); builder.setTripHeadsign(deduplicate(headsign)); builder.setTripShortName(deduplicate(trip.getTripShortName())); return builder.create(); }
AgencyAndId service = pattern.getExemplar().getServiceId(); if (options.serviceOn(service, serviceDate)) { Route route = trip.getRoute(); RouteSpec spec = new RouteSpec(route.getId().getAgencyId(), GtfsLibrary.getRouteName(route)); if (options.bannedRoutes.contains(spec)) { state1.tripId = trip.getId(); state1.justTransferred = true; state1.setZoneAndRoute(pattern.getZone(stopIndex), pattern.getExemplar().getRoute().getId(), pattern.getFareContext()); long transfer_penalty = 0; if (options.optimizeFor == OptimizeType.TRANSFERS && state0.getTrip() != -1) {
@Override public List<String> getTripAgencyIdsReferencingServiceId(AgencyAndId serviceId) { if (_tripAgencyIdsByServiceId == null) { Map<AgencyAndId, Set<String>> agencyIdsByServiceIds = new HashMap<AgencyAndId, Set<String>>(); for (Trip trip : getAllTrips()) { AgencyAndId tripId = trip.getId(); String tripAgencyId = tripId.getAgencyId(); AgencyAndId tripServiceId = trip.getServiceId(); Set<String> agencyIds = agencyIdsByServiceIds.get(tripServiceId); if (agencyIds == null) { agencyIds = new HashSet<String>(); agencyIdsByServiceIds.put(tripServiceId, agencyIds); } agencyIds.add(tripAgencyId); } _tripAgencyIdsByServiceId = new HashMap<AgencyAndId, List<String>>(); for (Map.Entry<AgencyAndId, Set<String>> entry : agencyIdsByServiceIds.entrySet()) { AgencyAndId tripServiceId = entry.getKey(); List<String> agencyIds = new ArrayList<String>(entry.getValue()); Collections.sort(agencyIds); _tripAgencyIdsByServiceId.put(tripServiceId, agencyIds); } } List<String> agencyIds = _tripAgencyIdsByServiceId.get(serviceId); if (agencyIds == null) agencyIds = new ArrayList<String>(); return agencyIds; }
private String areTripsEquivalent(Trip tripA, Trip tripB) { if (!equals(tripA.getDirectionId(), tripB.getDirectionId())) return "directionId"; if (!equals(tripA.getRoute(), tripB.getRoute())) return "route"; if (!equals(tripA.getRouteShortName(), tripB.getRouteShortName())) return "routeShortName"; if (!equals(tripA.getShapeId(), tripB.getShapeId())) return "shapeId"; if (!equals(tripA.getTripHeadsign(), tripB.getTripHeadsign())) return "tripHeadsign"; if (!equals(tripA.getTripShortName(), tripB.getTripShortName())) return "tripShortName"; return null; }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); String agency = dao.getAllTrips().iterator().next().getId().getAgencyId(); referenceTrips.put(trip.getId().getId(), trip); matches = 0; for (Trip trip : dao.getAllTrips()) { if (referenceTrips.containsKey(trip.getId().getId())) { matches++; serviceAgencyAndId = trip.getServiceId(); if (dao.getCalendarDatesForServiceId(serviceAgencyAndId).size() == 0) { countNoCd++; for (ServiceCalendarDate calDate : dao.getCalendarDatesForServiceId(trip.getServiceId())) { Date date = removeTime(calDate.getDate().getAsDate()); Date today = removeTime(new Date()); if (trip.getTripHeadsign() == null) { countNoHs++;
public String getName() { return GtfsLibrary.getRouteName(targetTrip.getRoute()); }
if (trip.getTripShortName() != null) { boolean isExpress = trip.getTripShortName().equals("EXPRESS"); if (isExpress) expressCount++; if (trip == null || trip.getTripShortName() == null) continue; boolean isExpress = trip.getTripShortName().equals("EXPRESS"); if (isExpress) { _log.info("route(" + route.getShortName() + ") gets an E for trip " + trip.getId()); trip.setRouteShortName(trip.getRoute().getShortName() + "E"); if (addLocalVsExpressToTripName) { String tripHeadsign = trip.getTripHeadsign(); if (tripHeadsign != null) trip.setTripHeadsign(tripHeadsign + " - Express");
BlockTask(Trip t) { this.route = t.getRoute(); this.cal = _dao.getCalendarForServiceId(t.getServiceId()); }
private BasicTripPattern makeTripPattern(Graph graph, Trip trip, List<StopTime> stopTimes, FareContext fareContext) { BasicTripPattern tripPattern = new BasicTripPattern(trip, stopTimes, fareContext); TraverseMode mode = GtfsLibrary.getTraverseMode(trip.getRoute()); int lastStop = stopTimes.size() - 1; int dwellTime = st0.getDepartureTime() - st0.getArrivalTime(); String departId = id(s0.getId()) + "_" + id(trip.getId()) + "_" + st0.getStopSequence() + "_D"; String arriveId = id(s1.getId()) + "_" + id(trip.getId()) + "_" + st1.getStopSequence() + "_A"; if (i != 0) { startJourneyArrive = graph.addVertex( id(s0.getId()) + "_" + id(trip.getId()) + "_" + st0.getStopSequence() + "_A", s0.getName(), s0.getId().getId(), s0.getLon(), s0.getLat()); tripPattern); hop.setFareContext(fareContext); hop.setGeometry(getHopGeometry(trip.getShapeId(), st0, st1, startJourneyDepart, endJourneyArrive)); tripPattern.setTripFlags(0, (trip.getWheelchairAccessible() != 0) ? TripPattern.FLAG_WHEELCHAIR_ACCESSIBLE : 0);
TripIdentifier getTripAsIdentifier(final Trip trip) { String routeName = trip.getRoute().getId().getId(); int startTime = -1, endTime = -1; String startStop; String[] parts = trip.getId().getId().toUpperCase().split("_"); if (parts.length > 2) { return new TripIdentifier(routeName, startTime, endTime, startStop, run, trip.getBlockId());
@Override public void run() { logger.header("gtfs_trips_with_missing_shape_ids.csv", "agency_id,trip_id"); for (Trip trip : _dao.getAllTrips()) { if (trip.getShapeId() == null) { logger.log("gtfs_trips_with_missing_shape_ids.csv", trip.getId().getAgencyId(), trip.getId().getId()); } } }
String agency = reference.getAllTrips().iterator().next().getId().getAgencyId(); ArrayList<String> missingStops = new ArrayList<>(); trip.setTripHeadsign(tripHeadSign); _log.error("No stoptimes for trip {} mta id", trip.toString(), trip.getMtaTripId()); if (trip.getTripHeadsign() == null && trip.getRouteShortName() == null) { _log.error("Removing trip {}", trip.getId()); dao.removeEntity(trip);