elevationLinePost method

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

Fetches the ElevationData by taking planar 2D line objects geometry and enriching them with elevation from a variety of datasets.

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

Implementation

Future<ElevationData> elevationLinePost({
  required Object geometry,
  required String formatIn,
  String formatOut = 'geojson',
  String dataset = 'srtm',
}) async {
  // Validate if geometry is correct formats. Check documentation for details.
  if (geometry is! String &&
      geometry is! List<List<double>> &&
      geometry is! Map) {
    throw ArgumentError.value(
      geometry,
      'geometry',
      'Must be a String, List<List<double>> or Map.',
    );
  }
  // Build the request URL.
  final Uri uri = Uri.parse('$_elevationEndpointURL/line');

  // Ready data to be sent.
  final Map<String, dynamic> queryParameters = <String, dynamic>{
    'format_in': formatIn,
    'format_out': formatOut,
    'dataset': dataset,
    'geometry': geometry,
  };

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