private ImmutableMap readCoordinates()

in bigtop-data-generators/bigtop-location-data/src/main/java/org/apache/bigtop/datagenerators/locations/LocationReader.java [113:146]


  private ImmutableMap<String, ZipcodeLocationRecord> readCoordinates(
          InputStream path) throws FileNotFoundException {
    Scanner scanner = new Scanner(path);

    // skip header
    scanner.nextLine();

    Map<String, ZipcodeLocationRecord> entries = Maps.newHashMap();
    while (scanner.hasNextLine()) {
      String line = scanner.nextLine().trim();

      String[] cols = line.split(", ");

      // remove quote marks
      String zipcode = cols[0].substring(1, cols[0].length() - 1);
      String state = cols[1].substring(1, cols[1].length() - 1);
      Double latitude = Double
              .parseDouble(cols[2].substring(1, cols[2].length() - 1));
      Double longitude = Double
              .parseDouble(cols[3].substring(1, cols[3].length() - 1));
      String city = cols[4].substring(1, cols[4].length() - 1);

      Pair<Double, Double> coords = Pair.of(latitude, longitude);

      ZipcodeLocationRecord record = new ZipcodeLocationRecord(coords, city,
              state);

      entries.put(zipcode, record);
    }

    scanner.close();

    return ImmutableMap.copyOf(entries);
  }