use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class TripStopTimesBeanServiceImpl method getStopTimesForTrip.
/**
**
* Private Methods
***
*/
private TripStopTimesBean getStopTimesForTrip(TripEntry trip) {
AgencyAndId tripId = trip.getId();
TripStopTimesBean bean = new TripStopTimesBean();
TimeZone tz = _agencyService.getTimeZoneForAgencyId(tripId.getAgencyId());
bean.setTimeZone(tz.getID());
for (StopTimeEntry stopTime : trip.getStopTimes()) {
TripStopTimeBean stBean = new TripStopTimeBean();
stBean.setArrivalTime(stopTime.getArrivalTime());
stBean.setDepartureTime(stopTime.getDepartureTime());
StopEntry stopEntry = stopTime.getStop();
StopBean stopBean = _stopBeanService.getStopForId(stopEntry.getId());
stBean.setStop(stopBean);
stBean.setDistanceAlongTrip(stopTime.getShapeDistTraveled());
bean.addStopTime(stBean);
}
return bean;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class GtfsRealtimeEntitySource method getStopId.
public Id getStopId(String stopId) {
for (String agencyId : _agencyIds) {
AgencyAndId id = new AgencyAndId(agencyId, stopId);
StopEntry stop = _transitGraphDao.getStopEntryForId(id);
if (stop != null)
return ServiceAlertLibrary.id(id);
}
try {
AgencyAndId id = AgencyAndId.convertFromString(stopId);
StopEntry stop = _transitGraphDao.getStopEntryForId(id);
if (stop != null)
return ServiceAlertLibrary.id(id);
} catch (IllegalArgumentException ex) {
}
_log.warn("stop not found with id \"{}\"", stopId);
AgencyAndId id = new AgencyAndId(_agencyIds.get(0), stopId);
return ServiceAlertLibrary.id(id);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class RouteBeanServiceImpl method getStopsInOrder.
private List<StopEntry> getStopsInOrder(StopSequenceCollection block) {
DirectedGraph<StopEntry> graph = new DirectedGraph<StopEntry>();
for (StopSequence sequence : block.getStopSequences()) {
StopEntry prev = null;
for (StopEntry stop : sequence.getStops()) {
if (prev != null) {
// We do this to avoid cycles
if (!graph.isConnected(stop, prev))
graph.addEdge(prev, stop);
}
prev = stop;
}
}
StopGraphComparator c = new StopGraphComparator(graph);
return graph.getTopologicalSort(c);
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class StopSequenceCollectionServiceImpl method getStopSequenceAsStopPairSet.
private Set<Pair<StopEntry>> getStopSequenceAsStopPairSet(StopSequence stopSequence) {
Set<Pair<StopEntry>> pairs = new HashSet<Pair<StopEntry>>();
StopEntry prev = null;
for (StopEntry stop : stopSequence.getStops()) {
if (prev != null) {
Pair<StopEntry> pair = Tuples.pair(prev, stop);
pairs.add(pair);
}
prev = stop;
}
return pairs;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class StopSequenceCollectionServiceImpl method getSegmentForStopSequence.
/**
* Compute a {@link Segment} object for the specified {@link StopSequence}. A
* Segment generally captures the start and end location of the stop sequence,
* along with the sequence's total length.
*
* @param pattern
* @return
*/
private Segment getSegmentForStopSequence(StopSequence pattern) {
Segment segment = new Segment();
List<StopEntry> stops = pattern.getStops();
StopEntry prev = null;
for (StopEntry stop : stops) {
if (prev == null) {
segment.fromLat = stop.getStopLat();
segment.fromLon = stop.getStopLon();
} else {
segment.distance += SphericalGeometryLibrary.distance(prev.getStopLat(), prev.getStopLon(), stop.getStopLat(), stop.getStopLon());
}
segment.toLat = stop.getStopLat();
segment.toLon = stop.getStopLon();
prev = stop;
}
return segment;
}
Aggregations