use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getStopsForRoute.
public StopsForRouteV2Bean getStopsForRoute(StopsForRouteBean stopsForRoute, boolean includePolylines) {
StopsForRouteV2Bean bean = new StopsForRouteV2Bean();
RouteBean route = stopsForRoute.getRoute();
if (route != null) {
addToReferences(route);
bean.setRouteId(route.getId());
}
List<String> stopIds = new ArrayList<String>();
for (StopBean stop : stopsForRoute.getStops()) {
stopIds.add(stop.getId());
addToReferences(stop);
}
bean.setStopIds(stopIds);
bean.setStopGroupings(stopsForRoute.getStopGroupings());
if (!includePolylines) {
for (StopGroupingBean grouping : stopsForRoute.getStopGroupings()) {
for (StopGroupBean group : grouping.getStopGroups()) group.setPolylines(null);
}
}
if (includePolylines)
bean.setPolylines(stopsForRoute.getPolylines());
return bean;
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getStopSchedule.
public StopScheduleV2Bean getStopSchedule(StopScheduleBean stopSchedule) {
StopScheduleV2Bean bean = new StopScheduleV2Bean();
StopBean stop = stopSchedule.getStop();
if (stop != null) {
addToReferences(stop);
bean.setStopId(stop.getId());
}
bean.setDate(stopSchedule.getDate().getTime());
List<StopRouteScheduleV2Bean> stopRouteScheduleBeans = new ArrayList<StopRouteScheduleV2Bean>();
for (StopRouteScheduleBean stopRouteSchedule : stopSchedule.getRoutes()) {
StopRouteScheduleV2Bean stopRouteScheduleBean = getStopRouteSchedule(stopRouteSchedule);
stopRouteScheduleBeans.add(stopRouteScheduleBean);
}
bean.setStopRouteSchedules(stopRouteScheduleBeans);
return bean;
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getArrivalAndDeparture.
public ArrivalAndDepartureV2Bean getArrivalAndDeparture(ArrivalAndDepartureBean ad) {
TripBean trip = ad.getTrip();
RouteBean route = trip.getRoute();
StopBean stop = ad.getStop();
ArrivalAndDepartureV2Bean bean = new ArrivalAndDepartureV2Bean();
bean.setTripId(trip.getId());
addToReferences(trip);
bean.setServiceDate(ad.getServiceDate());
bean.setVehicleId(ad.getVehicleId());
bean.setStopId(stop.getId());
addToReferences(stop);
bean.setStopSequence(ad.getStopSequence());
bean.setBlockTripSequence(ad.getBlockTripSequence());
bean.setTotalStopsInTrip(ad.getTotalStopsInTrip());
bean.setRouteId(route.getId());
addToReferences(route);
String routeShortName = ad.getRouteShortName();
if (routeShortName == null || routeShortName.isEmpty())
routeShortName = trip.getRouteShortName();
if (routeShortName == null || routeShortName.isEmpty())
routeShortName = route.getShortName();
bean.setRouteShortName(routeShortName);
bean.setRouteLongName(route.getLongName());
String tripHeadsign = ad.getTripHeadsign();
if (tripHeadsign == null || tripHeadsign.isEmpty())
tripHeadsign = trip.getTripHeadsign();
bean.setTripHeadsign(tripHeadsign);
bean.setArrivalEnabled(ad.isArrivalEnabled());
bean.setDepartureEnabled(ad.isDepartureEnabled());
bean.setScheduledArrivalTime(ad.getScheduledArrivalTime());
bean.setScheduledDepartureTime(ad.getScheduledDepartureTime());
bean.setPredictedArrivalTime(ad.getPredictedArrivalTime());
bean.setPredictedDepartureTime(ad.getPredictedDepartureTime());
bean.setScheduledArrivalInterval(getTimeInterval(ad.getScheduledArrivalInterval()));
bean.setScheduledDepartureInterval(getTimeInterval(ad.getScheduledDepartureInterval()));
bean.setPredictedArrivalInterval(getTimeInterval(ad.getPredictedArrivalInterval()));
bean.setPredictedDepartureInterval(getTimeInterval(ad.getPredictedDepartureInterval()));
if (ad.getFrequency() != null)
bean.setFrequency(getFrequency(ad.getFrequency()));
bean.setStatus(ad.getStatus());
if (ad.isDistanceFromStopSet())
bean.setDistanceFromStop(ad.getDistanceFromStop());
bean.setNumberOfStopsAway(ad.getNumberOfStopsAway());
TripStatusBean tripStatus = ad.getTripStatus();
if (tripStatus != null)
bean.setTripStatus(getTripStatus(tripStatus));
bean.setPredicted(ad.isPredicted());
bean.setLastUpdateTime(ad.getLastUpdateTime());
List<ServiceAlertBean> situations = ad.getSituations();
if (situations != null && !situations.isEmpty()) {
List<String> situationIds = new ArrayList<String>();
for (ServiceAlertBean situation : situations) {
situationIds.add(situation.getId());
addToReferences(situation);
}
bean.setSituationIds(situationIds);
}
return bean;
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class TripUpdatesForAgencyAction method fillFeedMessage.
@Override
protected void fillFeedMessage(FeedMessage.Builder feed, String agencyId, long timestamp) {
ListBean<VehicleStatusBean> vehicles = _service.getAllVehiclesForAgency(agencyId, timestamp);
for (VehicleStatusBean vehicle : vehicles.getList()) {
TripStatusBean tripStatus = vehicle.getTripStatus();
if (tripStatus == null) {
continue;
}
TripBean activeTrip = tripStatus.getActiveTrip();
RouteBean route = activeTrip.getRoute();
FeedEntity.Builder entity = feed.addEntityBuilder();
entity.setId(Integer.toString(feed.getEntityCount()));
TripUpdate.Builder tripUpdate = entity.getTripUpdateBuilder();
TripDescriptor.Builder tripDesc = tripUpdate.getTripBuilder();
tripDesc.setTripId(normalizeId(activeTrip.getId()));
tripDesc.setRouteId(normalizeId(route.getId()));
VehicleDescriptor.Builder vehicleDesc = tripUpdate.getVehicleBuilder();
vehicleDesc.setId(normalizeId(vehicle.getVehicleId()));
if (tripStatus.getTimepointPredictions() != null && tripStatus.getTimepointPredictions().size() > 0) {
for (TimepointPredictionBean timepointPrediction : tripStatus.getTimepointPredictions()) {
AgencyAndId stopId = modifiedStopId(agencyId, timepointPrediction.getTimepointId());
if (!stopId.getAgencyId().equals(agencyId))
continue;
TripUpdate.StopTimeUpdate.Builder stopTimeUpdate = tripUpdate.addStopTimeUpdateBuilder();
stopTimeUpdate.setStopId(normalizeId(stopId.toString()));
TripUpdate.StopTimeEvent.Builder arrival = stopTimeUpdate.getArrivalBuilder();
if (timepointPrediction.getTimepointPredictedArrivalTime() != -1) {
arrival.setTime(timepointPrediction.getTimepointPredictedArrivalTime() / 1000L);
}
TripUpdate.StopTimeEvent.Builder departure = stopTimeUpdate.getDepartureBuilder();
if (timepointPrediction.getTimepointPredictedDepartureTime() != -1) {
departure.setTime(timepointPrediction.getTimepointPredictedDepartureTime() / 1000L);
}
}
tripUpdate.setTimestamp(vehicle.getLastUpdateTime() / 1000);
} else {
StopBean nextStop = tripStatus.getNextStop();
if (nextStop != null) {
AgencyAndId stopId = modifiedStopId(agencyId, nextStop.getId());
if (stopId.getAgencyId().equals(agencyId)) {
TripUpdate.StopTimeUpdate.Builder stopTimeUpdate = tripUpdate.addStopTimeUpdateBuilder();
stopTimeUpdate.setStopId(normalizeId(stopId.toString()));
TripUpdate.StopTimeEvent.Builder departure = stopTimeUpdate.getDepartureBuilder();
departure.setTime(timestamp / 1000 + tripStatus.getNextStopTimeOffset());
}
}
}
tripUpdate.setDelay((int) tripStatus.getScheduleDeviation());
tripUpdate.setTimestamp(vehicle.getLastUpdateTime() / 1000);
}
}
use of org.onebusaway.transit_data.model.StopBean 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;
}
Aggregations