use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class HibernateGtfsRelationalDaoImplCaltrainTest method testGetStopTimesByTrip.
@Test
public void testGetStopTimesByTrip() {
Trip trip = _dao.getTripForId(aid("10101272009"));
List<StopTime> stopTimes = _dao.getStopTimesForTrip(trip);
assertEquals(22, stopTimes.size());
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class HibernateGtfsRelationalDaoImplCaltrainTest method testGetStopTimesForStop.
@Test
public void testGetStopTimesForStop() {
Stop stop = _dao.getStopForId(aid("Menlo Park Caltrain"));
List<StopTime> stopTimes = _dao.getStopTimesForStop(stop);
assertEquals(208, stopTimes.size());
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class EntityRetentionGraph method retainTrip.
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));
}
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class DeduplicateTripsStrategy method run.
@Override
public void run(TransformContext context, GtfsMutableRelationalDao dao) {
Map<String, List<Trip>> tripsByCommonId = new FactoryMap<String, List<Trip>>(new ArrayList<Trip>());
int total = 0;
int badIds = 0;
for (Trip trip : dao.getAllTrips()) {
AgencyAndId aid = trip.getId();
String id = aid.getId();
int index = id.indexOf('_');
if (index != -1) {
String commonId = id.substring(index + 1);
tripsByCommonId.get(commonId).add(trip);
} else {
badIds++;
}
}
_log.info("trips=" + total + " badIds=" + badIds);
int weird = 0;
int pairs = 0;
int patternMismatch = 0;
int propertyMismatch = 0;
for (List<Trip> trips : tripsByCommonId.values()) {
if (trips.size() == 1)
continue;
if (trips.size() != 2) {
System.out.println("weird: " + trips);
weird++;
continue;
}
pairs++;
Collections.sort(trips, _tripComparator);
Trip tripA = trips.get(0);
Trip tripB = trips.get(1);
List<StopTime> stopTimesA = dao.getStopTimesForTrip(tripA);
List<StopTime> stopTimesB = dao.getStopTimesForTrip(tripB);
StopSequencePattern patternA = StopSequencePattern.getPatternForStopTimes(stopTimesA);
StopSequencePattern patternB = StopSequencePattern.getPatternForStopTimes(stopTimesB);
if (!patternA.equals(patternB)) {
System.out.println(" pattern: " + tripA.getId() + " " + tripB.getId());
patternMismatch++;
continue;
}
String property = areTripsEquivalent(tripA, tripB);
if (property != null) {
System.out.println(" property: " + tripA.getId() + " " + tripB.getId() + " " + property);
propertyMismatch++;
continue;
}
}
_log.info("weird=" + weird + " pairs=" + pairs + " patternMismatch=" + patternMismatch + " propertyMismatch=" + propertyMismatch);
}
use of org.onebusaway.gtfs.model.StopTime in project onebusaway-gtfs-modules by OneBusAway.
the class EnsureStopTimesIncreaseUpdateStrategy method run.
@Override
public void run(TransformContext context, GtfsMutableRelationalDao dao) {
Map<String, List<Trip>> tripsByBlockId = TripsByBlockInSortedOrder.getTripsByBlockInSortedOrder(dao);
int hits = 0;
int total = 0;
int maxDeviation = 0;
for (List<Trip> trips : tripsByBlockId.values()) {
for (Trip trip : trips) {
/*
* we've moved prev variable inside of trips loop,
* thus we've stopped comparing trips against each other, but
* simply compare stop times specific to a trip.
*/
StopTime prev = null;
List<StopTime> stopTimes = dao.getStopTimesForTrip(trip);
int stopTimePosition = -1;
for (StopTime stopTime : stopTimes) {
total++;
stopTimePosition++;
if (prev != null) {
if (prev.getDepartureTime() > stopTime.getArrivalTime()) {
hits++;
int deviation = prev.getDepartureTime() - stopTime.getArrivalTime();
maxDeviation = Math.max(maxDeviation, deviation);
if (deviation > 60)
_log.info("out_of_order_stop_times: prev=" + prev.getDepartureTime() + " stop=" + stopTime.getArrivalTime() + " deviation=" + deviation + " for stopTime " + stopTime + " of trip" + trip + " at " + stopTimePosition + "/" + stopTimes.size());
stopTime.setArrivalTime(prev.getDepartureTime());
if (stopTime.getDepartureTime() < stopTime.getArrivalTime())
stopTime.setDepartureTime(stopTime.getArrivalTime());
}
}
prev = stopTime;
}
}
}
_log.info("stop times out of order: " + hits + "/" + total + " maxDeviation=" + maxDeviation);
}
Aggregations