Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
OpenAtomFoundation
pika
提交
66e5a165
pika
项目概览
镜像
/
OpenAtomFoundation
/
pika
11 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
pika
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
66e5a165
编写于
3月 28, 2017
作者:
L
Leviathan
提交者:
SongZhao
3月 28, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugfix GEO (#77)
* Update hyperloglog test example * Modify test * bugfix geo && update test
上级
e3c9bb3a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
20 deletion
+27
-20
pikatests/tests/unit/geo.tcl
pikatests/tests/unit/geo.tcl
+13
-13
src/pika_geo.cc
src/pika_geo.cc
+14
-7
未找到文件。
pikatests/tests/unit/geo.tcl
浏览文件 @
66e5a165
...
...
@@ -76,7 +76,7 @@ start_server {tags {"geo"}} {
foo bar
"luck market"
}
err
set err
}
{
*valid*
}
}
{
ERR value is not an float
}
test
{
GEOADD multi add
}
{
r geoadd nyc -73.9733487 40.7648057
"central park n/q/r"
-73.9903085 40.7362513
"union square"
-74.0131604 40.7126674
"wtc one"
-73.7858139 40.6428986
"jfk"
-73.9375699 40.7498929
"q4"
-73.9564142 40.7480973 4545
...
...
@@ -84,7 +84,7 @@ start_server {tags {"geo"}} {
test
{
Check geoset values
}
{
r zrange nyc 0 -1 withscores
}
{{
wtc one
}
1791873972053020
{
union square
}
1791875485187452
{
central park n/q/r
}
1791875761332224 4545 1791875796750882
{
lic market
}
1791875804419201 q4 1791875830079666 jfk 1791895905559723
}
}
{{
wtc one
}
27341826966
{
union square
}
27341850054
{
central park n/q/r
}
27341854268 4545 27341854808
{
lic market
}
27341854925 q4 27341855317 jfk 27342161644
}
test
{
GEORADIUS simple
(
sorted
)}
{
r georadius nyc -73.9798091 40.7598464 3 km asc
...
...
@@ -92,11 +92,11 @@ start_server {tags {"geo"}} {
test
{
GEORADIUS withdist
(
sorted
)}
{
r georadius nyc -73.9798091 40.7598464 3 km withdist asc
}
{{{
central park n/q/r
}
0.7
750
}
{
4545 2.3651
}
{{
union square
}
2.7697
}}
}
{{{
central park n/q/r
}
0.7
953
}
{
4545 2.3672
}
{{
union square
}
2.7844
}}
test
{
GEORADIUS with COUNT
}
{
r georadius nyc -73.9798091 40.7598464 10 km COUNT 3
}
{{
central park n/q/r
}
4545
{
union square
}}
}
{{
wtc one
}
{
union square
}
{
central park n/q/r
}}
test
{
GEORADIUS with COUNT but missing integer argument
}
{
catch
{
r georadius nyc -73.9798091 40.7598464 10 km COUNT
}
e
...
...
@@ -118,14 +118,14 @@ start_server {tags {"geo"}} {
test
{
GEORADIUSBYMEMBER withdist
(
sorted
)}
{
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.
1908
}
{{
central park n/q/r
}
6.6785
}
{
4545 6.1410
}
{{
lic market
}
6.8411
}}
test
{
GEOHASH is able to return geohash strings
}
{
# Example from Wikipedia.
r del points
r geoadd points -5.6 42.6 test
lindex
[
r geohash points test
]
0
}
{
ezs42e4
4yx
0
}
}
{
ezs42e4
d0j
0
}
test
{
GEOPOS simple
}
{
r del points
...
...
@@ -149,7 +149,7 @@ start_server {tags {"geo"}} {
r geoadd points 13.361389 38.115556
"Palermo"
\
15.087269 37.502669
"Catania"
set m
[
r geodist points Palermo Catania
]
assert
{
$m
> 1662
74 && $m < 166275
}
assert
{
$m
> 1662
85 && $m < 166287
}
set km
[
r geodist points Palermo Catania km
]
assert
{
$km
> 166.2 && $km < 166.3
}
}
...
...
@@ -209,14 +209,14 @@ start_server {tags {"geo"}} {
r del points
r geoadd points 13.361389 38.115556
"Palermo"
\
15.087269 37.502669
"Catania"
r georadius points 13.361389 38.115556 500 km storedist points
2
asc count 1
assert
{[
r zcard points
2
]
== 1
}
set res
[
r zrange points
2
0 -1 withscores
]
r georadius points 13.361389 38.115556 500 km storedist points
3
asc count 1
assert
{[
r zcard points
3
]
== 1
}
set res
[
r zrange points
3
0 -1 withscores
]
assert
{[
lindex $res 0
]
eq
"Palermo"
}
r georadius points 13.361389 38.115556 500 km storedist points
2
desc count 1
assert
{[
r zcard points
2
]
== 1
}
set res
[
r zrange points
2
0 -1 withscores
]
r georadius points 13.361389 38.115556 500 km storedist points
4
desc count 1
assert
{[
r zcard points
4
]
== 1
}
set res
[
r zrange points
4
0 -1 withscores
]
assert
{[
lindex $res 0
]
eq
"Catania"
}
}
...
...
src/pika_geo.cc
浏览文件 @
66e5a165
...
...
@@ -194,8 +194,8 @@ void GeoDistCmd::Do() {
double
distance
=
geohashGetDistance
(
first_xy
[
0
],
first_xy
[
1
],
second_xy
[
0
],
second_xy
[
1
]);
distance
=
length_converter
(
distance
,
unit_
);
char
buf
[
32
];
int64_t
len
=
slash
::
d2string
(
buf
,
sizeof
(
buf
)
,
distance
);
res_
.
AppendStringLen
(
len
);
sprintf
(
buf
,
"%.4f"
,
distance
);
res_
.
AppendStringLen
(
strlen
(
buf
)
);
res_
.
AppendContent
(
buf
);
}
...
...
@@ -290,6 +290,7 @@ static void GetAllNeighbors(std::string & key, GeoRange & range, CmdRes & res) {
// For each neighbor, get all the matching
// members and add them to the potential result list.
std
::
vector
<
NeighborPoint
>
result
;
int
last_processed
=
0
;
for
(
size_t
i
=
0
;
i
<
sizeof
(
neighbors
)
/
sizeof
(
*
neighbors
);
i
++
)
{
GeoHashFix52Bits
min
,
max
;
if
(
HASHISZERO
(
neighbors
[
i
]))
...
...
@@ -297,7 +298,11 @@ static void GetAllNeighbors(std::string & key, GeoRange & range, CmdRes & res) {
min
=
geohashAlign52Bits
(
neighbors
[
i
]);
neighbors
[
i
].
bits
++
;
max
=
geohashAlign52Bits
(
neighbors
[
i
]);
// When a huge Radius (in the 5000 km range or more) is used,
// adjacent neighbors can be the same, so need to remove duplicated elements
if
(
last_processed
&&
neighbors
[
i
].
bits
==
neighbors
[
last_processed
].
bits
&&
neighbors
[
i
].
step
==
neighbors
[
last_processed
].
step
)
{
continue
;
}
std
::
vector
<
nemo
::
SM
>
sm_v
;
s
=
g_pika_server
->
db
()
->
ZRangebyscore
(
key
,
(
double
)
min
,
(
double
)
max
,
sm_v
,
false
,
false
);
if
(
!
s
.
ok
())
{
...
...
@@ -317,10 +322,12 @@ static void GetAllNeighbors(std::string & key, GeoRange & range, CmdRes & res) {
result
.
push_back
(
item
);
}
}
last_processed
=
i
;
}
// If using the count opiton
if
(
range
.
count
)
{
count_limit
=
range
.
count_limit
;
count_limit
=
r
esult
.
size
()
<
range
.
count_limit
?
result
.
size
()
:
r
ange
.
count_limit
;
}
else
{
count_limit
=
result
.
size
();
}
...
...
@@ -366,9 +373,9 @@ static void GetAllNeighbors(std::string & key, GeoRange & range, CmdRes & res) {
geohashDecodeToLongLatWGS84
(
hash
,
xy
);
double
distance
=
geohashGetDistance
(
longitude
,
latitude
,
xy
[
0
],
xy
[
1
]);
distance
=
length_converter
(
distance
,
range
.
unit
);
char
buf
[
32
];
int64_t
len
=
slash
::
d2string
(
buf
,
sizeof
(
buf
)
,
distance
);
res
.
AppendStringLen
(
len
);
char
buf
[
32
];
sprintf
(
buf
,
"%.4f"
,
distance
);
res
.
AppendStringLen
(
strlen
(
buf
)
);
res
.
AppendContent
(
buf
);
}
// If using withcoord option
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录