THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Consumption model

Allow your user to utilise the vehicle-specific consumption model when requesting a new route. The consumption model can be calculated based on a number of Routing API parameters for two vehicle types: combustion or electric, and the output will contain the additional field fuelConsumptionInLiters or batteryConsumptionInkWh. For more details, please refer to: this documentation.

Sample use case: You are planning a journey and you want to select the most optimal route in terms of fuel / energy consumption.

To request a route and calculate the consumption model for a combustion vehicle:

1RouteDescriptor routeDescriptor = new RouteDescriptor.Builder()
2 .considerTraffic(false)
3 .build()
4
5RouteCalculationDescriptor routeCalculationDescriptor = new RouteCalculationDescriptor.Builder()
6 .routeDescription(routeDescriptor)
7 .maxAlternatives(2)
8 .build();
9
10//vehicle specific consumption model <speed, consumption in liters>
11Map<Double, Double> speedToConsumptionMap = new HashMap<>();
12speedToConsumptionMap.put(10.0, 6.5);
13speedToConsumptionMap.put(30.0, 7.0);
14speedToConsumptionMap.put(50.0, 8.0);
15speedToConsumptionMap.put(70.0, 8.4);
16speedToConsumptionMap.put(90.0, 7.7);
17speedToConsumptionMap.put(120.0, 7.5);
18speedToConsumptionMap.put(150.0, 9.0);
19
20CombustionVehicleConsumption combustionVehicleConsumption = new CombustionVehicleConsumption(
21 CURRENT_FUEL_IN_LITERS,
22 AUXILIARY_POWER_IN_LITERS_PER_HOUR,
23 FUEL_ENERGY_DENSITY_IN_MJOULES_PER_LITER,
24 speedToConsumptionMap
25);
26
27CombustionVehicleDescriptor combustionVehicleDescriptor = new CombustionVehicleDescriptor.Builder()
28 .vehicleConsumption(combustionVehicleConsumption)
29 .vehicleDimensions(new VehicleDimensions.Builder()
30 .vehicleWeightInKg(1600)
31 .build()
32 )
33 .vehicleEfficiency(new VehicleEfficiency.Builder()
34 .accelerationEfficiency(0.33)
35 .decelerationEfficiency(0.33)
36 .downhillEfficiency(0.33)
37 .uphillEfficiency(0.33)
38 .build()
39 )
40 .build();
41
42RouteSpecification routeSpecification = new RouteSpecification.Builder(routeConfig.getOrigin(), routeConfig.getDestination())
43 .routeCalculationDescriptor(routeCalculationDescriptor)
44 .combustionVehicleDescriptor(combustionVehicleDescriptor)
45 .build();
1val vehicleEfficiency = VehicleEfficiency.Builder()
2 .accelerationEfficiency(EFFICIENCY) //e.g. KineticEnergyGained/ChemicalEnergyConsumed
3 .decelerationEfficiency(EFFICIENCY) //e.g. ChemicalEnergySaved/KineticEnergyLost
4 .downhillEfficiency(EFFICIENCY) //e.g. ChemicalEnergySaved/PotentialEnergyLost
5 .uphillEfficiency(EFFICIENCY) //e.g. PotentialEnergyGained/ChemicalEnergyConsumed
6 .build()
7
8val vehicleDimensions = VehicleDimensions.Builder()
9 .vehicleWeightInKg(VEHICLE_WEIGHT)
10 .build()
11
12//vehicle specific consumption model <speed, consumption in liters>
13val combustionVehicleConsumption = CombustionVehicleConsumption(
14 CURRENT_FUEL,
15 AUXILIARY_POWER_COMBUSTION,
16 FUEL_ENERGY_DENSITY,
17 mapOf(
18 Pair(10.0, 6.5),
19 Pair(30.0, 7.0),
20 Pair(50.0, 8.0),
21 Pair(70.0, 8.4),
22 Pair(90.0, 7.7),
23 Pair(120.0, 7.5),
24 Pair(150.0, 9.0)
25 )
26)
27
28val combustionVehicleDescriptor = CombustionVehicleDescriptor.Builder()
29 .vehicleConsumption(combustionVehicleConsumption)
30 .vehicleEfficiency(vehicleEfficiency)
31 .vehicleDimensions(vehicleDimensions)
32 .build()
33
34val routeDescriptor = RouteDescriptor.Builder()
35 .considerTraffic(false)
36 .build()
37
38val routeCalculationDescriptor = RouteCalculationDescriptor.Builder()
39 .routeDescription(routeDescriptor)
40 .maxAlternatives(MAX_ALTERNATIVES)
41 .build()
42
43val routeSpecification = RouteSpecification.Builder(origin, destination)
44 .combustionVehicleDescriptor(combustionVehicleDescriptor)
45 .routeCalculationDescriptor(routeCalculationDescriptor)
46 .build()

