Click or drag to resize

RouteGetDirections Method (UnitSystem, String, IAsyncDirectionsHandler)

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Calculate the route and return a representative Directions object using the specified UnitSystem and culture.

Namespace:  Telogis.GeoBase.Routing
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public Directions GetDirections(
	UnitSystem units,
	string culture,
	IAsyncDirectionsHandler handler
)

Parameters

units
Type: Telogis.GeoBase.NavigationUnitSystem
Defines the unit system used when generating natural-language directions. In the USA you would typically use ImperialFeet and in Australia you would typically use Metric. This ensures that the generated directions are given in units familiar to the end user.
culture
Type: SystemString
The culture that the returned Directions will use.
handler
Type: Telogis.GeoBase.RoutingIAsyncDirectionsHandler
A handler for asynchronous generation of directions.

Return Value

Type: Directions
Directions for this route. An aborted call returns null.

Implements

IRouteGetDirections(UnitSystem, String, IAsyncDirectionsHandler)
Remarks

Used to asynchronously supply natural-language directions as they are generated. IAsyncDirectionsHandler methods supported include OnDirectionsAppended(AsyncDirectionsEventArgs) which fires when a new direction is added to the Directions object; OnDirectionsClearUncommitted(AsyncDirectionsEventArgs) which fires when a direction is found to be incorrect clearing all uncommitted directions, OnDirectionsCommitted(AsyncDirectionsEventArgs) which fires when directions are confirmed as correct and commits all appended directions since the last commit, and OnDirectionsCompleted(AsyncDirectionsEventArgs) which fires when all directions have been generated and committed.

Related articles: Creating a Route, Using Directions.

Examples
C#
class DirectionsHandler : IAsyncDirectionsHandler
{
    #region IAsyncDirectionsHandler Members

    public void OnDirectionsAppended(AsyncDirectionsEventArgs args)
    {

        Console.WriteLine("OnDirectionsAppended");
        DisplayDirectionsSoFar(args);

        Console.ReadKey();
    }

    public void OnDirectionsCommitted(AsyncDirectionsEventArgs args)
    {
        // This will be called when all the directions in the list
        // args.Directions are confirmed to be correct
        Console.WriteLine("OnDirectionsCommitted");

        DisplayDirectionsSoFar(args);
    }

    public void OnDirectionsClearUncommitted(AsyncDirectionsEventArgs args)
    {

        // This will be called when the last uncommitted directions instruction in
        // args.Directions is confirmed to be incorrect
        Console.WriteLine("OnDirectionsClearUncommitted");
        DisplayDirectionsSoFar(args);

    }

    public void OnDirectionsCompleted(AsyncDirectionsEventArgs args)
    {

        // This will be called when  all the directions for the route has been
        // confirmed as correct
        Console.WriteLine("That's all the directions!");
        DisplayDirectionsSoFar(args);

    }

    private void DisplayDirectionsSoFar(AsyncDirectionsEventArgs args)
    {
        // List the directions that GetDirections is sure about
        for (int i = 0; i < args.UncommittedIndex; i++)
        {
            Console.WriteLine(" * " + args.Directions[i]);
        }

        // List the directions that GetDirections is unsure about (the rest of the directions)
        for (int i = args.UncommittedIndex; i  < args.Directions.Count; i++)
        {
            Console.WriteLine("   " + args.Directions[i]);
        }
    }

    #endregion
}

Main() 

{
   Route route = new Route();

    route.Start = new RouteStop(33.903187, -118.225697);
    route.AddStopAtEnd(new RouteStop(33.903457, -118.225756));
    route.End = new RouteStop(33.903178, -118.225835);

    DirectionsHandler dh = new DirectionsHandler();

    //r.GetDirections();
    route.GetDirections(Telogis.GeoBase.Navigation.UnitSystem.Metric, "en-US", dh);
}
See Also