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
cd91beea
Commit
cd91beea
authored
Jun 27, 2015
by
antirez
Browse files
Geo: only one way to specify any given option.
parent
710c05ac
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/geo.c
View file @
cd91beea
...
@@ -413,6 +413,7 @@ void geoAddCommand(redisClient *c) {
...
@@ -413,6 +413,7 @@ void geoAddCommand(redisClient *c) {
#define RADIUS_MEMBER 2
#define RADIUS_MEMBER 2
/* GEORADIUS key x y radius unit [WITHDIST] [WITHHASH] [WITHCOORD] [ASC|DESC]
/* GEORADIUS key x y radius unit [WITHDIST] [WITHHASH] [WITHCOORD] [ASC|DESC]
* [LIMIT count]
* GEORADIUSBYMEMBER key member radius unit ... options ... */
* GEORADIUSBYMEMBER key member radius unit ... options ... */
static
void
geoRadiusGeneric
(
redisClient
*
c
,
int
type
)
{
static
void
geoRadiusGeneric
(
redisClient
*
c
,
int
type
)
{
robj
*
key
=
c
->
argv
[
1
];
robj
*
key
=
c
->
argv
[
1
];
...
@@ -457,17 +458,17 @@ static void geoRadiusGeneric(redisClient *c, int type) {
...
@@ -457,17 +458,17 @@ static void geoRadiusGeneric(redisClient *c, int type) {
int
remaining
=
c
->
argc
-
base_args
;
int
remaining
=
c
->
argc
-
base_args
;
for
(
int
i
=
0
;
i
<
remaining
;
i
++
)
{
for
(
int
i
=
0
;
i
<
remaining
;
i
++
)
{
char
*
arg
=
c
->
argv
[
base_args
+
i
]
->
ptr
;
char
*
arg
=
c
->
argv
[
base_args
+
i
]
->
ptr
;
if
(
!
str
n
casecmp
(
arg
,
"withdist"
,
8
))
if
(
!
strcasecmp
(
arg
,
"withdist"
))
{
withdist
=
1
;
withdist
=
1
;
else
if
(
!
strcasecmp
(
arg
,
"withhash"
))
}
else
if
(
!
strcasecmp
(
arg
,
"withhash"
))
{
withhash
=
1
;
withhash
=
1
;
else
if
(
!
str
n
casecmp
(
arg
,
"withcoord"
,
9
))
}
else
if
(
!
strcasecmp
(
arg
,
"withcoord"
))
{
withcoords
=
1
;
withcoords
=
1
;
else
if
(
!
str
n
casecmp
(
arg
,
"asc"
,
3
))
}
else
if
(
!
strcasecmp
(
arg
,
"asc"
))
{
sort
=
SORT_ASC
;
sort
=
SORT_ASC
;
else
if
(
!
str
n
casecmp
(
arg
,
"desc"
,
4
))
}
else
if
(
!
strcasecmp
(
arg
,
"desc"
))
{
sort
=
SORT_DESC
;
sort
=
SORT_DESC
;
else
{
}
else
{
addReply
(
c
,
shared
.
syntaxerr
);
addReply
(
c
,
shared
.
syntaxerr
);
return
;
return
;
}
}
...
...
tests/unit/geo.tcl
View file @
cd91beea
...
@@ -49,18 +49,18 @@ start_server {tags {"geo"}} {
...
@@ -49,18 +49,18 @@ start_server {tags {"geo"}} {
}
{{
wtc one
}
1791873972053020
{
union square
}
1791875485187452
{
central park n/q/r
}
1791875761332224 4545 1791875796750882
{
lic market
}
1791875804419201 q4 1791875830079666 jfk 1791895905559723
}
}
{{
wtc one
}
1791873972053020
{
union square
}
1791875485187452
{
central park n/q/r
}
1791875761332224 4545 1791875796750882
{
lic market
}
1791875804419201 q4 1791875830079666 jfk 1791895905559723
}
test
{
GEORADIUS simple
(
sorted
)}
{
test
{
GEORADIUS simple
(
sorted
)}
{
r georadius nyc -73.9798091 40.7598464 3 km asc
ending
r georadius nyc -73.9798091 40.7598464 3 km asc
}
{{
central park n/q/r
}
4545
{
union square
}}
}
{{
central park n/q/r
}
4545
{
union square
}}
test
{
GEORADIUS withdist
ance
(
sorted
)}
{
test
{
GEORADIUS withdist
(
sorted
)}
{
r georadius nyc -73.9798091 40.7598464 3 km withdist
ance ascending
r georadius nyc -73.9798091 40.7598464 3 km withdist
asc
}
{{{
central park n/q/r
}
0.7750
}
{
4545 2.3651
}
{{
union square
}
2.7697
}}
}
{{{
central park n/q/r
}
0.7750
}
{
4545 2.3651
}
{{
union square
}
2.7697
}}
test
{
GEORADIUSBYMEMBER simple
(
sorted
)}
{
test
{
GEORADIUSBYMEMBER simple
(
sorted
)}
{
r georadiusbymember nyc
"wtc one"
7 km
r georadiusbymember nyc
"wtc one"
7 km
}
{{
wtc one
}
{
union square
}
{
central park n/q/r
}
4545
{
lic market
}}
}
{{
wtc one
}
{
union square
}
{
central park n/q/r
}
4545
{
lic market
}}
test
{
GEORADIUSBYMEMBER withdist
ance
(
sorted
)}
{
test
{
GEORADIUSBYMEMBER withdist
(
sorted
)}
{
r georadiusbymember nyc
"wtc one"
7 km withdist
r georadiusbymember nyc
"wtc one"
7 km withdist
}
{{{
wtc one
}
0.0000
}
{{
union square
}
3.2544
}
{{
central park n/q/r
}
6.7000
}
{
4545 6.1975
}
{{
lic market
}
6.8969
}}
}
{{{
wtc one
}
0.0000
}
{{
union square
}
3.2544
}
{{
central park n/q/r
}
6.7000
}
{
4545 6.1975
}
{{
lic market
}
6.8969
}}
...
...
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