Follow Us

lanceur backend-1900

Real-time geofencing

GPS & Uber-like apps made easy

Kuzzle's real-time engine provides a powerful geofencing feature which lets you define boundaries, distance, distance range & polygons.
Geofencing can be used to trigger notifications based on location detection or build geographical data streams such as those used for GPS tracking.
Read the documentation to learn more

geofencing_info

Case Study

IOT GEOLOCATION MONITORING

Kuzzle tracks a set of connected bikes and sends notifications when the bikes enter or exit a specified geographic area.

Blazing fast real-time geofencing

Developers Corner

Reduce your development time with Kuzzle's SDKs, these provide easy access to Kuzzle's API to help you get started quickly.
To learn more read our guide

languages

  • Javascript
  • Android
  • GO
  • function subscribe() {    
    /** * Subscribe: * A client subscribes to Kuzzle and is notified when the user leaves a circular area */ //Connect to Kuzzle var kuzzle = new Kuzzle("localhost", { defaultIndex: "myindex" }); //Create a filter that defines the circular area around Big Ben var bigBen = { lat: 51.510357, lon: -0.116773 }; var filter = { geoDistance: { location: bigBen, distance: '2km' } }; //Create a subscription that triggers a notification when a user is in the circular area kuzzle .collection("mycollection", "myindex") .subscribe(filter, {scope: "out"}, function(error, result) { // triggered each time the user leaves the circular area around Big Ben if(error) { handleError(error); } else { console.log('User has left Big Ben!'); doSomething(result); } });
    }
    function publish() {    
    /** * Publish: * A client publishes a user's location */ //Connect to Kuzzle var kuzzle = new Kuzzle("localhost", { defaultIndex: "myindex" }); //Create the user's location: they are inside the circular area var bigBen = { lat: 51.510357, lon: -0.116773 }; var currentLocation = { firstName: 'Ada', lastName: 'Lovelace', location: bigBen }; return kuzzle .collection("mycollection", "myindex") .createDocumentPromise('326c8f08-63b0-429f-8917-b782d30930e9', currentLocation, {ifExist: "replace"}) .then(function(result){ var hydePark = { lat: 51.507268, lon: -0.165730 }; var newLocation = {location: hydePark}; //Update the user's location: now they are outside the circular area -> This will trigger the notification return kuzzle .collection("mycollection", "myindex") .updateDocument('326c8f08-63b0-429f-8917-b782d30930e9', newLocation); });
    }
  • public void subscribe() {    
    /** * Subscribe: * A client subscribes to Kuzzle and is notified when the user leaves a circular area */ //Create a filter that defines the circular area around Big Ben JSONObject bigBen = new JSONObject().put("lat", 51.510357).put("lon", -0.116773); JSONObject filter = new JSONObject() .put("geoDistance", new JSONObject() .put("location", bigBen) .put("distance", "2km")); //Create a subscription that triggers a notification when a user the circular area kuzzle.collection("mycollection", "myindex") .subscribe(filter, new RoomOptions().setScope(Scope.OUT), new ResponseListener<NotificationResponse>() { @Override public void onSuccess(NotificationResponse response) { //triggered each time the user leaves the circular area around Big Ben System.out.println("User has left Big Ben!"); doSomething(response); } @Override public void onError(JSONObject error) { handleError(error); } );
    }
    public void publish() {    
    /** * Publish: * A client publishes a user's location */ //Create the user's location: they are inside the circular area Collection collection = kuzzle.collection("mycollection", "myindex"); Document document = new Document(collection); JSONObject bigBen = new JSONObject().put("lat", 51.510357).put("lon", -0.116773); JSONObject currentLocation = new JSONObject().put("firstName", "Ada").put("lastName", "Lovelace").put("location", bigBen); document.setContent(currentLocation, true); collection.createDocument("326c8f08-63b0-429f-8917-b782d3093011", currentLocation, new ResponseListener<Document>() { @Override public void onSuccess(Document response) { //After the user's location is stored we can update it: now they are outside the circular area -> This will trigger the notification try { JSONObject hydePark = new JSONObject().put("lat", 51.507268).put("lon", -0.165730); JSONObject newLocation = new JSONObject().put("location", hydePark); kuzzle.collection("mycollection", "myindex") .updateDocument("326c8f08-63b0-429f-8917-b782d3093011", newLocation); } catch(Exception e){ handleError(e); } } @Override public void onError(JSONObject error) { handleError(error); } });
    }
  • func subscribe() {    
    /** * Subscribe: * A client subscribes to Kuzzle and is notified when the user leaves a circular area */ //Connect to Kuzzle ro := types.NewRoomOptions() cn := websocket.NewWebSocket("localhost", nil) k, _ := kuzzle.NewKuzzle(cn, nil) c := collection.NewCollection(k, "mycollection", "myindex") //Create a filter that defines the circular area around Big Ben type Location struct { Lat float64 `json:"lat"` Lon float64 `json:"lon"` } type GeoDistance struct { Location Location `json:"location"` Distance string `json:"distance"` } type GeofencingFilters struct { GeoDistance GeoDistance `json:"geoDistance"` } var filters = GeofencingFilters{ GeoDistance: GeoDistance{ Location: Location{ Lat: 51.510357, Lon: -0.116773, }, Distance: "2km", }, } //Create a subscription that triggers a notification when a user the circular area rtc := make(chan *types.KuzzleNotification) res := <- c.Subscribe(filters, ro.SetScope("out"), rtc) if res.Error != nil { handleError(res.Error) } else { go func (rtc chan *types.KuzzleNotification) { doSomething(<-rtc) // triggered each time the user leaves the circular area around Big Benn }(rtc) }
    }
    func publish() {    
    /** * Publish: * A client publishes a user's location */ //Connect to Kuzzle cn := websocket.NewWebSocket("localhost", nil) k, _ := kuzzle.NewKuzzle(cn, nil) c := collection.NewCollection(k, "mycollection", "myindex") //Create the user's location: they are inside the circular area q := types.NewQueryOptions() q.SetIfExist("replace") currentLocation := c.Document() currentLocation.Content = []byte(`{"firstName": "Ada", "lastName": "Lovelace", "location": {"lat": 51.510357, "lon": -0.116773}}`) c.CreateDocument("326c8f08-63b0-429f-8917-b782d30930e9", currentLocation, q) //After the user's location is stored we can update it: now they are outside the circular area -> This will trigger the notification newLocation := c.Document() newLocation.Content = []byte(`{"location": {"lat": 51.507268, "lon": -0.165730}}`) c.UpdateDocument("326c8f08-63b0-429f-8917-b782d30930e9", newLocation, nil)
    }

They Trust us

partners