Geo: GEOADD form using radius removed.

Can't immagine how this is useful in the context of the API exported by
Redis, and we are always in time to add more bloat if needed, later.
This commit is contained in:
antirez 2015-06-29 09:20:07 +02:00
parent 7d59e0a8c3
commit 6d21027a23

View File

@ -344,20 +344,11 @@ static int sort_gp_desc(const void *a, const void *b) {
/* GEOADD key long lat name [long2 lat2 name2 ... longN latN nameN] */ /* GEOADD key long lat name [long2 lat2 name2 ... longN latN nameN] */
void geoAddCommand(redisClient *c) { void geoAddCommand(redisClient *c) {
/* Prepare for the three different forms of the add command. */ /* Check arguments number for sanity. */
double radius_meters = 0; if ((c->argc - 2) % 3 != 0) {
if (c->argc == 7) {
if ((radius_meters = extractDistanceOrReply(c, c->argv + 5, NULL)) <
0) {
return;
}
} else if (c->argc == 6) {
addReplyError(c, "must provide units when asking for radius encode");
return;
} else if ((c->argc - 2) % 3 != 0) {
/* Need an odd number of arguments if we got this far... */ /* Need an odd number of arguments if we got this far... */
addReplyError(c, "format is: geoadd [key] [x1] [y1] [member1] " addReplyError(c, "syntax error. Try GEOADD key [x1] [y1] [name1] "
"[x2] [y2] [member2] ... "); "[x2] [y2] [name2] ... ");
return; return;
} }
@ -371,7 +362,6 @@ void geoAddCommand(redisClient *c) {
/* Create the argument vector to call ZADD in order to add all /* Create the argument vector to call ZADD in order to add all
* the score,value pairs to the requested zset, where score is actually * the score,value pairs to the requested zset, where score is actually
* an encoded version of lat,long. */ * an encoded version of lat,long. */
uint8_t step = geohashEstimateStepsByRadius(radius_meters,0);
int i; int i;
for (i = 0; i < elements; i++) { for (i = 0; i < elements; i++) {
double xy[2]; double xy[2];
@ -383,13 +373,9 @@ void geoAddCommand(redisClient *c) {
return; return;
} }
#ifdef DEBUG
printf("Adding with step size: %d\n", step);
#endif
/* Turn the coordinates into the score of the element. */ /* Turn the coordinates into the score of the element. */
GeoHashBits hash; GeoHashBits hash;
geohashEncodeWGS84(xy[0], xy[1], step, &hash); geohashEncodeWGS84(xy[0], xy[1], GEO_STEP_MAX, &hash);
GeoHashFix52Bits bits = geohashAlign52Bits(hash); GeoHashFix52Bits bits = geohashAlign52Bits(hash);
robj *score = createObject(REDIS_STRING, sdsfromlonglong(bits)); robj *score = createObject(REDIS_STRING, sdsfromlonglong(bits));
robj *val = c->argv[2 + i * 3 + 2]; robj *val = c->argv[2 + i * 3 + 2];