test_margin.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Boost.Geometry Index
  2. // Unit Test
  3. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  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_INDEX_TEST_MARGIN_HPP
  8. #define BOOST_GEOMETRY_INDEX_TEST_MARGIN_HPP
  9. #include <geometry_index_test_common.hpp>
  10. #include <boost/geometry/index/detail/algorithms/margin.hpp>
  11. //#include <boost/geometry/io/wkt/read.hpp>
  12. template <typename Geometry>
  13. void test_margin(Geometry const& geometry,
  14. typename bgi::detail::default_margin_result<Geometry>::type expected_value)
  15. {
  16. typename bgi::detail::default_margin_result<Geometry>::type value = bgi::detail::comparable_margin(geometry);
  17. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  18. std::ostringstream out;
  19. out << typeid(typename bg::coordinate_type<Geometry>::type).name()
  20. << " "
  21. << typeid(typename bgi::detail::default_margin_result<Geometry>::type).name()
  22. << " "
  23. << "content : " << value
  24. << std::endl;
  25. std::cout << out.str();
  26. #endif
  27. BOOST_CHECK_CLOSE(value, expected_value, 0.0001);
  28. }
  29. template <typename Geometry>
  30. void test_geometry(std::string const& wkt,
  31. typename bgi::detail::default_margin_result<Geometry>::type expected_value)
  32. {
  33. Geometry geometry;
  34. bg::read_wkt(wkt, geometry);
  35. test_margin(geometry, expected_value);
  36. }
  37. #endif