]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/within/within_sph_geo.cpp
3 // Copyright (c) 2016 Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 #include "test_within.hpp"
13 #include <boost/geometry/geometries/geometries.hpp>
16 template <typename Point
>
17 void test_point_box_by_side()
19 // Test spherical boxes
20 // See also http://www.gcmap.com/mapui?P=1E45N-19E45N-19E55N-1E55N-1E45N,10E55.1N,10E45.1N
21 typedef bg::model::box
<Point
> box_t
;
22 bg::strategy::within::point_in_box_by_side
<Point
, box_t
> by_side
;
24 bg::read_wkt("POLYGON((1 45,19 55))", box
);
25 BOOST_CHECK_EQUAL(bg::within(Point(10, 55.1), box
, by_side
), true);
26 BOOST_CHECK_EQUAL(bg::within(Point(10, 55.2), box
, by_side
), true);
27 BOOST_CHECK_EQUAL(bg::within(Point(10, 55.3), box
, by_side
), true);
28 BOOST_CHECK_EQUAL(bg::within(Point(10, 55.4), box
, by_side
), false);
30 BOOST_CHECK_EQUAL(bg::within(Point(10, 45.1), box
, by_side
), false);
31 BOOST_CHECK_EQUAL(bg::within(Point(10, 45.2), box
, by_side
), false);
32 BOOST_CHECK_EQUAL(bg::within(Point(10, 45.3), box
, by_side
), false);
33 BOOST_CHECK_EQUAL(bg::within(Point(10, 45.4), box
, by_side
), true);
35 // By default Box is not a polygon in spherical CS, edges are defined by small circles
36 BOOST_CHECK_EQUAL(bg::within(Point(10, 45.1), box
), true);
37 BOOST_CHECK_EQUAL(bg::within(Point(10, 54.9), box
), true);
38 BOOST_CHECK_EQUAL(bg::within(Point(10, 55), box
), false);
39 BOOST_CHECK_EQUAL(bg::within(Point(10, 45), box
), false);
41 // Crossing the dateline (Near Tuvalu)
42 // http://www.gcmap.com/mapui?P=178E10S-178W10S-178W6S-178E6S-178E10S,180W5.999S,180E9.999S
43 // http://en.wikipedia.org/wiki/Tuvalu
45 box_t
tuvalu(Point(178, -10), Point(-178, -6));
46 BOOST_CHECK_EQUAL(bg::within(Point(180, -8), tuvalu
, by_side
), true);
47 BOOST_CHECK_EQUAL(bg::within(Point(-180, -8), tuvalu
, by_side
), true);
48 BOOST_CHECK_EQUAL(bg::within(Point(180, -5.999), tuvalu
, by_side
), false);
49 BOOST_CHECK_EQUAL(bg::within(Point(180, -10.001), tuvalu
, by_side
), true);
51 // The above definition of a Box is not valid
52 // min should be lesser than max
53 // By default Box is not a polygon in spherical CS, edges are defined by small circles
54 box_t
tuvalu2(Point(178, -10), Point(182, -6));
55 BOOST_CHECK_EQUAL(bg::within(Point(180, -8), tuvalu2
), true);
56 BOOST_CHECK_EQUAL(bg::within(Point(-180, -8), tuvalu2
), true);
57 BOOST_CHECK_EQUAL(bg::within(Point(180, -6.001), tuvalu2
), true);
58 BOOST_CHECK_EQUAL(bg::within(Point(180, -5.999), tuvalu2
), false);
59 BOOST_CHECK_EQUAL(bg::within(Point(180, -9.999), tuvalu2
), true);
60 BOOST_CHECK_EQUAL(bg::within(Point(180, -10.001), tuvalu2
), false);
67 typedef bg::model::box
<P
> box_t
;
69 test_geometry
<P
, box_t
>("POINT(0 0)", "BOX(0 0, 1 1)", false);
70 test_geometry
<P
, box_t
>("POINT(1 1)", "BOX(0 0, 2 2)", true);
72 test_geometry
<P
, box_t
>("POINT(180 1)", "BOX(170 0, 190 2)", true);
73 test_geometry
<P
, box_t
>("POINT(-180 1)", "BOX(170 0, 190 2)", true);
74 test_geometry
<P
, box_t
>("POINT(180 1)", "BOX(170 0, 180 2)", false);
75 test_geometry
<P
, box_t
>("POINT(-180 1)", "BOX(170 0, 180 2)", false);
76 test_geometry
<P
, box_t
>("POINT(179 1)", "BOX(170 0, 190 2)", true);
77 test_geometry
<P
, box_t
>("POINT(-179 1)", "BOX(170 0, 190 2)", true);
78 test_geometry
<P
, box_t
>("POINT(179 1)", "BOX(170 0, 180 2)", true);
79 test_geometry
<P
, box_t
>("POINT(-179 1)", "BOX(170 0, 180 2)", false);
80 test_geometry
<P
, box_t
>("POINT(169 1)", "BOX(170 0, 180 2)", false);
82 test_point_box_by_side
<P
>();
88 typedef bg::model::box
<P
> box_t
;
90 test_geometry
<box_t
, box_t
>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
92 test_geometry
<box_t
, box_t
>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true);
93 test_geometry
<box_t
, box_t
>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)", true);
94 test_geometry
<box_t
, box_t
>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)", false);
95 test_geometry
<box_t
, box_t
>("BOX(0 0,1 1)", "BOX(170 0, 370 1)", true);
96 test_geometry
<box_t
, box_t
>("BOX(0 0,10 1)", "BOX(170 0, 370 1)", true);
97 test_geometry
<box_t
, box_t
>("BOX(-180 0,10 1)", "BOX(170 0, 370 1)", true);
98 test_geometry
<box_t
, box_t
>("BOX(-180 0,20 1)", "BOX(170 0, 370 1)", false);
99 test_geometry
<box_t
, box_t
>("BOX(10 0,20 1)", "BOX(170 0, 370 1)", false);
100 test_geometry
<box_t
, box_t
>("BOX(160 0,180 1)", "BOX(170 0, 370 1)", false);
102 test_geometry
<box_t
, box_t
>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)", true); // invalid?
103 test_geometry
<box_t
, box_t
>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)", true); // invalid?
104 test_geometry
<box_t
, box_t
>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)", true);
105 test_geometry
<box_t
, box_t
>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)", false); // invalid?
106 test_geometry
<box_t
, box_t
>("BOX(-180 0,-170 1)", "BOX(180 0, 189 1)", false); // invalid?
110 template <typename P
>
118 int test_main( int , char* [] )
120 test_cs
<bg::model::point
<double, 2, bg::cs::spherical_equatorial
<bg::degree
> > >();
121 test_cs
<bg::model::point
<double, 2, bg::cs::geographic
<bg::degree
> > >();
123 #if defined(HAVE_TTMATH)
124 test_cs
<bg::model::point
<ttmath_big
, 2, bg::cs::spherical_equatorial
<bg::degree
> > >();
125 test_cs
<bg::model::point
<ttmath_big
, 2, bg::cs::geographic
<bg::degree
> > >();