]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/make.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
8 // This file was modified by Oracle on 2020.
9 // Modifications copyright (c) 2020, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
20 #include <geometry_test_common.hpp>
22 #include <boost/geometry/algorithms/make.hpp>
24 #include <boost/geometry/io/wkt/write.hpp>
26 #include <boost/geometry/geometries/geometries.hpp>
27 #include <boost/geometry/geometries/adapted/c_array.hpp>
28 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
29 #include <test_common/test_point.hpp>
31 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian
)
32 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
35 template <typename T
, typename P
>
38 P p
= bg::make
<P
>((T
) 123, (T
) 456);
39 BOOST_CHECK_CLOSE(bg::get
<0>(p
), 123.0, 1.0e-6);
40 BOOST_CHECK_CLOSE(bg::get
<1>(p
), 456.0, 1.0e-6);
43 template <typename T
, typename P
>
46 P p
= bg::make
<P
>((T
) 123, (T
) 456, (T
) 789);
47 BOOST_CHECK_CLOSE( bg::get
<0>(p
), 123.0, 1.0e-6);
48 BOOST_CHECK_CLOSE( bg::get
<1>(p
), 456.0, 1.0e-6);
49 BOOST_CHECK_CLOSE( bg::get
<2>(p
), 789.0, 1.0e-6);
52 template <typename T
, typename P
>
55 typedef bg::model::box
<P
> B
;
56 B b
= bg::make
<B
>((T
) 123, (T
) 456, (T
) 789, (T
) 1011);
57 BOOST_CHECK_CLOSE( (bg::get
<bg::min_corner
, 0>(b
)), 123.0, 1.0e-6);
58 BOOST_CHECK_CLOSE( (bg::get
<bg::min_corner
, 1>(b
)), 456.0, 1.0e-6);
59 BOOST_CHECK_CLOSE( (bg::get
<bg::max_corner
, 0>(b
)), 789.0, 1.0e-6);
60 BOOST_CHECK_CLOSE( (bg::get
<bg::max_corner
, 1>(b
)), 1011.0, 1.0e-6);
62 b
= bg::make_inverse
<B
>();
65 template <typename T
, typename P
>
66 void test_linestring_2d()
68 typedef bg::model::linestring
<P
> L
;
70 T coors
[][2] = {{1,2}, {3,4}};
72 L line
= bg::detail::make::make_points
<L
>(coors
);
74 BOOST_CHECK_EQUAL(line
.size(), 2u);
77 template <typename T
, typename P
>
78 void test_linestring_3d()
80 typedef bg::model::linestring
<P
> L
;
82 T coors
[][3] = {{1,2,3}, {4,5,6}};
84 L line
= bg::detail::make::make_points
<L
>(coors
);
86 BOOST_CHECK_EQUAL(line
.size(), 2u);
87 //std::cout << dsv(line) << std::endl;
91 template <typename T
, typename P
>
94 test_point_2d
<T
, P
>();
96 test_linestring_2d
<T
, P
>();
103 test_2d_t
<float, P
>();
104 test_2d_t
<double, P
>();
107 template <typename T
, typename P
>
110 test_linestring_3d
<T
, P
>();
111 // test_point_3d<T, test_point>();
114 template <typename P
>
118 test_3d_t
<float, P
>();
119 test_3d_t
<double, P
>();
122 template <typename P
>
123 void test_2d_constexpr()
125 constexpr P p
= bg::make
<P
>(1, 2);
126 BOOST_CHECK_EQUAL((bg::get
<0>(p
)), 1);
127 BOOST_CHECK_EQUAL((bg::get
<1>(p
)), 2);
130 template <typename P
>
131 void test_3d_constexpr()
133 constexpr P p
= bg::make
<P
>(1, 2, 3);
134 BOOST_CHECK_EQUAL((bg::get
<0>(p
)), 1);
135 BOOST_CHECK_EQUAL((bg::get
<1>(p
)), 2);
136 BOOST_CHECK_EQUAL((bg::get
<2>(p
)), 3);
139 int test_main(int, char* [])
142 //test_2d<float[2]>();
143 //test_2d<double[2]>();
144 test_2d
<bg::model::point
<int, 2, bg::cs::cartesian
> >();
145 test_2d
<bg::model::point
<float, 2, bg::cs::cartesian
> >();
146 test_2d
<bg::model::point
<double, 2, bg::cs::cartesian
> >();
148 test_3d
<bg::model::point
<double, 3, bg::cs::cartesian
> >();
150 test_2d_constexpr
<bg::model::point
<double, 2, bg::cs::cartesian
> >();
152 test_3d_constexpr
<bg::model::point
<double, 3, bg::cs::cartesian
> >();