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 <boost/geometry/geometries/geometries.hpp> |
12 | #include <boost/geometry/geometries/point_xy.hpp> |
13 | |
14 | #include <algorithms/test_perimeter.hpp> |
15 | |
16 | |
17 | template <typename P> |
18 | void test_all() |
19 | { |
20 | // 3-4-5 triangle |
21 | //test_geometry<std::pair<P, P> >("LINESTRING(0 0,3 4)", 5); |
22 | |
23 | test_geometry<bg::model::ring<P> >( |
24 | "POLYGON((0 0,0 1,1 1,1 0,0 0))" , 4); |
25 | test_geometry<bg::model::polygon<P> >( |
26 | "POLYGON((0 0,0 1,1 0,0 0))" , 1.0 + 1.0 + sqrt(x: 2.0)); |
27 | test_geometry<bg::model::polygon<P> >( |
28 | "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,2 1,2 2,1 2,1 1))" , 20); |
29 | } |
30 | |
31 | template <typename P> |
32 | void test_open() |
33 | { |
34 | typedef bg::model::polygon<P, true, false> open_polygon; |
35 | test_geometry<open_polygon>("POLYGON((0 0,0 1,1 1,1 0))" , 4); |
36 | } |
37 | |
38 | template <typename P> |
39 | void test_empty_input() |
40 | { |
41 | bg::model::polygon<P> poly_empty; |
42 | bg::model::ring<P> ring_empty; |
43 | |
44 | test_empty_input(poly_empty); |
45 | test_empty_input(ring_empty); |
46 | } |
47 | |
48 | int test_main(int, char* []) |
49 | { |
50 | //test_all<bg::model::d2::point_xy<int> >(); |
51 | test_all<bg::model::d2::point_xy<float> >(); |
52 | test_all<bg::model::d2::point_xy<double> >(); |
53 | |
54 | test_open<bg::model::d2::point_xy<double> >(); |
55 | |
56 | #if defined(HAVE_TTMATH) |
57 | test_all<bg::model::d2::point_xy<ttmath_big> >(); |
58 | #endif |
59 | |
60 | // test_empty_input<bg::model::d2::point_xy<int> >(); |
61 | |
62 | return 0; |
63 | } |
64 | |