Request-level and general-purpose geography helpers built on top of GeoIPService: resolving the current request's location, looking up an ISO country code from a country name, and computing great-circle distance between two points. Registered in the application manager as geoManager, so it is reachable from JS, and is also used internally by fraud detection, the geo-location IDP rule, and the MC nonce provider.

Group: Managers


Methods

findLocation()

Returns: CityResponse

Finds the city-level location for the current HTTP request, based on its remote address. When the remote address is a comma-separated proxy chain, only the first non-blank entry is used. The result is cached on the request's attributes so repeated calls within the same request do not repeat the lookup.

findLocation(String ipAddress)

Returns: CityResponse

Finds the city-level location for the given IP address, delegating to GeoIPService. Any failure, including an uninitialised GeoIPService, is caught and logged rather than propagated.

ParameterDescription
ipAddressthe IP address to resolve

findCountryCode(String country)

Returns: String

Finds the ISO 3166-1 alpha-2 country code for the given country name. If the given value is already a valid ISO alpha-2 code, it is returned unchanged. Otherwise, the display name and ISO alpha-3 code of every known country are checked for a case-insensitive match.

ParameterDescription
countrya country name, ISO alpha-2 code or ISO alpha-3 code

distance(double lat1, double lat2, double lon1, double lon2)

Returns: double

Calculates the great-circle distance between two points on the earth's surface, ignoring any altitude difference. Equivalent to calling the six-argument overload with both altitudes set to zero.

ParameterDescription
lat1latitude of the first point, in degrees
lat2latitude of the second point, in degrees
lon1longitude of the first point, in degrees
lon2longitude of the second point, in degrees

distance(double lat1, double lat2, double lon1, double lon2, double el1, double el2)

Returns: double

Calculates the great-circle distance between two points on the earth's surface, using the Haversine formula, taking into account a difference in altitude between the two points. Pass zero for both altitudes if that difference is not of interest.

ParameterDescription
lat1latitude of the first point, in degrees
lat2latitude of the second point, in degrees
lon1longitude of the first point, in degrees
lon2longitude of the second point, in degrees
el1altitude of the first point, in metres
el2altitude of the second point, in metres
To get full access to the Kademi Hub existing customers can login here, or new customers can register here.