Table of Contents

Interface IRouter

Namespace
LansMap.Map.Routing

Turns a list of waypoints into a route line; implement this to route with your own provider or an offline engine.

public interface IRouter : IDisposable
Inherited Members

Remarks

Every member is called from the Unity main thread. The idiom is polling, not callbacks: call RequestRoute(IReadOnlyList<LatLon>), then call TryGetRoute(List<LatLon>, out double, out double) once per frame until it returns true.

A new request cancels any request still in flight, and only the newest one ever reports a route.

Properties

LastError

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

string LastError { get; }

Property Value

string

RoutePending

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

bool RoutePending { get; }

Property Value

bool

Methods

RequestRoute(IReadOnlyList<LatLon>)

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

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.

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.