This page describes how to use the geofencing engine within the IoT Bridge to detect when endpoints go in and out of designated locations. Geofencing allows quick events to be generated for polygon and circular geofences that can be defined from the user interface or from the API.
A geofence describes a boundary in the form of a circle (latitude, longitude, and radius) or a polygon (a set of latitude/longitude pairs that describe a polygon shape) in which endpoints can enter
and exit
based on their moving location.
Here is a sample circlular geofence, it is easy to define with only a location and a radius, and can easily be used to determine if endpoints are at a particular building.
Here is a sample polygon geofence describing the campus of Florida Atlantic University. As you can see, a polygon can follow the contours of the campus grounds, whereas a circle would encompass too large of an area.
When creating a geofence, the user interface is the easiest way to define a new shape.
Search map
field. Click the map icon to navigate to the address.polygon
, rectangle
, or circle
to define your geofence.edit
a geofence, this allows you to change the shape and add new verticies.Geofences are evaluated using the geofence.eval()
function.
Evaluate the geofences for an endpoint at a location.
// evaluate geofences at a given location.
geofence.eval(event.endpoint.key,event.ts,event.data.latitude,event.data.longitude,{context:{command:event.data.cmd, eventId: event.id}})
enter
or exit
events.This event fires when an endpoint enters a geofence.
{
"dateEntered":"2024-03-25T12:10:00Z",
"dateExited":"2024-03-25T13:10:00Z",
"duration": 3600,
"geofence": {
"name":"My Geofence",
"key":"mygeofence"
},
"context": { "command": "PUB", "eventId":"asdf" }
}
This event fires when an endpoint exits a geofence.
{
"dateEntered":"2024-03-25T12:10:00Z",
"dateExited":"2024-03-25T13:10:00Z",
"duration": 3600,
"geofence": {
"name":"My Geofence",
"key":"mygeofence"
},
"context": { "command": "PUB", "eventId":"asdf" }
}
geofence.eval()
, this is to ensure that no out of order processing errors occur.The following events are considered billable:
geofence.eval()