use of uk.org.siri.siri.MonitoredCallStructure in project onebusaway-application-modules by camsys.
the class SearchResultFactoryImpl method getPresentableTime.
private String getPresentableTime(MonitoredVehicleJourneyStructure journey, long updateTime, boolean isStopContext) {
NaturalLanguageStringStructure progressStatus = journey.getProgressStatus();
MonitoredCallStructure monitoredCall = journey.getMonitoredCall();
if (!isStopContext) {
return null;
}
int staleTimeout = _configurationService.getConfigurationValueAsInteger("display.staleTimeout", 120);
long age = (SystemTime.currentTimeMillis() - updateTime) / 1000;
if (age > staleTimeout) {
return null;
}
if (monitoredCall.getExpectedArrivalTime() != null) {
long predictedArrival = monitoredCall.getExpectedArrivalTime().getTime();
SiriExtensionWrapper wrapper = (SiriExtensionWrapper) monitoredCall.getExtensions().getAny();
SiriDistanceExtension distanceExtension = wrapper.getDistances();
String distance = distanceExtension.getPresentableDistance();
double minutes = Math.floor((predictedArrival - updateTime) / 60 / 1000);
String timeString = Math.round(minutes) + " minute" + ((Math.abs(minutes) != 1) ? "s" : "");
if (progressStatus != null && progressStatus.getValue().contains("prevTrip")) {
return timeString;
} else {
return "<strong>" + timeString + "</strong>" + ", " + distance;
}
}
return null;
}
Aggregations