|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74435 - in sandbox-branches/geometry/index/boost/geometry/extensions/index: filters rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2011-09-17 06:45:10
Author: awulkiew
Date: 2011-09-17 06:45:08 EDT (Sat, 17 Sep 2011)
New Revision: 74435
URL: http://svn.boost.org/trac/boost/changeset/74435
Log:
nearest_filter implemented, spatial_filter changed to query_filter.
Added:
sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/query_filter.hpp (contents, props changed)
Removed:
sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/spacial_filter.hpp
Text files modified:
sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/nearest_filter.hpp | 83 ++++++++++++++++++++-------------------
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/filters.hpp | 63 ++++++++++++++++++------------
sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp | 2
3 files changed, 81 insertions(+), 67 deletions(-)
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/nearest_filter.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/nearest_filter.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/nearest_filter.hpp 2011-09-17 06:45:08 EDT (Sat, 17 Sep 2011)
@@ -12,69 +12,70 @@
namespace boost { namespace geometry { namespace index {
-namespace filters {
-
-template <typename SpacialIndex>
+template <typename Index>
class nearest_filter
{
-public:
+ BOOST_MPL_ASSERT_MSG(
+ (false),
+ NOT_IMPLEMENTED_FOR_THIS_INDEX,
+ (nearest_filter));
+
typedef int* iterator;
typedef const int* const_iterator;
- template <typename Point>
- nearest_filter(
- SpacialIndex const&,
+ template <typename Point, typename Predicates>
+ inline nearest_filter(
+ Index const&,
Point const&,
- typename traits::coordinate_type<Point>::type const&
+ size_t,
+ Predicates const&
)
{}
- iterator begin() { return 0; }
- iterator end() { return 0; }
- const_iterator begin() const { return 0; }
- const_iterator end() const { return 0; }
+ inline iterator begin() { return 0; }
+ inline iterator end() { return 0; }
+ inline const_iterator begin() const { return 0; }
+ inline const_iterator end() const { return 0; }
};
namespace detail {
-template<typename Point>
-class nearest_filtered
+template<typename Point, typename Predicates>
+struct nearest_filtered
{
-public:
- explicit nearest_filtered(
- Point const& p,
- typename traits::coordinate_type<Point>::type const& distance)
- : m_point(p), m_distance(distance) {}
-
- Point const& point() const { return m_point; }
-
- typename traits::coordinate_type<Point>::type const&
- distance() const { return m_distance; }
-
-private:
- Point m_point;
- typename traits::coordinate_type<Point>::type m_distance;
+ inline nearest_filtered(
+ Point const& pt,
+ size_t k,
+ Predicates const& pred
+ )
+ : point(pt)
+ , count(k)
+ , predicates(pred)
+ {}
+
+ Point const& point;
+ size_t count;
+ Predicates const& predicates;
};
} // namespace detail
-template <typename Point>
-detail::nearest_filtered<Point> nearest_filtered(
- Point const& p,
- typename traits::coordinate_type<Point>::type const& distance)
+template <typename Point, typename Predicates>
+detail::nearest_filtered<Point, Predicates> nearest_filtered(
+ Point const& pt,
+ size_t k,
+ Predicates const& pred = detail::empty())
{
- return detail::nearest_filtered<Point>(p, distance);
+ return detail::nearest_filtered<Point, Predicates>(pt, k, pred);
}
-} // namespace filters
-
-template<typename SpacialIndex, typename Point>
-boost::geometry::index::filters::nearest_filter<SpacialIndex>
- operator|(
- SpacialIndex const& si,
- boost::geometry::index::filters::detail::nearest_filtered<Point> const& f)
+template<typename Index, typename Point, typename Predicates>
+index::nearest_filter<Index>
+operator|(
+ Index const& si,
+ detail::nearest_filtered<Point, Predicates> const& f)
{
- return boost::geometry::index::filters::nearest_filter<SpacialIndex>(si, f.point(), f.distance());
+ return index::nearest_filter<Index>(si, f.point, f.count, f.predicates);
}
}}} // namespace boost::geometry::index
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/query_filter.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/query_filter.hpp 2011-09-17 06:45:08 EDT (Sat, 17 Sep 2011)
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Boost.SpatialIndex - query filter implementation
+//
+// Copyright 2011 Adam Wulkiewicz.
+// 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_EXTENSIONS_INDEX_FILTERS_QUERY_FILTER_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_FILTERS_QUERY_FILTER_HPP
+
+namespace boost { namespace geometry { namespace index {
+
+template <typename Index>
+class query_filter
+{
+ BOOST_MPL_ASSERT_MSG(
+ (false),
+ NOT_IMPLEMENTED_FOR_THIS_INDEX,
+ (query_filter));
+
+ typedef int* iterator;
+ typedef const int* const_iterator;
+
+ template <typename Predicates>
+ inline query_filter(
+ 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; }
+};
+
+namespace detail {
+
+template<typename Predicates>
+struct query_filtered
+{
+ inline explicit query_filtered(Predicates const& pred)
+ : predicates(pred)
+ {}
+
+ Predicates const& predicates;
+};
+
+} // namespace detail
+
+template <typename Predicates>
+detail::query_filtered<Predicates> query_filtered(Predicates const& pred)
+{
+ return detail::query_filtered<Predicates>(pred);
+}
+
+template<typename Index, typename Predicates>
+index::query_filter<Index>
+operator|(
+ Index const& si,
+ index::detail::query_filtered<Predicates> const& f)
+{
+ return index::query_filter<Index>(si, f.predicates);
+}
+
+}}} // namespace boost::geometry::index
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_FILTERS_QUERY_FILTER_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/spacial_filter.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/filters/spacial_filter.hpp 2011-09-17 06:45:08 EDT (Sat, 17 Sep 2011)
+++ (empty file)
@@ -1,67 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-//
-// Boost.SpatialIndex - box query filter implementation
-//
-// Copyright 2011 Adam Wulkiewicz.
-// 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_EXTENSIONS_INDEX_FILTERS_SPACIAL_FILTER_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_FILTERS_SPACIAL_FILTER_HPP
-
-namespace boost { namespace geometry { namespace index {
-
-namespace filters {
-
-template <typename SpacialIndex>
-class spatial_filter
-{
-public:
- typedef int* iterator;
- typedef const int* const_iterator;
-
- template <typename Geometry>
- spatial_filter(SpacialIndex const&, Geometry const&) {}
-
- iterator begin() { return 0; }
- iterator end() { return 0; }
- const_iterator begin() const { return 0; }
- const_iterator end() const { return 0; }
-};
-
-namespace detail {
-
-template<typename Geometry>
-class spatially_filtered
-{
-public:
- explicit spatially_filtered(Geometry const& geom) : m_geom(geom) {}
- Geometry const& geometry() const { return m_geom; }
-
-private:
- Geometry const& m_geom;
-};
-
-} // namespace detail
-
-template <typename Geometry>
-detail::spatially_filtered<Geometry> spatially_filtered(Geometry const& geom)
-{
- return detail::spatially_filtered<Geometry>(geom);
-}
-
-} // namespace filters
-
-template<typename SpacialIndex, typename Geometry>
-index::filters::spatial_filter<SpacialIndex>
-operator|(
- SpacialIndex const& si,
- index::filters::detail::spatially_filtered<Geometry> const& f)
-{
- return index::filters::spatial_filter<SpacialIndex>(si, f.geometry());
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_FILTERS_SPACIAL_FILTER_HPP
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/filters.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/filters.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/filters.hpp 2011-09-17 06:45:08 EDT (Sat, 17 Sep 2011)
@@ -13,29 +13,29 @@
#include <deque>
#include <boost/static_assert.hpp>
-#include <boost/geometry/extensions/index/filters/spacial_filter.hpp>
-
-// TODO: awulkiew - implement nearest filter
-//#include <boost/geometry/extensions/index/filters/nearest_filter.hpp>
+#include <boost/geometry/extensions/index/filters/query_filter.hpp>
+#include <boost/geometry/extensions/index/filters/nearest_filter.hpp>
namespace boost { namespace geometry { namespace index {
template <typename Value, typename Options, typename Translator>
class rtree;
-namespace filters {
-
template <typename Value, typename Options, typename Translator>
-class spatial_filter< index::rtree<Value, Options, Translator> >
+class query_filter< index::rtree<Value, Options, Translator> >
{
public:
- typedef typename std::deque<Value>::iterator iterator;
- typedef typename std::deque<Value>::const_iterator const_iterator;
+ typedef std::vector<Value> result_type;
+ typedef typename result_type::iterator iterator;
+ typedef typename result_type::const_iterator const_iterator;
- template <typename Geometry>
- inline spatial_filter(index::rtree<Value, Options, Translator> const& rtree, Geometry const& geom)
+ template <typename Predicates>
+ inline query_filter(
+ index::rtree<Value, Options, Translator> const& rtree,
+ Predicates const& pred
+ )
{
- rtree.find(geom, std::back_inserter(m_result));
+ rtree.query(pred, std::back_inserter(m_result));
}
inline iterator begin() { return m_result.begin(); }
@@ -44,23 +44,36 @@
inline const_iterator end() const { return m_result.end(); }
private:
- std::deque<Value> m_result;
+ result_type m_result;
};
-} // namespace filters
+template <typename Value, typename Options, typename Translator>
+class nearest_filter< index::rtree<Value, Options, Translator> >
+{
+public:
+ typedef std::vector<Value> result_type;
+ typedef typename result_type::iterator iterator;
+ typedef typename result_type::const_iterator const_iterator;
+
+ template <typename Point, typename Predicates>
+ inline nearest_filter(
+ index::rtree<Value, Options, Translator> const& rtree,
+ Point const& pt,
+ size_t k,
+ Predicates const& pred
+ )
+ {
+ rtree.nearest(pt, k, pred, std::back_inserter(m_result));
+ }
-// TODO: awulkiew - filter may be implemented in operator|
+ 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(); }
-//template<typename Value, typename Translator, typename Tag, typename Geometry>
-//std::deque<Value>
-//operator|(
-// index::rtree<Value, Translator, Tag> const& si,
-// index::filters::detail::spatially_filtered<Geometry> const& f)
-//{
-// std::deque<Value> result;
-// si.find(f.geometry(), std::back_inserter(result));
-// return result;
-//}
+private:
+ result_type m_result;
+};
}}} // namespace boost::geometry::index
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp (original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/rtree/rtree.hpp 2011-09-17 06:45:08 EDT (Sat, 17 Sep 2011)
@@ -23,7 +23,7 @@
#include <boost/geometry/extensions/index/rtree/options.hpp>
#include <boost/geometry/extensions/index/rtree/predicates.hpp>
-//#include <boost/geometry/extensions/index/rtree/filters.hpp>
+#include <boost/geometry/extensions/index/rtree/filters.hpp>
#include <boost/geometry/extensions/index/rtree/node/node.hpp>
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