build method

  1. @override
Uri build(
  1. OsrmRequest options
)
override

build method to build the server uri

Implementation

@override
Uri build(OsrmRequest options) {
  var profiles = ['walking', 'cycling', 'driving', 'driving-traffic'];
  var services = [
    'nearest',
    'directions',
    'match',
    'trip',
    'table',
  ];

  final queryParameters = {
    ...options.queryParameters,
    'access_token': apiKey,
  };
  var coords =
      options.stringCoordinates.replaceAll(',', '%2C').replaceAll(';', '%3B');
  var urlToParse =
      '$baseUrl/${services[options.service.index]}/v5/mapbox/${profiles[options.profile.index]}/$coords';
  urlToParse += '?';
  urlToParse +=
      queryParameters.entries.map((e) => '${e.key}=${e.value}').join('&');
  return Uri.parse(urlToParse);
}