covered_by_multi.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. //
  3. // Copyright (c) 2007-2015 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/algorithms/correct.hpp>
  9. #include <boost/geometry/algorithms/covered_by.hpp>
  10. #include <boost/geometry/geometries/box.hpp>
  11. #include <boost/geometry/core/point_order.hpp>
  12. #include <boost/geometry/geometries/point_xy.hpp>
  13. #include <boost/geometry/geometries/multi_polygon.hpp>
  14. #include <boost/geometry/io/wkt/wkt.hpp>
  15. #include "test_covered_by.hpp"
  16. template <typename P>
  17. void test_all()
  18. {
  19. typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
  20. // test multi-with-one-polygon (trivial case)
  21. test_geometry<P, mp>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
  22. test_geometry<P, mp>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
  23. test_geometry<P, mp>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
  24. test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
  25. // test if it is in one of them
  26. std::string multi("MULTIPOLYGON("
  27. "((0 0,0 2,2 2,2 0,0 0))"
  28. "((3 3,3 6,6 6,6 3,3 3))"
  29. ")");
  30. test_geometry<P, mp>("POINT(4 4)", multi, true);
  31. test_geometry<P, mp>("POINT(1 1)", multi, true);
  32. test_geometry<P, mp>("POINT(0 1)", multi, true);
  33. }
  34. int test_main( int , char* [] )
  35. {
  36. //test_all<bg::model::d2::point_xy<int> >();
  37. test_all<bg::model::d2::point_xy<double> >();
  38. #if defined(HAVE_TTMATH)
  39. test_all<bg::model::d2::point_xy<ttmath_big> >();
  40. #endif
  41. return 0;
  42. }