Table of Contents

Class RoutingService

Namespace
LansMap.Map.Routing
public sealed class RoutingService : IRouter, IDisposable
Inheritance
object
RoutingService
Implements

Constructors

RoutingService(string, Func<string, string, CancellationToken, Task<string>>, string)

public RoutingService(string endpoint = null, Func<string, string, CancellationToken, Task<string>> transport = null, string userAgent = null)

Parameters

endpoint string
transport Func<string, string, CancellationToken, Task<string>>
userAgent string

Fields

OsrmDemoEndpoint

public const string OsrmDemoEndpoint = "https://router.project-osrm.org/route/v1/driving/"

Field Value

string

Properties

LastError

Why the most recent completed request produced no route, or null when it produced one.

public string LastError { get; }

Property Value

string

RoutePending

True while a request has been started and has not completed.

public bool RoutePending { get; }

Property Value

bool

UserAgent

public string UserAgent { get; }

Property Value

string

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

RequestRoute(IReadOnlyList<LatLon>)

Starts a request for a route through the waypoints, in order; returns immediately.

public void RequestRoute(IReadOnlyList<LatLon> waypoints)

Parameters

waypoints IReadOnlyList<LatLon>

At least two positions in degrees WGS84.

TryGetRoute(List<LatLon>, out double, out double)

Takes the result of a completed request.

public bool TryGetRoute(List<LatLon> points, out double distanceMeters, out double durationSeconds)

Parameters

points List<LatLon>

Filled with the route line in degrees WGS84, and left empty when there is no route. Check LastError to tell "no route" apart from a transport failure.

distanceMeters double

Route length in meters, 0 when there is no route.

durationSeconds double

Estimated travel time in seconds, 0 when there is no route.

Returns

bool

True exactly once per completed request, false while one is still running or when none was started.