Traffic Class |
Namespace: Telogis.GeoBase.Traffic
The Traffic type exposes the following members.
Name | Description | |
---|---|---|
Traffic(IGenericTrafficSource) |
Construct a new Traffic using the given Traffic Sources.
| |
Traffic(IGenericTrafficSource, DateTime) |
Construct a new Traffic using the given Traffic Sources.
|
Name | Description | |
---|---|---|
Dispose | Releases all resources used by the Traffic | |
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.) | |
GetSpeed(UInt64, DateTime, SpeedUnit) |
Query each of this Traffic's TrafficSources to get the speed along a given link at a given time.
| |
GetSpeed(UInt64, DateTime, TimeZone, SpeedUnit) |
Query each of this Traffic's TrafficSources to get the speed along a given link at a given time and timezone.
| |
GetSpeed(UInt64, TrafficDirectionType, DateTime, SpeedUnit) |
Query each of this Traffic's TrafficSources to get the speed along a given link at a given time and link direction.
| |
GetSpeed(UInt64, TrafficDirectionType, DateTime, TimeZone, SpeedUnit) |
Query each of this Traffic's TrafficSources to get the speed along a given link at a given time, link direction and timezone.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
A Traffic is a collection of traffic sources, implemented using the ITrafficSource interface, which may be queried to determine the speed of traffic along a given link.
See GetSpeed(UInt64, DateTime, SpeedUnit) to query the speed of traffic along a link.
The speed value returned using GetSpeed(UInt64, DateTime, SpeedUnit) will be the lowest value found for the given link ID and time. If more than one traffic source is specified, the traffic sources will be searched in order of priority. The order of priority is simply the order in which the traffic sources are listed when implementing the ITrafficSource collection.
See the Traffic tutorial for more detailed information on using the Traffic class.
Related articles: Routing with Traffic.
//Set units for returned speed SpeedUnit spd_unit = SpeedUnit.MilesPerHour; ulong link_id; double speed; //Location to look for speed LatLon location = new LatLon(33.58132, -117.72695); //Set file path to traffic data string dataFile = @"C:\data\NavteqHistoricalTraffic.gbhb"; //Create collection of traffic sources - just one in this case ITrafficSource[] srcs = new ITrafficSource[] { new HistoricalTrafficSource(dataFile) }; //Create traffic using the collection of traffic sources Traffic myTraffic = new Traffic(srcs); //Create a GeoCodeFull object, so that the link_id can be found from the location GeoCodeFull gcFull = GeoCoder.ReverseGeoCodeFull(location); link_id = gcFull.StreetLink.LinkId; //Get the speed speed = myTraffic.GetSpeed(link_id, DateTime.Now, gcFull.StreetLink.TimeZone, spd_unit);