Recalculate the route
Besides the updateNavigation
mutation, there is another way to alter the route in a navigation session. By using the recalculateNavigation
mutation a new route calculation can be enforced.
Mutation
To recalculate a route a navigation id
and current_location
need to be provided. Optionally, via
points, a state_of_charge
, and telemetry
data can be included to optimize the new route. If the mutation executed succesfully, OK
will be returned on the data object. The updates itself will be reflected on the navigationUpdatedById
subscription or the navigation
query. When using a query, please be aware that changes can take a little while to process.
To illustrate when this mutation should be used, two scenario's are described below.
1. Deviate from the route
In case a vehicle deviates from the calculated route (e.g. the driver takes a wrong exit), most navigation SDKs will detect this. It is recommended to hook into the event and send the location from the off route callback. Since recalculating a route can take a little while, make sure to not send multiple requests but wait until the navigationUpdatedById
returns a new route.
2. Changing the via points
The second use case for using this operation is to change the manually added via points. This allows the driver to change the order of the via points, to add new ones or to delete them. Note that via points that were already reached are eliminated automatically.
Arguments
input • NavigationRecalculateInput
• Required
Navigation recalculate input
Response
A response can either contain a data
or an
errors
object. The response header will always return
200
as a status code.
Data object
When successful, a data
object will be returned with the
requested fields. If there are no fields present the
data
object will return the operation name with the
appropriate return type. If the operation was a query, this output
will be an object of the schema’s query root type; if the operation
was a mutation, this output will be an object of the schema’s mutation
root type.
Error object
If unsuccessful, an errors
object will be returned with
more details in the extensions
object. The error object
can contain any of the following objects.
EMPTY_ARRAY_NOT_ALLOWED
Array $NAME should have at least one value
INVALID_COORDINATES
Coordinates provided for $LOCATION are not valid.
INVALID_UNIT
Provided unit type $TYPE for $LOCATION is not valid.
INVALID_VALUE
Provided value $VALUE for $LOCATION is not valid. Expected value of type $EXPECTEDTYPE.
NAVIGATION_TELEMETRY_INVALID
Field $TELEMETRYTYPE cannot be negative
NEGATIVE_VALUE_NOT_ALLOWED
Negative value for $LOCATION is not allowed.
OCCUPANTS_BELOW_ALLOWED
Provided number of occupants for $LOCATION is not valid. The value must be at least 1.
TIRE_PRESSURE_BELOW_ALLOWED
Provided tire pressure is not valid. The value must be at least 1.
ZERO_OR_NEGATIVE_VALUE_NOT_ALLOWED
Zero or negative value for $LOCATION is not allowed.