GEOSEARCH bybox bug fixes and new fuzzy tester#8375
GEOSEARCH bybox bug fixes and new fuzzy tester#8375yangbodong22011 wants to merge 8 commits intoredis:unstablefrom
Conversation
|
@yangbodong22011 thank you for this PR. this is not exactly the test i wanted, but maybe its is enough. what i was looking is more of a specific test that tests edge cases in the box code. and i would like to do that on various different box shapes (horizontally wide, and horizontally narrow). i didn't dig too much into the current test, if you can convince me that it covers the above concern, that would be great. |
Co-authored-by: Oran Agra <[email protected]>
|
Updated:
NOTICE:
|
oranagra
left a comment
There was a problem hiding this comment.
@yangbodong22011 thank you!
i assume the improved tests failed quite consistently on the old implementation, right?
considering the equator problem i mentioned and maybe the bent edges, they should still fail from time to time, and we can improve both tests and the code.
070c045 to
56e9dd7
Compare
@oranagra please have a look when you have time. |
tests/unit/geo.tcl
Outdated
| set bounds(0) [expr {$search_lon-$long_delta_top}] | ||
| set bounds(1) [expr {$search_lat+$lat_delta}] | ||
| set bounds(2) [expr {$search_lon+$long_delta_top}] | ||
| set bounds(3) [expr {$search_lat+$lat_delta}] | ||
| set bounds(4) [expr {$search_lon+$long_delta_middle}] | ||
| set bounds(5) $search_lat | ||
| set bounds(6) [expr {$search_lon+$long_delta_bottom}] | ||
| set bounds(7) [expr {$search_lat-$lat_delta}] | ||
| set bounds(8) [expr {$search_lon-$long_delta_bottom}] | ||
| set bounds(9) [expr {$search_lat-$lat_delta}] | ||
| set bounds(10) [expr {$search_lon-$long_delta_middle}] | ||
| set bounds(11) $search_lat |
There was a problem hiding this comment.
this test is a bit weak since it uses the same approach as the code it tests.
luckily we have the other new test (one that shifts the box by 1m) that covers for this.
but maybe we can improve this function too.
some wild idea is to try to convert the point that we're matching to the coordinate system of the box (km) rather than converting the box to long/lat.
consider:
- the search box center being: lon1,lat1 (
search_lonandsearch_latright?) - the the point we're to match to the box: lon2,lat2 (
lonandlat, right?)
we can create two new points, and measure the horizontal and vertical distance from the box center and match them to width and height.
# on one longitude (the one of the point being searched),
# measure the distance between two lats (the lat of the point being search and the one of the center of the box)
distance between lon2/lat1 and lon2,lat2 < height/2 ?
# on one latitude (the one of the point being searched),
# measure the distance between two lons (the lon of the point being search and the one of the center of the box)
distance between lon1,lat2 and lon2,lat2 < width/2 ?
is this silly? (it's very late at night here), or could that work?
There was a problem hiding this comment.
@yangbodong22011 what do you think of this?
if that algorithm indeed works, maybe instead of using it in the tests we should use it in redis itself?
i initially suggested it just so that we don't use the same algo in the tests as the one in redis (weak test), but if we prove that it's a valid algo, it might be more accurate than the polygon one.
Co-authored-by: Oran Agra <[email protected]>
18529c9 to
702f3c1
Compare
|
@oranagra Thank you very much for your detailed reply. I have updated the code, please have a look when you have time. |
|
closed in favor of #8445 |

[Edit]
trapezoid (when the meter box is converted to long / lat it's no longer a box).
This PR add fuzzy test for
GEOSEARCHcommand and fix the wrong order of widht and height parameters. As shown in the document, width is before height.