Giter Site home page Giter Site logo

node-georedis's People

Contributors

arjunmehta avatar boltunov-am avatar dependabot[bot] avatar knoxcard avatar shrikrishnaholla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-georedis's Issues

Alternative to using MULTI/EXEC

Hello and thanks for the great repo. Can you briefly explain the reason for using MULTI/EXEC? I am scaling redis using Twemproxy and unfortunately transaction operations are not supported. With that being said is there a way to implement emulation on a distributed redis cluster? Take note that twemproxy can route requests to appropriate shard via hash_tag. Twemproxy can also route requests by port to a sole redis instance provided in nutcracker configuration.

Upsert functionality

Hey, thanks for this awesome library.

I was wondering about the difference between addLocation and updateLocation - in my application, I am looking to do an "upsert" - just to add or update depending on if the location already exists. Does one or both of these methods already expose this functionality? And if not, is there a way to avoid doing a get and then an update or add depending on the existence of the value returned by get?

Getting error while adding and removing data in cluster

Hi,

It's a really interesting and great library, thanks for saving lot of our work.

I am getting below error when I run nearby in redis cluster.

{"correlationId":"89a9922e-019d-47d5-a8fd-804ae261b3b0","data":{"message":"MOVED 3400 10.20.41.108:6379","statusCode":500}}

What could be the reason, does it support cluster? I am using Amazon ElastiCache

Also while removing data using removeLocations getting below error

{"correlationId":"472b05c8-c73f-4e88-96ef-69072be8e510","data":{"message":"ERR wrong number of arguments for 'zrem' command","statusCode":500}}

Redis: unsupported command "COMMAND"

I keep getting the redis errors on my server as a result on the initialization of this library. Here is the problem area of the code:

                client.send_command('command', nativeCommands, function(err, response) {

                    if (!err) {
                        if (Array.isArray(response) && Array.isArray(response[0]) && response[0][0] === 'geoadd') {
                            set.clientInterface = new NativeInterface(client);
                        }
                    }
                });

Is there another command to send instead of command? to determine whether of not to use native or emulated, perhaps maybe INFO instead of COMMAND? I am trying to troubleshoot an issue with twemproxy and its hard to do so with all of the errors "unsupported command 'COMMAND'" in the error logs

coordinates entered are not exactly same as original

Lets say we have the following coordinate which we want to add

longitude,latitude
121.16625075805472,14.55976969490166

Now, if we try to insert it using node-georedis, it was inserted successfully, but the inserted coordinates are different from original. Why is that?

longitude,latitude
121.16625219583511353,14.55976912035422544

how to send response from different sets?

Thanks for providing nice package,

`// will find all PEOPLE ~5000m from the passed in coordinate
people.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, people){
if(err) console.error(err)
else console.log('people nearby:', people)
})

// will find all PLACES ~5000m from the passed in coordinate
places.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, places){
if(err) console.error(err)
else console.log('places nearby:', places)
})`

Is it possible to merge result from two sets (people and places) and then send as a single result? something like this -

`// will find all PEOPLE ~5000m from the passed in coordinate
people.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, people){
if(err) console.error(err)
else result['b'] = people
})

// will find all PLACES ~5000m from the passed in coordinate
places.nearby({latitude: 43.646838, longitude: -79.403723}, 5000, function(err, places){
if(err) console.error(err)
else result['a'] = places
})And thenreturn res.send(result)`
Please help me, I've asked this question at stack overflow but didn't get any answer
http://stackoverflow.com/questions/38238402/how-to-send-multiple-objects-using-nodejs-and-georedis

fakeredis doesn't seem to be working

This is a continuation of arjunmehta/node-geo-proximity#19

First off thanks for the re-write and the sorting!

I'm using nearby() with fakeredis and getting the following error:

Error: fakeredis: COMMAND is not implemented in fakeredis. Let me know if you need it.

From what I can tell, it looks like it is using georadius. Any idea if this error is coming from your code or fake redis? My hunch is the latter - and if so you know any workaround?

