/Src/Dependencies/Boost/libs/geometry/test/algorithms/test_length.hpp

http://hadesmem.googlecode.com/ · C++ Header · 48 lines · 30 code · 12 blank · 6 comment · 0 complexity · 647f970fb709b1ca598946ad8a2031a4 MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2011 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. #ifndef BOOST_GEOMETRY_TEST_LENGTH_HPP
  8. #define BOOST_GEOMETRY_TEST_LENGTH_HPP
  9. #include <geometry_test_common.hpp>
  10. #include <boost/geometry/algorithms/length.hpp>
  11. #include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
  12. #include <boost/geometry/strategies/strategies.hpp>
  13. template <typename Geometry>
  14. void test_length(Geometry const& geometry, long double expected_length)
  15. {
  16. typename bg::default_length_result<Geometry>::type length = bg::length(geometry);
  17. #ifdef GEOMETRY_TEST_DEBUG
  18. std::ostringstream out;
  19. out << typeid(typename bg::coordinate_type<Geometry>::type).name()
  20. << std::endl
  21. << typeid(typename bg::default_length_result<Geometry>::type).name()
  22. << std::endl
  23. << "length : " << bg::length(geometry)
  24. << std::endl;
  25. std::cout << out.str();
  26. #endif
  27. BOOST_CHECK_CLOSE(length, expected_length, 0.0001);
  28. }
  29. template <typename Geometry>
  30. void test_geometry(std::string const& wkt, double expected_length)
  31. {
  32. Geometry geometry;
  33. bg::read_wkt(wkt, geometry);
  34. test_length(geometry, expected_length);
  35. }
  36. #endif