To request a route and calculate the consumption model for an electric vehicle:

1RouteDescriptor routeDescriptor = new RouteDescriptor.Builder()
2 .considerTraffic(false)
3 .build();
4
5RouteCalculationDescriptor routeCalculationDescriptor = new RouteCalculationDescriptor.Builder()
6 .routeDescription(routeDescriptor)
7 .maxAlternatives(2)
8 .build();
9
10//vehicle specific consumption model <speed, consumption in kWh>
11Map<Double, Double> speedToConsumptionMap = new HashMap<>();
12speedToConsumptionMap.put(10.0, 5.0);
13speedToConsumptionMap.put(30.0, 10.0);
14speedToConsumptionMap.put(50.0, 15.0);
15speedToConsumptionMap.put(70.0, 20.0);
16speedToConsumptionMap.put(90.0, 25.0);
17speedToConsumptionMap.put(120.0, 30.0);
18
19ElectricVehicleConsumption electricVehicleConsumption = new ElectricVehicleConsumption(
20 MAX_CHARGE_IN_KWH,
21 CURRENT_CHARGE_IN_KWH,
22 AUXILIARY_POWER_IN_KW,
23 speedToConsumptionMap);
24
25ElectricVehicleDescriptor electricVehicleDescriptor = new ElectricVehicleDescriptor.Builder(electricVehicleConsumption)
26 .vehicleDimensions(new VehicleDimensions.Builder()
27 .vehicleWeightInKg(1600)
28 .build()
29 )
30 .vehicleEfficiency(new VehicleEfficiency.Builder()
31 .accelerationEfficiency(0.33)
32 .decelerationEfficiency(0.33)
33 .downhillEfficiency(0.33)
34 .uphillEfficiency(0.33)
35 .build()
36 )
37 .build();
38
39RouteSpecification routeSpecification = new RouteSpecification.Builder(routeConfig.getOrigin(), routeConfig.getDestination())
40 .routeCalculationDescriptor(routeCalculationDescriptor)
41 .electricVehicleDescriptor(electricVehicleDescriptor)
42 .build();
1val vehicleEfficiency = VehicleEfficiency.Builder()
2 .accelerationEfficiency(EFFICIENCY) //e.g. KineticEnergyGained/ChemicalEnergyConsumed
3 .decelerationEfficiency(EFFICIENCY) //e.g. ChemicalEnergySaved/KineticEnergyLost
4 .downhillEfficiency(EFFICIENCY) //e.g. ChemicalEnergySaved/PotentialEnergyLost
5 .uphillEfficiency(EFFICIENCY) //e.g. PotentialEnergyGained/ChemicalEnergyConsumed
6 .build()
7
8val vehicleDimensions = VehicleDimensions.Builder()
9 .vehicleWeightInKg(VEHICLE_WEIGHT)
10 .build()
11
12//vehicle specific consumption model <speed, consumption in liters>
13val electricVehicleConsumption = ElectricVehicleConsumption(
14 MAX_ELECTRIC_CHARGE,
15 CURRENT_ELECTRIC_CHARGE,
16 AUXILIARY_POWER_ELECTRIC,
17 mapOf(
18 Pair(10.0, 5.0),
19 Pair(30.0, 10.0),
20 Pair(50.0, 15.0),
21 Pair(70.0, 20.0),
22 Pair(90.0, 25.0),
23 Pair(120.0, 30.0)
24 )
25)
26
27val electricVehicleDescriptor = ElectricVehicleDescriptor.Builder(electricVehicleConsumption)
28 .vehicleEfficiency(vehicleEfficiency)
29 .vehicleDimensions(vehicleDimensions)
30 .build()
31
32val routeDescriptor = RouteDescriptor.Builder()
33 .considerTraffic(false)
34 .build()
35
36val routeCalculationDescriptor = RouteCalculationDescriptor.Builder()
37 .routeDescription(routeDescriptor)
38 .maxAlternatives(MAX_ALTERNATIVES)
39 .build()
40
41val routeSpecification = RouteSpecification.Builder(origin, destination)
42 .electricVehicleDescriptor(electricVehicleDescriptor)
43 .routeCalculationDescriptor(routeCalculationDescriptor)
44 .build()

image

Combustion

image

Electric