The traffic information functions allow you to set speed limits or prohibitions for areas or individual roads. These items of traffic information are used by the routing system to create modified routes. They can be added or removed at run-time, thus supporting the use of dynamic traffic information.

Here are some examples.

Adding traffic information to a road

line speed limit with route

The red border on the road indicates slow traffic going south-east. The green border indicates faster traffic going north-west. (Borders are on the driver's side, here the left for the UK; the sides are switched for right-driving countries.) The image shows a south-east-bound route avoiding the congested road.

Preventing routing within a circular area

circle speed limit with route

Routing has been prohibited in an area defined as a 3Km circle around Charing Cross.

Using an arbitrary polygon to define an area

polygon speed limit with route

A speed limit of 10kph has been imposed in a polygon surrounding the Luton-Dunstable built up area.

Defining an area using a loop of roads

closed line speed limit

closed line speed limit with route

Restricted areas can be defined using the road network. Here, a speed limit of 10kph has been imposed in the shaded area. The second image shows a route going into the area, which is legal because there is no prohibition of traffic, just a reduced speed.

API functions

Traffic information can be managed using the following CartoType framework API functions. Please refer to the detailed on-line API documentation for more details.

C++

functions in CartoType::CFramework:

 TResult AddTrafficInfo(uint64& aId,const CTrafficInfo& aTrafficInfo,CLocationRef& aLocationRef,bool aDriveOnLeft);
 TResult AddPolygonSpeedLimit(uint64& aId,const CGeometry& aPolygon,double aSpeed,uint32 aVehicleTypes);
 TResult AddLineSpeedLimit(uint64& aId,const CGeometry& aLine,double aSpeed,uint32 aVehicleTypes,bool aDriveOnLeft);
 TResult AddClosedLineSpeedLimit(uint64& aId,const CGeometry& aLine,double aSpeed,uint32 aVehicleTypes);
 TResult AddForbiddenArea(uint64& aId,const CGeometry& aPolygon);
 TResult DeleteTrafficInfo(uint64 aId);
 void ClearTrafficInfo();
 bool EnableTrafficInfo(bool aEnable);

iOS

functions in CartoTypeFramework:

 -(CTResult)addTrafficInfo:(uint64_t*)aId trafficInfo:(CartoTypeTrafficInfo*)aTrafficInfo locationRef:(CartoTypeLocationRef*)aLocationRef driveOnLeft:(bool)aDriveOnLeft;
 -(CTResult)addPolygonSpeedLimit:(uint64_t*)aId polygon:(CartoTypeGeometry*)aPolygon speed:(double)aSpeed vehicleTypes:(uint32_t)aVehicleTypes;
 -(CTResult)addLineSpeedLimit:(uint64_t*)aId line:(CartoTypeGeometry*)aLine speed:(double)aSpeed vehicleTypes:(uint32_t)aVehicleTypes driveOnLeft:(bool)aDriveOnLeft;
 -(CTResult)addClosedLineSpeedLimit:(uint64_t*)aId line:(CartoTypeGeometry*)aLine speed:(double)aSpeed vehicleTypes:(uint32_t)aVehicleTypes;
 -(CTResult)addForbiddenArea:(uint64_t*)aId polygon:(CartoTypeGeometry*)aPolygon;
 -(CTResult)deleteTrafficInfo:(uint64_t*)aId;
 -(void)clearTrafficInfo;
 -(bool)enableTrafficInfo:(bool)aEnable;

Android

functions in CartoType.Framework:

 public int addTrafficInfo(long aId,TrafficInfo aTrafficInfo,LocationRef aLocationRef,boolean aDriveOnLeft);
 public int addPolygonSpeedLimit(long aId,Geometry aPolygon,double aSpeed,int aVehicleTypes)
 public int addLineSpeedLimit(long aId,Geometry aLine,double aSpeed,int aVehicleTypes,boolean aDriveOnLeft)
 public int addClosedLineSpeedLimit(long aId,Geometry aLine,double aSpeed,int aVehicleTypes)
 public int addForbiddenArea(long aId,Geometry aPolygon)
 public int deleteTrafficInfo(long aId);
 public void clearTrafficInfo();
 public boolean enableTrafficInfo(boolean aEnable);

.NET

functions in CartoType.Framework, given here using C# syntax:

 public CartoType.Result AddTrafficInfo(ref long aId, CartoType.TrafficInfo aTrafficInfo, CartoType.LocationRef aLocationRef, bool aDriveOnLeft)
 public CartoType.Result AddPolygonSpeedLimit(ref long aId, CartoType.Geometry aPolygon, double aSpeed, int aVehicleTypes)
 public CartoType.Result AddLineSpeedLimit(ref long aId, CartoType.Geometry aLine, double aSpeed, int aVehicleTypes, bool aDriveOnLeft)
 public CartoType.Result AddClosedLineSpeedLimit(ref long aId, CartoType.Geometry aLine, double aSpeed, int aVehicleTypes)
 public CartoType.Result AddForbiddenArea(ref long aId, CartoType.Geometry aPolygon)
 public CartoType.Result DeleteTrafficInfo(long aId)
 public void ClearTrafficInfo()
 public bool EnableTrafficInfo(bool aEnable)