use of com.maxmind.geoip2.record.Subdivision in project nutch by apache.
the class GeoIPDocumentCreator method createDocFromCityDb.
public static NutchDocument createDocFromCityDb(String serverIp, NutchDocument doc, DatabaseReader reader) throws UnknownHostException, IOException, GeoIp2Exception {
doc.add("ip", serverIp);
CityResponse response = reader.city(InetAddress.getByName(serverIp));
City city = response.getCity();
// 'Minneapolis'
doc.add("cityName", city.getName());
// 50
doc.add("cityConfidence", city.getConfidence());
doc.add("cityGeoNameId", city.getGeoNameId());
Continent continent = response.getContinent();
doc.add("continentCode", continent.getCode());
doc.add("continentGeoNameId", continent.getGeoNameId());
doc.add("continentName", continent.getName());
Country country = response.getCountry();
// 'US'
doc.add("countryIsoCode", country.getIsoCode());
// 'United States'
doc.add("countryName", country.getName());
// 99
doc.add("countryConfidence", country.getConfidence());
doc.add("countryGeoName", country.getGeoNameId());
Location location = response.getLocation();
// 44.9733,
doc.add("latLon", location.getLatitude() + "," + location.getLongitude());
// -93.2323
// 3
doc.add("accRadius", location.getAccuracyRadius());
// 'America/Chicago'
doc.add("timeZone", location.getTimeZone());
doc.add("metroCode", location.getMetroCode());
Postal postal = response.getPostal();
// '55455'
doc.add("postalCode", postal.getCode());
// 40
doc.add("postalConfidence", postal.getConfidence());
RepresentedCountry rCountry = response.getRepresentedCountry();
doc.add("countryType", rCountry.getType());
Subdivision subdivision = response.getMostSpecificSubdivision();
// 'Minnesota'
doc.add("subDivName", subdivision.getName());
// 'MN'
doc.add("subDivIdoCode", subdivision.getIsoCode());
// 90
doc.add("subDivConfidence", subdivision.getConfidence());
doc.add("subDivGeoNameId", subdivision.getGeoNameId());
return doc;
}
Aggregations