Planning a long-distance route with an electric vehicle
For electric vehicles (EVs), when specifying additional parameters describing consumption and charging, additional features become available:
- Calculating the reachable offset along the route.
- Calculating a long-distance EV route (LDEVR), which includes automatically added charging stops as waypoints to ensure that the destination is reachable while minimizing overall travel time.
Calculating the reachable offset along the route
Planning an EV route is similar to planning a regular route, but with additional vehicle-specific information. To obtain reachability information, you must specify the RoutePlanningOptions
. These RoutePlanningOptions
must have a Vehicle
profile with:
The route planner returns a route where the reachableOffset
field in the summary of the route is set. It estimates how far you can get with the current charge level. That could be the length of the whole route if it’s reachable or less than the length of the entire route if it’s not. The same method can be used with combustion engines, too.
Besides the previously mentioned electric engine parameters, it’s possible to specify the ElectricVehicleEfficiency
. This helps the TomTom route planner provide more accurate estimates or arrival charges, though it is not required.
1val consumption = mapOf(2 Speed.kilometersPerHour(0.0) to ElectricConsumption.kilowattHoursPer100Kilometers(13.44),3 Speed.kilometersPerHour(50.0) to ElectricConsumption.kilowattHoursPer100Kilometers(16.4),4 Speed.kilometersPerHour(80.0) to ElectricConsumption.kilowattHoursPer100Kilometers(18.8),5 Speed.kilometersPerHour(120.0) to ElectricConsumption.kilowattHoursPer100Kilometers(19.65),6 Speed.kilometersPerHour(170.0) to ElectricConsumption.kilowattHoursPer100Kilometers(21.1),7)89val electricVehicle = Vehicle.Car(10 electricEngine = ElectricEngine(11 chargeLevel = ChargeLevel(12 currentCharge = Energy.kilowattHours(10),13 maxCharge = Energy.kilowattHours(60),14 ),15 consumption = ElectricVehicleConsumption(null, consumption),16 ),17)1819val amsterdam = GeoPoint(52.377956, 4.897070)20val rotterdam = GeoPoint(51.926517, 4.462456)2122val routePlanningOptions = RoutePlanningOptions(23 itinerary = Itinerary(amsterdam, rotterdam),24 vehicle = electricVehicle,25)
Calculating a long-distance EV route
To obtain a route with automatically generated waypoints that include charging information, you must:
- Specify everything as in the previous example.
- Specify the
ChargingParameters
of theElectricEngine
in theVehicle
. - Pass the
ChargingOptions
to theRoutePlanningOptions
. Then, the route planner can automatically insert charging stops to ensure the destination is reachable.
Ensure that the battery curve map has no more than twenty (20) entries. All energy values must be greater than or equal to zero, and all power values must be greater than zero. A battery curve with no entries is also considered valid. You should also make sure you are using plug types available in the region where you are trying to plan a route; otherwise, planning will fail.
1val consumption = mapOf(2 Speed.kilometersPerHour(0.0) to ElectricConsumption.kilowattHoursPer100Kilometers(13.44),3 Speed.kilometersPerHour(50.0) to ElectricConsumption.kilowattHoursPer100Kilometers(16.4),4 Speed.kilometersPerHour(80.0) to ElectricConsumption.kilowattHoursPer100Kilometers(18.8),5 Speed.kilometersPerHour(120.0) to ElectricConsumption.kilowattHoursPer100Kilometers(19.65),6 Speed.kilometersPerHour(170.0) to ElectricConsumption.kilowattHoursPer100Kilometers(21.1),7)89val batteryCurve = mapOf(10 Energy.kilowattHours(1) to Power.kilowatts(123),11 Energy.kilowattHours(18) to Power.kilowatts(121),12 Energy.kilowattHours(34) to Power.kilowatts(105),13 Energy.kilowattHours(50.8) to Power.kilowatts(66),14 Energy.kilowattHours(62.8) to Power.kilowatts(55.5),15)1617val chargingConnectors = listOf(18 ChargingConnector(19 currentType = CurrentType.AcThreePhase,20 plugTypes = listOf(ConnectorType.Iec62196Type2Outlet),21 ),22 ChargingConnector(23 currentType = CurrentType.Dc,24 plugTypes = listOf(ConnectorType.Iec62196Type2Ccs),25 ),26)2728val electricCar = Vehicle.Car(29 electricEngine = ElectricEngine(30 consumption = ElectricVehicleConsumption(null, consumption),31 chargeLevel = ChargeLevel(Energy.kilowattHours(10), Energy.kilowattHours(70)),32 chargingParameters = ChargingParameters(33 batteryCurve = batteryCurve,34 chargingConnectors = chargingConnectors,35 ),36 ),37)
Make sure to use valid charging options:
- The minimum charge at the destination must be less than the maximum charge of the vehicle.
- The minimum charge at charging stops cannot exceed half of the vehicle’s maximum charge (note that the first charging stop may have an arrival charge below this value).
1val chargingOptions = ChargingOptions(2 minChargeAtChargingStops = Energy.kilowattHours(5),3 minChargeAtDestination = Energy.kilowattHours(10),4)
Requesting the route
Once the charging options are set, the route can be planned either synchronously or asynchronously—just like a regular route planning request.
1val amsterdam = GeoPoint(52.377956, 4.897070)2val rotterdam = GeoPoint(51.926517, 4.462456)34val routePlanningOptions = RoutePlanningOptions(5 itinerary = Itinerary(amsterdam, rotterdam),6 vehicle = electricCar,7 chargingOptions = chargingOptions,8)910val result = routePlanner.planRoute(routePlanningOptions)11val routePlanningResponse = when (result) {12 is Result.Success -> result.value()13 is Result.Failure -> return14}
Unsupported route planning options
The following options are not supported in a long-distance EV routing:
WaypointOptimization.DistanceBased
is not supported.RouteType
values other thanRouteType.Fast
are not supported.Vehicle
types other thanCar
,Motorcycle
,Bus
, orVan
are not supported.
Charging stops information in a successfully computed route
The route contains charging stops as waypoints that have been added automatically based on the vehicle’s consumption and charging model. Charging stops contain additional information:
- Automatically added charging stops have
RouteStopSourceType
with valueAutoGenerated
. Arrival charge
.Charging information
.
Next steps
Since you have learned how to plan EV routes, here are recommendations for the next steps: