mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-10 23:42:12 +00:00
Added rtree free function insert.
Added adaptors::queried(). nearest_query_range and spatial_query_range moved to adaptors::detail. [SVN r82611]
This commit is contained in:
@@ -19,6 +19,8 @@ namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace adaptors {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Index>
|
||||
class nearest_query_range
|
||||
{
|
||||
@@ -45,8 +47,6 @@ class nearest_query_range
|
||||
inline const_iterator end() const { return 0; }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
// TODO: awulkiew - consider removing references from predicates
|
||||
|
||||
template<typename DistancesPredicates, typename Predicates>
|
||||
@@ -108,12 +108,12 @@ nearest_queried(
|
||||
} // namespace adaptors
|
||||
|
||||
template<typename Index, typename DistancesPredicates, typename Predicates>
|
||||
index::adaptors::nearest_query_range<Index>
|
||||
index::adaptors::detail::nearest_query_range<Index>
|
||||
operator|(
|
||||
Index const& si,
|
||||
index::adaptors::detail::nearest_query<DistancesPredicates, Predicates> const& f)
|
||||
{
|
||||
return index::adaptors::nearest_query_range<Index>(
|
||||
return index::adaptors::detail::nearest_query_range<Index>(
|
||||
si, f.distances_predicates, f.count, f.predicates);
|
||||
}
|
||||
|
||||
|
||||
88
include/boost/geometry/index/adaptors/query.hpp
Normal file
88
include/boost/geometry/index/adaptors/query.hpp
Normal file
@@ -0,0 +1,88 @@
|
||||
// Boost.Geometry Index
|
||||
//
|
||||
// Query range adaptor
|
||||
//
|
||||
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
|
||||
|
||||
/*!
|
||||
\defgroup adaptors Adaptors (boost::geometry::index::adaptors::)
|
||||
*/
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace adaptors {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Index>
|
||||
class query_range
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(
|
||||
(false),
|
||||
NOT_IMPLEMENTED_FOR_THIS_INDEX,
|
||||
(query_range));
|
||||
|
||||
typedef int* iterator;
|
||||
typedef const int* const_iterator;
|
||||
|
||||
template <typename Predicates>
|
||||
inline query_range(
|
||||
Index const&,
|
||||
Predicates const&)
|
||||
{}
|
||||
|
||||
inline iterator begin() { return 0; }
|
||||
inline iterator end() { return 0; }
|
||||
inline const_iterator begin() const { return 0; }
|
||||
inline const_iterator end() const { return 0; }
|
||||
};
|
||||
|
||||
// TODO: awulkiew - consider removing reference from predicates
|
||||
|
||||
template<typename Predicates>
|
||||
struct query
|
||||
{
|
||||
inline explicit query(Predicates const& pred)
|
||||
: predicates(pred)
|
||||
{}
|
||||
|
||||
Predicates const& predicates;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/*!
|
||||
\brief The query index adaptor generator.
|
||||
|
||||
\ingroup adaptors
|
||||
|
||||
\param pred Predicates.
|
||||
*/
|
||||
template <typename Predicates>
|
||||
detail::query<Predicates>
|
||||
queried(Predicates const& pred)
|
||||
{
|
||||
return detail::query<Predicates>(pred);
|
||||
}
|
||||
|
||||
} // namespace adaptors
|
||||
|
||||
template<typename Index, typename Predicates>
|
||||
index::adaptors::detail::query_range<Index>
|
||||
operator|(
|
||||
Index const& si,
|
||||
index::adaptors::detail::query<Predicates> const& f)
|
||||
{
|
||||
return index::adaptors::detail::query_range<Index>(si, f.predicates);
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
#endif // BOOST_GEOMETRY_INDEX_ADAPTORS_QUERY_HPP
|
||||
@@ -19,6 +19,8 @@ namespace boost { namespace geometry { namespace index {
|
||||
|
||||
namespace adaptors {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Index>
|
||||
class spatial_query_range
|
||||
{
|
||||
@@ -42,8 +44,6 @@ class spatial_query_range
|
||||
inline const_iterator end() const { return 0; }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
// TODO: awulkiew - consider removing reference from predicates
|
||||
|
||||
template<typename Predicates>
|
||||
@@ -75,12 +75,12 @@ spatial_queried(Predicates const& pred)
|
||||
} // namespace adaptors
|
||||
|
||||
template<typename Index, typename Predicates>
|
||||
index::adaptors::spatial_query_range<Index>
|
||||
index::adaptors::detail::spatial_query_range<Index>
|
||||
operator|(
|
||||
Index const& si,
|
||||
index::adaptors::detail::spatial_query<Predicates> const& f)
|
||||
{
|
||||
return index::adaptors::spatial_query_range<Index>(si, f.predicates);
|
||||
return index::adaptors::detail::spatial_query_range<Index>(si, f.predicates);
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
#include <boost/geometry/index/adaptors/spatial_query.hpp>
|
||||
#include <boost/geometry/index/adaptors/nearest_query.hpp>
|
||||
#include <boost/geometry/index/adaptors/query.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index {
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator>
|
||||
class rtree;
|
||||
|
||||
namespace adaptors {
|
||||
namespace adaptors { namespace detail {
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator>
|
||||
class spatial_query_range< index::rtree<Value, Options, Translator, Allocator> >
|
||||
@@ -78,7 +79,31 @@ private:
|
||||
result_type m_result;
|
||||
};
|
||||
|
||||
} // namespace adaptors
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator>
|
||||
class query_range< index::rtree<Value, Options, Translator, Allocator> >
|
||||
{
|
||||
public:
|
||||
typedef std::vector<Value> result_type;
|
||||
typedef typename result_type::iterator iterator;
|
||||
typedef typename result_type::const_iterator const_iterator;
|
||||
|
||||
template <typename Predicates> inline
|
||||
query_range(index::rtree<Value, Options, Translator, Allocator> const& rtree,
|
||||
Predicates const& pred)
|
||||
{
|
||||
rtree.query(pred, std::back_inserter(m_result));
|
||||
}
|
||||
|
||||
inline iterator begin() { return m_result.begin(); }
|
||||
inline iterator end() { return m_result.end(); }
|
||||
inline const_iterator begin() const { return m_result.begin(); }
|
||||
inline const_iterator end() const { return m_result.end(); }
|
||||
|
||||
private:
|
||||
result_type m_result;
|
||||
};
|
||||
|
||||
}} // namespace adaptors::detail
|
||||
|
||||
}}} // namespace boost::geometry::index
|
||||
|
||||
|
||||
@@ -1461,6 +1461,24 @@ remove(rtree<Value, Options, Translator, Allocator> & tree, Range const& rng)
|
||||
return tree.remove(rng);
|
||||
}
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename Predicates, typename OutIter> inline
|
||||
typename rtree<Value, Options, Translator, Allocator>::size_type
|
||||
query(rtree<Value, Options, Translator, Allocator> const& tree,
|
||||
Predicates const& pred,
|
||||
OutIter out_it)
|
||||
{
|
||||
return tree.query(pred, out_it);
|
||||
}
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Allocator, typename Predicates> inline
|
||||
typename rtree<Value, Options, Translator, Allocator>::size_type
|
||||
query(rtree<Value, Options, Translator, Allocator> const& tree,
|
||||
Predicates const& pred,
|
||||
typename rtree<Value, Options, Translator, Allocator>::value_type & v)
|
||||
{
|
||||
return tree.query(pred, v);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Find values meeting spatial predicates.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user