use of uk.org.siri.siri_2.OnwardCallStructure in project onebusaway-application-modules by camsys.
the class SiriSupportV2 method getOnwardCallStructure.
private static OnwardCallStructure getOnwardCallStructure(StopBean stopBean, PresentationService presentationService, double distanceOfCallAlongTrip, double distanceOfVehicleFromCall, int visitNumber, int index, TimepointPredictionRecord prediction, long responseTimestamp) {
OnwardCallStructure onwardCallStructure = new OnwardCallStructure();
onwardCallStructure.setVisitNumber(BigInteger.valueOf(visitNumber));
StopPointRefStructure stopPointRef = new StopPointRefStructure();
stopPointRef.setValue(stopBean.getId());
onwardCallStructure.setStopPointRef(stopPointRef);
NaturalLanguageStringStructure stopPoint = new NaturalLanguageStringStructure();
stopPoint.setValue(stopBean.getName());
onwardCallStructure.getStopPointName().add(stopPoint);
if (prediction != null) {
if (prediction.getTimepointPredictedArrivalTime() < responseTimestamp) {
// TODO - LCARABALLO - should this be setExpectedArrivalTime?
onwardCallStructure.setExpectedArrivalTime(DateUtil.toXmlGregorianCalendar(responseTimestamp));
onwardCallStructure.setExpectedDepartureTime(DateUtil.toXmlGregorianCalendar(responseTimestamp));
} else {
onwardCallStructure.setExpectedArrivalTime(DateUtil.toXmlGregorianCalendar(prediction.getTimepointPredictedArrivalTime()));
onwardCallStructure.setExpectedDepartureTime(DateUtil.toXmlGregorianCalendar(prediction.getTimepointPredictedArrivalTime()));
}
}
// Distances
NaturalLanguageStringStructure presentableDistance = new NaturalLanguageStringStructure();
presentableDistance.setValue(presentationService.getPresentableDistance(distanceOfVehicleFromCall, index));
onwardCallStructure.setNumberOfStopsAway(BigInteger.valueOf(index));
onwardCallStructure.setDistanceFromStop(new BigDecimal(distanceOfVehicleFromCall).toBigInteger());
onwardCallStructure.setArrivalProximityText(presentableDistance);
return onwardCallStructure;
}
Aggregations