Geofences
You can use geofences to set restrictions when planning routes and take into account vehicle characteristics, access conditions, and terrain features. For more information, see Vehicle.
When orders are being assigned, geofence incompatibility is taken into account: both the global option and the values set for individual couriers. When planning routes, you can also cancel all limits related to geofences.
Geofences in the interface
You can work with geofences using the Planning interface and an Excel file:
- Define geofences in Geofence list).(for more information, see
- Select an Excel file and upload it to the interface.
- When you manage optimization settings on the Settings tab, select .
When planning routes, orders will be automatically assigned to zones by their coordinates.
Geofences in the API
You can work with geofences in the API in one of the following ways:
- Using API methods.
- Setting geofence boundaries by coordinates in the planning task.
API methods for working with geofences
API methods can be effectively used in the following situations:
- You create and edit geofences in the RouteQ interfaceand then upload them to your corporate system using the Get company geofence or Get company geofence master data methods.
Using geofences from the master data
For more information on working with the master data via the interface, see Working with geofence data.
To use geofences from the master data, send a request to the mvrp with authorization resource:
curl -H "Content-Type: application/json" -H "Authorization: Auth your-OAuth-token" -X POST -d <request body> https://courier.yandex.ru/api/v1/vrs/add/mvrp
Copied to clipboard
In the Authorization: Auth your-OAuth-token
header, replace your-OAuth-token
with the OAuth token that you obtained to work with Track & Trace.
The path in the authorization request (with an OAuth token) is different from the path indicated in the specifications (with an API key).
Set geofences using coordinates
To set geofence coordinates directly in the planning task, create the zones
object in the request. Each element of this object describes one geofence and contains the coordinates of the polygon vertices.
To get the coordinates, use the Yandex Map Constructor tools:
- Draw the zone using the Polygons tool (for more information, see Create item in Yandex Map Constructor Help).
- Click Exporting map items in Yandex Map Constructor Help).(for more information, see
- Select.
- Use the
geometry
item in the request to form thezones
item.Sample geofence description in a request"zones": [ { "id": "zone1", "geometry": { "type": "Polygon", "coordinates": [ [ [ 37.3890158054755, 55.8142956464218 ], [ 37.4755331394599, 55.7415407888477 ], [ 37.5716635105537, 55.7984405246533 ], [ 37.5847097752021, 55.799987651288 ], [ 37.3890158054755, 55.8142956464218 ] ] ] } } ]
Copied to clipboard
To set geofences using coordinates, send a request to the mvrp resource:
curl -H "Content-Type: application/json" -X POST -d <request body> https://courier.yandex.ru/vrs/api/v1/add/mvrp?apikey=<API key>
Copied to clipboard