1 | #include <boost/geometry.hpp>
|
---|
2 | #include <boost/geometry/geometries/point.hpp>
|
---|
3 | namespace bg = boost::geometry;
|
---|
4 |
|
---|
5 | int main()
|
---|
6 | {
|
---|
7 | typedef bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > point;
|
---|
8 | typedef bg::model::box<point> box;
|
---|
9 |
|
---|
10 | point target(10.932501600000000, 59.922640600000001);
|
---|
11 | point pt(10.7535660, 59.9131705);
|
---|
12 | point pmin(10.187599199999999, 59.747306700000003);
|
---|
13 | point pmax(10.753619700000000, 59.917844000000002);
|
---|
14 | box bounding_box(pmin, pmax);
|
---|
15 |
|
---|
16 | bool target_inside_box = bg::covered_by(target, bounding_box);
|
---|
17 | bool point_inside_box = bg::covered_by(pt, bounding_box);
|
---|
18 | // the same for bg::comparable_distance()
|
---|
19 | double dp = bg::distance(target, pt);
|
---|
20 | double db = bg::distance(target, bounding_box);
|
---|
21 | double dm = bg::distance(target, pmax);
|
---|
22 |
|
---|
23 | std::cout << "target inside box = " << (target_inside_box ? "TRUE" : "FALSE") << std::endl;
|
---|
24 | std::cout << "point inside box = " << (point_inside_box ? "TRUE" : "FALSE") << std::endl;
|
---|
25 | std::cout << "target to point = " << dp << std::endl;
|
---|
26 | std::cout << "target to box = " << db << std::endl;
|
---|
27 | std::cout << "target to max = " << dm << std::endl;
|
---|
28 |
|
---|
29 | if (dp > db)
|
---|
30 | std::cout << "ok! the distance to box is smaller" << std::endl;
|
---|
31 | else
|
---|
32 | std::cout << "error! the distance to box should be smaller" << std::endl;
|
---|
33 |
|
---|
34 | return 0;
|
---|
35 | }
|
---|