String url = getElevationUrl("locations=" + latitude + "," + longitude); // TODO could be up to 512 locations
Get get = get(url);
String result = get.executeAsString();
if (get.isSuccessful())
try {
ElevationResponse elevationResponse = unmarshalElevation(result);
if (elevationResponse != null) {
String status = elevationResponse.getStatus();
if (status.equals(OK)) {
List<Double> elevations = extractElevations(elevationResponse.getResult());
return elevations != null && elevations.size() > 0 ? elevations.get(0) : null;
}
if (status.equals(OVER_QUERY_LIMIT))
throw new ServiceUnavailableException("maps.googleapis.com", url);
}