As I mentioned in the previous issue, I have to use fakeredis because I am using AWS lambda which does not currently have access to a redis server (via elasticache). Also my data set is pretty small so would like to pay the potential performance penalty to remove another thing I have to keep Highly Available.

Any ideas?

Here is my code (roughly):

...
var defaultNumResults = 10,
    defaultRadius     = 10,
    redisClient       = null,
    placeProximity    = null,
    nearbyOptions     = {
      withCoordinates: false, // Will provide coordinates with locations, default false
      withHashes: false, // Will provide a 52bit Geohash Integer, default false
      withDistances: true, // Will provide distance from query, default false
      order: 'ASC', // or 'DESC' or true (same as 'ASC'), default false
      units: 'mi', // or 'km', 'mi', 'ft', default 'm'
      count: 10, // Number of results to return, default undefined
      accurate: true, // Useful if in emulated mode and accuracy is important, default false
    };

exports.closestPlaces = function(lat, lng, numResults, radius) {
  if (!placeProximity) {
    redisClient    = require('fakeredis').createClient(0, '', {
      fast: true,
    });
    placeProximity = Promise.promisifyAll(require('georedis')).initialize(redisClient);
  }

  //Fastest: http://stackoverflow.com/questions/5349425/whats-the-fastest-way-to-loop-through-an-array-in-javascript
  for (var i = 0, len = channelsList.length; i < len; i++) {
    var entry = channelsList[i];

    try {
      placeProximity.addLocation(JSON.stringify(entry), {
        latitude: entry.lat,
        longitude: entry.lng,
      }, function(err, reply) {
        if (err) {
          console.error('error adding', entry, err);
          return Promise.reject(new MlnError(
              'Error adding' + JSON.stringify(entry, null, 2),
              MlnError.errorCodes.UNKNOWN
          ));
        }
      });
    } catch (e) {
      console.error('Error adding location', entry, e);
      return Promise.resolve([]);
    }
  }

  nearbyOptions.count = numResults || defaultNumResults;

  return placeProximity.nearbyAsync({latitude: lat, longitude: lng}, radius || defaultRadius, options)
      .then(function(locations) {
        return locations;
      })
      .catch(function(e) {
        return [];  //any error return cant find
      });
};

Not Working with ioredis

Not providing proper long and lat :

From Location() api => null { latitude: 43.64728555083275, longitude: -79.40306156873703 }
nearby locations: { '4': { key: [ '4' ], latitude: null, longitude: null },
null: { key: null, latitude: null, longitude: null },
'': { key: [], latitude: null, longitude: null } }
Got Data from Paged Results []

Providing same results for all the nearBy locations

nearby locations: [ { latitude: -89.99999865889549,
longitude: -179.99999731779099,
key: 'null' } ]

pubnub malforms location coordinate latitude values

Hi,

I am trying to store the lat long as:
{"lat":29.419506,"long":79.038539}

But on querying the position, it returns:
27.80180134535769554 79.03853863477706909

Same is the case with any other position. Also the variation is not fixed.

Incorrect results if not specifying nativeGeo when the redis server supports native geo command

Hi,

I am using redis server 3.2.3 which supports native geo command.
I found that if I call nearby() function with the following options, the results will be very limited (I guess the unit used isn't correct)

{
  withCoordinates: true,
  withDistances: true,
  units: 'mi',
  accurate: true
}

My peer uses old redis server (3.0.7), it works fine with the same code. Then I tried to append nativeGeo: true on initialization, everything goes well. But my server doesn't support native geo command, it will be great and better let the lib determine whether to use native command.

Thanks :]

Question regarding algorithm in GIS SE

https://gis.stackexchange.com/questions/18330/using-geohash-for-proximity-searches/228494#228494 I am trying to implement the algorithm in Python that you have published on the GIS SE site.

Here is where I am currently.
I have the following box which is like this
minLat, maxLat : 0.05
minLon,maxLon : 0.05

