forked from mourner/kdbush.hpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
33 lines (27 loc) · 1.39 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "include/kdbush.hpp"
#include <iostream>
#include <vector>
int main(int argc, char **argv) {
std::vector<double> coords = {
54, 1, 97, 21, 65, 35, 33, 54, 95, 39, 54, 3, 53, 54, 84, 72, 33, 34, 43, 15, 52, 83, 81,
23, 1, 61, 38, 74, 11, 91, 24, 56, 90, 31, 25, 57, 46, 61, 29, 69, 49, 60, 4, 98, 71, 15,
60, 25, 38, 84, 52, 38, 94, 51, 13, 25, 77, 73, 88, 87, 6, 27, 58, 22, 53, 28, 27, 91, 96,
98, 93, 14, 22, 93, 45, 94, 18, 28, 35, 15, 19, 81, 20, 81, 67, 53, 43, 3, 47, 66, 48, 34,
46, 12, 32, 38, 43, 12, 39, 94, 88, 62, 66, 14, 84, 30, 72, 81, 41, 92, 26, 4, 6, 76, 47,
21, 57, 70, 71, 82, 50, 68, 96, 18, 40, 31, 78, 53, 71, 90, 32, 14, 55, 6, 32, 88, 62, 32,
21, 67, 73, 81, 44, 64, 29, 50, 70, 5, 6, 22, 68, 3, 11, 23, 20, 42, 21, 73, 63, 86, 9,
40, 99, 2, 99, 76, 56, 77, 83, 6, 21, 72, 78, 30, 75, 53, 41, 11, 95, 20, 30, 38, 96, 82,
65, 48, 33, 18, 87, 28, 10, 10, 40, 34, 10, 20, 47, 29, 46, 78
};
KDBush index(coords, 10);
std::vector<std::size_t> result;
index.within(50, 50, 20, result);
std::cout << "radius query:\n";
for (auto i : result) std::cout << i << ' ';
std::cout << '\n';
std::vector<std::size_t> result2;
index.range(20, 30, 50, 70, result2);
std::cout << "range query:\n";
for (auto i : result2) std::cout << i << ' ';
std::cout << '\n';
}