use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method reverseFrequency.
public FrequencyBean reverseFrequency(FrequencyV2Bean frequency) {
FrequencyBean bean = new FrequencyBean();
bean.setStartTime(frequency.getStartTime());
bean.setEndTime(frequency.getEndTime());
bean.setHeadway(frequency.getHeadway());
bean.setExactTimes(frequency.getExactTimes());
return bean;
}
use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class TripStatusBeanServiceImpl method getBlockLocationAsStatusBean.
@Override
public TripStatusBean getBlockLocationAsStatusBean(BlockLocation blockLocation, long time) {
TripStatusBean bean = new TripStatusBean();
bean.setStatus("default");
BlockInstance blockInstance = blockLocation.getBlockInstance();
long serviceDate = blockInstance.getServiceDate();
bean.setServiceDate(serviceDate);
bean.setLastUpdateTime(blockLocation.getLastUpdateTime());
bean.setLastLocationUpdateTime(blockLocation.getLastLocationUpdateTime());
bean.setLastKnownLocation(blockLocation.getLastKnownLocation());
bean.setLastKnownOrientation(blockLocation.getLastKnownOrientation());
bean.setLocation(blockLocation.getLocation());
bean.setOrientation(blockLocation.getOrientation());
bean.setLastKnownLocation(blockLocation.getLastKnownLocation());
if (blockLocation.isLastKnownOrientationSet())
bean.setLastKnownOrientation(blockLocation.getLastKnownOrientation());
bean.setScheduleDeviation(blockLocation.getScheduleDeviation());
BlockTripInstance activeTripInstance = blockLocation.getActiveTripInstance();
if (activeTripInstance != null) {
BlockTripEntry activeBlockTrip = activeTripInstance.getBlockTrip();
bean.setScheduledDistanceAlongTrip(blockLocation.getScheduledDistanceAlongBlock() - activeBlockTrip.getDistanceAlongBlock());
bean.setDistanceAlongTrip(blockLocation.getDistanceAlongBlock() - activeBlockTrip.getDistanceAlongBlock());
TripEntry activeTrip = activeBlockTrip.getTrip();
bean.setTotalDistanceAlongTrip(activeTrip.getTotalTripDistance());
TripBean activeTripBean = _tripBeanService.getTripForId(activeTrip.getId());
bean.setActiveTrip(activeTripBean);
bean.setBlockTripSequence(activeBlockTrip.getSequence());
if (blockLocation.isLastKnownDistanceAlongBlockSet()) {
bean.setLastKnownDistanceAlongTrip(blockLocation.getLastKnownDistanceAlongBlock() - activeBlockTrip.getDistanceAlongBlock());
}
FrequencyEntry frequencyLabel = activeTripInstance.getFrequencyLabel();
if (frequencyLabel != null) {
FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(serviceDate, frequencyLabel);
bean.setFrequency(fb);
}
} else {
_log.warn("no active block trip for block location: blockInstance=" + blockLocation.getBlockInstance() + " time=" + time);
}
BlockStopTimeEntry closestStop = blockLocation.getClosestStop();
if (closestStop != null) {
StopTimeEntry stopTime = closestStop.getStopTime();
StopBean stopBean = _stopBeanService.getStopForId(stopTime.getStop().getId());
bean.setClosestStop(stopBean);
bean.setClosestStopTimeOffset(blockLocation.getClosestStopTimeOffset());
}
BlockStopTimeEntry nextStop = blockLocation.getNextStop();
if (nextStop != null) {
StopTimeEntry stopTime = nextStop.getStopTime();
StopBean stopBean = _stopBeanService.getStopForId(stopTime.getStop().getId());
bean.setNextStop(stopBean);
bean.setNextStopTimeOffset(blockLocation.getNextStopTimeOffset());
bean.setNextStopDistanceFromVehicle(blockLocation.getNextStop().getDistanceAlongBlock() - blockLocation.getDistanceAlongBlock());
}
BlockStopTimeEntry previousStop = blockLocation.getPreviousStop();
if (previousStop != null) {
StopTimeEntry stopTime = previousStop.getStopTime();
StopBean stopBean = _stopBeanService.getStopForId(stopTime.getStop().getId());
bean.setPreviousStop(stopBean);
bean.setPreviousStopTimeOffset(blockLocation.getPreviousStopTimeOffset());
bean.setPreviousStopDistanceFromVehicle(blockLocation.getPreviousStop().getDistanceAlongBlock() - blockLocation.getDistanceAlongBlock());
}
EVehiclePhase phase = blockLocation.getPhase();
if (phase != null)
bean.setPhase(phase.toLabel());
String status = blockLocation.getStatus();
if (status != null)
bean.setStatus(status);
if (blockLocation.getVehicleType() != null)
bean.setVehicleType(blockLocation.getVehicleType().toLabel());
bean.setPredicted(blockLocation.isPredicted());
AgencyAndId vid = blockLocation.getVehicleId();
if (vid != null)
bean.setVehicleId(ApplicationBeanLibrary.getId(vid));
if (activeTripInstance != null) {
List<ServiceAlertBean> situations = _serviceAlertBeanService.getServiceAlertsForVehicleJourney(time, activeTripInstance, blockLocation.getVehicleId());
if (!situations.isEmpty())
bean.setSituations(situations);
}
if (blockLocation.getTimepointPredictions() != null && blockLocation.getTimepointPredictions().size() > 0) {
List<TimepointPredictionBean> timepointPredictions = new ArrayList<TimepointPredictionBean>();
for (TimepointPredictionRecord tpr : blockLocation.getTimepointPredictions()) {
TimepointPredictionBean tpb = new TimepointPredictionBean();
tpb.setTimepointId(tpr.getTimepointId().toString());
tpb.setTripId(tpr.getTripId().toString());
tpb.setStopSequence(tpr.getStopSequence());
tpb.setTimepointPredictedArrivalTime(tpr.getTimepointPredictedArrivalTime());
tpb.setTimepointPredictedDepartureTime(tpr.getTimepointPredictedDepartureTime());
timepointPredictions.add(tpb);
}
bean.setTimepointPredictions(timepointPredictions);
}
return bean;
}
use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class FrequencyBeanLibrary method getBeanForFrequency.
public static FrequencyBean getBeanForFrequency(long serviceDate, FrequencyEntry frequency) {
if (frequency == null)
return null;
FrequencyBean bean = new FrequencyBean();
bean.setStartTime(serviceDate + frequency.getStartTime() * 1000);
bean.setEndTime(serviceDate + frequency.getEndTime() * 1000);
bean.setHeadway(frequency.getHeadwaySecs());
bean.setExactTimes(frequency.getExactTimes());
return bean;
}
Aggregations