use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesForStopAction method getArrivalsAsV1.
private List<ArrivalAndDepartureBeanV1> getArrivalsAsV1(StopWithArrivalsAndDeparturesBean result) {
List<ArrivalAndDepartureBeanV1> v1s = new ArrayList<ArrivalAndDepartureBeanV1>();
for (ArrivalAndDepartureBean bean : result.getArrivalsAndDepartures()) {
TripBean trip = bean.getTrip();
RouteBean route = trip.getRoute();
StopBean stop = bean.getStop();
ArrivalAndDepartureBeanV1 v1 = new ArrivalAndDepartureBeanV1();
v1.setPredictedArrivalTime(bean.getPredictedArrivalTime());
v1.setPredictedDepartureTime(bean.getPredictedDepartureTime());
v1.setRouteId(route.getId());
if (trip.getRouteShortName() != null)
v1.setRouteShortName(trip.getRouteShortName());
else
v1.setRouteShortName(route.getShortName());
v1.setScheduledArrivalTime(bean.getScheduledArrivalTime());
v1.setScheduledDepartureTime(bean.getScheduledDepartureTime());
v1.setStatus(bean.getStatus());
v1.setStopId(stop.getId());
v1.setTripHeadsign(trip.getTripHeadsign());
v1.setTripId(trip.getId());
v1s.add(v1);
}
return v1s;
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceImpl method getMonitoredStopVisitsForStop.
@Override
public List<MonitoredStopVisitStructure> getMonitoredStopVisitsForStop(String stopId, int maximumOnwardCalls, long currentTime) {
List<MonitoredStopVisitStructure> output = new ArrayList<MonitoredStopVisitStructure>();
for (ArrivalAndDepartureBean adBean : getArrivalsAndDeparturesForStop(stopId, currentTime)) {
TripStatusBean statusBeanForCurrentTrip = adBean.getTripStatus();
TripBean tripBeanForAd = adBean.getTrip();
final RouteBean routeBean = tripBeanForAd.getRoute();
if (statusBeanForCurrentTrip == null) {
_log.debug("status drop");
continue;
}
if (!_presentationService.include(statusBeanForCurrentTrip) || !_presentationService.include(adBean, statusBeanForCurrentTrip)) {
_log.debug("presentation drop for vehicle=" + statusBeanForCurrentTrip.getVehicleId());
continue;
}
if (!_transitDataService.stopHasRevenueServiceOnRoute((routeBean.getAgency() != null ? routeBean.getAgency().getId() : null), stopId, routeBean.getId(), adBean.getTrip().getDirectionId())) {
_log.debug("non reveunue drop");
continue;
}
// Filter out if the vehicle has realtime information and is ahead of current stop
if (statusBeanForCurrentTrip.isPredicted() && !(adBean.hasPredictedArrivalTime() || adBean.hasPredictedDepartureTime())) {
_log.debug("no realtime drop");
continue;
}
if (statusBeanForCurrentTrip.getVehicleId() != null) {
_log.debug("valid vehicle " + statusBeanForCurrentTrip.getVehicleId());
}
MonitoredStopVisitStructure stopVisit = new MonitoredStopVisitStructure();
// Check for Realtime Data
if (!statusBeanForCurrentTrip.isPredicted()) {
stopVisit.setRecordedAtTime(new Date(getTime()));
} else {
stopVisit.setRecordedAtTime(new Date(statusBeanForCurrentTrip.getLastUpdateTime()));
}
List<TimepointPredictionRecord> timePredictionRecords = null;
timePredictionRecords = createTimePredictionRecordsForStop(adBean, stopId);
stopVisit.setMonitoredVehicleJourney(new MonitoredVehicleJourneyStructure());
SiriSupport.fillMonitoredVehicleJourney(stopVisit.getMonitoredVehicleJourney(), tripBeanForAd, statusBeanForCurrentTrip, adBean.getStop(), OnwardCallsMode.STOP_MONITORING, _presentationService, _transitDataService, maximumOnwardCalls, timePredictionRecords, statusBeanForCurrentTrip.isPredicted(), currentTime, false);
output.add(stopVisit);
}
Collections.sort(output, new Comparator<MonitoredStopVisitStructure>() {
public int compare(MonitoredStopVisitStructure arg0, MonitoredStopVisitStructure arg1) {
try {
Date expectedArrival0 = arg0.getMonitoredVehicleJourney().getMonitoredCall().getExpectedArrivalTime();
Date expectedArrival1 = arg1.getMonitoredVehicleJourney().getMonitoredCall().getExpectedArrivalTime();
return expectedArrival0.compareTo(expectedArrival1);
} catch (Exception e) {
return -1;
}
}
});
return output;
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class BookmarkPresentationServiceImpl method getRoutesForRouteFilter.
private List<RouteBean> getRoutesForRouteFilter(RouteFilterBean routeFilter) {
List<RouteBean> routes = new ArrayList<RouteBean>();
for (String routeId : routeFilter.getRouteIds()) {
RouteBean route = _transitDataService.getRouteForId(routeId);
if (route != null)
routes.add(route);
}
Collections.sort(routes, new RouteNameComparator());
return routes;
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesForRouteAction method getRouteIdsForMatchingRoutes.
private Set<String> getRouteIdsForMatchingRoutes() {
StopsWithArrivalsAndDeparturesBean result = _model.getResult();
Set<String> ids = new HashSet<String>();
for (StopBean stop : result.getStops()) {
for (RouteBean route : stop.getRoutes()) {
if (route.getShortName().equals(_route))
ids.add(route.getId());
}
}
return ids;
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesModel method getRouteKeyForArrivalAndDeparture.
private String getRouteKeyForArrivalAndDeparture(ArrivalAndDepartureBean bean) {
String name = bean.getRouteShortName();
if (name != null)
return name;
TripBean trip = bean.getTrip();
name = trip.getRouteShortName();
if (name != null)
return name;
RouteBean route = trip.getRoute();
name = route.getShortName();
if (name != null)
return name;
return route.getId();
}
Aggregations