]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/strategies/point_in_box.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // This file was modified by Oracle on 2014.
7 // Modifications copyright (c) 2014 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
16 #include <strategies/test_within.hpp>
19 template <typename Point
>
20 void test_box_of(std::string
const& wkt_point
, std::string
const& wkt_box
,
21 bool expected_within
, bool expected_covered_by
)
23 typedef bg::model::box
<Point
> box_type
;
27 bg::read_wkt(wkt_point
, point
);
28 bg::read_wkt(wkt_box
, box
);
30 bool detected_within
= bg::within(point
, box
);
31 bool detected_covered_by
= bg::covered_by(point
, box
);
32 BOOST_CHECK_EQUAL(detected_within
, expected_within
);
33 BOOST_CHECK_EQUAL(detected_covered_by
, expected_covered_by
);
35 // Also test with the non-default agnostic side version
36 namespace wi
= bg::strategy::within
;
37 wi::point_in_box_by_side
<> within_strategy
;
38 wi::point_in_box_by_side
<wi::decide_covered_by
> covered_by_strategy
;
40 detected_within
= bg::within(point
, box
, within_strategy
);
41 detected_covered_by
= bg::covered_by(point
, box
, covered_by_strategy
);
42 BOOST_CHECK_EQUAL(detected_within
, expected_within
);
43 BOOST_CHECK_EQUAL(detected_covered_by
, expected_covered_by
);
45 // We might exchange strategies between within/covered by.
46 // So the lines below might seem confusing, but are as intended
47 detected_within
= bg::covered_by(point
, box
, within_strategy
);
48 detected_covered_by
= bg::within(point
, box
, covered_by_strategy
);
49 BOOST_CHECK_EQUAL(detected_within
, expected_within
);
50 BOOST_CHECK_EQUAL(detected_covered_by
, expected_covered_by
);
52 // Finally we call the strategies directly
53 detected_within
= within_strategy
.apply(point
, box
);
54 detected_covered_by
= covered_by_strategy
.apply(point
, box
);
55 BOOST_CHECK_EQUAL(detected_within
, expected_within
);
56 BOOST_CHECK_EQUAL(detected_covered_by
, expected_covered_by
);
59 template <typename Point
>
62 test_box_of
<Point
>("POINT(1 1)", "BOX(0 0,2 2)", true, true);
63 test_box_of
<Point
>("POINT(0 0)", "BOX(0 0,2 2)", false, true);
64 test_box_of
<Point
>("POINT(2 2)", "BOX(0 0,2 2)", false, true);
65 test_box_of
<Point
>("POINT(0 1)", "BOX(0 0,2 2)", false, true);
66 test_box_of
<Point
>("POINT(1 0)", "BOX(0 0,2 2)", false, true);
67 test_box_of
<Point
>("POINT(3 3)", "BOX(0 0,2 2)", false, false);
71 int test_main(int, char* [])
73 test_box
<bg::model::point
<float, 2, bg::cs::cartesian
> >();
74 test_box
<bg::model::point
<double, 2, bg::cs::cartesian
> >();