We now offer enterprise level support and paid hosting. To inquire please email  [email protected] .

Geofencing

Geofence animation A geofence is a virtual boundary that can detect when an object enters or exits the area. This boundary can be a radius or any search area format, such as a bounding box, GeoJSON object, etc. Tile38 can turn any standard search into a geofence monitor by adding the FENCE keyword to the search.

A simple example:

NEARBY fleet FENCE POINT 33.462 -112.268 6000

This command opens a geofence that monitors the fleet collection. The server will respond with:

{ "ok": true, "live": true }

And the connection will be kept open. If any object enters or exits the 6 km radius around 33.462,-112.268 the server will respond in realtime with messages such as:

{ "command": "set", "detect": "enter", "hook": "warehouse", "time": "2016-03-20T09:37:49.567854293-07:00", "key": "fleet", "id": "truck02", "object": { "type": "Point", "coordinates": [-112.2695, 33.4626] } }

The server will notify the client if the command is del or set or drop.

  • del notifies the client that an object has been deleted from the collection that is being fenced.
  • drop notifies the client that the entire collection is dropped.
  • set notifies the client that an object has been added or updated, and when it’s position is detected by the fence.

The detect may be one of the following values.

  • inside is when an object is inside the specified area.
  • outside is when an object is outside the specified area.
  • enter is when an object that was not previously in the fence has entered the area.
  • exit is when an object that was previously in the fence has exited the area.
  • cross is when an object that was not previously in the fence has entered and exited the area.

By default all detect types and commands are returned. If you would like to only have a select few then use the DETECT option, for example:

NEARBY fleet FENCE DETECT inside,outside POINT 33.462 -112.268 6000

This command will only tell the fence that you only want inside and outside detection.

It’s also possible to mask which commands are returned by using the COMMANDS option, for example:

NEARBY fleet FENCE DETECT enter COMMANDS set POINT 33.462 -112.268 6000

This specifies that you only want the enter detection for the set command.