Route (NEW)
Route (NEW) is the new iteration of Chargetrip’s route schema, including a query, mutation and subscription, similar to our legacy routing service. The input and output are better organized and include some renamed and new fields.
The routePath
query has been removed; the information about the route path can be retrieved by requesting the route_path
field on the RouteDetails
. Route sections
have been introduced and offer a better way of displaying different ways of transportation included in the route. Also, each route now contains meta
information, which will be extended with more information in future releases.
How it works
Routes is the API service for calculating a route with a vehicle. It predicts the amount of energy required for a particular vehicle to drive from a starting point to a destination. Based on that predicted energy consumption, it then creates an optimal route including charge stops that is compatible with the vehicle being used. How the recommended route and charge stops are calculated is flexible and can be tailored to your needs by setting operator preferences.
Use case
The most common use case for Routes is to build route planning into EV driver apps where drivers can input their start, stops, and destination and get a recommended route. Routes can also be used to build routing and dispatching for electric commercial vehicles as part of fleet management software.
Implementation
To create a route use the createRoute
mutation and route
subscription. We strongly recommend to use subscriptions. Recursively querying a route ID until the route is processed increases costs and delays your application. A visual representation is added below. For a more detailed explanation keep reading.
First, use a GraphQL client to execute the mutation. This mutation takes a CreateRouteInput
object which contains all the parameters needed to create a route. It returns the ID
of that newly created route. Use that route ID to subscribe to route updates. The status of the route (RouteStatus
) will be updated from pending
, to processing
, and when the route calculation is finished, to the final status done
. If a route is not found or something goes wrong during the calculation, the final status resolves to either not_found
or error
. It is recommended to unsubscribe from further updates when the route has reached a final status.