So my coordinate set is a grid with a grid spacing of 0.05 degrees. The boundaries of the grid are marked by minLat,maxLat,minLon,maxLon. In my case the data grid is a constant and will never change.

So for each grid coordinate(gridLat,gridLon) I encode using a geohash and calculate it's eight neighbors as well. For me the precision is 26 because my query window is 5 kms(query window will never change)
Then I add one to the 9 members above. So I have 18 members in total.
Since my data set is evenly distributed can I store these in a HashMap because the lookup can be of complexity O(1) ?

georedis with own storage

Good day,

I would like to implement geohashing based on your module, but using own storage ( not redis ).
Currently I store locations as int geohash (bit depth 52). For one location this is: 3672837726667608

By using the module I can calculate ranges based on location and radius. The result is:

[ 3672437556248576, 3672506275725312 ],
[ 3672574995202048, 3672918592585728 ],
[ 3672987312062464, 3673056031539200 ],
[ 3673193470492672, 3673330909446144 ]

My question:

  1. How should the query to the database look like? How should I compare the stored locations to the calculated range values? Should I just have 4 conditions testing if the geohash falls between the range boundaries?
  2. Why are there 4 ranges and not 8?
  3. Is searching within 4 ranges actually searching within a rectangle and not within a circle? ( the ranges have been calculated based on a radius.

Thank you.

Add additional properties?

I need to save additional data ("authorID" and "workshopID") to the locations saved. Right now there's only a field for the 'locationName'. The only way I can save the extra data is if I save a JSON as a string into the locationName field. This means I have to parse each locationName as a JSON when I retrieve the location. Is there any other way to do this?

getting points with label searching

var locationSet = {
'Toronto': {latitude: 43.6667, longitude: -79.4167,label:"a"},
'Philadelphia': {latitude: 39.9523, longitude: -75.1638,label:"b"},
'Palo Alto': {latitude: 37.4688, longitude: -122.1411,label:"c"},
'San Francisco': {latitude: 37.7691, longitude: -122.4449,label:"b"},
'St. John's': {latitude: 47.5500, longitude: -52.6667,label:"a"},
'New York': {latitude: 40.7143, longitude: -74.0060,label:"b"},
'Twillingate': {latitude: 49.6500, longitude: -54.7500,label:"a"},
'Ottawa': {latitude: 45.4167, longitude: -75.7000,label:"b"},
'Calgary': {latitude: 51.0833, longitude: -114.0833,label:"a"},
'Mumbai': {latitude: 18.9750, longitude: 72.8258,label:"c"}
}
geo.nearby('Toronto',50000000, options,function(err, locations){
if(err) console.error(err)
else console.log('nearby locations:', locations);
});

i want to get nearby with respect label,

withDistances doesn't respect `units` parameter

Hey! I noticed that when doing a query like:

geo.nearby(location, 0.5, { withDistances: true, units: 'mi' }, function(err, locations) {
    // locations contain a distance key, but the distance is in meters
})

Not a big deal (I can do the conversion on my side), but I figured it might be nice to have the units be consistent if it's an easy change.

[Enhancement] Paging for geo.nearby

My app shows a list of nearby ATMs.
At first only the 20 closest ATMs are shown in the list (see screenshot below). When the user scrolls, more ATMs are loaded from node-georedis. As the user scrolls more and more, they get further and further ATMs.

An ideal geographic database would return ATMs in concentric rings, allowing an offset parameter in the request, and keeping a kind of cache internally so that subsequent requests do not cost more and more CPU/memory.

If would be great if node-georedis could provide this paging. Meanwhile, if you have any tricks for dealing with this kind of situation I would be glad to hear about them :-) Cheers!

screenshot from 2016-08-31 12-06-52

Set/get metadata at locations in addition to name

Hi,

GeoRedis feature currently utilizes 3 properties: latitude, longitude, and name. When adding a location, is it possible to add additional key value pairs aside from name itself? Let us say we are adding name, address, etc. Is it possible? If not, what are best workaround / practices?

