private Map<String, List<StopBean>> createDirectionToStopBeansMap(String routeId) { Map<String, List<StopBean>> directionIdToStopBeans = new HashMap<String, List<StopBean>>(); StopsForRouteBean stopsForRoute = transitService.getStopsForRoute(routeId); List<StopBean> stopBeansList = stopsForRoute.getStops(); List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings(); for (StopGroupingBean stopGroupingBean : stopGroupings) { List<StopGroupBean> stopGroups = stopGroupingBean.getStopGroups(); for (StopGroupBean stopGroupBean : stopGroups) { NameBean name = stopGroupBean.getName(); String type = name.getType(); if (!type.equals("destination")) continue; List<StopBean> stopsForDirection = new ArrayList<StopBean>(); String directionId = stopGroupBean.getId(); Set<String> stopIds = new HashSet<String>(stopGroupBean.getStopIds()); for (StopBean stopBean : stopBeansList) { String stopBeanId = stopBean.getId(); if (stopIds.contains(stopBeanId)) stopsForDirection.add(stopBean); } directionIdToStopBeans.put(directionId, stopsForDirection); } } return directionIdToStopBeans; }
private void handleStopGroupBean(String stopIdString, SituationQueryBean query, RouteBean route, StopGroupBean stopGroup) { List<StopGroupBean> subGroups = stopGroup.getSubGroups(); if (subGroups != null && !subGroups.isEmpty()) { for (StopGroupBean stopSubGroup : subGroups) { handleStopGroupBean(stopIdString, query, route, stopSubGroup); } } String direction = stopGroup.getId(); for (String groupStopId : stopGroup.getStopIds()) { if (groupStopId.equals(stopIdString)) { SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean(); query.getAffects().add(affects); affects.setRouteId(route.getId()); affects.setDirectionId(direction); } } }
private void groupByDirection(StopSelectionTreeBean tree, StopsForRouteBean stopsForRoute, StopGroupingBean byDirection, Map<String, StopBean> stopsById) { List<StopGroupBean> groups = byDirection.getStopGroups(); if (groups.isEmpty()) { groupByStop(tree, stopsForRoute.getStops()); return; } for (StopGroupBean group : groups) { StopSelectionTreeBean subTree = tree.getSubTree(group.getName()); List<StopBean> stops = new ArrayList<StopBean>(); for (String stopId : group.getStopIds()) stops.add(stopsById.get(stopId)); groupByStop(subTree, stops); } }
List<EncodedPolylineBean> polylines = _shapeBeanService.getMergedPolylinesForShapeIds(shapeIds); StopGroupBean group = new StopGroupBean(); group.setId(block.getPublicId()); group.setName(name); group.setStopIds(groupStopIds); group.setPolylines(polylines); directionGroups.add(group);
for (StopGroupBean stopGroup : stopGrouping.getStopGroups()) { String directionId = stopGroup.getId(); if (stopGroup.getStopIds().contains(stopBean.getId())) { if (!routesByDirection.containsKey(directionId)) { routesByDirection.put(directionId,
private String getName(StopGroupBean bean) { StringBuilder b = new StringBuilder(); for (String name : bean.getName().getNames()) b.append(name); return b.toString(); } });
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; }
List<EncodedPolylineBean> polylines = _shapeBeanService.getMergedPolylinesForShapeIds(shapeIds); StopGroupBean group = new StopGroupBean(); group.setId(block.getPublicId()); group.setName(name); group.setStopIds(groupStopIds); group.setPolylines(polylines); directionGroups.add(group);
private void groupByDirection(StopSelectionTreeBean tree, StopsForRouteBean stopsForRoute, StopGroupingBean byDirection, Map<String, StopBean> stopsById) { List<StopGroupBean> groups = byDirection.getStopGroups(); if (groups.isEmpty()) { groupByStop(tree, stopsForRoute.getStops()); return; } for (StopGroupBean group : groups) { StopSelectionTreeBean subTree = tree.getSubTree(group.getName()); List<StopBean> stops = new ArrayList<StopBean>(); for (String stopId : group.getStopIds()) stops.add(stopsById.get(stopId)); groupByStop(subTree, stops); } }
private String getName(StopGroupBean bean) { StringBuilder b = new StringBuilder(); for (String name : bean.getName().getNames()) b.append(name); return b.toString(); } });
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; }