coordinate_system.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <geometry_test_common.hpp>
  8. #include <boost/geometry/core/coordinate_system.hpp>
  9. #include <boost/geometry/geometries/geometries.hpp>
  10. #include <boost/geometry/geometries/adapted/c_array.hpp>
  11. #include <boost/geometry/geometries/adapted/boost_tuple.hpp>
  12. #include <boost/geometry/geometries/register/linestring.hpp>
  13. #include <vector>
  14. #include <deque>
  15. BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
  16. BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
  17. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::vector)
  18. BOOST_GEOMETRY_REGISTER_LINESTRING_TEMPLATED(std::deque)
  19. template <typename G, typename Expected>
  20. void test_geometry()
  21. {
  22. BOOST_CHECK_EQUAL(typeid(typename bg::coordinate_system<G>::type).name(),
  23. typeid(Expected).name());
  24. }
  25. template <typename P, typename Expected>
  26. void test_all()
  27. {
  28. test_geometry<P, Expected>();
  29. test_geometry<P const, Expected>();
  30. test_geometry<bg::model::linestring<P> , Expected>();
  31. test_geometry<bg::model::ring<P> , Expected>();
  32. test_geometry<bg::model::polygon<P> , Expected>();
  33. test_geometry<bg::model::box<P> , Expected>();
  34. test_geometry<bg::model::segment<P> , Expected>();
  35. test_geometry<bg::model::referring_segment<P const> , Expected>();
  36. test_geometry<std::vector<P>, Expected>();
  37. test_geometry<std::deque<P>, Expected>();
  38. }
  39. int test_main(int, char* [])
  40. {
  41. // Because of the included headerfiles, there are always cartesian
  42. test_geometry<int[2], bg::cs::cartesian>();
  43. test_geometry<float[2], bg::cs::cartesian>();
  44. test_geometry<double[2], bg::cs::cartesian>();
  45. test_geometry<int[3], bg::cs::cartesian>();
  46. test_geometry<float[3], bg::cs::cartesian>();
  47. test_geometry<double[3], bg::cs::cartesian>();
  48. // Because of the included headerfiles, there are always cartesian
  49. test_geometry<boost::tuple<double, double>, bg::cs::cartesian>();
  50. test_geometry<boost::tuple<double, double, double>, bg::cs::cartesian>();
  51. // Test cartesian
  52. test_all<bg::model::point<int, 2, bg::cs::cartesian>, bg::cs::cartesian>();
  53. test_all<bg::model::point<float, 2, bg::cs::cartesian>, bg::cs::cartesian>();
  54. test_all<bg::model::point<double, 2, bg::cs::cartesian>, bg::cs::cartesian>();
  55. // Test spherical
  56. test_all<bg::model::point<int, 2, bg::cs::spherical<bg::degree> >,
  57. bg::cs::spherical<bg::degree> >();
  58. test_all<bg::model::point<float, 2, bg::cs::spherical<bg::degree> >,
  59. bg::cs::spherical<bg::degree> >();
  60. test_all<bg::model::point<double, 2, bg::cs::spherical<bg::degree> >,
  61. bg::cs::spherical<bg::degree> >();
  62. test_all<bg::model::point<int, 2, bg::cs::spherical<bg::radian> >,
  63. bg::cs::spherical<bg::radian> >();
  64. test_all<bg::model::point<float, 2, bg::cs::spherical<bg::radian> >,
  65. bg::cs::spherical<bg::radian> >();
  66. test_all<bg::model::point<double, 2, bg::cs::spherical<bg::radian> >,
  67. bg::cs::spherical<bg::radian> >();
  68. // Test other
  69. test_all<bg::model::point<double, 2, bg::cs::polar<bg::degree> >,
  70. bg::cs::polar<bg::degree> >();
  71. test_all<bg::model::point<double, 2, bg::cs::geographic<bg::degree> >,
  72. bg::cs::geographic<bg::degree> >();
  73. return 0;
  74. }