GuidesAPI Reference
Guides

How to use speed cap

The vehicle[speedCap] parameter allows you to set the maximum speed of the vehicle for which you calculate the route. Applicable speed limits always take precedence over the set speed cap value. The impact of this parameter changes depending on the transportMode used in the request. See the following table:

Transport modevehicle[speedCap] impact
scooterRoute shape, ETA, consumption
car, truckETA, consumption
othernot supported

In route calculation requests for cars and trucks, setting a speed cap can be used to limit fuel or energy consumption. This can be an effective way to ensure that an electric vehicle reaches its destination without making additional stops for charging, or that a truck reaches the logistics hub in the desired time window to ensure the availability of resources for unloading cargo.

The following example calculates a route for a car with a speed cap set to 13.89 m/s (50 km/h).

curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.514774,13.389289&'\
'destination=52.447211,13.3535751&'\
'return=polyline,summary&'\
'spans=dynamicSpeedInfo&'\
'transportMode=car&'\
'vehicle[speedCap]=13.89&'\
'apiKey=YOUR_API_KEY'

Speed cap per Functional Class

The vehicle[speedCapPerFc] parameter allows you to set dedicated speed caps per road Functional Class.

📘

Note

This parameter is supported in for car and truck transport modes only.

You can use the vehicle[speedCapPerFc] parameter and the vehicle[speedCap] parameter together in a single request. When that's the case, the API uses the lowest speed cap value that applies to the given road. For example, when you set vehicle[speedCap]=13.89 and vehicle[speedCapPerFc]=20 in your request, the API uses the speed cap of 13.98 m/s for all roads of Funcional Class 1 (FC1) and all other roads that are a part of the calculated route.

The vehicle[speedCapPerFc] parameter takes the desired speed cap values as a comma-separated list of speeds expressed in m/s. The order in which the values are supplied correspond to the order of road Functional Classes. See these examples:

  • vehicle[speedCapPerFc]=20 - Applies a speed cap of 20 m/s to FC1 roads.
  • vehicle[speedCapPerFc]=20,,15 - Applies a speed cap of 20 m/s to FC1 roads and a speed cap of 15 m/s to FC3 roads.
  • vehicle[speedCapPerFc]=,,,,10 - Applies a speed cap of 10 m/s to FC5 roads.
  • vehicle[speedCapPerFc]=20,18 - Applies a speed cap of 20 m/s to FC1 roads and a speed cap of 18 m/s to FC2 roads.

The following example calculates a route for a truck with the FC1 speed cap set to 20 m/s (72 km/h) and the FC3 speed cap set to 15 m/s (54 km/h). Note that the vehicle[speedCap] parameter is also used. Since its value is higher than that set for FC1 and FC3 roads, it will be used for roads other than those that belong to FC1 and FC3.

curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.495650,13.276807&'\
'destination=52.506097,13.461151&'\
'return=summary&'\
'spans=dynamicSpeedInfo&'\
'transportMode=truck&'\
'vehicle[speedCap]=25&'\
'vehicle[speedCapPerFc]=20,,15&'\
'apiKey=YOUR_API_KEY'

Impact on fuel/energy consumption

Setting speed caps can be an effective way to limit fuel or energy consumption. Consider these examples of route calculation requests for electric vehicles. One request doesn't set a speed cap, which results in energy consumption of 43 kWh. The request with speed cap set to 25 m/s (90 km/h) results in energy consumption of 36 kWh.

No speed cap set

Request

curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.66181,13.38251&'\
'destination=51.772324,12.402652&'\
'return=summary&'\
'transportMode=car&'\
'departureTime=any&'\
'ev[freeFlowSpeedTable]=10,0.130,20,0.132,30,0.136,40,0.142,50,0.151,60,0.161,70,0.176,80,0.194,90,0.214,100,0.237,110,0.264,120,0.290,130,0.321,140,0.354,150,0.389,160,0.426,170,0.466,180,0.509,190,0.554,200,0.601&'\
'ev[trafficSpeedTable]=0,0.349,27,0.319,45,0.329,60,0.266,75,0.287,90,0.318,100,0.33,110,0.335,120,0.35,130,0.36,250,0.36&'\
'ev[ascent]=9&'\
'ev[descent]=4.3&'\
'apiKey=YOUR_API_KEY'

Response

Note that the response is truncated.

{
  "routes" : [
    {
      "id" : "dc225dd3-78d8-49ad-ad82-6350dc6848cd",
      "sections" : [
        {
          ...,
          "summary": {
            "duration": 5582,
            "length": 165625,
            "consumption": 47.824,
            "baseDuration": 5582
          }
        }
      ]
    }
  ]
}

Speed cap set

Request

curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.66181,13.38251&'\
'destination=51.772324,12.402652&'\
'return=summary&'\
'transportMode=car&'\
'vehicle[speedCap]=25&'\
'departureTime=any&'\
'ev[freeFlowSpeedTable]=10,0.130,20,0.132,30,0.136,40,0.142,50,0.151,60,0.161,70,0.176,80,0.194,90,0.214,100,0.237,110,0.264,120,0.290,130,0.321,140,0.354,150,0.389,160,0.426,170,0.466,180,0.509,190,0.554,200,0.601&'\
'ev[trafficSpeedTable]=0,0.349,27,0.319,45,0.329,60,0.266,75,0.287,90,0.318,100,0.33,110,0.335,120,0.35,130,0.36,250,0.36&'\
'ev[ascent]=9&'\
'ev[descent]=4.3&'\
'apiKey=YOUR_API_KEY'

Response

Note that the response is truncated.

{
  "routes" : [
    {
      "id" : "58f003f1-a472-4f5e-a818-f6ef3b82c8fa",
      "sections" : [
        {
          ...,
          "summary": {
            "duration": 6946,
            "length": 165625,
            "consumption": 37.0997,
            "baseDuration": 6946
          }
        }
      ]
    }
  ]
}

Related content