use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class MultipleStopsFoundAction method displayData.
private String displayData() {
List<StopBean> stops = (List<StopBean>) sessionMap.get("stops");
int index = 1;
addMessage(Messages.MULTIPLE_STOPS_WERE_FOUND);
for (StopBean stop : stops) {
addMessage(Messages.FOR);
String destination = _destinationPronunciation.modify(stop.getName());
destination = destination.replaceAll("\\&", "and");
addText(destination);
addText(", ");
addMessage(Messages.PLEASE_PRESS);
String key = Integer.toString(index++);
addText(key);
addText(". ");
}
addMessage(Messages.TO_REPEAT);
sessionMap.put("stops", stops);
sessionMap.put("navState", new Integer(DO_ROUTING));
return SUCCESS;
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class StopForCodeAction method execute.
public String execute() throws Exception {
_log.info("in stop for code");
CoordinateBounds bounds = getDefaultSearchArea();
if (bounds == null)
return NEEDS_DEFAULT_SEARCH_LOCATION;
if (_stopCode == null || _stopCode.length() == 0)
return INPUT;
if (_stop != null) {
_stops = Arrays.asList(_stop);
} else {
_log.info("searching on stopCode=" + _stopCode);
SearchQueryBean searchQuery = new SearchQueryBean();
searchQuery.setBounds(bounds);
searchQuery.setMaxCount(5);
searchQuery.setType(EQueryType.BOUNDS_OR_CLOSEST);
searchQuery.setQuery(_stopCode);
StopsBean stopsBean = _transitDataService.getStops(searchQuery);
_stops = stopsBean.getStops();
}
logUserInteraction("query", _stopCode);
if (_stops.size() == 0) {
sessionMap.put("messageFromAction", getText(Messages.NO_STOPS_WERE_FOUND));
sessionMap.put("backAction", "stops-index");
return "noStopsFound";
} else if (_stops.size() == 1) {
StopBean stop = _stops.get(0);
_stopIds = Arrays.asList(stop.getId());
return SUCCESS;
} else {
sessionMap.put("stops", _stops);
return "multipleStopsFound";
}
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class StopFoundAction method execute.
@Override
public String execute() throws Exception {
Integer navState = (Integer) sessionMap.get("navState");
if (navState == null) {
navState = DISPLAY_DATA;
}
_log.debug("StopsForRouteNavigationAction:navState: " + navState);
if (navState == DISPLAY_DATA) {
ActionContext context = ActionContext.getContext();
ValueStack vs = context.getValueStack();
StopBean stop = (StopBean) vs.findValue("stop");
sessionMap.put("stop", stop);
addMessage(Messages.THE_STOP_NUMBER_FOR);
addText(_destinationPronunciation.modify(stop.getName()));
String stopDir = stop.getDirection();
if (stopDir != null && stopDir.length() > 0) {
String direction = _directionPronunciation.modify(stopDir);
addMessage(Messages.DIRECTION_BOUND, direction);
}
addMessage(Messages.IS);
addText(stop.getCode() + ".");
addMessage(Messages.STOP_FOUND_ARRIVAL_INFO);
// AgiActionName arrivalInfoAction = addAction("1", "/stop/arrivalsAndDeparturesForStopId");
// arrivalInfoAction.putParam("stopIds", Arrays.asList(stop.getId()));
addMessage(Messages.STOP_FOUND_BOOKMARK_THIS_LOCATION);
// AgiActionName bookmarkAction = addAction("2", "/stop/bookmark");
// bookmarkAction.putParam("stop", stop);
addMessage(Messages.STOP_FOUND_RETURN_TO_MAIN_MENU);
// addAction("3", "/index");
// addAction("[04-9]", "/repeat");
addMessage(Messages.HOW_TO_GO_BACK);
// addAction("\\*", "/back");
addMessage(Messages.TO_REPEAT);
sessionMap.put("navState", new Integer(DO_ROUTING));
return SUCCESS;
} else {
if (PREVIOUS_MENU_ITEM.equals(getInput())) {
return "back";
} else if ("1".equals(getInput())) {
StopBean stop = (StopBean) sessionMap.get("stop");
_stopIds = Arrays.asList(stop.getId());
return "arrivals-and-departures";
} else if ("2".equals(getInput())) {
StopBean stop = (StopBean) sessionMap.get("stop");
_stopIds = Arrays.asList(stop.getId());
return "bookmark-stop";
}
return SUCCESS;
}
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class SearchResultFactoryImpl method getRouteResult.
@Override
public SearchResult getRouteResult(RouteBean routeBean) {
List<RouteDirection> directions = new ArrayList<RouteDirection>();
StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(routeBean.getId());
// create stop ID->stop bean map
Map<String, StopBean> stopIdToStopBeanMap = new HashMap<String, StopBean>();
for (StopBean stopBean : stopsForRoute.getStops()) {
stopIdToStopBeanMap.put(stopBean.getId(), stopBean);
}
// add stops in both directions
List<VehicleActivityStructure> journeyList = _realtimeService.getVehicleActivityForRoute(routeBean.getId(), null, 0, SystemTime.currentTimeMillis(), false);
Map<String, List<String>> stopIdToDistanceAwayStringMap = new HashMap<String, List<String>>();
Map<String, List<String>> stopIdToVehicleIdMap = new HashMap<String, List<String>>();
Map<String, Boolean> stopIdToRealtimeDataMap = new HashMap<String, Boolean>();
// build map of stop IDs to list of distance strings
for (VehicleActivityStructure journey : journeyList) {
// on detour?
MonitoredCallStructure monitoredCall = journey.getMonitoredVehicleJourney().getMonitoredCall();
if (monitoredCall == null) {
continue;
}
String stopId = monitoredCall.getStopPointRef().getValue();
fillDistanceAwayStringsList(journey.getMonitoredVehicleJourney(), journey.getRecordedAtTime(), stopId, stopIdToDistanceAwayStringMap);
fillVehicleIdsStringList(journey.getMonitoredVehicleJourney(), journey.getRecordedAtTime(), stopId, stopIdToVehicleIdMap);
fillRealtimeData(journey.getMonitoredVehicleJourney(), stopId, stopIdToRealtimeDataMap);
}
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGroupingBean : stopGroupings) {
for (StopGroupBean stopGroupBean : stopGroupingBean.getStopGroups()) {
NameBean name = stopGroupBean.getName();
String type = name.getType();
if (!type.equals("destination"))
continue;
// service in this direction
Boolean hasUpcomingScheduledService = _transitDataService.routeHasUpcomingScheduledService((routeBean.getAgency() != null ? routeBean.getAgency().getId() : null), SystemTime.currentTimeMillis(), routeBean.getId(), stopGroupBean.getId());
// if there are buses on route, always have "scheduled service"
Boolean routeHasVehiclesInService = _realtimeService.getVehiclesInServiceForRoute(routeBean.getId(), stopGroupBean.getId(), SystemTime.currentTimeMillis());
if (routeHasVehiclesInService) {
hasUpcomingScheduledService = true;
}
// stops in this direction
List<StopOnRoute> stopsOnRoute = null;
if (!stopGroupBean.getStopIds().isEmpty()) {
stopsOnRoute = new ArrayList<StopOnRoute>();
for (String stopId : stopGroupBean.getStopIds()) {
if (_transitDataService.stopHasRevenueServiceOnRoute((routeBean.getAgency() != null ? routeBean.getAgency().getId() : null), stopId, routeBean.getId(), stopGroupBean.getId())) {
stopsOnRoute.add(new StopOnRoute(stopIdToStopBeanMap.get(stopId), stopIdToDistanceAwayStringMap.get(stopId), stopIdToRealtimeDataMap.get(stopId), stopIdToVehicleIdMap.get(stopId)));
}
}
}
directions.add(new RouteDirection(stopGroupBean.getName().getName(), stopGroupBean, stopsOnRoute, hasUpcomingScheduledService, null));
}
}
// service alerts in this direction
Set<String> serviceAlertDescriptions = new HashSet<String>();
List<ServiceAlertBean> serviceAlertBeans = _realtimeService.getServiceAlertsForRoute(routeBean.getId());
populateServiceAlerts(serviceAlertDescriptions, serviceAlertBeans);
return new RouteResult(routeBean, directions, serviceAlertDescriptions);
}
use of org.onebusaway.transit_data.model.StopBean in project onebusaway-application-modules by camsys.
the class StopsOnRouteForDirectionAction method execute.
@Override
public String execute() {
if (_routeId == null) {
return SUCCESS;
}
StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(_routeId);
// create stop ID->stop bean map
Map<String, StopBean> stopIdToStopBeanMap = new HashMap<String, StopBean>();
for (StopBean stopBean : stopsForRoute.getStops()) {
stopIdToStopBeanMap.put(stopBean.getId(), stopBean);
}
// break up stops into destinations
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGroupingBean : stopGroupings) {
for (StopGroupBean stopGroupBean : stopGroupingBean.getStopGroups()) {
NameBean name = stopGroupBean.getName();
String type = name.getType();
if (!type.equals("destination") || !stopGroupBean.getId().equals(_directionId))
continue;
if (!stopGroupBean.getStopIds().isEmpty()) {
for (String stopId : stopGroupBean.getStopIds()) {
String agencyId = AgencyAndIdLibrary.convertFromString(_routeId).getAgencyId();
if (_transitDataService.stopHasRevenueServiceOnRoute(agencyId, stopId, stopsForRoute.getRoute().getId(), stopGroupBean.getId())) {
_stops.add(new StopOnRoute(stopIdToStopBeanMap.get(stopId)));
}
}
}
}
}
return SUCCESS;
}
Aggregations