elevationPointPost method

Future<ElevationData> elevationPointPost({
  1. required ORSCoordinate geometry,
  2. String formatIn = 'point',
  3. String formatOut = 'geojson',
  4. String dataset = 'srtm',
})

Fetches the ElevationData by taking a 2D coordinate and enriching it with elevation from a variety of datasets. Uses the POST method for the endpoint.

Information about the endpoint, parameters, response etc. can be found at: https://openrouteservice.org/dev/#/api-docs/elevation/point/post

Implementation

Future<ElevationData> elevationPointPost({
  required ORSCoordinate geometry,
  String formatIn = 'point',
  String formatOut = 'geojson',
  String dataset = 'srtm',
}) async {
  // Build the request URL.
  final Uri uri = Uri.parse('$_elevationEndpointURL/point');

  // Ready data to be sent.
  final Map<String, dynamic> queryParameters = <String, dynamic>{
    'format_in': formatIn,
    'format_out': formatOut,
    'dataset': dataset,
    'geometry': formatIn == 'geojson'
        ? <String, dynamic>{
            'type': 'Point',
            'coordinates': geometry.toList(),
          }
        : geometry.toList(),
  };

  // Fetch and parse the data.
  final Map<String, dynamic> data =
      await _openRouteServicePost(uri: uri, data: queryParameters);
  return ElevationData.fromJson(data);
}