Click or drag to resize

Traffic Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
A Traffic is a collection of traffic sources which may be queried to determine the speed of traffic along a given link.
Inheritance Hierarchy

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

The Traffic type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyExpires
The expiry time for this traffic data.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by the Traffic
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 methodGetSpeed(UInt64, DateTime, SpeedUnit)
Query each of this Traffic's TrafficSources to get the speed along a given link at a given time.
Public methodGetSpeed(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.
Public methodGetSpeed(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.
Public methodGetSpeed(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.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

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.

Examples
In this example, a Traffic object is created using HERE Historical Traffic data. The GetSpeed(UInt64, DateTime, SpeedUnit) method is then used to find out the speed along a link, at a specified time.
C#
//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);
See Also