Long Distance EV Routing
Purpose
The Long Distance EV Routing service calculates a route between a given origin and destination, passing through waypoints if they are specified. The route contains charging stops that have been added automatically based on the vehicle's consumption and charging model.
- The route considers factors such as the current traffic and the typical road speeds on the requested day of the week and time of day.
- Information returned includes the distance, estimated travel time, a representation of the route geometry, and charging stops that have been added automatically based on the vehicle's consumption and charging model.
- Each charging stop results in an additional leg in the route response.
- Each additional leg contains a
chargingInformationAtEndOfLeg
element in its leg summary. - Both the route summary and the leg summary include a
remainingChargeAtArrivalInkWh
element. - The route summary includes a
totalChargingTimeInSeconds
element.
The chargingInformationAtEndOfLeg
field consists of:
- target battery charge
- charging time
- details about the charging stop
Run this endpoint
You can easily run this and other endpoints. Go to the TomTom API Explorer page and follow the directions.
Deprecation notice
March 15, 2024
- Value
tollRoad
for the input parametersectionType
as well as the respective response section typeTOLL_ROAD
have been deprecated.- This section will be withdrawn following a 12 months deprecation period.
- The planned withdrawal date is March 15, 2025.
- Following withdrawal, requests for
toll road section
may result in an HTTP 400 error in the response.We recommend using
toll
andtoll vignette
sections instead.
Request data
HTTPS method: POST
- Constants and parameters enclosed in curly brackets { } must be replaced with their values.
Generic request format
- Please see the following Request parameters section with the required and optional parameters tables for their values. The generic request format is as follows.
URL example
1https://{baseURL}/routing/{versionNumber}/calculateLongDistanceEVRoute/{routePlanningLocations}/json?key={Your_API_Key}2&vehicleEngineType=electric3&constantSpeedConsumptionInkWhPerHundredkm={ElectricConstantSpeedConsumptionPairs}4¤tChargeInkWh={float}5&maxChargeInkWh={float}6&minChargeAtDestinationInkWh={float}7&criticalMinChargeAtDestinationInkWh={float}8&minChargeAtChargingStopsInkWh={float}9&minChargeAtFirstChargingStopInkWh={float}10&callback={callback}11&alternativeType={alternativeType}12&maxAlternatives={alternativeRoutes}13&minDeviationDistance={integer}14&minDeviationTime={integer}15&vehicleHeading={integer}16§ionType={sectionType}17&report={effectiveSettings}18&departAt={time}19&arriveAt={time}20&traffic=true21&avoid={avoidType}22&prefer={preferType}23&instructionsType={instructionsType}24&language={language}25&chargingStopsStrategy={chargingStopsStrategy}26&vehicleMaxSpeed={vehicleMaxSpeed}27&vehicleWeight={vehicleWeight}28&vehicleAxleWeight={vehicleAxleWeight}29&vehicleNumberOfAxles={vehicleNumberOfAxles}30&vehicleLength={vehicleLength}31&vehicleWidth={vehicleWidth}32&vehicleHeight={vehicleHeight}33&vehicleCommercial={boolean}34&vehicleLoadType={vehicleLoadType}35&vehicleAdrTunnelRestrictionCode={vehicleAdrTunnelRestrictionCode}36&handsFreeDrivingCapability={handsFreeDrivingCapability}37&accelerationEfficiency={float}38&decelerationEfficiency={float}39&uphillEfficiency={float}40&downhillEfficiency={float}41&consumptionInkWhPerkmAltitudeGain={float}42&recuperationInkWhPerkmAltitudeLoss={float}43&auxiliaryPowerInkW={float}44&chargeMarginsInkWh={commaSeparatedFloats}
curl command example
1curl -X POST 'https://api.tomtom.com/routing/1/calculateLongDistanceEVRoute/52.507,13.492:50.104,8.624/json?key={Your_API_Key}&vehicleEngineType=electric&constantSpeedConsumptionInkWhPerHundredkm=32,10.87:77,18.01¤tChargeInkWh=20&maxChargeInkWh=40&minChargeAtDestinationInkWh=4&criticalMinChargeAtDestinationInkWh=2&minChargeAtChargingStopsInkWh=4'\2 -H 'Content-Type: application/json' -d '{3 "chargingParameters": {4 "batteryCurve": [5 {6 "stateOfChargeInkWh": 50.0,7 "maxPowerInkW": 2008 },9 {10 "stateOfChargeInkWh": 70.0,11 "maxPowerInkW": 10012 },13 {14 "stateOfChargeInkWh": 80.0,15 "maxPowerInkW": 4016 }17 ],18 "chargingConnectors": [19 {20 "currentType": "AC3",21 "plugTypes": [22 "IEC_62196_Type_2_Outlet",23 "IEC_62196_Type_2_Connector_Cable_Attached",24 "Combo_to_IEC_62196_Type_2_Base"25 ],26 "efficiency": 0.9,27 "baseLoadInkW": 0.2,28 "maxPowerInkW": 1129 },30 {31 "currentType": "DC",32 "plugTypes": [33 "IEC_62196_Type_2_Outlet",34 "IEC_62196_Type_2_Connector_Cable_Attached",35 "Combo_to_IEC_62196_Type_2_Base"36 ],37 "voltageRange": {38 "minVoltageInV": 0,39 "maxVoltageInV": 50040 },41 "efficiency": 0.9,42 "baseLoadInkW": 0.2,43 "maxPowerInkW": 15044 },45 {46 "currentType": "DC",47 "plugTypes": [48 "IEC_62196_Type_2_Outlet",49 "IEC_62196_Type_2_Connector_Cable_Attached",50 "Combo_to_IEC_62196_Type_2_Base"51 ],52 "voltageRange": {53 "minVoltageInV": 500,54 "maxVoltageInV": 200055 },56 "efficiency": 0.9,57 "baseLoadInkW": 0.258 }59 ],60 "chargingTimeOffsetInSec": 6061 }62}'
Types
The following table describes the types that can be used in the Long Distance EV Routing service.
Type | Description |
---|---|
| Latitude, longitude pair (in EPSG:4326 projection), with the following constraints:
Example: |
| A |
| A date and time specified in RFC 3339 format with an optional time zone offset. Examples:
|
| Comma-separated |
commaSeparatedFloats | Comma-separated list of floats.
Example: |
Avoid parameter possible values
Value | Description |
---|---|
tollRoads | Avoids toll roads. |
motorways | Avoids motorways. |
ferries | Avoids ferries. |
unpavedRoads | Avoids unpaved roads. |
carpools | Avoids routes that require use of carpool (HOV/High Occupancy Vehicle) lanes. |
alreadyUsedRoads | Avoids using the same road multiple times. |
borderCrossings | Avoids crossing country borders. |
tunnels | Avoids tunnels. |
carTrains | Avoids car trains. |
lowEmissionZones | Avoids low-emission zones. |
Possible values for other types
Type | Possible values |
---|---|
|
|
|
|
|
|
|
|
Request headers
The following data table describes supported HTTP request headers.
- Required headers must be used or the call will fail.
- Optional headers may be used.
- The order of request headers is not important.
Required headers | Description |
---|---|
Content-Type | Specifies the MIME type of the request body.
Value: |
Optional headers | Description |
---|---|
Accept-Encoding | Requests that the response be compressed.
Value: |
Content-Encoding | Specifies the compression used for the request body. Currently, only
|
Tracking-ID | Specifies an identifier for the request.
|
Base path parameters
The following table describes the set of parameters that can be used in the Long Distance EV Routing service. Note that all the parameters are required and must be used, otherwise, the call will fail. The order of the required parameters is important and must be followed.
Required parameters | Description |
---|---|
| Base URL for calling the API. Values:
|
| The service version number.
Value: The current value is |
| Locations through which the route is calculated. The following constraints apply:
Values: Colon-delimited |
| The only possible value for the Long Distance EV Routing service is |
Request parameters
This section presents a set of loosely connected parameters that influence the operation of the Long Distance EV Routing algorithm. While some of them are associated, the majority can be used independently of the others. Note that the required parameters must be used or the call will fail. Optional parameters may be used. The order of the request parameters is not important.
Required parameters | Description |
---|---|
| Authorization key to access the API.
Value: Your valid |
| This parameter has been deprecated. It may be removed in the future.
Only allowed value: |
| Specifies the current electric energy supply in kilowatt hours (kWh).
Minimum value: |
| The battery level upon arrival at the destination of the resulting route
will be at least this much.
Minimum value: |
| The desired minimum battery charge level upon arrival at each charging
station. However, the remaining charge at the first charging stop may be
lower. See |
Optional parameters | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Specifies which data should be reported for diagnostic purposes. A
possible value is:
Default value: | ||||||||||||||||||||
| The date and time of departure from the origin point.
Default value: | ||||||||||||||||||||
| The date and time of arrival at the destination point.
The
Value: | ||||||||||||||||||||
| Specifies the type of optimization used when calculating routes.
The only possible value in the Long Distance EV Routing service is | ||||||||||||||||||||
| The only possible value for the Long Distance EV Routing service is | ||||||||||||||||||||
| Specifies something that the route calculation should try to avoid when
determining the route. The | ||||||||||||||||||||
| Specifies something that the route calculation should try to prefer when determining the route. Possible value:
| ||||||||||||||||||||
| Specifies the hands-free driving capability of the vehicle.
The available hands-free driving data is matched against
| ||||||||||||||||||||
| The mode of travel for the requested route.
Default value:
| ||||||||||||||||||||
| Maximum speed of the vehicle in kilometers/hour.
Default value: | ||||||||||||||||||||
| Weight of the vehicle in kilograms.
Default value: | ||||||||||||||||||||
| Weight per axle of the vehicle in kilograms. A value of
| ||||||||||||||||||||
| Number of axle of the vehicle. A value of | ||||||||||||||||||||
| Length of the vehicle in meters, including the length of any additional
equipment, e.g., trailers, bike racks, etc. A value of | ||||||||||||||||||||
| Width of the vehicle in meters. A value of | ||||||||||||||||||||
| Height of the vehicle in meters. A value of | ||||||||||||||||||||
| Vehicle is used for commercial purposes and thus may not be allowed to
drive on some roads. | ||||||||||||||||||||
| Specifies types of cargo that may be classified as hazardous materials
and are restricted from some roads. The
or
). Available values are:
Use these values for routing in the USA:
Use these values for routing in all other countries:
Notes: The | ||||||||||||||||||||
| If
Notes: The
| ||||||||||||||||||||
| Specifies the route calculation should try to avoid ETC-transponder-only toll roads when determining the route if a vehicle does not have an ETC transponder. Possible values are:
If this parameter is not specified, ETC-transponder-only toll roads are not avoided. | ||||||||||||||||||||
| Specifies the precision of coordinates in the response. Possible values are:
Default value: | ||||||||||||||||||||
| Specifies how to reconstruct a given polyline or individual legs.
Note: this parameter can only be used when a route or legs are provided as part
of the request by using
Note: In any of the modes, the algorithm might relax certain restrictions near the origin and destination to offer a more sensible route instead of a no-route-found. This ensures that routes planned with our service can be reconstructed.
In short, this table summarizes the differences between the modes and restrictions:
| ||||||||||||||||||||
| Specifies the preference of roadside on arrival to waypoints and destination. Stop on the road has to be set at least two meters to the preferred side,
otherwise the behavior will default to
Default value: | ||||||||||||||||||||
| Number of desired alternative routes to be calculated. Fewer alternative routes may be returned if either fewer
alternatives exist, or the requested number of alternatives is larger than the service can calculate.
Default value: | ||||||||||||||||||||
| When
Note: The | ||||||||||||||||||||
| All alternative routes returned will follow the reference route (see the
POST data parameters section)
from the origin point of the
0 | ||||||||||||||||||||
| All alternative routes returned will follow the reference route (see the
POST data parameters section) from
the origin point of the
0 | ||||||||||||||||||||
| Largest index in the array of
Minimum value: | ||||||||||||||||||||
| Specifies the representation of the set of routes provided as a response. Possible values are:
Default value:
| ||||||||||||||||||||
| The directional heading of the vehicle, in degrees starting at true North and continuing in a clockwise direction.
Maximum value: | ||||||||||||||||||||
| Specifies which of the section types is reported in the route response.
travelMode | ||||||||||||||||||||
| Include toll payment types in the toll section. If a toll section has different toll payment types in its subsections, this toll section splits into multiple toll sections with the toll payment types. Possible values:
The value | ||||||||||||||||||||
| Specifies a list of margins in kilowatt-hours (kWh) for computing
Minimum value: | ||||||||||||||||||||
| Specifies the extended representation of the set of routes provided as a
response.
| ||||||||||||||||||||
| This feature allows EV drivers to manually choose the charging stops along their itinerary, while optimizing charging times for minimal Estimated Travel Time (ETT). Possible values are:
Default value: | ||||||||||||||||||||
| The desired minimum battery charge level upon arrival at the first charging station.
If this parameter is not provided,
an internal formula determines its value to allow route calculations with low current charge. | ||||||||||||||||||||
| Upon arrival at the destination, the minimum battery charge level may be reduced to this value if it allows the planning of a route without any charging stops.
For example, if the driver has a personal home charger and sets the home as the destination, it could be okay
to arrive there with a charge level lower than Minimum value: 0.0 Maximum value: minChargeAtDestinationInkWh Default value: minChargeAtDestinationInkWh | ||||||||||||||||||||
| The
en-GB |
POST data parameters
Some parameters are provided using the HTTP POST
method.
- The POST data should be in JSON format, see the Content-Type header.
- The POST data body must contain either a
chargingParameters
field (recommended charging model) or achargingModes
field (legacy charging model). It may also contain other fields such asreassessmentParameterSets
,supportingPoints
,encodedPolyline
, etc., that are defined and explained in the upcoming subsections.
There is an upper limit on the total size of the POST data.
- Exceeding this limit results in a response with the response code
413
, indicating invalid POST data. - The client must not rely on the exact value of this limit.
- The current limit is 10 MB.
Charging parameters and charging modes fields are respectively defined in the following two subsections.
ChargingParameters
The following tables show required and optional charging parameters, respectively:
Required parameters | Description |
---|---|
| A piecewise-constant function which maps a state of charge (SoC) of a
battery to the maximum charging power supported for this state of
charge. It is used to compute the charging times of the vehicle.
It must contain zero to up to 20 (inclusive) JSON objects each
containing the properties
If an empty curve is provided, the charging power will be limited solely by the maximum power of the specified connectors and the charging facility's supported charging power. |
| Must be a non-empty array of
|
| One of the values |
| A non-empty list of |
Optional parameters | Description |
---|---|
| A constant time offset in seconds added to the computed charging time
at each charging stop planned along the route. If not specified, the
default value |
| Optional efficiency factor applied to the power provided by a charging
facility and the maximum charging power for each point of the battery
charging curve. If not specified, the default value |
| An optional base load considered when determining the available
charging power. The base load is subtracted from the power
provided by the charging facility prior to applying the efficiency
factor. If not specified, the default value |
| Sets an upper limit for the charging power. The resulting
charging power is the minimum of the charging power supported by the
respective charging facility and this value.
It must be a positive number or zero, where |
| Sets an upper limit for the voltage when charging. The resulting
voltage is the minimum of the voltage supported by the respective
charging facility and this value.
It must be a positive number or zero, where |
| Sets an upper limit for the current when charging. The resulting
amperage is the minimum of the amperage supported by the respective
charging facility and this value.
It must be a positive number or zero, where |
| Specifies a voltage range as a right-open interval for the connector,
defaulting to the range
Note: Explicitly specifying the voltage range of a connector may be necessary when the vehicle supports multiple connectors with the same current type (typically DC) and plug type, with each connector supporting different maximum charging powers depending on the voltage. |
An example to POST request for charging parameters is as follows:
1 {2 [...],3 "chargingParameters": {4 "batteryCurve": [5 {6 "stateOfChargeInkWh": 50.0,7 "maxPowerInkW": 2008 },9 {10 "stateOfChargeInkWh": 70.0,11 "maxPowerInkW": 10012 },13 {14 "stateOfChargeInkWh": 80.0,15 "maxPowerInkW": 4016 }17 ],18 "chargingConnectors": [19 {20 "currentType": "AC3",21 "plugTypes": [22 "IEC_62196_Type_2_Outlet",23 "IEC_62196_Type_2_Connector_Cable_Attached",24 "Combo_to_IEC_62196_Type_2_Base"25 ],26 "efficiency": 0.9,27 "baseLoadInkW": 0.2,28 "maxPowerInkW": 1129 },30 {31 "currentType": "DC",32 "plugTypes": [33 "IEC_62196_Type_2_Outlet",34 "IEC_62196_Type_2_Connector_Cable_Attached",35 "Combo_to_IEC_62196_Type_2_Base"36 ],37 "voltageRange": {38 "minVoltageInV": 0,39 "maxVoltageInV": 50040 },41 "efficiency": 0.9,42 "baseLoadInkW": 0.2,43 "maxPowerInkW": 15044 },45 {46 "currentType": "DC",47 "plugTypes": [48 "IEC_62196_Type_2_Outlet",49 "IEC_62196_Type_2_Connector_Cable_Attached",50 "Combo_to_IEC_62196_Type_2_Base"51 ],52 "voltageRange": {53 "minVoltageInV": 500,54 "maxVoltageInV": 200055 },56 "efficiency": 0.9,57 "baseLoadInkW": 0.258 }59 ],60 "chargingTimeOffsetInSec": 60,61 "preferredMSPs": ["Shell Recharge", "MyEasyCharge"]62 }
ChargingModes
The following table shows required and optional charging modes, respectively:
Required parameters | Description |
---|---|
| A string matching a |
| A string matching a |
| A battery charge level in kWh. |
| A time span in seconds. A non-negative integer. |
| A supporting point of a charging curve consisting of |
| A piecewise-linear function which maps a target charge level to the time it takes to charge an empty battery to this level, that is used to compute charging times of the vehicle.
|
| Contains one |
| A non-empty list of at most 20 unique |
| Contains |
| A non-empty list of at most 10 |
An example POST request for charging modes is as follows:
1 {2 [...],3 "chargingModes" : [4 {5 "chargingConnections" : [6 {"facilityType" : "Charge_200_to_240V_1_Phase_at_32A", "plugType" : "CHAdeMO"},7 {"facilityType" : "Charge_380_to_480V_3_Phase_at_16A", "plugType" : "CHAdeMO"}8 ],9 "chargingCurve" : [10 {"chargeInkWh" : 1.0, "timeToChargeInSeconds" : 300},11 {"chargeInkWh" : 2.1, "timeToChargeInSeconds" : 500},12 {"chargeInkWh" : 10.0, "timeToChargeInSeconds" : 3100}13 ]14 },15 {16 "chargingConnections" : [17 {"facilityType" : "Charge_200_to_240V_1_Phase_at_10A", "plugType" : "Standard_Household_Country_Specific"},18 {"facilityType" : "Charge_100_to_120V_1_Phase_at_16A", "plugType" : "CHAdeMO"}19 ],20 "chargingCurve" : [21 {"chargeInkWh" : 1.0, "timeToChargeInSeconds" : 600},22 {"chargeInkWh" : 3.0, "timeToChargeInSeconds" : 2000},23 {"chargeInkWh" : 10.0, "timeToChargeInSeconds" : 8000}24 ]25 },26 "reassessmentParameterSets" : [27 {"auxiliaryPowerInkW" : 0.3}28 ]29 ]30 }
Other POST parameters
The supportingPoints
field is used to reconstruct a route. This route is then used as a reference route for route reassessment, or calculating zero or more alternative routes.
- The provided sequence of supporting points is used as input for route reconstruction.
- The
pointWaypoints
field is used to represent waypoints when reconstructing a route. - The alternative routes are calculated between the origin and destination points specified in the
routePlanningLocations
, passing through all intermediate locations specified in thepointWaypoints
field. - If
supportingPointIndexOfOrigin
is not used, and bothminDeviationDistance
andminDeviationTime
are set to zero, then these origin and destination points are expected to be at (or very near) the beginning and end of the reference route, respectively. - The reference route may contain traffic incidents of type
ROAD_CLOSURE
, which are ignored for the calculation of the reference route's travel time and traffic delay.
Using supportingPointIndexOfOrigin
, or setting at least one of minDeviationDistance
or minDeviationTime
to a value greater than zero, has the following consequences:
- The origin point of the
calculateLongDistanceEVRoute
request must be on (or very near) the input reference route. - If this is not the case, an error is returned.
- However, the origin point does not need to be at the beginning of the input reference route (it can be thought of as the current vehicle position on the reference route).
- If used,
supportingPointIndexOfOrigin
must precisely indicate the location of the origin point in relation to thesupportingPoints
. - The reference route, returned as the first route in the
calculateLongDistanceEVRoute
response, will start at the origin point specified in thecalculateLongDistanceEVRoute
request. The initial part of the input reference route up until the origin point will be excluded from the response. - The values of
minDeviationDistance
andminDeviationTime
determine how far alternative routes will be guaranteed to follow the reference route from the origin point onwards. - The
vehicleHeading
is ignored.
The calculateLongDistanceEVRoute
endpoint accepts requests with user defined (manual) waypoints
to visit. A manual waypoint is specified by its coordinates and needs to be added to routePlanningLocations
of the request path.
A subset of such manually added waypoints can be marked as charging stops by extending the POST data body with the
chargingWaypoints
parameter. The details, such as the charging park unique identifier (UUID), of all the charging stops
in the locations list must be provided under this parameter. If the charging stop details are not provided then the
location is considered as a non-charging waypoint.
The following table describes the set of common POST request parameters that can be used in the Long Distance EV Routing service. All of them are optional.
Parameter | Description |
---|---|
| This is an array of strings. Each string should be a 3-character, ISO 3166-1, alpha-3 country code.
Note: It is an error to specify both |
| This is an array of strings. Each string should be a 3-character, ISO 3166-1, alpha-3 country code.
Note: It is an error to specify both |
| An array of |
| A string in the Encoded polyline format representing the array of points to be used as input for route reconstruction.
The precision used to encode the polyline must be set in the |
| The precision used to encode the polyline in the
|
pointWaypoints | An array of
|
pointWaypoint | Contains one |
chargingWaypoints | A list of one or more
|
| A |
reassessmentParameterSets | An array of
|
| An array of objects with the parameters for the computation of each leg. If the parameter is such
that it is available for use in the query parameters, then its simultaneous use in the query
parameters and in the POST data is prohibited, and such a request will be returned with an error.
If the |
| A non-empty list of UUIDs of charging parks to avoid in the route. You can specify up to 40 charging parks to be avoided. Every element must follow the format specified in RFC4122. This is a soft avoid, i.e., a route with avoided parks is returned if no other route can be found. |
| A list of unique preferred operators to use in the route. You can specify up to 20 preferred operators. |
| A list of unique operators to avoid in the route. You can specify up to 40 operators to be avoided. This is a soft avoid, i.e., a route with avoided operators is returned if no other route can be found. |
| A non-empty JSON array of unique Plug-and-Charge Providers. The charging parks with these providers are preferred if there is a connector available that supports Plug-and-Charge. You can specify up to 20 Plug-and-Charge preferred providers. Each string can be up to 40 letters long. |
| The name of the preferred Mobility Service Provider (MSP). It can be up to 40 characters long. |
| A non-empty JSON array of one or more
|
| Must contain a |
| Specifies additional parameters for the stop at the end of the current leg. See route stop for details. |
routeStop
Optional parameters | Description |
---|---|
| Specifies the waiting time at route stops (including charging time).
It must be 0 in the last leg (the destination).
Default value: |
| Specifies the entry points for the stop at the end of the current leg. The route to the stop is calculated based on these entry points. Entries with the same location are not allowed. |
entryPoint
Parameters | Description |
---|---|
| Latitude of the entry point. Required. |
| Longitude of the entry point. Required. |
pointWaypoints
Required parameters | Description |
---|---|
| Denotes the source of the waypoint. Possible values:
|
supportingPointIndex | An index into the
|
Optional parameters | Description |
---|---|
| Specified if the waypoint is a charging stop. Must contain the fields
|
An example POST request for point waypoints is as follows:
1 {2 [...],3 "supportingPoints": [4 {"latitude": 52.50930, "longitude": 13.42936},5 {"latitude": 52.50844, "longitude": 13.42859},6 {"latitude": 52.50764, "longitude": 13.42752}7 ],8 "pointWaypoints": [9 {10 "waypointSourceType": "AUTO_GENERATED",11 "supportingPointIndex": 1,12 "chargingInformationAtWaypoint": {13 "chargingParkUuid": "ffffffff-bcd3-2fa5-0000-000000153b86",14 "targetChargeInkWh": 40.0,15 "chargingTimeInSeconds": 1800,16 "chargingConnectionInfo": {17 "chargingPlugType": "Combo_to_IEC_62196_Type_2_Base",18 "chargingCurrentType": "Direct_Current",19 "chargingPowerInkW": 25.0,20 "chargingVoltageInV": 400.0,21 "chargingCurrentInA": 62.022 }23 }24 }25 ]26 }
chargingWaypoints
Required parameters | Description |
---|---|
| A positive integer depicting the charging waypoint's index in the route planning locations list. Must be in the range 1-150. |
| A non-blank string depicting the ID of the charging park, which is at the index |
An example POST request for charging waypoints is as follows:
1 {2 [...],3 "chargingWaypoints": [4 {5 "waypointIndex": 1,6 "chargingParkId": "64470d9f-100f-3c41-5d48-d2a500153b86"7 }8 ]9 }
Request content example
Note: for the purpose of brevity the following example may contain fields that are incompatible with others, and in practice only a subset of them will be present in the request.
1 {2 "chargingParameters": {3 "batteryCurve": [4 {5 "stateOfChargeInkWh": 50.0,6 "maxPowerInkW": 2007 },8 {9 "stateOfChargeInkWh": 70.0,10 "maxPowerInkW": 10011 },12 {13 "stateOfChargeInkWh": 80.0,14 "maxPowerInkW": 4015 }16 ],17 "chargingConnectors": [18 {19 "currentType": "AC3",20 "plugTypes": [21 "IEC_62196_Type_2_Outlet",22 "IEC_62196_Type_2_Connector_Cable_Attached",23 "Combo_to_IEC_62196_Type_2_Base"24 ],25 "efficiency": 0.9,26 "baseLoadInkW": 0.2,27 "maxPowerInkW": 1128 },29 {30 "currentType": "DC",31 "plugTypes": [32 "IEC_62196_Type_2_Outlet",33 "IEC_62196_Type_2_Connector_Cable_Attached",34 "Combo_to_IEC_62196_Type_2_Base"35 ],36 "voltageRange": {37 "minVoltageInV": 0,38 "maxVoltageInV": 50039 },40 "efficiency": 0.9,41 "baseLoadInkW": 0.2,42 "maxPowerInkW": 15043 },44 {45 "currentType": "DC",46 "plugTypes": [47 "IEC_62196_Type_2_Outlet",48 "IEC_62196_Type_2_Connector_Cable_Attached",49 "Combo_to_IEC_62196_Type_2_Base"50 ],51 "voltageRange": {52 "minVoltageInV": 500,53 "maxVoltageInV": 200054 },55 "efficiency": 0.9,56 "baseLoadInkW": 0.257 }58 ],59 "chargingTimeOffsetInSec": 6060 },61 "avoidChargingParks": ["{uuid1}", "{uuid2}", {...}, "{uuidN}"],62 "preferChargingParkOperators": ["{id1}", "{id2}", {...}, "{idN}"],63 "avoidChargingParkOperators": ["{id1}", "{id2}", {...}, "{idN}"],64 "preferredPlugAndChargeProviders": ["{PnC1}", "{PnC2}", {...}, "{PnCN}"]65 "preferredMSPs": ["Shell Recharge", "MyEasyCharge"],66 "supportingPoints": [67 {"latitude": 52.50930, "longitude": 13.42936},68 {"latitude": 52.50844, "longitude": 13.42859},69 {"latitude": 52.50764, "longitude": 13.42752}70 ],71 "encodedPolyline": "ogcph^_esc_GnxOf`N~rNv{S",72 "encodedPolylinePrecision": 7,73 "pointWaypoints": [74 {75 "waypointSourceType": "AUTO_GENERATED",76 "supportingPointIndex": 1,77 "chargingInformationAtWaypoint": {78 "chargingParkUuid": "ffffffff-bcd3-2fa5-0000-000000153b86",79 "targetChargeInkWh": 40.0,80 "chargingTimeInSeconds": 1800,81 "chargingConnectionInfo": {82 "chargingPlugType": "Combo_to_IEC_62196_Type_2_Base",83 "chargingCurrentType": "Direct_Current",84 "chargingPowerInkW": 25.0,85 "chargingVoltageInV": 400.0,86 "chargingCurrentInA": 62.087 }88 }89 }90 ],91 "chargingWaypoints": [92 {93 "waypointIndex": 1,94 "chargingParkId": "{uuid}"95 }96 ],97 "chargingDestination":98 {99 "chargingParkId": "{uuid}"100 },101 "legs": [102 {103 "routeStop": {104 "pauseTimeInSeconds": 610,105 "entryPoints": [106 {107 "latitude": 52.50601,108 "longitude": 13.42742109 }110 ]111 }112 },113 {114 }115 ]116 }
Consumption and charging models
The following data table describes all the parameters that can be specified in a request using the Electric model.
- Required parameters must be used or the call will fail.
- Optional parameters may be used.
- The order of parameters in a request is not important.
- The
vehicleEngineType
parameter must beelectric
to be able to usecalculateLongDistanceEVRoute
.
Required parameters | Description |
---|---|
| Specifies the speed-dependent component of consumption.
Consumption rates for speeds not in the list are found as follows:
The list must contain between 1 and 25 points (inclusive), and may not contain duplicate points for the same speed.
Minimum value: |
Optional parameters | Description |
---|---|
| Specifies the maximum electric energy supply in kilowatt hours (kWh)
that may be stored in the vehicle's battery.
Note: Requires |
| Specifies the amount of power consumed for sustaining auxiliary systems,
in kilowatts (kW). It can be used to specify consumption due to devices
and systems such as AC systems, radio, heating, etc. |
| Specifies the efficiency of converting electric energy to kinetic energy
when the vehicle accelerates (i.e.,
Minimum value: |
| Specifies the efficiency of converting kinetic energy to electric energy
when the vehicle decelerates (i.e.,
Minimum value: |
| Specifies the efficiency of converting electric energy to potential
energy when the vehicle gains elevation (i.e.,
Minimum value: |
| Specifies the efficiency of converting potential energy to electric
energy when the vehicle loses elevation (i.e,
Minimum value: |
| Specifies the electric energy in kWh consumed by the vehicle through gaining 1000 meters of elevation. Notes:
Minimum value: |
| Specifies the electric energy in kWh gained by the vehicle through losing 1000 meters of elevation. Notes:
Minimum value: |
In the Electric Consumption model, explicitly specifying some parameters requires specifying some others as well. In addition, some parameters are mutually exclusive. These are the constraints:
accelerationEfficiency
anddecelerationEfficiency
must always be specified as a pair (i.e., both or none).- If
accelerationEfficiency
anddecelerationEfficiency
are specified, the product of their values must not be greater than1
(to prevent perpetual motion).
- If
uphillEfficiency
anddownhillEfficiency
must always be specified as a pair (i.e., both or none).- If
uphillEfficiency
anddownhillEfficiency
are specified, the product of their values must not be greater than1
(to prevent perpetual motion).
- If
consumptionInkWhPerkmAltitudeGain
andrecuperationInkWhPerkmAltitudeLoss
must always be specified as a pair (i.e., both or none).- If they are specified,
recuperationInkWhPerkmAltitudeLoss
must not be greater thanconsumptionInkWhPerkmAltitudeGain
(to prevent perpetual motion).
- If they are specified,
- If
accelerationEfficiency
,decelerationEfficiency
,uphillEfficiency
,downhillEfficiency
parameters are specified by the user, thenvehicleWeight
must also be specified. - If
accelerationEfficiency
,decelerationEfficiency
,uphillEfficiency
,downhillEfficiency
parameters are specified by the user, thenconsumptionInkWhPerkmAltitudeGain
andrecuperationInkWhPerkmAltitudeLoss
cannot be specified. maxChargeInkWh
andcurrentChargeInkWh
must always be specified as a pair (i.e., both or none).
Note that if only constantSpeedConsumptionInkWhPerHundredKm
is specified, no other consumption aspects are taken into account, i.e., slopes and vehicle acceleration are not considered for consumption computations.
Sensible values of consumption parameters
It is possible that a particular set of consumption parameters is rejected, even though it might fulfill all the explicit requirements specified previously. This will happen when the value of a specific parameter, or a combination of values of several parameters, is deemed to lead to unreasonable magnitudes of consumption values.
If that happens, it most likely indicates an input error, as proper care is taken to accommodate all sensible values of consumption parameters. In case a particular set of consumption parameters is rejected, the accompanying error message will contain a textual explanation of the reason(s).
Example:
Parameter | Sensible values by model |
---|---|
| 50,8.2:130,21.3 |
| 1900 |
| 43 |
| 85 |
| 1.7 |
| 0.66 |
| 0.91 |
| 0.74 |
| 0.73 |
| 7.0 |
| 3.8 |
Response data
Response headers
The following data table describes HTTP response headers of particular interest to the Long Distance EV Routing service clients.
Header | Description |
---|---|
Access-Control-Expose-Headers | The service whitelists response headers that browsers are allowed to
access.
Value: |
Access-Control-Allow-Origin | The service allows cross-origin resource sharing.
Value: |
Content-Encoding | The service supports HTTP compression, if requested by the client.
Value: |
Content-Type | The format of the response. The service supports specifying the desired
response format. See the
|
Cache-Control | The Cache-Control general-header field is used to specify directives that must be obeyed by all caching mechanisms along the request/response chain. It is supported by HTTP/1.1 clients. It may not be supported by HTTP/1.0 clients. Values:
|
Pragma | The Pragma general-header field is used to specify directives that might
apply to any recipient along the request/response chain. It is supported
by HTTP/1.0 client.
Value: |
Tracking-ID | This is an identifier for the request. If |
Warning | This may be sent for deprecated features. |
Response codes
The following table describes HTTP response codes of particular interest to the Long Distance EV Routing service clients.
Code | Meaning & possible causes |
---|---|
200 | OK: A route or range was calculated and the body of the response contains the data for a successful response. |
400 | Bad request:
|
403 | Permission or authentication issues:
|
404 | Not Found: The requested resource could not be found, but it may be available again in the future. |
405 | Method Not Allowed: The client used a HTTP method other than GET or POST. |
408 | Request timeout: The client took too long to transmit the request. |
414 | Requested uri is too long. |
415 | Unsupported Media Type. |
429 | Too Many Requests: Too many requests were sent in a given amount of time for the supplied API Key. |
500 | An error occurred while processing the request. Please try again later. This can also indicate that the request reached an internal computation time threshold and timed out. |
502 | Internal network connectivity issue. |
503 | Service currently unavailable. |
504 | Internal network connectivity issue. |
596 | Service not found. |
Example of a successful response
A successful route response is received if the input parameters comprised of the coordinates, chargingParkId
and waypointIndex
are valid.
- The routes in a successful response are listed in the order of decreasing optimality.
- In case the request includes the supporting points supportingPoints field, the response will specify the reconstructed route before any alternative routes.
- The response would contain all the specified waypoints in the requested order.
- It may also contain charging stops that are automatically added based on the vehicle's consumption and charging model.
- The most optimal charging times are chosen for all the charging stops in order to get the fastest possible route.
- This may result in some manually added charging waypoints to have zero charging time, i.e., charge at departure = charge at arrival.
The type of charging stop is defined by the chargingStopType
attribute in chargingInformationAtEndOfLeg
. This attribute has the following values:
User_Defined
for user-specified charging stops.Auto_Generated
for automatically-added charging stops.
In the case of invalid input parameters, route calculation fails, and no route is received.
A successful response when chargingParameters
is used in the request could look like this:
1 [...],2 "routes": [3 {4 [...],5 "summary": {6 [...],7 "remainingChargeAtArrivalInkWh": 16.5,8 "totalChargingTimeInSeconds": 25429 },10 "legs": [11 [...],12 {13 [...],14 "summary": {15 [...],16 "originalWaypointIndexAtEndOfLeg": 0,17 "remainingChargeAtArrivalInkWh": 12.5,18 "chargingInformationAtEndOfLeg": {19 "targetChargeInkWh" : 30.0,20 "chargingTimeInSeconds" : 2542,21 "chargingParkUuid" : "a4b60dff-b599-339a-0a1b-aae200153b86",22 "chargingParkExternalId" : "4e9989d7-6586-44f6-ae76-fd6901b58777",23 "chargingParkName" : "Charging park 1",24 "chargingParkOperatorName": "Charging park operator name",25 "chargingParkLocation": {26 "coordinate" : {"latitude" : 0.6666667, "longitude" : -33.3333333},27 "street" : "Main street",28 "houseNumber" : "42a",29 "city" : "New Berlin",30 "postalCode" : "32606",31 "countryCode" : "US"32 },33 "chargingConnectionInfo": {34 "chargingVoltageInV": 900.0,35 "chargingCurrentInA": 194.0,36 "chargingCurrentType" : "Direct_Current",37 "chargingPowerInkW" : 174.6,38 "chargingPlugType" : "Combo_to_IEC_62196_Type_2_Base",39 "plugAndChargeSupport" : "SUPPORTED"40 },41 "chargingParkPaymentOptions": [42 {"method": "Direct"}43 ],44 "chargingStopType" : "Auto_Generated",45 "chargingParkPowerInkW" : 175.046 }47 }48 }49 ]50 }51 ]52}
A successful response when chargingModes
is used in the request could look like this:
1 [...],2 "routes": [3 {4 [...],5 "summary": {6 [...],7 "remainingChargeAtArrivalInkWh": 16.5,8 "totalChargingTimeInSeconds": 25429 },10 "legs": [11 [...],12 {13 [...],14 "summary": {15 [...],16 "originalWaypointIndexAtEndOfLeg": 0,17 "remainingChargeAtArrivalInkWh": 12.5,18 "chargingInformationAtEndOfLeg": {19 "targetChargeInkWh" : 30.0,20 "chargingTimeInSeconds" : 2542,21 "chargingConnections" : [22 {"facilityType" : "Charge_380_to_480V_3_Phase_at_32A", "plugType" : "NEMA_5_20"},23 {"facilityType" : "Charge_Direct_Current_at_50kW", "plugType" : "IEC_62196_Type_2_Outlet"}24 ],25 "chargingParkUuid" : "a4b60dff-b599-339a-0a1b-aae200153b86",26 "chargingParkName" : "Charging park 1",27 "chargingParkOperatorName": "Charging park operator name",28 "chargingParkLocation": {29 "coordinate" : {"latitude" : 0.6666667, "longitude" : -33.3333333},30 "street" : "Main street",31 "houseNumber" : "42a",32 "city" : "New Berlin",33 "postalCode" : "32606",34 "countryCode" : "US"35 },36 "chargingConnectionInfo": {37 "chargingCurrentType" : "Direct_Current",38 "chargingPowerInkW" : 25.0,39 "chargingPlugType" : "IEC_62196_Type_2_Outlet"40 },41 "chargingParkPaymentOptions": [42 {"method": "Direct"}43 ],44 "chargingStopType" : "Auto_Generated",45 "chargingParkPowerInkW" : 50.046 }47 }48 }49 ]50 }51 ]52 }
The following changes apply to the response when chargingModes
is used instead of chargingParameters
in the request:
chargingInformationAtEndOfLeg
containschargingConnections
.chargingInformationAtEndOfLeg
does not containchargingParkExternalId
.chargingConnectionInfo
does not containchargingVoltageInV
andchargingCurrentInA
.
Example of an error response
If an error occurs, the response contains the description of the error. The error response would look like this:
1 {2 "formatVersion": "0.0.12",3 "detailedError": {4 "code": "<error code>",5 "message": "Error message"6 }7 }
Special behavior of certain types of errors - authentication errors, request quota related errors, etc.
- For those errors the HTTP status code is returned as normal (
400
,500
, ...) and the response content type istext/xml
independent of the request content type. - For those errors, the content does not follow the documented format for error responses.
- Note: This imperfection should not cause problems during normal use of the API.
Structure of a successful response
Note that some names are implicitly defined. One example is the name leg
when describing legs
as an array of leg
objects.
JSON field | Description | ||
---|---|---|---|
| The format version. | ||
| The request may return more than one route.
Each object has at least a | ||
|
| ||
| A description of a part of a route, comprised of an array of points.
| ||
| Each object in the array is a location on the surface of the globe
defined by its | ||
| A string in the encoded polyline format
representing the array of points describing a part of a route.
The precision used to encode the polyline is set in the | ||
| The precision used to encode the polyline in the | ||
| This array is available inside
| ||
| Index of the first point (offset | ||
| Index of the last point (offset | ||
| Type of the incident.
| ||
| The effective speed of the incident in km/h, averaged over its entire length. | ||
| The delay in seconds caused by the incident. | ||
| The magnitude of delay caused by the incident. Possible values:
These values correspond to the values of the response field
| ||
| Details of the traffic event. It uses the definitions in the
TPEG2-TEC
standard. It can contain the | ||
| The effect on the traffic flow. Contains a value in the
| ||
| Each object in the array describes one cause of the traffic event.
| ||
| The main cause of the traffic event. Contains a value in the
| ||
| The sub-cause of the traffic event. Contains a value in the sub cause
table defined by the | ||
| The route or leg length in meters. | ||
| The estimated travel time in seconds. | ||
| The delay in seconds compared to free-flow conditions according to real-time traffic information. | ||
| The portion of the route or leg, expressed in meters, that is affected by traffic events which cause the delay. | ||
| The estimated travel time in seconds calculated as if there are no
delays on the route due to traffic conditions (e.g., congestion).
Included if requested using the | ||
| The estimated travel time in seconds calculated using time-dependent
historic traffic data. Included if requested using the
| ||
| The estimated travel time in seconds calculated using real-time speed
data. Included if requested using the | ||
| The distance (in meters) from the origin point of the
| ||
| The travel time (in seconds) from the origin point of the
| ||
| The coordinates of the first point following the origin point of the
| ||
| The estimated electric energy consumption in kilowatt hours (kWh) using the Electric Consumption Model.
| ||
| This field is included if
| ||
| The estimated departure time for the route or leg. Specified as a
| ||
| The estimated arrival time for the route or leg. Specified as a
| ||
| Each object in the array represents an effective parameter or a data
used when calling the Calculate Route API. Each object has fields
| ||
| The reason for a better route proposal. Can currently be:
This field is included in the response only if the route is requested
with | ||
| This field is included if
A
| ||
| The index of the waypoint at the end of the leg that corresponds to:
This field is not provided if the end of the leg corresponds to the destination or to a new charging waypoint that is not present in the request. | ||
| Contains the value of | ||
| Identifies the entry point that was used for the route at the end of the leg.
This index corresponds to the position of this entry point in the list of entry points within the respective leg.
The first entry point has an index equal to 0.
This field is only present if the leg had | ||
| The base URL of the Road Shields service to fetch the road shield atlas and metadata resources. Currently available resources are:
We recommend to cache the sprite atlas ( | ||
| The speed in km/h for the hands-free section. | ||
| The integer value of importance. The index starts from 0, and a lower value means higher importance. The index is needed for two reasons:
| ||
| An object contains a | ||
| An array of objects of type | ||
| A summary of a route or a route leg. The
| ||
| The estimated battery charge in kWh upon arrival at the end of the leg or the route. | ||
| The
In addition, it may contain any of the following:
| ||
| The charge in kWh to which the battery should be charged. | ||
| The estimated time in seconds spent at the charging stop, allowing for some additional time needed to use the charging facility. | ||
| A list of | ||
| The common name of this charging park. | ||
| The operator name of this charging park. | ||
chargingParkPowerInkW float | The rated power in kilowatts of the charging park. | ||
| The
| ||
| Object is the coordinate of the charging station defined by its latitude and longitude fields. It may differ from the location on the road to drive to. | ||
| The street name of the charging park. | ||
| The house number of the charging park. | ||
| The city of the charging park. | ||
| The region of the charging park. | ||
| The postal code of the charging park. | ||
| The country code of the charging park in the
| ||
| The
In addition, it may contain any of the following:
For requests having
In addition, it may contain any of the following:
| ||
| The rated voltage in volts of the charging process. | ||
| The rated current in amperes of the charging process. | ||
| An element of the
| ||
| The rated maximal power in kilowatts of the charging connection. | ||
| Indicates if the selected charging connector supports Plug-and-Charge. Possible values are:
| ||
| The element of the
|
| Indicates if the selected charging connector supports Plug-and-Charge. Possible values are:
|
| A list of one or more | ||
| The
| ||
| An element of the
| ||
| A list of | ||
| A brand name associated with the charging park. The brand and a Mobility Service Provider are synonymous. | ||
| The source of the charging stop at the end of this leg.
| ||
| The unique identifier of this charging park. This UUID can be used to check the availability of the charging park. | ||
| The estimated time spent at all charging stops in the route. The
| ||
| Contains one | ||
| An element of the
| ||
| A unique string id for search purposes. | ||
| An element of the
|
Structure of the section object
Each section
object contains additional information about parts of a route. A section
object contains at least the fields startPointIndex
, endPointIndex
, and sectionType
.
JSON field | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Contains the response section type.
| ||||||||||||||||||||||||||||||||||||||||
| This field is either set to the value given to the request parameter
| ||||||||||||||||||||||||||||||||||||||||
| The
|
Structure of an error response
JSON field | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| This object provides a representation of the error message. It contains
a
|
Structure of a road shield reference object
JSON field | Description | ||||||
---|---|---|---|---|---|---|---|
| This object describes a single road shield reference. It contains the following fields:
|
Calculating Long Distance EV Route with a charging park as the final destination
The calculateLongDistanceEVRoute
endpoint accepts requests with a charging park as the destination. A charging park is specified by its unique identifier (UUID) which must be added to the POST data of the request. It's required the charging park specified by the UUID matches the destination's coordinates.
POST request body with chargingDestination
1{2 [...],3 "chargingDestination":4 {5 "chargingParkId": "{uuid}"6 },7 [...]8}
Description of the chargingDestination
parameter
Parameter | Description |
---|---|
| A non-blank string depicting the ID of the charging park of the destination. The user can retrieve this ID from the TomTom EV Search. |
Example curl command with chargingPark
as the destination
1curl -X POST "https://api.tomtom.com/routing/1/calculateLongDistanceEVRoute/52.507,13.492:52.47582,13.36404/json?key={YOUR_API_KEY}&vehicleEngineType=electric&constantSpeedConsumptionInkWhPerHundredkm=32,10.87:77,18.01¤tChargeInkWh=20&maxChargeInkWh=40&minChargeAtDestinationInkWh=4&minChargeAtChargingStopsInkWh=4"\2 -H 'Content-Type: application/json' -d '{3 "chargingDestination":4 {5 "chargingParkId": "27cddfad-d11e-42bb-aba2-b5a850ee0db3"6 },7 "chargingModes": [8 {9 "chargingConnections": [10 {11 "facilityType": "Charge_380_to_480V_3_Phase_at_32A",12 "plugType": "IEC_62196_Type_2_Outlet"13 }14 ],15 "chargingCurve": [16 {17 "chargeInkWh": 6,18 "timeToChargeInSeconds": 36019 },20 {21 "chargeInkWh": 12,22 "timeToChargeInSeconds": 72023 },24 {25 "chargeInkWh": 28,26 "timeToChargeInSeconds": 194427 },28 {29 "chargeInkWh": 40,30 "timeToChargeInSeconds": 468031 }32 ]33 },34 {35 "chargingConnections": [36 {37 "facilityType": "Charge_200_to_240V_1_Phase_at_10A",38 "plugType": "Standard_Household_Country_Specific"39 }40 ],41 "chargingCurve": [42 {43 "chargeInkWh": 6,44 "timeToChargeInSeconds": 1562445 },46 {47 "chargeInkWh": 12,48 "timeToChargeInSeconds": 3265249 },50 {51 "chargeInkWh": 28,52 "timeToChargeInSeconds": 7624853 },54 {55 "chargeInkWh": 40,56 "timeToChargeInSeconds": 10908057 }58 ]59 }60 ]61}'
Long Distance EV Routing response
A successful route response is received if the input parameter chargingParkId
is valid. The response would contain
the data field chargingInformationAtEndOfLeg
with charging information of the specified charging park in the summary
of the last leg. The charging information would contain targetChargeInkWh
calculated as
max(maxChargeInkWh * 0.8, remainingChargeAtArrivalInkWh)
, and chargingTimeInSeconds
set either to 0
or to the
respective charging time if targetChargeInkWh
is greater than remainingChargeAtArrivalInkWh
. chargingTimeInSeconds
in the summary
of the last leg is not included into the route's nor the leg's travel time travelTimeInSeconds
,
and is provided as reference information for the driver.
In the case of an invalid input parameter chargingParkId
, the chargingParkId
is ignored, and the destination is
considered as a destination without a charging park. The destination's coordinates are used as a final destination.
Route geometry representation formats
Certain request and response fields that describe route geometry as a polyline support two alternative representation formats:
- An array of points defined as raw decimal coordinates, such as the
supportingPoints
field in requests and thepoints
field in responses. - An encoded polyline string, such as the
encodedPolyline
field in both requests and responses.
Where documented, either of the two representations can be used. This is purely a matter of representation and is independent of any other statements about route geometry. The field containing the array of points is used as a stand-in for the concern of route geometry. For brevity, any references and constraints related to the polyline are stated using the stand-in only.
Using encoded polylines can significantly reduce the data size of requests and responses.
Encoded polyline format
For efficient representation of polylines as encoded polyline strings, this service uses an extended version of the
Encoded Polyline Algorithm Format.
The original algorithm limits coordinate precision to 5 decimal places by using a multiplier of 1e5
for the decimal values.
The extension allows using multipliers of both 1e5
and 1e7
.
These multipliers correspond to precisions of 5 and 7 decimal places.
Please note that each field in the encoded polyline format may have limitations on its supported precisions.
Since the encoded polyline string doesn't contain information of the precision or multiplier used, this information must be provided separately alongside each encoded polyline string.
We recommend taking special care when using the higher precision, as some encoding implementations may suffer internal overflows with the higher multiplier.
Encoding
When encoding a polyline, select a supported precision and use the respective multiplier for the decimal value instead of the fixed 1e5
multiplier in the original algorithm (refer to the following table).
Otherwise, the encoding process remains the same as in the original algorithm.
Ensure to send the precision used alongside each encoded polyline string in the request.
Decoding
When decoding a received polyline, use the provided precision next to the encoded polyline string to determine the appropriate multiplier for the decimal value instead of the fixed 1e5
multiplier in the original algorithm (refer to the following table).
Otherwise, the decoding process remains the same as in the original algorithm.
Note that each encoded polyline string is accompanied by the precision used for its encoding.
Precisions and multipliers
The following table illustrates the relationship between precision and multiplier:
Precision | Multiplier |
---|---|
5 | 1e5 |
7 | 1e7 |