public void getRate() {
    RouteId id = new RouteId();
    HubEntity hub = hubsRegistry.findHubByName(selectedHub);
    CoefficientsInfo coef = hubsRegistry.getCoefficientsForHub(selectedHub);
    id.setDestName(Parser.getCity(destination));
    id.setDestState(Parser.getState(destination));
    id.setHubName(hub.getCity());
    id.setHubState(hub.getState());
    RouteEntity route = repo.findRoute(id);

    if (route == null) {
      try {
        route =
            GoogleHandler.createRouteEntity(
                id.getHubName(), id.getHubState(), id.getDestName(), id.getDestState());
        route = repo.saveRoute(route, id);
      } 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();
      }
    }
    float interceptX = coef.getIntercept().getX();
    float rate = 0;
    if (route.getDistanceInMiles() < interceptX) {
      rate = route.getDistanceInMiles() * coef.getCoef1().getBeta() + coef.getCoef1().getAlpha();
    } else {
      rate = route.getDistanceInMiles() * coef.getCoef2().getBeta() + coef.getCoef2().getAlpha();
    }

    Messanger.show(
        "Got rate ",
        route.getDestName() + " : " + route.getDistanceInMiles() + "mi, rate: " + rate);
  }
 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;
 }