radius.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  6. // This file was modified by Oracle on 2014.
  7. // Modifications copyright (c) 2014 Oracle and/or its affiliates.
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  10. // (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)
  14. #include <geometry_test_common.hpp>
  15. #include <boost/geometry/core/cs.hpp>
  16. #include <boost/geometry/core/radius.hpp>
  17. #include <boost/geometry/srs/sphere.hpp>
  18. #include <boost/geometry/srs/spheroid.hpp>
  19. #include <boost/geometry/algorithms/make.hpp>
  20. template <std::size_t I, typename G>
  21. void test_get_set()
  22. {
  23. typedef typename bg::radius_type<G>::type radius_type;
  24. G g;
  25. bg::set_radius<I>(g, radius_type(5));
  26. radius_type x = bg::get_radius<I>(g);
  27. BOOST_CHECK_CLOSE(double(x), 5.0, 0.0001);
  28. }
  29. template <typename T>
  30. void test_all()
  31. {
  32. typedef bg::srs::spheroid<T> Sd;
  33. test_get_set<0, Sd>();
  34. test_get_set<2, Sd>();
  35. typedef bg::srs::sphere<T> Se;
  36. test_get_set<0, Se>();
  37. }
  38. int test_main(int, char* [])
  39. {
  40. test_all<int>();
  41. test_all<float>();
  42. test_all<double>();
  43. return 0;
  44. }