• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3 
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
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 
11 #include <algorithms/test_for_each.hpp>
12 
13 #include <boost/geometry/geometries/geometries.hpp>
14 
15 
16 
17 template <typename P>
test_all()18 void test_all()
19 {
20     test_geometry<P>
21         (
22             "POINT(1 1)"
23 
24             // per point
25             , 1
26             , "POINT(101 1)"
27             , "POINT(101 100)"
28             // per segment
29             , ""
30             , 0
31             , "POINT(1 1)"
32         );
33     test_geometry<bg::model::linestring<P> >
34         (
35             "LINESTRING(1 1,2 2)"
36 
37             , 3
38             , "LINESTRING(101 1,102 2)"
39             , "LINESTRING(101 100,102 200)"
40 
41             , "((1, 1), (2, 2))"
42             , std::sqrt(2.0)
43             , "LINESTRING(10 1,2 2)"
44         );
45     test_geometry<bg::model::linestring<P> >
46         (
47             "LINESTRING EMPTY"
48 
49             , 0
50             , "LINESTRING()"
51             , "LINESTRING()"
52 
53             , ""
54             , 0
55             , "LINESTRING()"
56         );
57     test_geometry<bg::model::ring<P> >
58         (
59             "POLYGON((1 1,1 4,4 4,4 1,1 1))"
60 
61             , 11
62             , "POLYGON((101 1,101 4,104 4,104 1,101 1))"
63             , "POLYGON((101 100,101 400,104 400,104 100,101 100))"
64 
65             , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
66             , 4 * 3.0
67             , "POLYGON((10 1,10 4,4 4,4 1,1 1))"
68         );
69     test_geometry<bg::model::ring<P> >
70         (
71             "POLYGON EMPTY"
72 
73             , 0
74             , "POLYGON(())"
75             , "POLYGON(())"
76 
77             , ""
78             , 0
79             , "POLYGON(())"
80         );
81     test_geometry<bg::model::ring<P, true, false> > // open ring
82         (
83             "POLYGON((1 1,1 4,4 4,4 1))"
84 
85             , 10
86             , "POLYGON((101 1,101 4,104 4,104 1))"
87             , "POLYGON((101 100,101 400,104 400,104 100))"
88 
89             , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1))"
90             , 4 * 3.0
91             , "POLYGON((10 1,10 4,4 4,4 1))"
92         );
93     test_geometry<bg::model::polygon<P> >
94         (
95             "POLYGON((1 1,1 4,4 4,4 1,1 1),(2 2,3 2,3 3,2 3,2 2))"
96 
97             , 23
98             , "POLYGON((101 1,101 4,104 4,104 1,101 1),(102 2,103 2,103 3,102 3,102 2))"
99             , "POLYGON((101 100,101 400,104 400,104 100,101 100),(102 200,103 200,103 300,102 300,102 200))"
100 
101             , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1)) "
102               "((2, 2), (3, 2)) ((3, 2), (3, 3)) ((3, 3), (2, 3)) ((2, 3), (2, 2))"
103             , 4 * 3.0 + 4 * 1.0
104             , "POLYGON((10 1,10 4,4 4,4 1,1 1,10 1),(2 2,3 2,3 3,2 3,2 2))"
105         );
106     test_geometry<bg::model::polygon<P, true, false> > // open polygon
107         (
108             "POLYGON((1 1,1 4,4 4,4 1),(2 2,3 2,3 3,2 3))"
109 
110             , 20
111             , "POLYGON((101 1,101 4,104 4,104 1,101 1),(102 2,103 2,103 3,102 3,102 2))"
112             , "POLYGON((101 100,101 400,104 400,104 100,101 100),(102 200,103 200,103 300,102 300,102 200))"
113 
114             , "((1, 1), (1, 4)) ((1, 4), (4, 4)) ((4, 4), (4, 1)) ((4, 1), (1, 1)) "
115               "((2, 2), (3, 2)) ((3, 2), (3, 3)) ((3, 3), (2, 3)) ((2, 3), (2, 2))"
116             , 4 * 3.0 + 4 * 1.0
117             , "POLYGON((10 1,10 4,4 4,4 1,10 1),(2 2,3 2,3 3,2 3,2 2))"
118         );
119 }
120 
test_main(int,char * [])121 int test_main(int, char* [])
122 {
123     test_all<bg::model::point<double, 2, bg::cs::cartesian> >();
124 
125 #if defined(HAVE_TTMATH)
126     test_all<bg::model::point<ttmath_big, 2, bg::cs::cartesian> >();
127 #endif
128 
129     return 0;
130 }
131