rtree_contains_point.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Boost.Geometry Index
  2. // Unit Test
  3. // Copyright (c) 2016 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. #include <rtree/test_rtree.hpp>
  8. #include <boost/geometry/index/rtree.hpp>
  9. #include <boost/geometry/geometries/geometries.hpp>
  10. template <typename Params>
  11. void test_one()
  12. {
  13. typedef bg::model::point<double, 2, bg::cs::cartesian> Pt;
  14. typedef bgi::rtree<Pt, Params> Rtree;
  15. Rtree rtree;
  16. rtree.insert(Pt(0, 0));
  17. rtree.insert(Pt(1, 1));
  18. rtree.insert(Pt(2, 2));
  19. rtree.insert(Pt(3, 3));
  20. rtree.insert(Pt(4, 4));
  21. rtree.insert(Pt(4, 3));
  22. rtree.insert(Pt(0, 3));
  23. for (typename Rtree::const_iterator it = rtree.begin() ; it != rtree.end() ; ++it)
  24. {
  25. std::vector<Pt> result;
  26. rtree.query(bgi::contains(*it), std::back_inserter(result));
  27. BOOST_CHECK(result.size() == 1);
  28. }
  29. }
  30. int test_main(int, char* [])
  31. {
  32. test_one< bgi::linear<4> >();
  33. test_one< bgi::quadratic<4> >();
  34. test_one< bgi::rstar<4> >();
  35. return 0;
  36. }