rtree_intersects_geom.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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/geometries/geometries.hpp>
  9. #include <boost/geometry/geometries/point_xy.hpp>
  10. template <typename Value, typename Point, typename Params>
  11. void test_all()
  12. {
  13. typedef bg::model::box<Point> Box;
  14. typedef bg::model::segment<Point> Seg;
  15. typedef bg::model::ring<Point> Ring;
  16. typedef bg::model::polygon<Point> Poly;
  17. typedef bg::model::multi_polygon<Poly> MPoly;
  18. typedef bg::model::linestring<Point> Ls;
  19. typedef bg::model::multi_linestring<Ls> MLs;
  20. typedef bg::model::multi_point<Point> MPt;
  21. bgi::rtree<Value, Params> rt;
  22. std::vector<Value> found;
  23. rt.query(bgi::intersects(Point()), back_inserter(found));
  24. rt.query(bgi::intersects(Seg()), back_inserter(found));
  25. rt.query(bgi::intersects(Box()), back_inserter(found));
  26. rt.query(bgi::intersects(Ring()), back_inserter(found));
  27. rt.query(bgi::intersects(Poly()), back_inserter(found));
  28. rt.query(bgi::intersects(MPoly()), back_inserter(found));
  29. rt.query(bgi::intersects(Ls()), back_inserter(found));
  30. rt.query(bgi::intersects(MLs()), back_inserter(found));
  31. rt.query(bgi::intersects(MPt()), back_inserter(found));
  32. }
  33. int test_main(int, char* [])
  34. {
  35. typedef bg::model::d2::point_xy<double> Pt;
  36. typedef bg::model::box<Pt> Box;
  37. test_all< Pt, Pt, bgi::linear<16> >();
  38. test_all< Pt, Pt, bgi::quadratic<4> >();
  39. test_all< Pt, Pt, bgi::rstar<4> >();
  40. test_all< Box, Pt, bgi::linear<16> >();
  41. test_all< Box, Pt, bgi::quadratic<4> >();
  42. test_all< Box, Pt, bgi::rstar<4> >();
  43. return 0;
  44. }