mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Geo: commands top comment as in other Redis code.
This commit is contained in:
parent
a3b07b1718
commit
7d59e0a8c3
19
src/geo.c
19
src/geo.c
@ -341,11 +341,9 @@ static int sort_gp_desc(const void *a, const void *b) {
|
|||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
* Commands
|
* Commands
|
||||||
* ==================================================================== */
|
* ==================================================================== */
|
||||||
void geoAddCommand(redisClient *c) {
|
|
||||||
/* args 0-4: [cmd, key, lng, lat, val]; optional 5-6: [radius, units]
|
|
||||||
* - OR -
|
|
||||||
* args 0-N: [cmd, key, lng, lat, val, lng2, lat2, val2, ...] */
|
|
||||||
|
|
||||||
|
/* GEOADD key long lat name [long2 lat2 name2 ... longN latN nameN] */
|
||||||
|
void geoAddCommand(redisClient *c) {
|
||||||
/* Prepare for the three different forms of the add command. */
|
/* Prepare for the three different forms of the add command. */
|
||||||
double radius_meters = 0;
|
double radius_meters = 0;
|
||||||
if (c->argc == 7) {
|
if (c->argc == 7) {
|
||||||
@ -568,18 +566,17 @@ static void geoRadiusGeneric(redisClient *c, int type) {
|
|||||||
geoArrayFree(ga);
|
geoArrayFree(ga);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GEORADIUS wrapper function. */
|
||||||
void geoRadiusCommand(redisClient *c) {
|
void geoRadiusCommand(redisClient *c) {
|
||||||
/* args 0-5: ["georadius", key, long, lat, radius, units];
|
|
||||||
* optionals: [withdist, withcoords, asc|desc] */
|
|
||||||
geoRadiusGeneric(c, RADIUS_COORDS);
|
geoRadiusGeneric(c, RADIUS_COORDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GEORADIUSBYMEMBER wrapper function. */
|
||||||
void geoRadiusByMemberCommand(redisClient *c) {
|
void geoRadiusByMemberCommand(redisClient *c) {
|
||||||
/* args 0-4: ["georadius", key, compare-against-member, radius, units];
|
|
||||||
* optionals: [withdist, withcoords, asc|desc] */
|
|
||||||
geoRadiusGeneric(c, RADIUS_MEMBER);
|
geoRadiusGeneric(c, RADIUS_MEMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GEODECODE long lat */
|
||||||
void geoDecodeCommand(redisClient *c) {
|
void geoDecodeCommand(redisClient *c) {
|
||||||
GeoHashBits geohash;
|
GeoHashBits geohash;
|
||||||
if (getLongLongFromObjectOrReply(c, c->argv[1], (long long *)&geohash.bits,
|
if (getLongLongFromObjectOrReply(c, c->argv[1], (long long *)&geohash.bits,
|
||||||
@ -612,10 +609,8 @@ void geoDecodeCommand(redisClient *c) {
|
|||||||
addReplyDouble(c, lat);
|
addReplyDouble(c, lat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* GEOENCODE long lat [radius unit] */
|
||||||
void geoEncodeCommand(redisClient *c) {
|
void geoEncodeCommand(redisClient *c) {
|
||||||
/* args 0-2: ["geoencode", long, lat];
|
|
||||||
* optionals: [radius, units] */
|
|
||||||
|
|
||||||
double radius_meters = 0;
|
double radius_meters = 0;
|
||||||
if (c->argc >= 5) {
|
if (c->argc >= 5) {
|
||||||
if ((radius_meters = extractDistanceOrReply(c, c->argv + 3, NULL)) < 0)
|
if ((radius_meters = extractDistanceOrReply(c, c->argv + 3, NULL)) < 0)
|
||||||
@ -628,7 +623,7 @@ void geoEncodeCommand(redisClient *c) {
|
|||||||
double xy[2];
|
double xy[2];
|
||||||
if (extractLongLatOrReply(c, c->argv + 1, xy) == REDIS_ERR) return;
|
if (extractLongLatOrReply(c, c->argv + 1, xy) == REDIS_ERR) return;
|
||||||
|
|
||||||
/* Encode lat/long into our geohash */
|
/* Encode long/lat into our geohash */
|
||||||
GeoHashBits geohash;
|
GeoHashBits geohash;
|
||||||
uint8_t step = geohashEstimateStepsByRadius(radius_meters,0);
|
uint8_t step = geohashEstimateStepsByRadius(radius_meters,0);
|
||||||
geohashEncodeWGS84(xy[0], xy[1], step, &geohash);
|
geohashEncodeWGS84(xy[0], xy[1], step, &geohash);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user