test_disjoint_seg_box.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Boost.Geometry
  2. // Copyright (c) 2016-2017 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #include <boost/geometry/algorithms/disjoint.hpp>
  9. #include <boost/geometry/algorithms/make.hpp>
  10. #include <boost/geometry/io/wkt/read.hpp>
  11. template <typename Geometry1, typename Geometry2>
  12. inline void test_disjoint_check(bool result, bool expected_result,
  13. Geometry1 const& geometry1, Geometry2 const& geometry2)
  14. {
  15. BOOST_CHECK_MESSAGE((result == expected_result),
  16. "result {" << result << "} different than expected result {"
  17. << expected_result << "} for geometries "
  18. << bg::wkt(geometry1) << " and " << bg::wkt(geometry2));
  19. }
  20. template <typename Geometry1, typename Geometry2>
  21. inline void test_disjoint(std::string const& wkt1,
  22. std::string const& wkt2,
  23. bool const expected_result)
  24. {
  25. Geometry1 geometry1;
  26. bg::read_wkt(wkt1, geometry1);
  27. Geometry2 geometry2;
  28. bg::read_wkt(wkt2, geometry2);
  29. test_disjoint_check(bg::disjoint(geometry1, geometry2), expected_result,
  30. geometry1, geometry2);
  31. //reverse
  32. test_disjoint_check(bg::disjoint(geometry2, geometry1), expected_result,
  33. geometry2, geometry1);
  34. }
  35. template <typename Geometry1, typename Geometry2, typename Strategy>
  36. inline void test_disjoint_strategy(std::string const& wkt1,
  37. std::string const& wkt2,
  38. bool const expected_result,
  39. Strategy strategy)
  40. {
  41. Geometry1 geometry1;
  42. bg::read_wkt(wkt1, geometry1);
  43. Geometry2 geometry2;
  44. bg::read_wkt(wkt2, geometry2);
  45. test_disjoint_check(bg::disjoint(geometry1, geometry2, strategy), expected_result,
  46. geometry1, geometry2);
  47. //reverse
  48. test_disjoint_check(bg::disjoint(geometry2, geometry1, strategy), expected_result,
  49. geometry2, geometry1);
  50. }