use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsHelperV2 method addSituationExchangeToSiriForStops.
public void addSituationExchangeToSiriForStops(ServiceDelivery serviceDelivery, List<MonitoredStopVisitStructure> visits, TransitDataService transitDataService, List<AgencyAndId> stopIds) {
Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();
for (MonitoredStopVisitStructure visit : visits) {
if (visit.getMonitoredVehicleJourney() != null)
addSituationElement(transitDataService, ptSituationElements, visit.getMonitoredVehicleJourney().getSituationRef());
}
if (stopIds != null && stopIds.size() > 0) {
for (AgencyAndId stopId : stopIds) {
String stopIdString = stopId.toString();
// First get service alerts for the stop
SituationQueryBean query = new SituationQueryBean();
List<String> stopIdStrings = new ArrayList<String>();
stopIdStrings.add(stopIdString);
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setStopId(stopIdString);
addFromQuery(transitDataService, ptSituationElements, query);
// Now also add service alerts for (route+direction)s of the stop
query = new SituationQueryBean();
StopBean stopBean = transitDataService.getStop(stopIdString);
List<RouteBean> routes = stopBean.getRoutes();
for (RouteBean route : routes) {
StopsForRouteBean stopsForRoute = transitDataService.getStopsForRoute(route.getId());
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGrouping : stopGroupings) {
if (!stopGrouping.getType().equalsIgnoreCase("direction"))
continue;
for (StopGroupBean stopGroup : stopGrouping.getStopGroups()) {
handleStopGroupBean(stopIdString, query, route, stopGroup);
}
}
}
addFromQuery(transitDataService, ptSituationElements, query);
}
}
addPtSituationElementsToServiceDelivery(serviceDelivery, ptSituationElements);
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getStop.
public StopV2Bean getStop(StopBean stop) {
StopV2Bean bean = new StopV2Bean();
bean.setCode(stop.getCode());
bean.setDirection(stop.getDirection());
bean.setId(stop.getId());
bean.setLat(stop.getLat());
bean.setLon(stop.getLon());
bean.setLocationType(stop.getLocationType());
bean.setName(stop.getName());
bean.setWheelchairBoarding(stop.getWheelchairBoarding());
List<String> routeIds = new ArrayList<String>();
for (RouteBean route : stop.getRoutes()) {
routeIds.add(route.getId());
addToReferences(route);
}
bean.setRouteIds(routeIds);
return bean;
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class VehiclePositionsForAgencyAction 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()) {
FeedEntity.Builder entity = feed.addEntityBuilder();
entity.setId(Integer.toString(feed.getEntityCount()));
VehiclePosition.Builder vehiclePosition = entity.getVehicleBuilder();
TripStatusBean tripStatus = vehicle.getTripStatus();
if (tripStatus != null) {
TripBean activeTrip = tripStatus.getActiveTrip();
RouteBean route = activeTrip.getRoute();
TripDescriptor.Builder tripDesc = vehiclePosition.getTripBuilder();
tripDesc.setTripId(normalizeId(activeTrip.getId()));
tripDesc.setRouteId(normalizeId(route.getId()));
}
VehicleDescriptor.Builder vehicleDesc = vehiclePosition.getVehicleBuilder();
vehicleDesc.setId(normalizeId(vehicle.getVehicleId()));
CoordinatePoint location = vehicle.getLocation();
if (location != null) {
Position.Builder position = vehiclePosition.getPositionBuilder();
position.setLatitude((float) location.getLat());
position.setLongitude((float) location.getLon());
}
vehiclePosition.setTimestamp(vehicle.getLastUpdateTime() / 1000);
}
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class SearchResultFactoryImplTest method createRouteBean.
private RouteBean createRouteBean() {
Builder builder = RouteBean.builder();
builder.setId(ROUTE_ID);
RouteBean routeBean = builder.create();
return routeBean;
}
use of org.onebusaway.transit_data.model.RouteBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesAction method filterArrivalsAndDeparturesByRoute.
private void filterArrivalsAndDeparturesByRoute(String[] tokens) {
// Filter by route
Set<String> routes = new HashSet<String>();
for (String token : tokens) {
String[] routeNames = token.split(",");
for (String routeName : routeNames) routes.add(routeName);
}
StopsWithArrivalsAndDeparturesBean result = _model.getResult();
Iterator<ArrivalAndDepartureBean> it = result.getArrivalsAndDepartures().iterator();
while (it.hasNext()) {
ArrivalAndDepartureBean bean = it.next();
TripBean trip = bean.getTrip();
RouteBean route = trip.getRoute();
String routeName = RoutePresenter.getNameForRoute(route);
if (!routes.contains(routeName))
it.remove();
}
}
Aggregations