• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 
3 // Copyright (c) 2016 Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5 
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)
9 
10 #include "test_intersects.hpp"
11 
12 
13 #include <boost/geometry/geometries/geometries.hpp>
14 
15 
16 template <typename P>
test_point_box()17 void test_point_box()
18 {
19     typedef bg::model::box<P> box_t;
20 
21     test_geometry<P, box_t>("POINT(0 0)",    "BOX(0 0, 1 1)", true);
22     test_geometry<P, box_t>("POINT(1 1)",    "BOX(0 0, 2 2)", true);
23 
24     test_geometry<P, box_t>("POINT(180 1)",  "BOX(170 0, 190 2)", true);
25     test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 190 2)", true);
26     test_geometry<P, box_t>("POINT(180 1)",  "BOX(170 0, 180 2)", true);
27     test_geometry<P, box_t>("POINT(-180 1)", "BOX(170 0, 180 2)", true);
28     test_geometry<P, box_t>("POINT(179 1)",  "BOX(170 0, 190 2)", true);
29     test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 190 2)", true);
30     test_geometry<P, box_t>("POINT(179 1)",  "BOX(170 0, 180 2)", true);
31     test_geometry<P, box_t>("POINT(-179 1)", "BOX(170 0, 180 2)", false);
32     test_geometry<P, box_t>("POINT(169 1)", "BOX(170 0, 180 2)", false);
33 }
34 
35 template <typename P>
test_box_box()36 void test_box_box()
37 {
38     typedef bg::model::box<P> box_t;
39 
40     test_geometry<box_t, box_t>("BOX(0 0, 1 1)", "BOX(0 0, 1 1)", true);
41 
42     test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(-180 0, 180 1)", true);
43     test_geometry<box_t, box_t>("BOX(-170 0,-160 1)", "BOX(170 0, 200 1)",  true);
44     test_geometry<box_t, box_t>("BOX(-170 0,-150 1)", "BOX(170 0, 200 1)",  true);
45     test_geometry<box_t, box_t>("BOX(201 0,202 1)",   "BOX(170 0, 200 1)",  false); // invalid g1?
46     test_geometry<box_t, box_t>("BOX(-159 0,-158 1)", "BOX(170 0, 200 1)",  false);
47     test_geometry<box_t, box_t>("BOX(160 0,169 1)",   "BOX(170 0, 200 1)",  false);
48     test_geometry<box_t, box_t>("BOX(-159 0,169 1)",  "BOX(170 0, 200 1)",  false);
49     test_geometry<box_t, box_t>("BOX(0 0,1 1)",       "BOX(170 0, 370 1)",  true);
50     test_geometry<box_t, box_t>("BOX(0 0,10 1)",      "BOX(170 0, 370 1)",  true);
51     test_geometry<box_t, box_t>("BOX(-180 0,10 1)",   "BOX(170 0, 370 1)",  true);
52     test_geometry<box_t, box_t>("BOX(-180 0,20 1)",   "BOX(170 0, 370 1)",  true);
53     test_geometry<box_t, box_t>("BOX(10 0,20 1)",     "BOX(170 0, 370 1)",  true);
54     test_geometry<box_t, box_t>("BOX(160 0,180 1)",   "BOX(170 0, 370 1)",  true);
55     test_geometry<box_t, box_t>("BOX(160 0,165 1)",   "BOX(170 0, 370 1)",  false);
56     test_geometry<box_t, box_t>("BOX(15 0,20 1)",     "BOX(170 0, 370 1)",  false);
57     test_geometry<box_t, box_t>("BOX(375 0,380 1)",   "BOX(170 0, 370 1)",  false); // invalid g1?
58 
59     test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 190 1)",  true); // invalid?
60     test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 191 1)",  true); // invalid?
61     test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(179 0, 190 1)",  true);
62     test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(181 0, 190 1)",  true); // invalid?
63     test_geometry<box_t, box_t>("BOX(-180 0,-170 1)", "BOX(180 0, 189 1)",  true); // invalid?
64 }
65 
66 
67 template <typename P>
test_cs()68 void test_cs()
69 {
70     test_point_box<P>();
71     test_box_box<P>();
72 }
73 
74 
test_main(int,char * [])75 int test_main( int , char* [] )
76 {
77     test_cs<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
78     test_cs<bg::model::point<double, 2, bg::cs::geographic<bg::degree> > >();
79 
80 #if defined(HAVE_TTMATH)
81     test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
82     test_cs<bg::model::point<ttmath_big, 2, bg::cs::geographic<bg::degree> > >();;
83 #endif
84 
85     return 0;
86 }
87