private List<RouteInfo> getRouteInfoForDestinations( Map<String, Set<String>> from, Map<String, Set<String>> to, List<String> errors) { List<RouteInfo> routes = new ArrayList<RouteInfo>(); // loop through all destination states and find all hubs that belongs to // the catchment for (String destState : to.keySet()) { List<String> reqTo = new ArrayList<String>(), reqFrom = new ArrayList<String>(); for (String destCity : to.get(destState)) { reqTo.add(destCity + "," + destState); } if (from.get(destState) != null) { for (String hubName : from.get(destState)) { reqFrom.add(hubName + "," + destState); } } for (State hubState : catchment.getDestinations().get(State.valueOf(destState))) { if (from.get(hubState.name()) == null) continue; for (String hubName : from.get(hubState.name())) { reqFrom.add(hubName + "," + hubState); } } try { if (!reqFrom.isEmpty() & !reqTo.isEmpty()) routes.addAll(GoogleHandler.getRouteInfoList(reqFrom, reqTo, errors)); } catch (GoogleServiceParamException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (GoogleServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return routes; }