geoadd

// Using callbacks (NodeJS or Web Browser)
var points = [
  {
    lon: 13.361389,
    lat: 38.115556,
    name: 'Palermo'
  },
  {
    lon: 15.087269,
    lat: 37.502669,
    name: 'Catania'
  }
];

kuzzle.memoryStorage.geoadd('key', points, function (err, count) {
  // callback called once the action has completed
});

// Using promises (NodeJS only)
kuzzle.memoryStorage.geoaddPromise('key', points)
  .then(count => {
    // resolved once the action has completed
  });
JSONObject[] points = new JSONObject[]{
  new JSONObject()
    .put("lon", 13.361389)
    .put("lat", 38.115556)
    .put("name", "Palermo"),
  new JSONObject()
    .put("lon", 15.087269)
    .put("lat", 37.502669)
    .put("name", "Catania")
};

kuzzle.memoryStorage.geoadd("key", points, new ResponseListener<Long>() {
  @Override
  public void onSuccess(int count) {
    // callback called once the action has completed
  }

  @Override
  public void onError(JSONObject error) {
  }
});
<?php

use \Kuzzle\Kuzzle;

$kuzzle = new Kuzzle('localhost');

$points = [
  [
    'lon' => 13.361389,
    'lat' => 38.115556,
    'name' => 'Palermo'
  ],
  [
    'lon' => 15.087269,
    'lat' => 37.502669,
    'name' => 'Catania'
  ]
];

try {
  $count = $kuzzle->memoryStorage()->geoadd('key', points);
}
catch (ErrorException $e) {

}

Callback response:

2

Adds geospatial points to the specified key.

[Redis documentation]


geoadd(key, points, [options], [callback])

ArgumentsTypeDescription
keystringDestination key identifier
pointsarray of objectsList of geospatial points to add. Each point is described by a JSON object containing the following properties:
lon (longitude, float), lat (latitude, float), name (point identifier, string)
optionsJSON ObjectOptional parameters
callbackfunctionCallback

Options

OptionTypeDescriptionDefault
queuablebooleanMark this request as (not) queuabletrue

Return value

Returns the MemoryStorage object to allow chaining.


Callback response

Resolves to an integer containing the number of points added to the key