]>
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 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
9 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
16 #include <geometry_test_common.hpp>
18 #include <boost/geometry/algorithms/make.hpp>
20 #include <boost/geometry/io/wkt/write.hpp>
22 #include <boost/geometry/geometries/geometries.hpp>
23 #include <boost/geometry/geometries/adapted/c_array.hpp>
24 #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
25 #include <test_common/test_point.hpp>
27 BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian
)
28 BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian
)
31 template <typename T
, typename P
>
34 P p
= bg::make
<P
>((T
) 123, (T
) 456);
35 BOOST_CHECK_CLOSE(bg::get
<0>(p
), 123.0, 1.0e-6);
36 BOOST_CHECK_CLOSE(bg::get
<1>(p
), 456.0, 1.0e-6);
39 template <typename T
, typename P
>
42 P p
= bg::make
<P
>((T
) 123, (T
) 456, (T
) 789);
43 BOOST_CHECK_CLOSE( bg::get
<0>(p
), 123.0, 1.0e-6);
44 BOOST_CHECK_CLOSE( bg::get
<1>(p
), 456.0, 1.0e-6);
45 BOOST_CHECK_CLOSE( bg::get
<2>(p
), 789.0, 1.0e-6);
48 template <typename T
, typename P
>
51 typedef bg::model::box
<P
> B
;
52 B b
= bg::make
<B
>((T
) 123, (T
) 456, (T
) 789, (T
) 1011);
53 BOOST_CHECK_CLOSE( (bg::get
<bg::min_corner
, 0>(b
)), 123.0, 1.0e-6);
54 BOOST_CHECK_CLOSE( (bg::get
<bg::min_corner
, 1>(b
)), 456.0, 1.0e-6);
55 BOOST_CHECK_CLOSE( (bg::get
<bg::max_corner
, 0>(b
)), 789.0, 1.0e-6);
56 BOOST_CHECK_CLOSE( (bg::get
<bg::max_corner
, 1>(b
)), 1011.0, 1.0e-6);
58 b
= bg::make_inverse
<B
>();
61 template <typename T
, typename P
>
62 void test_linestring_2d()
64 typedef bg::model::linestring
<P
> L
;
66 T coors
[][2] = {{1,2}, {3,4}};
68 L line
= bg::detail::make::make_points
<L
>(coors
);
70 BOOST_CHECK_EQUAL(line
.size(), 2u);
73 template <typename T
, typename P
>
74 void test_linestring_3d()
76 typedef bg::model::linestring
<P
> L
;
78 T coors
[][3] = {{1,2,3}, {4,5,6}};
80 L line
= bg::detail::make::make_points
<L
>(coors
);
82 BOOST_CHECK_EQUAL(line
.size(), 2u);
83 //std::cout << dsv(line) << std::endl;
87 template <typename T
, typename P
>
90 test_point_2d
<T
, P
>();
92 test_linestring_2d
<T
, P
>();
99 test_2d_t
<float, P
>();
100 test_2d_t
<double, P
>();
103 template <typename T
, typename P
>
106 test_linestring_3d
<T
, P
>();
107 // test_point_3d<T, test_point>();
110 template <typename P
>
114 test_3d_t
<float, P
>();
115 test_3d_t
<double, P
>();
118 int test_main(int, char* [])
121 //test_2d<float[2]>();
122 //test_2d<double[2]>();
123 test_2d
<bg::model::point
<int, 2, bg::cs::cartesian
> >();
124 test_2d
<bg::model::point
<float, 2, bg::cs::cartesian
> >();
125 test_2d
<bg::model::point
<double, 2, bg::cs::cartesian
> >();
128 test_3d
<bg::model::point
<double, 3, bg::cs::cartesian
> >();
130 #if defined(HAVE_TTMATH)
131 test_2d
<bg::model::point
<ttmath_big
, 2, bg::cs::cartesian
> >();
132 test_3d
<bg::model::point
<ttmath_big
, 3, bg::cs::cartesian
> >();