private static void onlyKeepCenterOfStreetsOrAddresses(final List<Result> filtered) {
    final Map<String, List<Result>> resultsPerStreet = new HashMap<String, List<Result>>();
    for (Result result : filtered) {
      switch (result.getGeocodeQuality()) {
          // sometimes several results for one given address... Just keep one.
        case ADDRESS:
        case CITY:
        case COUNTRY:
        case STATE:
          // when no street number is available, one gets matches all along the street.
        case STREET:
          final String street = result.getFormattedAddress();
          final List<Result> inStreet = MapUtils.getList(street, resultsPerStreet);
          inStreet.add(result);
          break;
        case UNKNOWN:
        case INTERSECTION:
        case COUNTY:
        case POINT:
        case ZIP:
        case ZIP_EXTENDED:
        default:
          break;
      }
    }

    for (List<Result> inStreet : resultsPerStreet.values()) {
      final Coord coord = getCenter(inStreet);
      final Result toKeep = getClosest(coord, inStreet);
      inStreet.remove(toKeep);
      filtered.removeAll(inStreet);
    }
  }
示例#2
0
 private String getActivityType(String s) {
   String type = typeMap.get(s);
   if (type == null) {
     log.warn("There is no activity type mapping for " + s + "! Returning NULL");
   }
   MapUtils.addToInteger(type, typeCount, 0, 1);
   return type;
 }