use of uk.org.siri.siri20.VehicleActivityStructure in project OpenTripPlanner by opentripplanner.
the class SiriFuzzyTripMatcher method match.
/**
* Matches VehicleActivity to a set of possible Trips based on tripId
*/
public Set<Trip> match(VehicleActivityStructure activity) {
VehicleActivityStructure.MonitoredVehicleJourney monitoredVehicleJourney = activity.getMonitoredVehicleJourney();
Set<Trip> trips = new HashSet<>();
if (monitoredVehicleJourney != null) {
String datedVehicleRef = null;
if (monitoredVehicleJourney.getFramedVehicleJourneyRef() != null) {
datedVehicleRef = monitoredVehicleJourney.getFramedVehicleJourneyRef().getDatedVehicleJourneyRef();
if (datedVehicleRef != null) {
trips = mappedTripsCache.get(datedVehicleRef);
}
}
if (monitoredVehicleJourney.getDestinationRef() != null) {
String destinationRef = monitoredVehicleJourney.getDestinationRef().getValue();
ZonedDateTime arrivalTime = monitoredVehicleJourney.getDestinationAimedArrivalTime();
if (arrivalTime != null) {
trips = getMatchingTripsOnStopOrSiblings(destinationRef, arrivalTime);
}
}
}
return trips;
}
use of uk.org.siri.siri20.VehicleActivityStructure in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method getVehicleActivityForRoute.
/**
* SIRI METHODS
*/
@Override
public List<VehicleActivityStructure> getVehicleActivityForRoute(String routeId, String directionId, int maximumOnwardCalls, DetailLevel detailLevel, long currentTime) {
List<VehicleActivityStructure> output = new ArrayList<VehicleActivityStructure>();
ListBean<TripDetailsBean> trips = getAllTripsForRoute(routeId, currentTime);
for (TripDetailsBean tripDetails : trips.getList()) {
if (tripDetails == null)
continue;
// filter out interlined routes
if (routeId != null && !tripDetails.getTrip().getRoute().getId().equals(routeId))
continue;
// filtered out by user
if (directionId != null && !tripDetails.getTrip().getDirectionId().equals(directionId))
continue;
if (!_presentationService.include(tripDetails.getStatus()))
continue;
VehicleActivityStructure activity = new VehicleActivityStructure();
activity.setRecordedAtTime(DateUtil.toXmlGregorianCalendar(tripDetails.getStatus().getLastUpdateTime()));
List<TimepointPredictionRecord> timePredictionRecords = null;
timePredictionRecords = _transitDataService.getPredictionRecordsForTrip(AgencyAndId.convertFromString(routeId).getAgencyId(), tripDetails.getStatus());
boolean showApc = useApc();
if (!TransitDataConstants.STATUS_CANCELED.equals(tripDetails.getStatus().getStatus())) {
activity.setMonitoredVehicleJourney(new MonitoredVehicleJourney());
SiriSupportV2.fillMonitoredVehicleJourney(activity.getMonitoredVehicleJourney(), tripDetails.getTrip(), tripDetails.getStatus(), null, OnwardCallsMode.VEHICLE_MONITORING, _presentationService, _transitDataService, maximumOnwardCalls, timePredictionRecords, tripDetails.getStatus().isPredicted(), showApc, detailLevel, currentTime, null);
}
output.add(activity);
}
Collections.sort(output, new Comparator<VehicleActivityStructure>() {
public int compare(VehicleActivityStructure arg0, VehicleActivityStructure arg1) {
try {
SiriExtensionWrapper wrapper0 = (SiriExtensionWrapper) arg0.getMonitoredVehicleJourney().getMonitoredCall().getExtensions().getAny();
SiriExtensionWrapper wrapper1 = (SiriExtensionWrapper) arg1.getMonitoredVehicleJourney().getMonitoredCall().getExtensions().getAny();
return wrapper0.getDistances().getDistanceFromCall().compareTo(wrapper1.getDistances().getDistanceFromCall());
} catch (Exception e) {
return -1;
}
}
});
return output;
}
Aggregations