TrafficRouting Class |
Namespace: Telogis.GeoBase.Traffic
The TrafficRouting type exposes the following members.
Name | Description | |
---|---|---|
TrafficRouting |
Creates a new TrafficRouting from the given Traffic
and time (as a DateTime).
|
Name | Description | |
---|---|---|
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
RecalculateRouteTime(Directions, DateTime) |
Recalculate (by accounting for traffic congestion) the time required to travel a given
route (specified as Directions) starting
at a given time.
| |
RecalculateRouteTime(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.
| |
RemoveTrafficFromRouteStrategy |
Configures a RoutingStrategy to route without traffic information.
| |
setUpRouteStrategy |
Configures a RoutingStrategy to route in this Traffic.
| |
ToString | 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); 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); }