Geofencing options
You can create geofences in the interface and then use them for planning via Excel or API. You can also set geofences directly in the API request.
Ignore geofences
If you enable the options.ignore_zones
option, you will cancel all geofencing restrictions. For more information, see Geofences and Incompatible geofences.
"options": {
"ignore_zones": true
}
When planning with an Excel file, the option ignore_zones
is set in the Planning interface on the Settings → Consider geofences tab. The ignore_zones
= true
field value corresponds to the pressed button No.
Incompatible geofences
When planning routes, you may need to allocate orders to different runs:
-
Due to the road's characteristics. For example, we don't recommend delivering orders to opposite sides of a river or railway in one run. This way, you use bridges and crossings less often.
-
Because of billing specifics. For example, to divide orders by direction.
In such cases, you can use geofences and specify their incompatibility on the Options sheet in the incompatible_zones.N
field, where N is the number of the incompatible geofence set (there can be multiple sets, numbering starts from 0).
Orders in incompatible geofences can't be delivered in the same run. When planning routes, orders are distributed to different runs if they have at least one incompatible geofence.
"options": {
"incompatible_zones": [
[
"zone2",
"zone3"
]
]
}
Incompatible zones can also be set for individual couriers.
Example 1
This example shows incompatible geofences zone1
and zone2
. Their orders can't be delivered in one run. Order 2 is in zone1
, and order 4 is in zone2
. All orders are delivered by the same vehicle.
As a result, the vehicle does two runs.
API request (JSON) ⋅ API response ⋅ View on map
Example 2
The same conditions as in Example 1, but the following setting is used in the Planning interface: Settings → Consider geofences → No.
As a result, the vehicle delivers all orders in the same run.
API request (JSON) ⋅ API response ⋅ View on map
Excluded zones
The company can prohibit couriers from entering certain zones. These could be areas like mountainous roads with high accident rates, unsafe bridges, or river crossings. You can set such geofences in the interface or via the API and list them by name, separated by commas, in the avoid_zones
field on the Options sheet when planning a route.
The difference between forbidden and excluded zones
You can specify geofences within which the couriers aren't allowed to deliver orders in the forbidden_zones
field on the Vehicles sheet. See Geofences. But couriers can still travel through these geofences. Geofences listed in the Options sheet in the avoid_zones
field restrict couriers from traveling through them.
Allocation of problem orders
If the route to the delivery location can't be planned using roads without passing through excluded zones, the order is added to the planned route by default, but planned as a straight-line distance. The length of the route segment is calculated as five times the straight-line distance to the delivery location. To avoid such planning, specify the option haversine_fallback
as false
(by default it's true
). This way, such orders will be placed in the unassigned category.
Example 1
The courier delivers 5 orders. Order 5 needs to be delivered to an island. The route is planned through the bridge. The length of the route is 46.08 km. The distance to Order 5 is 5.78 km. The route to the delivery location is plotted via the bridge. You can see this in the "by road" mode.
API request (JSON) ⋅ API response ⋅ View on map
Example 2
The same as in Example 1, but all bridges to the island are defined as excluded zones. By default, haversine_fallback
is set to true
, and the route to Order 5 is calculated as a straight-line distance. The route length is 57.64 km, and the distance to Order 5 is 10.35 km.
API request (JSON) ⋅ API response ⋅ View on map
Example 3
The same as in Example 2, but the haversine_fallback
parameter is false
. Order 5 becomes unassigned.
API request (JSON) ⋅ API response ⋅ View on map