Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
9acd40d9
Unverified
Commit
9acd40d9
authored
Dec 14, 2020
by
Itamar Haber
Committed by
GitHub
Dec 14, 2020
Browse files
GEOSEARCH: change 'FROMLOC' to 'FROMLONLAT' (#8190)
And formats style a tiniee-winiee bit
parent
cfb449cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/geo.c
View file @
9acd40d9
...
@@ -591,7 +591,7 @@ void georadiusGeneric(client *c, int srcKeyIndex, int flags) {
...
@@ -591,7 +591,7 @@ void georadiusGeneric(client *c, int srcKeyIndex, int flags) {
}
}
frommember
=
1
;
frommember
=
1
;
i
++
;
i
++
;
}
else
if
(
!
strcasecmp
(
arg
,
"fromlo
c
"
)
&&
}
else
if
(
!
strcasecmp
(
arg
,
"fromlo
nlat
"
)
&&
(
i
+
2
)
<
remaining
&&
(
i
+
2
)
<
remaining
&&
flags
&
GEOSEARCH
&&
flags
&
GEOSEARCH
&&
!
frommember
)
!
frommember
)
...
@@ -635,12 +635,16 @@ void georadiusGeneric(client *c, int srcKeyIndex, int flags) {
...
@@ -635,12 +635,16 @@ void georadiusGeneric(client *c, int srcKeyIndex, int flags) {
}
}
if
((
flags
&
GEOSEARCH
)
&&
!
(
frommember
||
fromloc
))
{
if
((
flags
&
GEOSEARCH
)
&&
!
(
frommember
||
fromloc
))
{
addReplyErrorFormat
(
c
,
"exactly one of FROMMEMBER or FROMLOC can be specified for %s"
,
(
char
*
)
c
->
argv
[
0
]
->
ptr
);
addReplyErrorFormat
(
c
,
"exactly one of FROMMEMBER or FROMLONLAT can be specified for %s"
,
(
char
*
)
c
->
argv
[
0
]
->
ptr
);
return
;
return
;
}
}
if
((
flags
&
GEOSEARCH
)
&&
!
(
byradius
||
bybox
))
{
if
((
flags
&
GEOSEARCH
)
&&
!
(
byradius
||
bybox
))
{
addReplyErrorFormat
(
c
,
"exactly one of BYRADIUS and BYBOX can be specified for %s"
,
(
char
*
)
c
->
argv
[
0
]
->
ptr
);
addReplyErrorFormat
(
c
,
"exactly one of BYRADIUS and BYBOX can be specified for %s"
,
(
char
*
)
c
->
argv
[
0
]
->
ptr
);
return
;
return
;
}
}
...
...
tests/unit/geo.tcl
View file @
9acd40d9
...
@@ -95,31 +95,31 @@ start_server {tags {"geo"}} {
...
@@ -95,31 +95,31 @@ start_server {tags {"geo"}} {
}
{{
central park n/q/r
}
4545
{
union square
}}
}
{{
central park n/q/r
}
4545
{
union square
}}
test
{
GEOSEARCH simple
(
sorted
)}
{
test
{
GEOSEARCH simple
(
sorted
)}
{
r geosearch nyc fromlo
c
-73.9798091 40.7598464 bybox 6 6 km asc
r geosearch nyc fromlo
nlat
-73.9798091 40.7598464 bybox 6 6 km asc
}
{{
central park n/q/r
}
4545
{
union square
}
{
lic market
}}
}
{{
central park n/q/r
}
4545
{
union square
}
{
lic market
}}
test
{
GEOSEARCH FROMLO
C
and FROMMEMBER cannot exist at the same time
}
{
test
{
GEOSEARCH FROMLO
NLAT
and FROMMEMBER cannot exist at the same time
}
{
catch
{
r geosearch nyc fromlo
c
-73.9798091 40.7598464 frommember xxx bybox 6 6 km asc
}
e
catch
{
r geosearch nyc fromlo
nlat
-73.9798091 40.7598464 frommember xxx bybox 6 6 km asc
}
e
set e
set e
}
{
ERR*syntax*
}
}
{
ERR*syntax*
}
test
{
GEOSEARCH FROMLO
C
and FROMMEMBER one must exist
}
{
test
{
GEOSEARCH FROMLO
NLAT
and FROMMEMBER one must exist
}
{
catch
{
r geosearch nyc bybox 3 3 km asc desc withhash withdist withcoord
}
e
catch
{
r geosearch nyc bybox 3 3 km asc desc withhash withdist withcoord
}
e
set e
set e
}
{
ERR*exactly one of FROMMEMBER or FROMLO
C
*
}
}
{
ERR*exactly one of FROMMEMBER or FROMLO
NLAT
*
}
test
{
GEOSEARCH BYRADIUS and BYBOX cannot exist at the same time
}
{
test
{
GEOSEARCH BYRADIUS and BYBOX cannot exist at the same time
}
{
catch
{
r geosearch nyc fromlo
c
-73.9798091 40.7598464 byradius 3 km bybox 3 3 km asc
}
e
catch
{
r geosearch nyc fromlo
nlat
-73.9798091 40.7598464 byradius 3 km bybox 3 3 km asc
}
e
set e
set e
}
{
ERR*syntax*
}
}
{
ERR*syntax*
}
test
{
GEOSEARCH BYRADIUS and BYBOX one must exist
}
{
test
{
GEOSEARCH BYRADIUS and BYBOX one must exist
}
{
catch
{
r geosearch nyc fromlo
c
-73.9798091 40.7598464 asc desc withhash withdist withcoord
}
e
catch
{
r geosearch nyc fromlo
nlat
-73.9798091 40.7598464 asc desc withhash withdist withcoord
}
e
set e
set e
}
{
ERR*exactly one of BYRADIUS and BYBOX*
}
}
{
ERR*exactly one of BYRADIUS and BYBOX*
}
test
{
GEOSEARCH with STOREDIST option
}
{
test
{
GEOSEARCH with STOREDIST option
}
{
catch
{
r geosearch nyc fromlo
c
-73.9798091 40.7598464 bybox 6 6 km asc storedist
}
e
catch
{
r geosearch nyc fromlo
nlat
-73.9798091 40.7598464 bybox 6 6 km asc storedist
}
e
set e
set e
}
{
ERR*syntax*
}
}
{
ERR*syntax*
}
...
@@ -128,7 +128,7 @@ start_server {tags {"geo"}} {
...
@@ -128,7 +128,7 @@ start_server {tags {"geo"}} {
}
{{{
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
{
GEOSEARCH withdist
(
sorted
)}
{
test
{
GEOSEARCH withdist
(
sorted
)}
{
r geosearch nyc fromlo
c
-73.9798091 40.7598464 bybox 6 6 km withdist asc
r geosearch nyc fromlo
nlat
-73.9798091 40.7598464 bybox 6 6 km withdist asc
}
{{{
central park n/q/r
}
0.7750
}
{
4545 2.3651
}
{{
union square
}
2.7697
}
{{
lic market
}
3.1991
}}
}
{{{
central park n/q/r
}
0.7750
}
{
4545 2.3651
}
{{
union square
}
2.7697
}
{{
lic market
}
3.1991
}}
test
{
GEORADIUS with COUNT
}
{
test
{
GEORADIUS with COUNT
}
{
...
@@ -163,7 +163,7 @@ start_server {tags {"geo"}} {
...
@@ -163,7 +163,7 @@ start_server {tags {"geo"}} {
r geoadd Sicily 12.758489 38.788135
"edge1"
17.241510 38.788135
"eage2"
r geoadd Sicily 12.758489 38.788135
"edge1"
17.241510 38.788135
"eage2"
set ret1
[
r georadius Sicily 15 37 200 km asc
]
set ret1
[
r georadius Sicily 15 37 200 km asc
]
assert_equal $ret1
{
Catania Palermo
}
assert_equal $ret1
{
Catania Palermo
}
set ret2
[
r geosearch Sicily fromlo
c
15 37 bybox 400 400 km asc
]
set ret2
[
r geosearch Sicily fromlo
nlat
15 37 bybox 400 400 km asc
]
assert_equal $ret2
{
Catania Palermo eage2 edge1
}
assert_equal $ret2
{
Catania Palermo eage2 edge1
}
}
}
...
@@ -173,12 +173,12 @@ start_server {tags {"geo"}} {
...
@@ -173,12 +173,12 @@ start_server {tags {"geo"}} {
r geoadd Sicily 12.75 36.50
"test2"
r geoadd Sicily 12.75 36.50
"test2"
r geoadd Sicily 13.00 36.50
"test3"
r geoadd Sicily 13.00 36.50
"test3"
# box height=2km width=400km
# box height=2km width=400km
set ret1
[
r geosearch Sicily fromlo
c
15 37 bybox 2 400 km
]
set ret1
[
r geosearch Sicily fromlo
nlat
15 37 bybox 2 400 km
]
assert_equal $ret1
{
test1
}
assert_equal $ret1
{
test1
}
# Add a western Hemisphere point
# Add a western Hemisphere point
r geoadd Sicily -1 37.00
"test3"
r geoadd Sicily -1 37.00
"test3"
set ret2
[
r geosearch Sicily fromlo
c
15 37 bybox 2 3000 km asc
]
set ret2
[
r geosearch Sicily fromlo
nlat
15 37 bybox 2 3000 km asc
]
assert_equal $ret2
{
test1 test3
}
assert_equal $ret2
{
test1 test3
}
}
}
...
@@ -241,7 +241,7 @@ start_server {tags {"geo"}} {
...
@@ -241,7 +241,7 @@ start_server {tags {"geo"}} {
}
{
*ERR*syntax*
}
}
{
*ERR*syntax*
}
test
{
GEOSEARCHSTORE STORE option: syntax error
}
{
test
{
GEOSEARCHSTORE STORE option: syntax error
}
{
catch
{
r geosearchstore abc points fromlo
c
13.361389 38.115556 byradius 50 km store abc
}
e
catch
{
r geosearchstore abc points fromlo
nlat
13.361389 38.115556 byradius 50 km store abc
}
e
set e
set e
}
{
*ERR*syntax*
}
}
{
*ERR*syntax*
}
...
@@ -266,7 +266,7 @@ start_server {tags {"geo"}} {
...
@@ -266,7 +266,7 @@ start_server {tags {"geo"}} {
}
}
test
{
GEOSEARCHSTORE STORE option: plain usage
}
{
test
{
GEOSEARCHSTORE STORE option: plain usage
}
{
r geosearchstore points2 points fromlo
c
13.361389 38.115556 byradius 500 km
r geosearchstore points2 points fromlo
nlat
13.361389 38.115556 byradius 500 km
assert_equal
[
r zrange points 0 -1
]
[
r zrange points2 0 -1
]
assert_equal
[
r zrange points 0 -1
]
[
r zrange points2 0 -1
]
}
}
...
@@ -282,7 +282,7 @@ start_server {tags {"geo"}} {
...
@@ -282,7 +282,7 @@ start_server {tags {"geo"}} {
}
}
test
{
GEOSEARCHSTORE STOREDIST option: plain usage
}
{
test
{
GEOSEARCHSTORE STOREDIST option: plain usage
}
{
r geosearchstore points2 points fromlo
c
13.361389 38.115556 byradius 500 km storedist
r geosearchstore points2 points fromlo
nlat
13.361389 38.115556 byradius 500 km storedist
set res
[
r zrange points2 0 -1 withscores
]
set res
[
r zrange points2 0 -1 withscores
]
assert
{[
lindex $res 1
]
< 1
}
assert
{[
lindex $res 1
]
< 1
}
assert
{[
lindex $res 3
]
> 166
}
assert
{[
lindex $res 3
]
> 166
}
...
...
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