Class RoutingService
public sealed class RoutingService : IRouter, IDisposable
- Inheritance
-
objectRoutingService
- 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
Fields
OsrmDemoEndpoint
public const string OsrmDemoEndpoint = "https://router.project-osrm.org/route/v1/driving/"
Field Value
Properties
LastError
Why the most recent completed request produced no route, or null when it produced one.
public string LastError { get; }
Property Value
RoutePending
True while a request has been started and has not completed.
public bool RoutePending { get; }
Property Value
UserAgent
public string UserAgent { get; }
Property Value
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
waypointsIReadOnlyList<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
pointsList<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.
distanceMetersdoubleRoute length in meters, 0 when there is no route.
durationSecondsdoubleEstimated 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.