Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82611 - in sandbox-branches/geometry/index/boost/geometry/index: . adaptors detail/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-01-25 13:43:49


Author: awulkiew
Date: 2013-01-25 13:43:48 EST (Fri, 25 Jan 2013)
New Revision: 82611
URL: http://svn.boost.org/trac/boost/changeset/82611

Log:
Added rtree free function insert.
Added adaptors::queried().
nearest_query_range and spatial_query_range moved to adaptors::detail.
Added:
   sandbox-branches/geometry/index/boost/geometry/index/adaptors/query.hpp (contents, props changed)
Text files modified:
   sandbox-branches/geometry/index/boost/geometry/index/adaptors/nearest_query.hpp | 8 ++++----
   sandbox-branches/geometry/index/boost/geometry/index/adaptors/spatial_query.hpp | 8 ++++----
   sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/adaptors.hpp | 29 +++++++++++++++++++++++++++--
   sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp | 18 ++++++++++++++++++
   4 files changed, 53 insertions(+), 10 deletions(-)

Modified: sandbox-branches/geometry/index/boost/geometry/index/adaptors/nearest_query.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/adaptors/nearest_query.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/adaptors/nearest_query.hpp 2013-01-25 13:43:48 EST (Fri, 25 Jan 2013)
@@ -19,6 +19,8 @@
 
 namespace adaptors {
 
+namespace detail {
+
 template <typename Index>
 class nearest_query_range
 {
@@ -45,8 +47,6 @@
     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 @@
 } // 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);
 }
 

Added: sandbox-branches/geometry/index/boost/geometry/index/adaptors/query.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/index/adaptors/query.hpp 2013-01-25 13:43:48 EST (Fri, 25 Jan 2013)
@@ -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

Modified: sandbox-branches/geometry/index/boost/geometry/index/adaptors/spatial_query.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/adaptors/spatial_query.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/adaptors/spatial_query.hpp 2013-01-25 13:43:48 EST (Fri, 25 Jan 2013)
@@ -19,6 +19,8 @@
 
 namespace adaptors {
 
+namespace detail {
+
 template <typename Index>
 class spatial_query_range
 {
@@ -42,8 +44,6 @@
     inline const_iterator end() const { return 0; }
 };
 
-namespace detail {
-
 // TODO: awulkiew - consider removing reference from predicates
 
 template<typename Predicates>
@@ -75,12 +75,12 @@
 } // 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

Modified: sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/adaptors.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/adaptors.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/detail/rtree/adaptors.hpp 2013-01-25 13:43:48 EST (Fri, 25 Jan 2013)
@@ -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 @@
     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
 

Modified: sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/index/rtree.hpp 2013-01-25 13:43:48 EST (Fri, 25 Jan 2013)
@@ -1461,6 +1461,24 @@
     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.
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk