1 | #include <vector>
|
---|
2 | #include <boost/geometry.hpp>
|
---|
3 | #include <boost/geometry/geometries/point_xy.hpp>
|
---|
4 | #include <boost/geometry/geometries/box.hpp>
|
---|
5 | #include <boost/geometry/geometries/polygon.hpp>
|
---|
6 | #include <boost/geometry/index/rtree.hpp>
|
---|
7 |
|
---|
8 | void testSpacialIndexing()
|
---|
9 | {
|
---|
10 | namespace bg = boost::geometry;
|
---|
11 | namespace bgm = boost::geometry::model;
|
---|
12 | namespace bgi = boost::geometry::index;
|
---|
13 |
|
---|
14 | typedef bgm::d2::point_xy<double> P;
|
---|
15 | typedef bgm::box<P> B;
|
---|
16 |
|
---|
17 | P qpt;
|
---|
18 | B qbox;
|
---|
19 | bgm::ring<P> qring;
|
---|
20 | bgm::polygon<P> qpoly;
|
---|
21 | bgm::multi_polygon<bgm::polygon<P>> qmpoly;
|
---|
22 | bgm::segment<P> qseg;
|
---|
23 | bgm::linestring<P> qls;
|
---|
24 |
|
---|
25 | // spacial indexing example
|
---|
26 | typedef std::pair<B, int> Value_t;
|
---|
27 | bgi::rtree<Value_t, bgi::quadratic<8>> rtree1;
|
---|
28 |
|
---|
29 | std::vector<Value_t> found;
|
---|
30 |
|
---|
31 | // works for all versions
|
---|
32 | rtree1.query(bgi::intersects(qpt), back_inserter(found));
|
---|
33 | rtree1.query(bgi::intersects(qbox), back_inserter(found));
|
---|
34 | rtree1.query(bgi::intersects(qseg), back_inserter(found));
|
---|
35 | rtree1.query(bgi::intersects(qls), back_inserter(found));
|
---|
36 |
|
---|
37 | // does not work for 1.59 to 1.61 beta
|
---|
38 | rtree1.query(bgi::intersects(qring), back_inserter(found));
|
---|
39 | rtree1.query(bgi::intersects(qpoly), back_inserter(found));
|
---|
40 | rtree1.query(bgi::intersects(qmpoly), back_inserter(found));
|
---|
41 | }
|
---|