Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
7d59e0a8
Commit
7d59e0a8
authored
Jun 29, 2015
by
antirez
Browse files
Geo: commands top comment as in other Redis code.
parent
a3b07b17
Changes
1
Show whitespace changes
Inline
Side-by-side
src/geo.c
View file @
7d59e0a8
...
...
@@ -341,11 +341,9 @@ static int sort_gp_desc(const void *a, const void *b) {
/* ====================================================================
* 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. */
double
radius_meters
=
0
;
if
(
c
->
argc
==
7
)
{
...
...
@@ -568,18 +566,17 @@ static void geoRadiusGeneric(redisClient *c, int type) {
geoArrayFree
(
ga
);
}
/* GEORADIUS wrapper function. */
void
geoRadiusCommand
(
redisClient
*
c
)
{
/* args 0-5: ["georadius", key, long, lat, radius, units];
* optionals: [withdist, withcoords, asc|desc] */
geoRadiusGeneric
(
c
,
RADIUS_COORDS
);
}
/* GEORADIUSBYMEMBER wrapper function. */
void
geoRadiusByMemberCommand
(
redisClient
*
c
)
{
/* args 0-4: ["georadius", key, compare-against-member, radius, units];
* optionals: [withdist, withcoords, asc|desc] */
geoRadiusGeneric
(
c
,
RADIUS_MEMBER
);
}
/* GEODECODE long lat */
void
geoDecodeCommand
(
redisClient
*
c
)
{
GeoHashBits
geohash
;
if
(
getLongLongFromObjectOrReply
(
c
,
c
->
argv
[
1
],
(
long
long
*
)
&
geohash
.
bits
,
...
...
@@ -612,10 +609,8 @@ void geoDecodeCommand(redisClient *c) {
addReplyDouble
(
c
,
lat
);
}
/* GEOENCODE long lat [radius unit] */
void
geoEncodeCommand
(
redisClient
*
c
)
{
/* args 0-2: ["geoencode", long, lat];
* optionals: [radius, units] */
double
radius_meters
=
0
;
if
(
c
->
argc
>=
5
)
{
if
((
radius_meters
=
extractDistanceOrReply
(
c
,
c
->
argv
+
3
,
NULL
))
<
0
)
...
...
@@ -628,7 +623,7 @@ void geoEncodeCommand(redisClient *c) {
double
xy
[
2
];
if
(
extractLongLatOrReply
(
c
,
c
->
argv
+
1
,
xy
)
==
REDIS_ERR
)
return
;
/* Encode l
at/long
into our geohash */
/* Encode l
ong/lat
into our geohash */
GeoHashBits
geohash
;
uint8_t
step
=
geohashEstimateStepsByRadius
(
radius_meters
,
0
);
geohashEncodeWGS84
(
xy
[
0
],
xy
[
1
],
step
,
&
geohash
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment