Click or drag to resize

TrafficRouting Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
This class may be used to route through Traffic.
Inheritance Hierarchy

Namespace:  Telogis.GeoBase.Traffic
Assembly: (in Version:
public class TrafficRouting

The TrafficRouting type exposes the following members.

Public methodTrafficRouting
Creates a new TrafficRouting from the given Traffic and time (as a DateTime).
Public propertyTraffic
The current Traffic through which we are routing.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodRecalculateRouteTime(Directions, DateTime)
Recalculate (by accounting for traffic congestion) the time required to travel a given route (specified as Directions) starting at a given time.
Public methodRecalculateRouteTime(Directions, LatLon, DateTime)
Recalculate (by accounting for traffic congestion) the time required to complete a given route (specified as Directions) starting at a given time and given that progress has already been made to a certain point.
Public methodStatic memberRemoveTrafficFromRouteStrategy
Configures a RoutingStrategy to route without traffic information.
Public methodsetUpRouteStrategy
Configures a RoutingStrategy to route in this Traffic.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

The class is used to route through Traffic using Directions. The routing strategy can be configured using setUpRouteStrategy(RoutingStrategy).

The code below demonstrates how to use the TrafficRouting methods: RecalculateRouteTime(Directions, DateTime) and setUpRouteStrategy(RoutingStrategy)

Related articles: Routing with Traffic.

private void TrafficRoute(LatLon A, LatLon B, String dataFile) {
    // create a new Route from A to B
    Route myRoute = new Route(new RouteStop(A), new RouteStop(B));

    // create a Traffic from our XML data
    XmlReader myXmlReader = XmlReader.Create(dataFile);
    ITrafficSource[] srcs = new ITrafficSource[] { new InrixRealTimeTrafficSource(myXmlReader) };
    Traffic myTraffic = new Traffic(srcs);

    // set up a TrafficRoute and configure the strategy from myRoute
    TrafficRouting myTrafficRouting = new TrafficRouting(myTraffic);

    // set the start time for the journey. This does not have to
    // be the current time, but if you override it, make sure to 
    // convert it to UTC.
    myRoute.CurrentTime = DateTime.UtcNow;

    // get Directions between A and B, accounting for traffic conditions
    Directions myDirections = myRoute.GetDirections();

    // find the end time for the journey, given that it starts at startTime
    DateTime startTime = DateTime.UtcNow + TimeSpan.FromHours(1);
    DateTime endTime = myTrafficRouting.RecalculateRouteTime(myDirections, startTime);
See Also