use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class StopTimeServiceImpl method getDepartureForStopAndServiceDate.
@Override
public Range getDepartureForStopAndServiceDate(AgencyAndId stopId, ServiceDate serviceDate) {
StopEntry stop = _graph.getStopEntryForId(stopId, true);
List<BlockStopTimeIndex> indices = _blockIndexService.getStopTimeIndicesForStop(stop);
Range interval = new Range();
for (BlockStopTimeIndex index : indices) {
extendIntervalWithIndex(serviceDate, interval, index);
}
List<FrequencyBlockStopTimeIndex> freqIndices = _blockIndexService.getFrequencyStopTimeIndicesForStop(stop);
for (FrequencyBlockStopTimeIndex index : freqIndices) extendIntervalWithIndex(serviceDate, interval, index);
return interval;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesBeanServiceImpl method getStopTimeInstanceAsBean.
/**
**
* Private Methods
***
*/
private ArrivalAndDepartureBean getStopTimeInstanceAsBean(long time, ArrivalAndDepartureInstance instance, Map<AgencyAndId, StopBean> stopBeanCache) {
ArrivalAndDepartureBean pab = new ArrivalAndDepartureBean();
pab.setServiceDate(instance.getServiceDate());
BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
BlockTripEntry blockTrip = blockStopTime.getTrip();
StopTimeEntry stopTime = blockStopTime.getStopTime();
StopEntry stop = stopTime.getStop();
TripEntry trip = stopTime.getTrip();
TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
pab.setTrip(tripBean);
pab.setBlockTripSequence(blockTrip.getSequence());
pab.setArrivalEnabled(stopTime.getSequence() > 0);
pab.setDepartureEnabled(stopTime.getSequence() + 1 < trip.getStopTimes().size());
StopTimeNarrative stopTimeNarrative = _narrativeService.getStopTimeForEntry(stopTime);
pab.setRouteShortName(stopTimeNarrative.getRouteShortName());
pab.setTripHeadsign(stopTimeNarrative.getStopHeadsign());
StopBean stopBean = stopBeanCache.get(stop.getId());
if (stopBean == null) {
stopBean = _stopBeanService.getStopForId(stop.getId());
stopBeanCache.put(stop.getId(), stopBean);
}
pab.setStop(stopBean);
pab.setStopSequence(stopTime.getSequence());
pab.setTotalStopsInTrip(stopTime.getTotalStopsInTrip());
pab.setStatus("default");
pab.setScheduledArrivalTime(instance.getScheduledArrivalTime());
pab.setScheduledDepartureTime(instance.getScheduledDepartureTime());
FrequencyEntry frequency = instance.getFrequencyLabel();
pab.setFrequency(null);
if (frequency != null) {
FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(instance.getServiceDate(), frequency);
pab.setFrequency(fb);
}
return pab;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class ScheduledBlockLocationServiceImpl method getScheduledBlockLocationWhenAtStopTime.
private ScheduledBlockLocation getScheduledBlockLocationWhenAtStopTime(BlockStopTimeEntry blockStopTime, BlockStopTimeEntry previousBlockStopTime, StopTimeEntry stopTime, int scheduleTime, int stopTimeIndex) {
StopEntry stop = stopTime.getStop();
ScheduledBlockLocation result = new ScheduledBlockLocation();
int shapePointIndex = stopTime.getShapePointIndex();
PointAndOrientation po = getLocationAlongShape(blockStopTime.getTrip(), blockStopTime.getDistanceAlongBlock(), shapePointIndex, shapePointIndex + 1);
if (po != null) {
result.setLocation(po.getPoint());
result.setOrientation(po.getOrientation());
} else {
CoordinatePoint location = new CoordinatePoint(stop.getStopLat(), stop.getStopLon());
result.setLocation(location);
result.setOrientation(0);
}
result.setClosestStop(blockStopTime);
result.setClosestStopTimeOffset(0);
result.setNextStop(blockStopTime);
result.setNextStopTimeOffset(0);
result.setScheduledTime(scheduleTime);
result.setDistanceAlongBlock(blockStopTime.getDistanceAlongBlock());
result.setActiveTrip(blockStopTime.getTrip());
result.setInService(true);
result.setStopTimeIndex(stopTimeIndex);
// If there is more than 1 stop, grab the previous stop
if (blockStopTime.hasPreviousStop()) {
result.setPreviousStop(previousBlockStopTime);
}
return result;
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class BlockIndexFactoryServiceImpl method computeDirectionOfTravel.
private double computeDirectionOfTravel(List<BlockStopTimeEntry> bsts) {
BlockStopTimeEntry fromBst = bsts.get(0);
BlockStopTimeEntry toBst = bsts.get(bsts.size() - 1);
StopEntry fromStop = fromBst.getStopTime().getStop();
StopEntry toStop = toBst.getStopTime().getStop();
return SphericalGeometryLibrary.getOrientation(fromStop.getStopLat(), fromStop.getStopLon(), toStop.getStopLat(), toStop.getStopLon());
}
use of org.onebusaway.transit_data_federation.services.transit_graph.StopEntry in project onebusaway-application-modules by camsys.
the class TransitDataServiceTemplateImpl method createArrivalAndDepartureQuery.
protected ArrivalAndDepartureQuery createArrivalAndDepartureQuery(ArrivalAndDepartureForStopQueryBean query) {
ArrivalAndDepartureQuery adQuery = new ArrivalAndDepartureQuery();
AgencyAndId stopId = AgencyAndIdLibrary.convertFromString(query.getStopId());
StopEntry stop = _transitGraphDao.getStopEntryForId(stopId, true);
AgencyAndId tripId = AgencyAndIdLibrary.convertFromString(query.getTripId());
TripEntry trip = _transitGraphDao.getTripEntryForId(tripId);
if (trip == null)
throw new NoSuchTripServiceException(query.getTripId());
adQuery.setStop(stop);
adQuery.setStopSequence(query.getStopSequence());
adQuery.setTrip(trip);
adQuery.setServiceDate(query.getServiceDate());
adQuery.setVehicleId(AgencyAndIdLibrary.convertFromString(query.getVehicleId()));
adQuery.setTime(query.getTime());
return adQuery;
}
Aggregations