When you have requested your elevation, the returned object is an ElevationResponse
. It wraps a status and results.
The available status are defined by the ElevationStatus
constants.
$status = $response->getStatus();
The results is an array of elevations.
$results = $response->getResults();
Each elevation result contains a location, an elevation and a resolution.
foreach ($response->getResults() as $result) {
// ...
}
The location is represented by the Coordinate
. It is the position for which elevation data is being computed.
Note that for path requests, the set of location elements will contain the sampled coordinate along the path.
$location = $result->getLocation();
It indicates the elevation of the location in meters.
$elevation = $result->getElevation();
It indicates the maximum distance between data points from which the elevation was interpolated, in meters. This property will be missing if the resolution is not known. Note that elevation data becomes more coarse (larger resolution values) when multiple points are passed. To obtain the most accurate elevation value for a point, it should be queried independently.
$resolution = $result->getResolution();