Fix GEOSEARCH tcl test error (#8451)

Issue with new test due to longitude wraparound.
This commit is contained in:
Yang Bodong 2021-02-05 01:39:07 +08:00 committed by GitHub
parent ded1655d49
commit b7b23a0ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -566,6 +566,13 @@ start_server {tags {"geo"}} {
foreach name [array names points] { foreach name [array names points] {
set x [lindex $points($name) 0] set x [lindex $points($name) 0]
set y [lindex $points($name) 1] set y [lindex $points($name) 1]
# If longitude crosses -180° or 180°, we need to convert it.
# latitude doesn't have this problem, because it's scope is -70~70, see geo_random_point
if {$x > 180} {
set x [expr {$x-360}]
} elseif {$x < -180} {
set x [expr {$x+360}]
}
r geoadd mypoints $x $y place:$name r geoadd mypoints $x $y place:$name
lappend tcl_result "place:$name" lappend tcl_result "place:$name"
lappend debuginfo "geoadd mypoints $x $y place:$name" lappend debuginfo "geoadd mypoints $x $y place:$name"
@ -579,7 +586,7 @@ start_server {tags {"geo"}} {
set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]] set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]]
if {$res != $res2} { if {$res != $res2} {
set diff [compare_lists $res $res2] set diff [compare_lists $res $res2]
lappend debuginfo "diff: $diff" lappend debuginfo "res: $res, res2: $res2, diff: $diff"
fail "place should be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new" fail "place should be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new"
} }
@ -588,8 +595,7 @@ start_server {tags {"geo"}} {
set height_new [expr {$height_m+4}] set height_new [expr {$height_m+4}]
set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]] set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]]
if {$res != {place:north place:south}} { if {$res != {place:north place:south}} {
set diff [compare_lists $res $res2] lappend debuginfo "res: $res"
lappend debuginfo "diff: $diff"
fail "place should not be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new" fail "place should not be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new"
} }
@ -598,8 +604,7 @@ start_server {tags {"geo"}} {
set height_new [expr {$height_m-4}] set height_new [expr {$height_m-4}]
set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]] set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]]
if {$res != {place:east place:west}} { if {$res != {place:east place:west}} {
set diff [compare_lists $res $res2] lappend debuginfo "res: $res"
lappend debuginfo "diff: $diff"
fail "place should not be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new" fail "place should not be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new"
} }