String url = getGeocodingUrl("latlng=" + latitude + "," + longitude);
Get get = get(url);
String result = get.executeAsString();
if (get.isSuccessful())
try {
GeocodeResponse geocodeResponse = unmarshalGeocode(result);
if (geocodeResponse != null) {
String status = geocodeResponse.getStatus();
if (status.equals(OK))
return extractClosestLocation(geocodeResponse.getResult(), longitude, latitude);
if (status.equals(OVER_QUERY_LIMIT))
throw new ServiceUnavailableException("maps.googleapis.com", url);
}
} catch (JAXBException e) {
throw new IOException("Cannot unmarshall " + result + ": " + e, e);