Skip to main content

Geofences

Geofences are a way to define a virtual perimeter around a real-world area. Yggio supports Geofence as its own API.

To create a geofence, you need to send a POST request to the geofence endpoint with a body with the following format: POST https://public.yggio.net/api/geofences

{
"fence": {
"type": "Polygon",
"coordinates": [[
[13, 55],
[33, 55],
[33, 75],
[13, 75],
[13, 55]
]]
},
"ref": "<id of my device>", // optional
"refType": "device" // optional
}

To note, the coordinates is an array of arrays of points. Currently we only support a single simple polygon. The polygon must always be counter-clockwise and the points are longitude first ([longitude, latitude]).
The ref and refType are optional and can be used to link the geofence to a device. The ref is the id of the device and the refType is the type of the reference. Currently only device is supported.

More details on the specifics of the geofence routes can be found on our swagger.

Devices

Yggio also supports geofencing for devices. If a device has a GPS position (as the property 'lnglat' on the device, following the GeoJSON format) it can be sought after by calling the regular iotnodes API with a geoquery querystring. Currently only polygons are supported.
The geoquery querystring consists of a type and coordinates, or an id of a geofence. Currently, the type must be contains. contains means the device point must be entirely inside the geofence.

Example of a geoquery contains querystring:
GET https://public.yggio.net/api/iotnodes?geoquery=type:contains;coordinates=[[13,55],[33,55],[33,75],[13,75],[13,55]] Do note that the last point in the coordinates must be the same as the first point to close the polygon.

Example of a geoquery id querystring:
GET https://public.yggio.net/api/iotnodes?geoquery=id:203981cd5a19c81efac16a4f