Search in sources :

Example 1 with OnwardCallStructure

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;
}
Also used : NaturalLanguageStringStructure(uk.org.siri.siri_2.NaturalLanguageStringStructure) StopPointRefStructure(uk.org.siri.siri_2.StopPointRefStructure) OnwardCallStructure(uk.org.siri.siri_2.OnwardCallStructure) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 NaturalLanguageStringStructure (uk.org.siri.siri_2.NaturalLanguageStringStructure)1 OnwardCallStructure (uk.org.siri.siri_2.OnwardCallStructure)1 StopPointRefStructure (uk.org.siri.siri_2.StopPointRefStructure)1