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
SystemObject
  Telogis.GeoBase.TrafficTrafficRouting

Namespace:  Telogis.GeoBase.Traffic
Assembly:  geobase.net (in geobase.net.dll) Version: 4.84.0.0
Syntax
public class TrafficRouting

The TrafficRouting type exposes the following members.

Constructors
  NameDescription
Public methodTrafficRouting
Creates a new TrafficRouting from the given Traffic and time (as a DateTime).
Top
Properties
  NameDescription
Public propertyTraffic
The current Traffic through which we are routing.
Top
Methods
  NameDescription
Public methodEquals (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (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 (Inherited from Object.)
Top
Remarks

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.

Examples
C#
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);
    myTrafficRouting.setUpRouteStrategy(myRoute.Strategy);

    // 
    // 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