Get Nearby location items issues in local and AWS server.

Im using below options and get nearby orders :

var options = {
  withCoordinates: true, // Will provide coordinates with locations, default false
  withHashes: true, // Will provide a 52bit Geohash Integer, default false
  withDistances: true, // Will provide distance from query, default false
  order: 'ASC', // or 'DESC' or true (same as 'ASC'), default false
  units: 'km', // or 'km', 'mi', 'ft', default 'm'
  count: 100, // Number of results to return, default undefined
  accurate: true // Useful if in emulated mode and accuracy is important, default false
}

// look for all points within ~5000m of Toronto with the options.
geo.nearby({latitude: 43.646838, longitude: -79.403723}, 3, options, function(err, locations){
  if(err) console.error(err)
  else console.log('nearby locations:', locations)
})

Local Mechine :
In my local mechine my using below version

Node Redis client: 2.71
Redis-Server : 2.4.6

Already set the orders with locations and using nearby location i can get the orders within 3kms.

AWS Server :

  Node Redis client: 2.71
  Redis-Server : 3.4

when emit 3km i can't get the orders and i can get orders within 0.68 Km only.

I can't get the solutions. Let me know if anything version problem.

node_redis: Deprecated: The ZADD command contains a "undefined" argument.

node_redis: Deprecated: The ZADD command contains a "undefined" argument.
This is converted to a "undefined" string now and will return an error from v.3.0 on.
Please handle this in your code to make sure everything works as you intended it to.

   var geo = georedis.initialize(client, {
        zset: 'acceptToStart',
        nativeGeo: false
    });

If you can check and fix. why I am getting this error. How can I fix this.

ioredis is not working with georedis

I am trying to use 'ioredis' with georedis but getting error

` const Redis = require("ioredis");
const redisClient = new Redis(
config.get('database').redis.port,
config.get('database').redis.ip);

let geo = require('georedis').initialize(redisClient);
let driverslocations = geo.addSet('abc');`

getting this ERROR
ReplyError: ERR syntax error. Try GEOADD key [x1] [y1] [name1] [x2] [y2] [name2

"ioredis": "^4.17.3",
"georedis": "3.1.1",

Requesting a new release to NPM

Hi,

Would it be possible to publish a new release to NPM registry? The current release (3.0.3) is already one year old and is missing for example the following commit: bbf88ba. Without the fix introduced in the commit the module crashes if the "geo.location" function is called for an id that is not present or has already been deleted.

Thanks! :)

Get nearby locations timeouts the server with 10km radius

I retrieve locations with the nearby method. However I see the following errors:

{ AbortError: GEORADIUS can't be processed. The connection is already closed.}
at handle_offline_command (/srv/node_modules/redis/index.js:851:15) 
at RedisClient.internal_send_command (/srv/node_modules/redis/index.js:885:9) 
at RedisClient.georadius (/srv/node_modules/redis/lib/commands.js:58:25) 
at RedisClient.send_command.RedisClient.sendCommand (/srv/node_modules/redis/lib/extendedApi.js:46:26) 
at georadiusGeneric (/srv/node_modules/georedis/lib/interfaceNative.js:178:10) 
at NativeInterface.georadius (/srv/node_modules/georedis/lib/interfaceNative.js:124:3) 
at GeoSet.nearby (/srv/node_modules/georedis/main.js:146:31) ) 
at new Promise (<anonymous>) 
at process._tickCallback (internal/process/next_tick.js:68:7) 
command: 'GEORADIUS', 
code: 'NR_CLOSED', 

args: 
 [ 'geo', 
   -87.75563344016012, 
   41.89034192093163, 
   10000, 
  'm' ] } 

There's 250K locations saved.

Other simple redis commands works.
Should I consider using another way of storing locations? Any ideas of the cause?

By reducing the radius to 5km it seems to happen less.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.