I have created a geofencing area around the Ram Manohar Lohia Hospital in New Delhi by using geojson.io.
I added two point, one inside and the other one outside the hospital but very close to geofencing zone limit (~2m).
Then I use Kuzzle realtime engine to subscribe to notification about document entering or exiting the Hospital geofencing area.
Finally I will send new documents to Kuzzle with a location corresponding to one of the two point, the program will print Document is inside
or Document is outside
according to the received notifications.
First you need to run a Kuzzle instance or your compute, follow instructions here: https://docs.kuzzle.io/core/2/guides/essentials/installing-kuzzle/
Then you need to install Kourou, the Kuzzle CLI using NPM (Node.js package manager): npm i -g kourou
Download the two scripts present in this Gist: subscribe.js
and publish.js
.
Subscribe to notifications in a first terminal: kourou sdk:execute < subscribe.js
Then in another terminal we are going to simulate document creation:
# trigger notification for someone entering the hospital
kourou sdk:execute -v 'pos="inside"' < publish.js
# trigger notification for someone exiting the hospital
kourou sdk:execute -v 'pos="outside"' < publish.js