adaptors.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Boost.Geometry Index
  2. //
  3. // R-tree queries range adaptors
  4. //
  5. // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
  6. //
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ADAPTORS_HPP
  11. #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ADAPTORS_HPP
  12. #include <deque>
  13. #include <boost/static_assert.hpp>
  14. #include <boost/geometry/index/adaptors/query.hpp>
  15. namespace boost { namespace geometry { namespace index {
  16. template <typename Value, typename Options, typename IndexableGetter, typename EqualTo, typename Allocator>
  17. class rtree;
  18. namespace adaptors { namespace detail {
  19. template <typename Value, typename Options, typename IndexableGetter, typename EqualTo, typename Allocator>
  20. class query_range< index::rtree<Value, Options, IndexableGetter, EqualTo, Allocator> >
  21. {
  22. public:
  23. typedef std::vector<Value> result_type;
  24. typedef typename result_type::iterator iterator;
  25. typedef typename result_type::const_iterator const_iterator;
  26. template <typename Predicates> inline
  27. query_range(index::rtree<Value, Options, IndexableGetter, EqualTo, Allocator> const& rtree,
  28. Predicates const& pred)
  29. {
  30. rtree.query(pred, std::back_inserter(m_result));
  31. }
  32. inline iterator begin() { return m_result.begin(); }
  33. inline iterator end() { return m_result.end(); }
  34. inline const_iterator begin() const { return m_result.begin(); }
  35. inline const_iterator end() const { return m_result.end(); }
  36. private:
  37. result_type m_result;
  38. };
  39. }} // namespace adaptors::detail
  40. }}} // namespace boost::geometry::index
  41. #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ADAPTORS_HPP