From b65c697cadbc4c44d0a33da88d0a69e543caabaf Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Tue, 26 Jul 2011 02:21:17 +0000 Subject: [PATCH] within and distance_sqr removed from index/algorithms. geometry::covered_by used in remove visitor. [SVN r73370] --- .../index/algorithms/distance_sqr.hpp | 78 ----------- .../extensions/index/algorithms/within.hpp | 131 ------------------ .../index/rtree/visitors/remove.hpp | 4 +- 3 files changed, 2 insertions(+), 211 deletions(-) delete mode 100644 include/boost/geometry/extensions/index/algorithms/distance_sqr.hpp delete mode 100644 include/boost/geometry/extensions/index/algorithms/within.hpp diff --git a/include/boost/geometry/extensions/index/algorithms/distance_sqr.hpp b/include/boost/geometry/extensions/index/algorithms/distance_sqr.hpp deleted file mode 100644 index 0a27cbf5e..000000000 --- a/include/boost/geometry/extensions/index/algorithms/distance_sqr.hpp +++ /dev/null @@ -1,78 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Boost.SpatialIndex - n-dimensional distance_sqr between points -// -// 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_ALGORITHMS_DISTANCE_SQR_HPP -#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DISTANCE_SQR_HPP - -namespace boost { namespace geometry { namespace index { - -template -class default_distance_sqr_result -{ - typedef typename select_most_precise< - typename traits::coordinate_type::type, - long double - >::type intermediate_type; - -public: - typedef typename select_most_precise< - typename traits::coordinate_type::type, - intermediate_type - >::type type; -}; - -namespace detail { - -template -struct distance_sqr_for_each_dimension -{ - BOOST_STATIC_ASSERT(0 < CurrentDimension); - BOOST_STATIC_ASSERT(CurrentDimension <= traits::dimension::value); - - typedef typename default_distance_sqr_result::type result_type; - - static inline result_type apply(Point1 const& p1, Point2 const& p2) - { - result_type temp = geometry::get(p1) - geometry::get(p2); - return distance_sqr_for_each_dimension::apply(p1, p2) + - temp * temp; - } -}; - -template -struct distance_sqr_for_each_dimension -{ - BOOST_STATIC_ASSERT(1 <= traits::dimension::value); - - typedef typename default_distance_sqr_result::type result_type; - - static inline result_type apply(Point1 const& p1, Point2 const& p2) - { - result_type temp = geometry::get<0>(p1) - geometry::get<0>(p2); - return temp * temp; - } -}; - -} // namespace detail - -template -typename default_distance_sqr_result::type distance_sqr(Point1 const& p1, Point2 const& p2) -{ - BOOST_STATIC_ASSERT(traits::dimension::value == traits::dimension::value); - - return detail::distance_sqr_for_each_dimension< - Point1, - Point2, - index::traits::dimension::value - >::apply(p1, p2); -} - -}}} // namespace boost::geometry::index - -#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DISTANCE_SQR_HPP diff --git a/include/boost/geometry/extensions/index/algorithms/within.hpp b/include/boost/geometry/extensions/index/algorithms/within.hpp deleted file mode 100644 index a65d8a6e3..000000000 --- a/include/boost/geometry/extensions/index/algorithms/within.hpp +++ /dev/null @@ -1,131 +0,0 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) -// -// Boost.SpatialIndex - n-dimensional within box -// -// 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_ALGORITHMS_WITHIN_HPP -#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_WITHIN_HPP - -namespace boost { namespace geometry { namespace index { - -namespace dispatch { - -template -struct within_compare -{ - // TODO: awulkiew - static assert? -}; - -template -struct within_compare -{ - template - static inline bool apply(Indexable const& b1, Box const& b2) - { - return index::get(b2) <= index::get(b1); - } -}; - -template -struct within_compare -{ - template - static inline bool apply(Indexable const& b1, Box const& b2) - { - return index::get(b1) <= index::get(b2); - } -}; - -template -struct within_compare -{ - template - static inline bool apply(Indexable const& p, Box const& b) - { - return index::get(b) <= geometry::get(p); - } -}; - -template -struct within_compare -{ - template - static inline bool apply(Indexable const& p, Box const& b) - { - return geometry::get(p) <= index::get(b); - } -}; - -} // namespace dispatch - -namespace detail { - -template -struct within_for_each_dimension -{ - BOOST_STATIC_ASSERT(0 < CurrentDimension); - BOOST_STATIC_ASSERT(CurrentDimension <= traits::dimension::value); - BOOST_STATIC_ASSERT(traits::dimension::value == traits::dimension::value); - - static inline bool apply(Indexable const& i, Box const& b) - { - return - within_for_each_dimension< - Box, - Indexable, - CurrentDimension - 1 - >::apply(i, b) && - dispatch::within_compare< - min_corner, - CurrentDimension - 1, - Indexable, - typename traits::tag::type - >::apply(i, b) && - dispatch::within_compare< - max_corner, - CurrentDimension - 1, - Indexable, - typename traits::tag::type - >::apply(i, b); - } -}; - -template -struct within_for_each_dimension -{ - BOOST_STATIC_ASSERT(1 <= traits::dimension::value); - BOOST_STATIC_ASSERT(traits::dimension::value == traits::dimension::value); - - static inline bool apply(Indexable const& i, Box const& b) - { - return - dispatch::within_compare< - min_corner, - 0, - Indexable, - typename traits::tag::type - >::apply(i, b) && - dispatch::within_compare< - max_corner, - 0, - Indexable, - typename traits::tag::type - >::apply(i, b); - } -}; - -} // namespace detail - -template -bool within(Indexable const& i, Box const& box) -{ - return detail::within_for_each_dimension::value>::apply(i, box); -} - -}}} // namespace boost::geometry::index - -#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_WITHIN_HPP diff --git a/include/boost/geometry/extensions/index/rtree/visitors/remove.hpp b/include/boost/geometry/extensions/index/rtree/visitors/remove.hpp index 57b9a1527..5db8b079b 100644 --- a/include/boost/geometry/extensions/index/rtree/visitors/remove.hpp +++ b/include/boost/geometry/extensions/index/rtree/visitors/remove.hpp @@ -14,7 +14,7 @@ #include -#include +#include namespace boost { namespace geometry { namespace index { @@ -60,7 +60,7 @@ public: size_t child_node_index = 0; for ( ; child_node_index < children.size() ; ++child_node_index ) { - if ( index::within(m_tr(m_value), children[child_node_index].first) ) + if ( geometry::covered_by(m_tr(m_value), children[child_node_index].first) ) { // next traversing step traverse_apply_visitor(n, child_node_index);