use of com.baeldung.spring.form.GeoIP in project tutorials by eugenp.
the class RawDBDemoGeoIPLocationService method getLocation.
public GeoIP getLocation(String ip) throws IOException, GeoIp2Exception {
InetAddress ipAddress = InetAddress.getByName(ip);
CityResponse response = dbReader.city(ipAddress);
String cityName = response.getCity().getName();
String latitude = response.getLocation().getLatitude().toString();
String longitude = response.getLocation().getLongitude().toString();
return new GeoIP(ip, cityName, latitude, longitude);
}
Aggregations