]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/core/radian_access.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/core/radian_access.hpp>
20 #include <boost/geometry/core/cs.hpp>
21 #include <boost/geometry/core/coordinate_type.hpp>
22 #include <boost/geometry/geometries/point.hpp>
25 template <std::size_t D
, typename P
, typename T
>
26 void test_get(T
const& c
, T
const& e
)
28 //std::cout << "get_as_radian " << typeid(P).name() << std::endl;
30 typedef typename
bg::coordinate_type
<P
>::type coordinate_type
;
33 bg::set
<D
>(p
, coordinate_type(c
));
35 coordinate_type g
= bg::get_as_radian
<D
>(p
);
37 BOOST_CHECK_CLOSE(double(g
), double(e
), 0.0001);
41 template <std::size_t D
, typename P
, typename T
>
42 void test_set(T
const& c
, T
const& e
)
44 //std::cout << "set_from_radian " << typeid(P).name() << std::endl;
46 typedef typename
bg::coordinate_type
<P
>::type coordinate_type
;
49 bg::set_from_radian
<D
>(p
, coordinate_type(c
));
51 coordinate_type g
= bg::get
<D
>(p
);
53 BOOST_CHECK_CLOSE(double(g
), double(e
), 0.0001);
60 double d2r
= 3.1415926535897932384626433832795 / 180.0;
63 test_get
<0, bg::model::point
<T
, 2, bg::cs::spherical
<bg::degree
> > >
65 test_get
<1, bg::model::point
<T
, 2, bg::cs::spherical
<bg::degree
> > >
68 test_set
<0, bg::model::point
<T
, 2, bg::cs::spherical
<bg::degree
> > >
70 test_set
<1, bg::model::point
<T
, 2, bg::cs::spherical
<bg::degree
> > >
75 test_get
<0, bg::model::point
<T
, 2, bg::cs::spherical
<bg::radian
> > >
77 test_get
<1, bg::model::point
<T
, 2, bg::cs::spherical
<bg::radian
> > >
80 test_set
<0, bg::model::point
<T
, 2, bg::cs::spherical
<bg::radian
> > >
82 test_set
<1, bg::model::point
<T
, 2, bg::cs::spherical
<bg::radian
> > >
86 // Cartesian (== untouched, no conversion)
87 test_get
<0, bg::model::point
<T
, 2, bg::cs::cartesian
> >
89 test_get
<1, bg::model::point
<T
, 2, bg::cs::cartesian
> >
92 // Dimension >=2, should always be untouched, even for degree
93 // (assuming lat/lon + height)
94 test_set
<2, bg::model::point
<T
, 3, bg::cs::spherical
<bg::radian
> > >
96 test_set
<2, bg::model::point
<T
, 3, bg::cs::spherical
<bg::degree
> > >
104 int test_main(int, char* [])