1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3 
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
7 
8 // This file was modified by Oracle on 2015.
9 // Modifications copyright (c) 2015 Oracle and/or its affiliates.
10 
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
19 
20 #include <cstddef>
21 #include <string>
22 
23 #include <algorithms/test_convex_hull.hpp>
24 
25 #include <boost/geometry/geometries/geometries.hpp>
26 #include <boost/geometry/geometries/point_xy.hpp>
27 
28 
29 template <typename P>
test_all()30 void test_all()
31 {
32     // from sample linestring
33     test_geometry<bg::model::linestring<P> >(
34         "linestring(1.1 1.1, 2.5 2.1, 3.1 3.1, 4.9 1.1, 3.1 1.9)", 5, 4, 3.8);
35 
36     // rectangular, with concavity
37     test_geometry<bg::model::polygon<P> >(
38         "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))",
39                 9, 5, 12.0);
40 
41     // from sample polygon, with concavity
42     test_geometry<bg::model::polygon<P> >(
43         "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
44         ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
45                 12, 8, 5.245);
46 
47     test_geometry<bg::model::ring<P> >(
48         "polygon((2.0 1.3, 2.4 1.7, 2.8 1.8, 3.4 1.2, 3.7 1.6,3.4 2.0, 4.1 3.0"
49         ", 5.3 2.6, 5.4 1.2, 4.9 0.8, 2.9 0.7,2.0 1.3))",
50                 12, 8, 5.245);
51 
52     test_geometry<bg::model::box<P> >("box(0 0,2 2)", 4, 5, 4);
53 
54     // https://svn.boost.org/trac/boost/ticket/6443
55     {
56         test_geometry<bg::model::ring<P> >(
57             "polygon((0 0, 2 0))", // note that this polygon is very invalid
58             2, 4, 0, 4);
59     }
60 
61     // degenerated hulls
62     test_geometry<bg::model::multi_point<P> >(
63         "multipoint(0 0)",
64         1, 4, 0, 0);
65     test_geometry<bg::model::multi_point<P> >(
66         "multipoint(0 0, 2 0)",
67         2, 4, 0, 4);
68     test_geometry<bg::model::linestring<P> >(
69         "linestring(0 0, 2 0)",
70         2, 4, 0, 4);
71 
72     test_empty_input<bg::model::linestring<P> >();
73     test_empty_input<bg::model::ring<P> >();
74     test_empty_input<bg::model::polygon<P> >();
75 }
76 
77 
test_main(int,char * [])78 int test_main(int, char* [])
79 {
80     //test_all<bg::model::d2::point_xy<int> >();
81     test_all<bg::model::d2::point_xy<float> >();
82     test_all<bg::model::d2::point_xy<double> >();
83 
84     return 0;
85 }
86