Calculate fuel consumption and CO2 emissions per section
This tutorial provides examples of routing requests that return the Fuel consumption for a fuel-based diesel vehicle.
Each request provides a fuel consumption table using the fuel[freeFlowSpeedTable] and fuel[trafficSpeedTable] parameters.
The responses specify the fuel consumption in liters (l).
Fuel consumption calculation with traffic enabled
curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.542146,13.347508&'\
'destination=52.512139,13.438468&'\
'via=52.527319,13.387999!passThrough=true&'\
'return=summary,polyline&'\
'transportMode=car&'\
'departureTime=2024-09-04T11:00:00&'\
'fuel[type]=diesel&'\
'fuel[freeFlowSpeedTable]=10,0.095,20,0.072,30,0.058,40,0.049,50,0.045,60,0.043,70,0.042,80,0.043,90,0.045,100,0.047,110,0.05,120,0.052,130,0.055&'\
'fuel[trafficSpeedTable]=10,0.012,20,0.09,30,0.07,40,0.06,50,0.045,60,0.043,70,0.042,80,0.043,90,0.045,100,0.047,110,0.05,120,0.052,130,0.055&'\
'fuel[additionalConsumption]=0.1&'\
'fuel[ascent]=0.1&'\
'apiKey=YOUR_API_KEY'{
"routes": [
{
"id": "4843146e-b1c2-4fad-b239-96841ce9526c",
"sections": [
{
...,
"summary": {
"duration": 1353,
"length": 8705,
"consumption": 0.6295,
"baseDuration": 1008,
"co2Emission": 1.698
},
"transport": {
"mode": "car"
},
"consumptionType": "diesel"
}
]
}
]
}Fuel consumption calculation with traffic disabled
This example uses the same request as the previous example, except that traffic is disabled using the parameter traffic[mode]=disabled.
Note in the response that the route length is the same as before, but duration, consumption, and co2Emission have decreased because the vehicle isn't slowed down by traffic.
curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.542146,13.347508&'\
'destination=52.512139,13.438468&'\
'via=52.527319,13.387999!passThrough=true&'\
'return=summary,polyline&'\
'transportMode=car&'\
'departureTime=2024-09-04T11:00:00&'\
'fuel[type]=diesel&'\
'fuel[freeFlowSpeedTable]=10,0.095,20,0.072,30,0.058,40,0.049,50,0.045,60,0.043,70,0.042,80,0.043,90,0.045,100,0.047,110,0.05,120,0.052,130,0.055&'\
'fuel[trafficSpeedTable]=10,0.012,20,0.09,30,0.07,40,0.06,50,0.045,60,0.043,70,0.042,80,0.043,90,0.045,100,0.047,110,0.05,120,0.052,130,0.055&'\
'fuel[additionalConsumption]=0.1&'\
'fuel[ascent]=0.1&'\
'traffic[mode]=disabled&'\
'apiKey=YOUR_API_KEY'{
"routes": [
{
"id": "424e62f5-b0b0-4118-95b1-cb96d0a5fa2e",
"sections": [
{
...,
"summary": {
"duration": 1008,
"length": 8705,
"consumption": 0.5668,
"baseDuration": 1008,
"co2Emission": 1.529
},
"transport": {
"mode": "car"
},
"consumptionType": "diesel"
}
]
}
]
}Calculate fuel consumption per span
This request returns the fuel consumption for a fuel-based diesel vehicle per span.
curl -gX GET 'https://router.hereapi.com/v8/routes?'\
'origin=52.542146,13.347508&'\
'destination=52.512139,13.438468&'\
'via=52.527319,13.387999!passThrough=true&'\
'return=summary,polyline&'\
'spans=maxSpeed,consumption&'\
'transportMode=car&'\
'departureTime=2024-09-04T11:00:00&'\
'fuel[type]=diesel&'\
'fuel[freeFlowSpeedTable]=10,0.095,20,0.072,30,0.058,40,0.049,50,0.045,60,0.043,70,0.042,80,0.043,90,0.045,100,0.047,110,0.05,120,0.052,130,0.055&'\
'fuel[trafficSpeedTable]=10,0.012,20,0.09,30,0.07,40,0.06,50,0.045,60,0.043,70,0.042,80,0.043,90,0.045,100,0.047,110,0.05,120,0.052,130,0.055&'\
'fuel[additionalConsumption]=0.1&'\
'fuel[ascent]=0.1&'\
'apiKey=YOUR_API_KEY'{
"routes": [
{
"id": "b832f221-e207-4d30-a487-05fb13597c0b",
"sections": [
{
...,
"summary": {
"duration": 1371,
"length": 8705,
"consumption": 0.6273,
"baseDuration": 1008,
"co2Emission": 1.692
},
"polyline": "...",
"spans": [
{
"offset": 0,
"maxSpeed": 8.333334,
"consumption": 0.006
},
{
"offset": 2,
"maxSpeed": 13.8888893,
"consumption": 0.0509
},
{
"offset": 24,
"maxSpeed": 8.333334,
"consumption": 0.0351
},
{
"offset": 35,
"maxSpeed": 13.8888893,
"consumption": 0.1971
},
{
"offset": 138,
"maxSpeed": 8.333334,
"consumption": 0.1494
},
{
"offset": 211,
"maxSpeed": 13.8888893,
"consumption": 0.1194
},
{
"offset": 265,
"maxSpeed": 8.333334,
"consumption": 0.0045
},
{
"offset": 267,
"maxSpeed": 13.8888893,
"consumption": 0.0649
}
],
"transport": {
"mode": "car"
},
"consumptionType": "diesel"
}
]
}
]
}Updated last month