tile38/tests/keys_search.go
Josh Baker 04290ec535 KNN results for NEARBY command
This commit includes the ability to search for k nearest neighbors using
a NEARBY command. When the LIMIT keyword is included and the 'meters'
param is excluded, the knn algorithm will be used instead of the
standard overlap+haversine algorithm.

   NEARBY fleet LIMIT 10 POINT 33.5 -115.8

This will find the 10 closest points to 33.5,-115.8.

closes #136, #130, and #138.
ping @tomquas, @joernroeder, and @m1ome
2017-01-30 16:41:12 -07:00

26 lines
752 B
Go

package tests
import "testing"
func subTestSearch(t *testing.T, mc *mockServer) {
runStep(t, mc, "KNN", keys_KNN_test)
}
func keys_KNN_test(mc *mockServer) error {
return mc.DoBatch([][]interface{}{
{"SET", "mykey", "1", "POINT", 5, 5}, {"OK"},
{"SET", "mykey", "2", "POINT", 19, 19}, {"OK"},
{"SET", "mykey", "3", "POINT", 12, 19}, {"OK"},
{"SET", "mykey", "4", "POINT", -5, 5}, {"OK"},
{"SET", "mykey", "5", "POINT", 33, 21}, {"OK"},
{"NEARBY", "mykey", "LIMIT", 10, "DISTANCE", "POINTS", "POINT", 20, 20}, {
"[0 [" +
"[2 [19 19] 152808.67164037024] " +
"[3 [12 19] 895945.1409106688] " +
"[5 [33 21] 1448929.5916252395] " +
"[1 [5 5] 2327116.1069888202] " +
"[4 [-5 5] 3227402.6159841116]" +
"]]"},
})
}