use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.
the class GenerateNarrativesTask method getAllOrientationsForStop.
private Collection<PointAndOrientation> getAllOrientationsForStop(NarrativeProviderImpl provider, StopEntry stop) {
List<BlockStopTimeIndex> stopTimeIndices = _blockIndexService.getStopTimeIndicesForStop(stop);
List<PointAndOrientation> pos = new ArrayList<PointAndOrientation>();
Map<ShapeIdAndDistance, PointAndOrientation> orientationsByKey = new HashMap<ShapeIdAndDistance, PointAndOrientation>();
for (BlockStopTimeIndex stopTimeIndex : stopTimeIndices) {
for (BlockStopTimeEntry blockStopTime : stopTimeIndex.getStopTimes()) {
StopTimeEntry stopTime = blockStopTime.getStopTime();
TripEntry trip = stopTime.getTrip();
AgencyAndId shapeId = trip.getShapeId();
if (shapeId == null)
continue;
ShapePoints shapePoints = provider.getShapePointsForId(shapeId);
if (shapePoints == null)
continue;
int shapePointIndex = stopTime.getShapePointIndex();
if (shapePointIndex == -1)
continue;
ShapeIdAndDistance key = new ShapeIdAndDistance(shapeId, stopTime.getShapeDistTraveled());
PointAndOrientation orientation = orientationsByKey.get(key);
if (orientation == null) {
int indexFrom = Math.max(0, shapePointIndex - 5);
int indexTo = Math.min(shapePoints.getSize(), shapePointIndex + 5);
ShapePointIndex shapePointIndexMethod = new DistanceTraveledShapePointIndex(stopTime.getShapeDistTraveled(), indexFrom, indexTo);
orientation = shapePointIndexMethod.getPointAndOrientation(shapePoints);
if (orientation == null)
continue;
orientationsByKey.put(key, orientation);
}
pos.add(orientation);
}
}
return orientationsByKey.values();
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.
the class RunTripEntry method getStopTime.
public int getStopTime() {
// this run could end before the last stop
int lastTime = reliefTime;
if (lastTime < 0) {
List<StopTimeEntry> stopTimes = entry.getStopTimes();
StopTimeEntry lastStopTime = stopTimes.get(stopTimes.size() - 1);
lastTime = lastStopTime.getDepartureTime();
}
return lastTime;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.
the class UnitTestingSupport method addStopTime.
public static StopTimeEntryImpl addStopTime(TripEntryImpl trip, StopTimeEntryImpl stopTime) {
List<StopTimeEntry> stopTimes = trip.getStopTimes();
if (stopTimes == null) {
stopTimes = new ArrayList<StopTimeEntry>();
trip.setStopTimes(stopTimes);
}
int sequence = stopTimes.size();
if (!stopTimes.isEmpty()) {
StopTimeEntry prev = stopTimes.get(stopTimes.size() - 1);
stopTime.setAccumulatedSlackTime(prev.getAccumulatedSlackTime() + prev.getSlackTime());
}
stopTimes.add(stopTime);
stopTime.setTrip(trip);
stopTime.setSequence(sequence);
return stopTime;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.
the class BlockStopSequenceIndex method computeServiceInterval.
/**
**
* Private Methods
***
*/
private ServiceInterval computeServiceInterval(BlockSequenceIndex index, int stopIndex) {
List<BlockSequence> sequences = _index.getSequences();
BlockStopTimeEntry fromBst = sequences.get(0).getStopTimes().get(stopIndex);
BlockStopTimeEntry toBst = sequences.get(sequences.size() - 1).getStopTimes().get(stopIndex);
StopTimeEntry fromSt = fromBst.getStopTime();
StopTimeEntry toSt = toBst.getStopTime();
return new ServiceInterval(fromSt.getArrivalTime(), fromSt.getDepartureTime(), toSt.getArrivalTime(), toSt.getDepartureTime());
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry in project onebusaway-application-modules by camsys.
the class GtfsController method getStops.
@RequestMapping(value = "/stops/{agencyId}/{id}")
@ResponseBody
public List<CoordinatePoint> getStops(@PathVariable String agencyId, @PathVariable String id) {
AgencyAndId routeId = new AgencyAndId(agencyId, id);
RouteEntry route = _transitGraphDao.getRouteForId(routeId);
TripEntry trip = routeToTrip(route);
List<StopTimeEntry> stopTimes = trip.getStopTimes();
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
for (StopTimeEntry entry : stopTimes) {
StopEntry stop = entry.getStop();
points.add(stop.getStopLocation());
}
return points;
}
Aggregations