Exemplo n.º 1
0
  public Map<Integer, List<LocationBean>> groupLocationsByWeight() {
    Map<Integer, List<LocationBean>> groupings = new HashMap<Integer, List<LocationBean>>();

    for (LocationBean location : this.locations) {
      int weight = location.getGoogleContourWeightFloor();

      if (!groupings.containsKey(weight)) {
        System.out.println(
            "Creating new grouping for weight: " + weight + " from " + location.getWeight());
        groupings.put(weight, new ArrayList<LocationBean>());
      }
      groupings.get(weight).add(location);
    }

    return groupings;
  }
Exemplo n.º 2
0
  // very innefficient, but works well enough for simple testing
  public void printGrouping(List<LocationBean> grouping, LocationBean[][] locationArray) {
    int rows = locationArray[0].length;
    int cols = locationArray.length;
    LocationBean[][] groupedLocationArray = new LocationBean[cols][rows];

    for (int x = 0; x < rows; x++) {
      for (int y = 0; y < cols; y++) {
        for (LocationBean location : grouping) {
          if (location == locationArray[x][y]) {
            groupedLocationArray[x][y] = new LocationBean(1.0, 1.0, location.getWeight());
          }
        }
      }
    }

    printLocationWeightsAsMap(groupedLocationArray);
  }