use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class RouteStopsInCommonDuplicateScoringStrategy method getAllStopsForRoute.
private Set<Stop> getAllStopsForRoute(GtfsRelationalDao dao, Route route) {
Set<Stop> stops = new HashSet<Stop>();
List<Trip> tripsForRoute = new ArrayList<Trip>();
// make this thread safe
tripsForRoute.addAll(dao.getTripsForRoute(route));
for (Trip trip : tripsForRoute) {
List<StopTime> stopTimesForTrip = new ArrayList<StopTime>();
stopTimesForTrip.addAll(dao.getStopTimesForTrip(trip));
for (StopTime stopTime : stopTimesForTrip) {
stops.add(stopTime.getStop());
}
}
return stops;
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class WSFScheduleService method resolve.
public Trip resolve(String departingTerminalId, long departureTime, String arrivingTerminalId) {
ServiceDate initialServiceDate = new ServiceDate(new Date(departureTime * 1000));
int lookBackDays = (_maxStopTime / 86400) + 1;
AgencyAndId stopId = new AgencyAndId(_agencyId, departingTerminalId);
AgencyAndId routeId = new AgencyAndId(_agencyId, departingTerminalId + arrivingTerminalId);
for (StopTime st : _dao.getAllStopTimes()) {
if (st.getStop().getId().equals(stopId) && st.getTrip().getRoute().getId().equals(routeId)) {
ServiceDate sd = initialServiceDate;
for (int i = 0; i < lookBackDays; i++) {
if (_csd.getServiceIdsForDate(sd).contains(st.getTrip().getServiceId()) && st.getDepartureTime() == (departureTime - (sd.getAsCalendar(_agencyTimeZone).getTimeInMillis() / 1000))) {
return st.getTrip();
}
sd = sd.previous();
}
}
}
_log.warn("no trip found for resolve(departId=" + departingTerminalId + ", departureTime=" + departureTime + ", arrivalId=" + arrivingTerminalId + ")");
return null;
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class StopMergeStrategy method replaceDuplicateEntry.
@Override
protected void replaceDuplicateEntry(GtfsMergeContext context, Stop oldStop, Stop newStop) {
GtfsRelationalDao source = context.getSource();
for (StopTime stopTime : source.getStopTimesForStop(oldStop)) {
stopTime.setStop(newStop);
}
MergeSupport.bulkReplaceValueInProperties(source.getAllTransfers(), oldStop, newStop, "fromStop", "toStop");
MergeSupport.bulkReplaceValueInProperties(source.getAllPathways(), oldStop, newStop, "fromStop", "toStop");
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class TrimTripTransformStrategy method getStopIndices.
private Map<String, Integer> getStopIndices(List<StopTime> stopTimes) {
Map<String, Integer> indices = new HashMap<String, Integer>();
int index = 0;
for (StopTime stopTime : stopTimes) {
String id = stopTime.getStop().getId().getId();
if (!indices.containsKey(id)) {
indices.put(id, index);
}
index++;
}
return indices;
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class TripKey method getTripKeyForTrip.
public static TripKey getTripKeyForTrip(GtfsMutableRelationalDao dao, Trip trip) {
List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
Stop[] stops = new Stop[stopTimes.size()];
int[] arrivalTimes = new int[stopTimes.size()];
int[] departureTimes = new int[stopTimes.size()];
for (int i = 0; i < stopTimes.size(); i++) {
StopTime stopTime = stopTimes.get(i);
stops[i] = stopTime.getStop();
arrivalTimes[i] = stopTime.getArrivalTime();
departureTimes[i] = stopTime.getDepartureTime();
}
return new TripKey(stops, arrivalTimes, departureTimes);
}
Aggregations