$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82545 - in sandbox-branches/geometry/index: boost/geometry/extensions/index/algorithms boost/geometry/extensions/index/algorithms/detail boost/geometry/extensions/index/detail boost/geometry/extensions/index/detail/algorithms boost/geometry/extensions/index/detail/rtree boost/geometry/extensions/index/detail/rtree/linear boost/geometry/extensions/index/detail/rtree/quadratic boost/geometry/extensions/index/detail/rtree/rstar boost/geometry/extensions/index/detail/rtree/visitors test/rtree
From: adam.wulkiewicz_at_[hidden]
Date: 2013-01-18 20:15:58
Author: awulkiew
Date: 2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
New Revision: 82545
URL: http://svn.boost.org/trac/boost/changeset/82545
Log:
index/algorithms/* moved to index/detail/algorithms/*
Added:
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_centroid.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_far.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_near.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/content.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/diff_abs.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/intersection_content.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/margin.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/minmaxdist.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/smallest_for_indexable.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp   (contents, props changed)
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/union_content.hpp   (contents, props changed)
Removed:
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_centroid.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_far.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_near.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/content.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/smallest_for_indexable.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/intersection_content.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/margin.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/minmaxdist.hpp
   sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/union_content.hpp
Text files modified: 
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/distance_predicates.hpp                   |    12 +++++-----                              
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/linear/redistribute_elements.hpp    |    25 +++++++++-------------                  
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/options.hpp                         |    24 ++++++++++----------                    
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/quadratic/redistribute_elements.hpp |    30 +++++++++++---------------              
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/choose_next_node.hpp          |    36 ++++++++++++++------------------        
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/insert.hpp                    |    12 +++-------                              
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/redistribute_elements.hpp     |    44 ++++++++++++++++++--------------------- 
   sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp                 |    18 ++++++++--------                        
   sandbox-branches/geometry/index/test/rtree/test_rtree.hpp                                                        |    10 ++++----                                
   9 files changed, 95 insertions(+), 116 deletions(-)
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_centroid.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_centroid.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,81 +0,0 @@
-// Boost.Geometry Index
-//
-// squared distance between point and centroid of the box or point
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP
-
-#include <boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp>
-#include <boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-struct comparable_distance_centroid_tag {};
-
-template <
-    typename Point,
-    typename PointIndexable,
-    size_t N>
-struct sum_for_indexable<Point, PointIndexable, point_tag, comparable_distance_centroid_tag, N>
-{
-    typedef typename geometry::default_distance_result<Point, PointIndexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, PointIndexable const& i)
-    {
-        return geometry::comparable_distance(pt, i);
-    }
-};
-
-template <
-    typename Point,
-    typename BoxIndexable,
-    size_t DimensionIndex>
-struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_centroid_tag, DimensionIndex>
-{
-    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, BoxIndexable const& i)
-    {
-        typedef typename index::detail::traits::coordinate_type<Point>::type point_coord_t;
-        typedef typename index::detail::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
-
-        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
-        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
-        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
-        
-        indexable_coord_t ind_c_avg = ind_c_min + (ind_c_max - ind_c_min) / 2;
-        // TODO: awulkiew - is (ind_c_min + ind_c_max) / 2 safe?
-
-        result_type diff = detail::diff_abs(ind_c_avg, pt_c);
-
-        return diff * diff;
-    }
-};
-
-} // namespace detail
-
-template <typename Point, typename Indexable>
-typename geometry::default_distance_result<Point, Indexable>::type
-comparable_distance_centroid(Point const& pt, Indexable const& i)
-{
-    return detail::sum_for_indexable<
-        Point,
-        Indexable,
-        typename index::detail::traits::tag<Indexable>::type,
-        detail::comparable_distance_centroid_tag,
-        index::detail::traits::dimension<Indexable>::value
-    >::apply(pt, i);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // #define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP
-
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_far.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_far.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,70 +0,0 @@
-// Boost.Geometry Index
-//
-// squared distance between point and furthest point of the box or point
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
-
-#include <boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp>
-#include <boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-// minmaxdist component
-
-struct comparable_distance_far_tag {};
-
-template <
-    typename Point,
-    typename BoxIndexable,
-    size_t DimensionIndex>
-struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_far_tag, DimensionIndex>
-{
-    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, BoxIndexable const& i)
-    {
-        typedef typename index::detail::traits::coordinate_type<Point>::type point_coord_t;
-        typedef typename index::detail::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
-
-        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
-        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
-        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
-
-        result_type further_diff = 0;
-
-        if ( (ind_c_min + ind_c_max) / 2 <= pt_c )
-            further_diff = pt_c - ind_c_min;
-        else
-            further_diff = detail::diff_abs(pt_c, ind_c_max); // unsigned values protection
-
-        return further_diff * further_diff;
-    }
-};
-
-} // namespace detail
-
-template <typename Point, typename Indexable>
-typename geometry::default_distance_result<Point, Indexable>::type
-comparable_distance_far(Point const& pt, Indexable const& i)
-{
-    return detail::sum_for_indexable<
-        Point,
-        Indexable,
-        typename index::detail::traits::tag<Indexable>::type,
-        detail::comparable_distance_far_tag,
-        index::detail::traits::dimension<Indexable>::value
-    >::apply(pt, i);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_near.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/comparable_distance_near.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,81 +0,0 @@
-// Boost.Geometry Index
-//
-// squared distance between point and nearest point of the box or point
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP
-
-#include <boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-struct comparable_distance_near_tag {};
-
-template <
-    typename Point,
-    typename PointIndexable,
-    size_t N>
-struct sum_for_indexable<Point, PointIndexable, point_tag, comparable_distance_near_tag, N>
-{
-    typedef typename geometry::default_distance_result<Point, PointIndexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, PointIndexable const& i)
-    {
-        return geometry::comparable_distance(pt, i);
-    }
-};
-
-template <
-    typename Point,
-    typename BoxIndexable,
-    size_t DimensionIndex>
-struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_near_tag, DimensionIndex>
-{
-    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, BoxIndexable const& i)
-    {
-        typedef typename index::detail::traits::coordinate_type<Point>::type point_coord_t;
-        typedef typename index::detail::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
-
-        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
-        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
-        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
-
-        result_type diff = 0;
-
-        if ( pt_c < ind_c_min )
-            diff = ind_c_min - pt_c;
-        else if ( ind_c_max < pt_c )
-            diff = pt_c - ind_c_max;
-
-        return diff * diff;
-    }
-};
-
-} // namespace detail
-
-template <typename Point, typename Indexable>
-typename geometry::default_distance_result<Point, Indexable>::type
-comparable_distance_near(Point const& pt, Indexable const& i)
-{
-    return detail::sum_for_indexable<
-        Point,
-        Indexable,
-        typename index::detail::traits::tag<Indexable>::type,
-        detail::comparable_distance_near_tag,
-        index::detail::traits::dimension<Indexable>::value
-    >::apply(pt, i);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/content.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/content.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,87 +0,0 @@
-// Boost.Geometry Index
-//
-// n-dimensional box's content (hypervolume) - 2d area, 3d volume, ...
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_CONTENT_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_CONTENT_HPP
-
-namespace boost { namespace geometry { namespace index {
-
-template <typename Indexable>
-struct default_content_result
-{
-    typedef typename select_most_precise<
-        typename detail::traits::coordinate_type<Indexable>::type,
-        long double
-    >::type type;
-};
-
-namespace detail {
-
-template <typename Box, size_t CurrentDimension>
-struct content_for_each_dimension
-{
-    BOOST_STATIC_ASSERT(0 < CurrentDimension);
-    BOOST_STATIC_ASSERT(CurrentDimension <= traits::dimension<Box>::value);
-
-    static inline typename default_content_result<Box>::type apply(Box const& b)
-    {
-        return content_for_each_dimension<Box, CurrentDimension - 1>::apply(b) *
-            ( detail::get<max_corner, CurrentDimension - 1>(b) - detail::get<min_corner, CurrentDimension - 1>(b) );
-    }
-};
-
-template <typename Box>
-struct content_for_each_dimension<Box, 1>
-{
-    static inline typename default_area_result<Box>::type apply(Box const& b)
-    {
-        return detail::get<max_corner, 0>(b) - detail::get<min_corner, 0>(b);
-    }
-};
-
-} // namespace detail
-
-namespace dispatch {
-
-template <typename Indexable, typename Tag>
-struct content
-{
-    // TODO: awulkiew - static assert?
-};
-
-template <typename Indexable>
-struct content<Indexable, point_tag>
-{
-    static typename default_content_result<Indexable>::type apply(Indexable const&)
-    {
-        return 0;
-    }
-};
-
-template <typename Indexable>
-struct content<Indexable, box_tag>
-{
-    static typename default_content_result<Indexable>::type apply(Indexable const& b)
-    {
-        return detail::content_for_each_dimension<Indexable, detail::traits::dimension<Indexable>::value>::apply(b);
-    }
-};
-
-} // namespace dispatch
-
-template <typename Indexable>
-typename default_content_result<Indexable>::type content(Indexable const& b)
-{
-    return dispatch::content<Indexable, typename detail::traits::tag<Indexable>::type>::apply(b);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_CONTENT_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,28 +0,0 @@
-// Boost.Geometry Index
-//
-// Abs of difference
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_DIFF_ABS_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_DIFF_ABS_HPP
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-template <typename T>
-inline T diff_abs(T const& v1, T const& v2)
-{
-    return v1 < v2 ? v2 - v1 : v1 - v2;
-}
-
-} // namespace detail
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_DIFF_ABS_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/smallest_for_indexable.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/smallest_for_indexable.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,84 +0,0 @@
-// Boost.Geometry Index
-//
-// Get smallest value calculated for indexable's dimensions, used in R-tree k nearest neighbors query
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SMALLEST_FOR_INDEXABLE_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SMALLEST_FOR_INDEXABLE_HPP
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-template <
-    typename Geometry,
-    typename Indexable,
-    typename IndexableTag,
-    typename AlgoTag,
-    size_t DimensionIndex>
-struct smallest_for_indexable_dimension
-{
-    BOOST_MPL_ASSERT_MSG(
-        (false),
-        NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE,
-        (smallest_for_indexable_dimension));
-};
-
-template <
-    typename Geometry,
-    typename Indexable,
-    typename IndexableTag,
-    typename AlgoTag,
-    size_t N>
-struct smallest_for_indexable
-{
-    typedef typename smallest_for_indexable_dimension<
-        Geometry, Indexable, IndexableTag, AlgoTag, N - 1
-    >::result_type result_type;
-
-    template <typename Data>
-    inline static result_type apply(Geometry const& g, Indexable const& i, Data const& data)
-    {
-        result_type r1 = smallest_for_indexable<
-            Geometry, Indexable, IndexableTag, AlgoTag, N - 1
-        >::apply(g, i, data);
-
-        result_type r2 = smallest_for_indexable_dimension<
-            Geometry, Indexable, IndexableTag, AlgoTag, N - 1
-        >::apply(g, i, data);
-
-        return r1 < r2 ? r1 : r2;
-    }
-};
-
-template <
-    typename Geometry,
-    typename Indexable,
-    typename IndexableTag,
-    typename AlgoTag>
-struct smallest_for_indexable<Geometry, Indexable, IndexableTag, AlgoTag, 1>
-{
-    typedef typename smallest_for_indexable_dimension<
-        Geometry, Indexable, IndexableTag, AlgoTag, 0
-    >::result_type result_type;
-
-    template <typename Data>
-    inline static result_type apply(Geometry const& g, Indexable const& i, Data const& data)
-    {
-        return
-            smallest_for_indexable_dimension<
-                Geometry, Indexable, IndexableTag, AlgoTag, 0
-            >::apply(g, i, data);
-    }
-};
-
-} // namespace detail
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SMALLEST_FOR_INDEXABLE_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,80 +0,0 @@
-// Boost.Geometry Index
-//
-// Sum values calculated for indexable's dimensions, used e.g. in R-tree k nearest neighbors query
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SUM_FOR_INDEXABLE_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SUM_FOR_INDEXABLE_HPP
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-template <
-    typename Geometry,
-    typename Indexable,
-    typename IndexableTag,
-    typename AlgoTag,
-    size_t DimensionIndex>
-struct sum_for_indexable_dimension
-{
-    BOOST_MPL_ASSERT_MSG(
-        (false),
-        NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE,
-        (sum_for_indexable_dimension));
-};
-
-template <
-    typename Geometry,
-    typename Indexable,
-    typename IndexableTag,
-    typename AlgoTag,
-    size_t N>
-struct sum_for_indexable
-{
-    typedef typename sum_for_indexable_dimension<
-        Geometry, Indexable, IndexableTag, AlgoTag, N - 1
-    >::result_type result_type;
-
-    inline static result_type apply(Geometry const& g, Indexable const& i)
-    {
-        return
-            sum_for_indexable<
-                Geometry, Indexable, IndexableTag, AlgoTag, N - 1
-            >::apply(g, i) +
-            sum_for_indexable_dimension<
-                Geometry, Indexable, IndexableTag, AlgoTag, N - 1
-            >::apply(g, i);
-    }
-};
-
-template <
-    typename Geometry,
-    typename Indexable,
-    typename IndexableTag,
-    typename AlgoTag>
-struct sum_for_indexable<Geometry, Indexable, IndexableTag, AlgoTag, 1>
-{
-    typedef typename sum_for_indexable_dimension<
-        Geometry, Indexable, IndexableTag, AlgoTag, 0
-    >::result_type result_type;
-
-    inline static result_type apply(Geometry const& g, Indexable const& i)
-    {
-        return
-            sum_for_indexable_dimension<
-                Geometry, Indexable, IndexableTag, AlgoTag, 0
-            >::apply(g, i);
-    }
-};
-
-} // namespace detail
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SUM_FOR_INDEXABLE_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/intersection_content.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/intersection_content.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,36 +0,0 @@
-// Boost.Geometry Index
-//
-// boxes union/intersection area/volume
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_INTERSECTION_CONTENT_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_INTERSECTION_CONTENT_HPP
-
-#include <boost/geometry/algorithms/intersection.hpp>
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-/**
- * \brief Compute the area of the intersection of b1 and b2
- */
-template <typename Box>
-inline typename default_content_result<Box>::type intersection_content(Box const& box1, Box const& box2)
-{
-    if ( geometry::intersects(box1, box2) )
-    {
-        Box box_intersection;
-        geometry::intersection(box1, box2, box_intersection);
-        return index::content(box_intersection);
-    }
-    return 0;
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_INTERSECTION_CONTENT_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/margin.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/margin.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,103 +0,0 @@
-// Boost.Geometry Index
-//
-// n-dimensional box's margin value (hypersurface), 2d perimeter, 3d surface, etc...
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_MARGIN_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_MARGIN_HPP
-
-namespace boost { namespace geometry { namespace index {
-
-template <typename Box>
-struct default_margin_result
-{
-    typedef typename select_most_precise<
-        typename coordinate_type<Box>::type,
-        long double
-    >::type type;
-};
-
-namespace detail {
-
-template <typename Box, size_t CurrentDimension, size_t EdgeDimension>
-struct margin_for_each_edge
-{
-    BOOST_STATIC_ASSERT(0 < CurrentDimension);
-    BOOST_STATIC_ASSERT(0 < EdgeDimension);
-
-    static inline typename default_margin_result<Box>::type apply(Box const& b)
-    {
-        return margin_for_each_edge<Box, CurrentDimension, EdgeDimension - 1>::apply(b) *
-            ( geometry::get<max_corner, EdgeDimension - 1>(b) - geometry::get<min_corner, EdgeDimension - 1>(b) );
-    }
-};
-
-template <typename Box, size_t CurrentDimension>
-struct margin_for_each_edge<Box, CurrentDimension, CurrentDimension>
-{
-    BOOST_STATIC_ASSERT(0 < CurrentDimension);
-
-    static inline typename default_margin_result<Box>::type apply(Box const& b)
-    {
-        return margin_for_each_edge<Box, CurrentDimension, CurrentDimension - 1>::apply(b);
-    }
-};
-
-template <typename Box, size_t CurrentDimension>
-struct margin_for_each_edge<Box, CurrentDimension, 1>
-{
-    BOOST_STATIC_ASSERT(0 < CurrentDimension);
-
-    static inline typename default_margin_result<Box>::type apply(Box const& b)
-    {
-        return geometry::get<max_corner, 0>(b) - geometry::get<min_corner, 0>(b);
-    }
-};
-
-template <typename Box>
-struct margin_for_each_edge<Box, 1, 1>
-{
-    static inline typename default_margin_result<Box>::type apply(Box const& /*b*/)
-    {
-        return 1;
-    }
-};
-
-template <typename Box, size_t CurrentDimension>
-struct margin_for_each_dimension
-{
-    BOOST_STATIC_ASSERT(0 < CurrentDimension);
-    BOOST_STATIC_ASSERT(CurrentDimension <= detail::traits::dimension<Box>::value);
-
-    static inline typename default_margin_result<Box>::type apply(Box const& b)
-    {
-        return margin_for_each_dimension<Box, CurrentDimension - 1>::apply(b) +
-            margin_for_each_edge<Box, CurrentDimension, detail::traits::dimension<Box>::value>::apply(b);
-    }
-};
-
-template <typename Box>
-struct margin_for_each_dimension<Box, 1>
-{
-    static inline typename default_margin_result<Box>::type apply(Box const& b)
-    {
-        return margin_for_each_edge<Box, 1, detail::traits::dimension<Box>::value>::apply(b);
-    }
-};
-
-} // namespace detail
-
-template <typename Box>
-typename default_margin_result<Box>::type margin(Box const& b)
-{
-    return 2 * detail::margin_for_each_dimension<Box, detail::traits::dimension<Box>::value>::apply(b);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_MARGIN_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/minmaxdist.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/minmaxdist.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,123 +0,0 @@
-// Boost.Geometry Index
-//
-// minmaxdist used in R-tree k nearest neighbors query
-//
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_MINMAXDIST_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_MINMAXDIST_HPP
-
-#include <boost/geometry/algorithms/distance.hpp>
-#include <boost/geometry/algorithms/comparable_distance.hpp>
-
-#include <boost/geometry/extensions/index/algorithms/detail/diff_abs.hpp>
-#include <boost/geometry/extensions/index/algorithms/detail/sum_for_indexable.hpp>
-#include <boost/geometry/extensions/index/algorithms/detail/smallest_for_indexable.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-namespace detail {
-
-struct minmaxdist_tag {};
-
-template <
-    typename Point,
-    typename BoxIndexable,
-    size_t DimensionIndex>
-struct smallest_for_indexable_dimension<Point, BoxIndexable, box_tag, minmaxdist_tag, DimensionIndex>
-{
-    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, BoxIndexable const& i, result_type const& maxd)
-    {
-        typedef typename index::traits::coordinate_type<Point>::type point_coord_t;
-        typedef typename index::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
-
-        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
-        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
-        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
-
-        indexable_coord_t ind_c_avg = ind_c_min + (ind_c_max - ind_c_min) / 2;
-        // TODO: awulkiew - is (ind_c_min + ind_c_max) / 2 safe?
-
-        // TODO: awulkiew - optimize! don't calculate 2x pt_c <= ind_c_avg
-        // take particular case pt_c == ind_c_avg into account
-
-        result_type closer_comp = 0;
-        if ( pt_c <= ind_c_avg )
-            closer_comp = detail::diff_abs(pt_c, ind_c_min); // unsigned values protection
-        else
-            closer_comp = ind_c_max - pt_c;
-        
-        result_type further_comp = 0;
-        if ( ind_c_avg <= pt_c )
-            further_comp = pt_c - ind_c_min;
-        else
-            further_comp = detail::diff_abs(pt_c, ind_c_max); // unsigned values protection
-
-        return (maxd + closer_comp * closer_comp) - further_comp * further_comp;
-    }
-};
-
-template <typename Point, typename Indexable, typename IndexableTag>
-struct minmaxdist_impl
-{
-    BOOST_MPL_ASSERT_MSG(
-        (false),
-        NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE,
-        (minmaxdist_impl));
-};
-
-template <typename Point, typename Indexable>
-struct minmaxdist_impl<Point, Indexable, point_tag>
-{
-    typedef typename geometry::default_distance_result<Point, Indexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, Indexable const& i)
-    {
-        return geometry::comparable_distance(pt, i);
-    }
-};
-
-template <typename Point, typename Indexable>
-struct minmaxdist_impl<Point, Indexable, box_tag>
-{
-    typedef typename geometry::default_distance_result<Point, Indexable>::type result_type;
-
-    inline static result_type apply(Point const& pt, Indexable const& i)
-    {
-        result_type maxd = geometry::comparable_distance(pt, i);
-
-        return smallest_for_indexable<
-            Point,
-            Indexable,
-            box_tag,
-            minmaxdist_tag,
-            index::traits::dimension<Indexable>::value
-        >::apply(pt, i, maxd);
-    }
-};
-
-} // namespace detail
-
-/**
- * This is comparable distace.
- */
-template <typename Point, typename Indexable>
-typename geometry::default_distance_result<Point, Indexable>::type
-minmaxdist(Point const& pt, Indexable const& i)
-{
-    return detail::minmaxdist_impl<
-        Point,
-        Indexable,
-        typename index::traits::tag<Indexable>::type
-    >::apply(pt, i);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_MINMAXDIST_HPP
Deleted: sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/union_content.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/algorithms/union_content.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
+++ (empty file)
@@ -1,33 +0,0 @@
-// Boost.Geometry Index
-//
-// boxes union/sum area/volume
-//
-// Copyright (c) 2008 Federico J. Fernandez.
-// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_UNION_CONTENT_HPP
-#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_UNION_CONTENT_HPP
-
-#include <boost/geometry/algorithms/expand.hpp>
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
-
-namespace boost { namespace geometry { namespace index {
-
-/**
- * \brief Compute the area of the union of b1 and b2
- */
-template <typename Box, typename Geometry>
-inline typename default_content_result<Box>::type union_content(Box const& b, Geometry const& g)
-{
-    Box expanded_box(b);
-    geometry::expand(expanded_box, g);
-    return index::content(expanded_box);
-}
-
-}}} // namespace boost::geometry::index
-
-#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_UNION_CONTENT_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_centroid.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_centroid.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,77 @@
+// Boost.Geometry Index
+//
+// squared distance between point and centroid of the box or point
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP
+
+#include <boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/diff_abs.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+struct comparable_distance_centroid_tag {};
+
+template <
+    typename Point,
+    typename PointIndexable,
+    size_t N>
+struct sum_for_indexable<Point, PointIndexable, point_tag, comparable_distance_centroid_tag, N>
+{
+    typedef typename geometry::default_distance_result<Point, PointIndexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, PointIndexable const& i)
+    {
+        return geometry::comparable_distance(pt, i);
+    }
+};
+
+template <
+    typename Point,
+    typename BoxIndexable,
+    size_t DimensionIndex>
+struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_centroid_tag, DimensionIndex>
+{
+    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, BoxIndexable const& i)
+    {
+        typedef typename index::detail::traits::coordinate_type<Point>::type point_coord_t;
+        typedef typename index::detail::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
+
+        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
+        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
+        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
+        
+        indexable_coord_t ind_c_avg = ind_c_min + (ind_c_max - ind_c_min) / 2;
+        // TODO: awulkiew - is (ind_c_min + ind_c_max) / 2 safe?
+
+        result_type diff = detail::diff_abs(ind_c_avg, pt_c);
+
+        return diff * diff;
+    }
+};
+
+template <typename Point, typename Indexable>
+typename geometry::default_distance_result<Point, Indexable>::type
+comparable_distance_centroid(Point const& pt, Indexable const& i)
+{
+    return detail::sum_for_indexable<
+        Point,
+        Indexable,
+        typename index::detail::traits::tag<Indexable>::type,
+        detail::comparable_distance_centroid_tag,
+        index::detail::traits::dimension<Indexable>::value
+    >::apply(pt, i);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // #define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP
+
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_far.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_far.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,66 @@
+// Boost.Geometry Index
+//
+// squared distance between point and furthest point of the box or point
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
+
+#include <boost/geometry/extensions/index/detail/algorithms/diff_abs.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+// minmaxdist component
+
+struct comparable_distance_far_tag {};
+
+template <
+    typename Point,
+    typename BoxIndexable,
+    size_t DimensionIndex>
+struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_far_tag, DimensionIndex>
+{
+    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, BoxIndexable const& i)
+    {
+        typedef typename index::detail::traits::coordinate_type<Point>::type point_coord_t;
+        typedef typename index::detail::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
+
+        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
+        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
+        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
+
+        result_type further_diff = 0;
+
+        if ( (ind_c_min + ind_c_max) / 2 <= pt_c )
+            further_diff = pt_c - ind_c_min;
+        else
+            further_diff = detail::diff_abs(pt_c, ind_c_max); // unsigned values protection
+
+        return further_diff * further_diff;
+    }
+};
+
+template <typename Point, typename Indexable>
+typename geometry::default_distance_result<Point, Indexable>::type
+comparable_distance_far(Point const& pt, Indexable const& i)
+{
+    return detail::sum_for_indexable<
+        Point,
+        Indexable,
+        typename index::detail::traits::tag<Indexable>::type,
+        detail::comparable_distance_far_tag,
+        index::detail::traits::dimension<Indexable>::value
+    >::apply(pt, i);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_near.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/comparable_distance_near.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,77 @@
+// Boost.Geometry Index
+//
+// squared distance between point and nearest point of the box or point
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP
+
+#include <boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+struct comparable_distance_near_tag {};
+
+template <
+    typename Point,
+    typename PointIndexable,
+    size_t N>
+struct sum_for_indexable<Point, PointIndexable, point_tag, comparable_distance_near_tag, N>
+{
+    typedef typename geometry::default_distance_result<Point, PointIndexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, PointIndexable const& i)
+    {
+        return geometry::comparable_distance(pt, i);
+    }
+};
+
+template <
+    typename Point,
+    typename BoxIndexable,
+    size_t DimensionIndex>
+struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_near_tag, DimensionIndex>
+{
+    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, BoxIndexable const& i)
+    {
+        typedef typename index::detail::traits::coordinate_type<Point>::type point_coord_t;
+        typedef typename index::detail::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
+
+        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
+        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
+        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
+
+        result_type diff = 0;
+
+        if ( pt_c < ind_c_min )
+            diff = ind_c_min - pt_c;
+        else if ( ind_c_max < pt_c )
+            diff = pt_c - ind_c_max;
+
+        return diff * diff;
+    }
+};
+
+template <typename Point, typename Indexable>
+typename geometry::default_distance_result<Point, Indexable>::type
+comparable_distance_near(Point const& pt, Indexable const& i)
+{
+    return detail::sum_for_indexable<
+        Point,
+        Indexable,
+        typename index::detail::traits::tag<Indexable>::type,
+        detail::comparable_distance_near_tag,
+        index::detail::traits::dimension<Indexable>::value
+    >::apply(pt, i);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/content.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/content.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,85 @@
+// Boost.Geometry Index
+//
+// n-dimensional box's content (hypervolume) - 2d area, 3d volume, ...
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template <typename Indexable>
+struct default_content_result
+{
+    typedef typename select_most_precise<
+        typename detail::traits::coordinate_type<Indexable>::type,
+        long double
+    >::type type;
+};
+
+namespace dispatch {
+
+template <typename Box, size_t CurrentDimension>
+struct content_for_each_dimension
+{
+    BOOST_STATIC_ASSERT(0 < CurrentDimension);
+    BOOST_STATIC_ASSERT(CurrentDimension <= traits::dimension<Box>::value);
+
+    static inline typename detail::default_content_result<Box>::type apply(Box const& b)
+    {
+        return content_for_each_dimension<Box, CurrentDimension - 1>::apply(b) *
+            ( detail::get<max_corner, CurrentDimension - 1>(b) - detail::get<min_corner, CurrentDimension - 1>(b) );
+    }
+};
+
+template <typename Box>
+struct content_for_each_dimension<Box, 1>
+{
+    static inline typename detail::default_content_result<Box>::type apply(Box const& b)
+    {
+        return detail::get<max_corner, 0>(b) - detail::get<min_corner, 0>(b);
+    }
+};
+
+template <typename Indexable, typename Tag>
+struct content
+{
+    // TODO: awulkiew - static assert?
+};
+
+template <typename Indexable>
+struct content<Indexable, point_tag>
+{
+    static typename detail::default_content_result<Indexable>::type apply(Indexable const&)
+    {
+        return 0;
+    }
+};
+
+template <typename Indexable>
+struct content<Indexable, box_tag>
+{
+    static typename default_content_result<Indexable>::type apply(Indexable const& b)
+    {
+        return dispatch::content_for_each_dimension<Indexable, detail::traits::dimension<Indexable>::value>::apply(b);
+    }
+};
+
+} // namespace dispatch
+
+template <typename Indexable>
+typename default_content_result<Indexable>::type content(Indexable const& b)
+{
+    return dispatch::content<Indexable,
+                             typename detail::traits::tag<Indexable>::type
+                            >::apply(b);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/diff_abs.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/diff_abs.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,24 @@
+// Boost.Geometry Index
+//
+// Abs of difference
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_DIFF_ABS_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_DIFF_ABS_HPP
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template <typename T>
+inline T diff_abs(T const& v1, T const& v2)
+{
+    return v1 < v2 ? v2 - v1 : v1 - v2;
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_DIFF_ABS_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/intersection_content.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/intersection_content.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,36 @@
+// Boost.Geometry Index
+//
+// boxes union/intersection area/volume
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
+
+#include <boost/geometry/algorithms/intersection.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+/**
+ * \brief Compute the area of the intersection of b1 and b2
+ */
+template <typename Box>
+inline typename default_content_result<Box>::type intersection_content(Box const& box1, Box const& box2)
+{
+    if ( geometry::intersects(box1, box2) )
+    {
+        Box box_intersection;
+        geometry::intersection(box1, box2, box_intersection);
+        return detail::content(box_intersection);
+    }
+    return 0;
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/margin.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/margin.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,99 @@
+// Boost.Geometry Index
+//
+// n-dimensional box's margin value (hypersurface), 2d perimeter, 3d surface, etc...
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_MARGIN_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_MARGIN_HPP
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template <typename Box>
+struct default_margin_result
+{
+    typedef typename select_most_precise<
+        typename coordinate_type<Box>::type,
+        long double
+    >::type type;
+};
+
+template <typename Box, size_t CurrentDimension, size_t EdgeDimension>
+struct margin_for_each_edge
+{
+    BOOST_STATIC_ASSERT(0 < CurrentDimension);
+    BOOST_STATIC_ASSERT(0 < EdgeDimension);
+
+    static inline typename default_margin_result<Box>::type apply(Box const& b)
+    {
+        return margin_for_each_edge<Box, CurrentDimension, EdgeDimension - 1>::apply(b) *
+            ( geometry::get<max_corner, EdgeDimension - 1>(b) - geometry::get<min_corner, EdgeDimension - 1>(b) );
+    }
+};
+
+template <typename Box, size_t CurrentDimension>
+struct margin_for_each_edge<Box, CurrentDimension, CurrentDimension>
+{
+    BOOST_STATIC_ASSERT(0 < CurrentDimension);
+
+    static inline typename default_margin_result<Box>::type apply(Box const& b)
+    {
+        return margin_for_each_edge<Box, CurrentDimension, CurrentDimension - 1>::apply(b);
+    }
+};
+
+template <typename Box, size_t CurrentDimension>
+struct margin_for_each_edge<Box, CurrentDimension, 1>
+{
+    BOOST_STATIC_ASSERT(0 < CurrentDimension);
+
+    static inline typename default_margin_result<Box>::type apply(Box const& b)
+    {
+        return geometry::get<max_corner, 0>(b) - geometry::get<min_corner, 0>(b);
+    }
+};
+
+template <typename Box>
+struct margin_for_each_edge<Box, 1, 1>
+{
+    static inline typename default_margin_result<Box>::type apply(Box const& /*b*/)
+    {
+        return 1;
+    }
+};
+
+template <typename Box, size_t CurrentDimension>
+struct margin_for_each_dimension
+{
+    BOOST_STATIC_ASSERT(0 < CurrentDimension);
+    BOOST_STATIC_ASSERT(CurrentDimension <= detail::traits::dimension<Box>::value);
+
+    static inline typename default_margin_result<Box>::type apply(Box const& b)
+    {
+        return margin_for_each_dimension<Box, CurrentDimension - 1>::apply(b) +
+            margin_for_each_edge<Box, CurrentDimension, detail::traits::dimension<Box>::value>::apply(b);
+    }
+};
+
+template <typename Box>
+struct margin_for_each_dimension<Box, 1>
+{
+    static inline typename default_margin_result<Box>::type apply(Box const& b)
+    {
+        return margin_for_each_edge<Box, 1, detail::traits::dimension<Box>::value>::apply(b);
+    }
+};
+
+template <typename Box>
+typename default_margin_result<Box>::type margin(Box const& b)
+{
+    return 2 * detail::margin_for_each_dimension<Box, detail::traits::dimension<Box>::value>::apply(b);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_MARGIN_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/minmaxdist.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/minmaxdist.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,119 @@
+// Boost.Geometry Index
+//
+// minmaxdist used in R-tree k nearest neighbors query
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_MINMAXDIST_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_MINMAXDIST_HPP
+
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/comparable_distance.hpp>
+
+#include <boost/geometry/extensions/index/detail/algorithms/diff_abs.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/smallest_for_indexable.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+struct minmaxdist_tag {};
+
+template <
+    typename Point,
+    typename BoxIndexable,
+    size_t DimensionIndex>
+struct smallest_for_indexable_dimension<Point, BoxIndexable, box_tag, minmaxdist_tag, DimensionIndex>
+{
+    typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, BoxIndexable const& i, result_type const& maxd)
+    {
+        typedef typename index::traits::coordinate_type<Point>::type point_coord_t;
+        typedef typename index::traits::coordinate_type<BoxIndexable>::type indexable_coord_t;
+
+        point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
+        indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
+        indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
+
+        indexable_coord_t ind_c_avg = ind_c_min + (ind_c_max - ind_c_min) / 2;
+        // TODO: awulkiew - is (ind_c_min + ind_c_max) / 2 safe?
+
+        // TODO: awulkiew - optimize! don't calculate 2x pt_c <= ind_c_avg
+        // take particular case pt_c == ind_c_avg into account
+
+        result_type closer_comp = 0;
+        if ( pt_c <= ind_c_avg )
+            closer_comp = detail::diff_abs(pt_c, ind_c_min); // unsigned values protection
+        else
+            closer_comp = ind_c_max - pt_c;
+        
+        result_type further_comp = 0;
+        if ( ind_c_avg <= pt_c )
+            further_comp = pt_c - ind_c_min;
+        else
+            further_comp = detail::diff_abs(pt_c, ind_c_max); // unsigned values protection
+
+        return (maxd + closer_comp * closer_comp) - further_comp * further_comp;
+    }
+};
+
+template <typename Point, typename Indexable, typename IndexableTag>
+struct minmaxdist_impl
+{
+    BOOST_MPL_ASSERT_MSG(
+        (false),
+        NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE,
+        (minmaxdist_impl));
+};
+
+template <typename Point, typename Indexable>
+struct minmaxdist_impl<Point, Indexable, point_tag>
+{
+    typedef typename geometry::default_distance_result<Point, Indexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, Indexable const& i)
+    {
+        return geometry::comparable_distance(pt, i);
+    }
+};
+
+template <typename Point, typename Indexable>
+struct minmaxdist_impl<Point, Indexable, box_tag>
+{
+    typedef typename geometry::default_distance_result<Point, Indexable>::type result_type;
+
+    inline static result_type apply(Point const& pt, Indexable const& i)
+    {
+        result_type maxd = geometry::comparable_distance(pt, i);
+
+        return smallest_for_indexable<
+            Point,
+            Indexable,
+            box_tag,
+            minmaxdist_tag,
+            index::traits::dimension<Indexable>::value
+        >::apply(pt, i, maxd);
+    }
+};
+
+/**
+ * This is comparable distace.
+ */
+template <typename Point, typename Indexable>
+typename geometry::default_distance_result<Point, Indexable>::type
+minmaxdist(Point const& pt, Indexable const& i)
+{
+    return detail::minmaxdist_impl<
+        Point,
+        Indexable,
+        typename index::traits::tag<Indexable>::type
+    >::apply(pt, i);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_MINMAXDIST_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/smallest_for_indexable.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/smallest_for_indexable.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,80 @@
+// Boost.Geometry Index
+//
+// Get smallest value calculated for indexable's dimensions, used in R-tree k nearest neighbors query
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SMALLEST_FOR_INDEXABLE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SMALLEST_FOR_INDEXABLE_HPP
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template <
+    typename Geometry,
+    typename Indexable,
+    typename IndexableTag,
+    typename AlgoTag,
+    size_t DimensionIndex>
+struct smallest_for_indexable_dimension
+{
+    BOOST_MPL_ASSERT_MSG(
+        (false),
+        NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE,
+        (smallest_for_indexable_dimension));
+};
+
+template <
+    typename Geometry,
+    typename Indexable,
+    typename IndexableTag,
+    typename AlgoTag,
+    size_t N>
+struct smallest_for_indexable
+{
+    typedef typename smallest_for_indexable_dimension<
+        Geometry, Indexable, IndexableTag, AlgoTag, N - 1
+    >::result_type result_type;
+
+    template <typename Data>
+    inline static result_type apply(Geometry const& g, Indexable const& i, Data const& data)
+    {
+        result_type r1 = smallest_for_indexable<
+            Geometry, Indexable, IndexableTag, AlgoTag, N - 1
+        >::apply(g, i, data);
+
+        result_type r2 = smallest_for_indexable_dimension<
+            Geometry, Indexable, IndexableTag, AlgoTag, N - 1
+        >::apply(g, i, data);
+
+        return r1 < r2 ? r1 : r2;
+    }
+};
+
+template <
+    typename Geometry,
+    typename Indexable,
+    typename IndexableTag,
+    typename AlgoTag>
+struct smallest_for_indexable<Geometry, Indexable, IndexableTag, AlgoTag, 1>
+{
+    typedef typename smallest_for_indexable_dimension<
+        Geometry, Indexable, IndexableTag, AlgoTag, 0
+    >::result_type result_type;
+
+    template <typename Data>
+    inline static result_type apply(Geometry const& g, Indexable const& i, Data const& data)
+    {
+        return
+            smallest_for_indexable_dimension<
+                Geometry, Indexable, IndexableTag, AlgoTag, 0
+            >::apply(g, i, data);
+    }
+};
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SMALLEST_FOR_INDEXABLE_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/sum_for_indexable.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,76 @@
+// Boost.Geometry Index
+//
+// Sum values calculated for indexable's dimensions, used e.g. in R-tree k nearest neighbors query
+//
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SUM_FOR_INDEXABLE_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SUM_FOR_INDEXABLE_HPP
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+template <
+    typename Geometry,
+    typename Indexable,
+    typename IndexableTag,
+    typename AlgoTag,
+    size_t DimensionIndex>
+struct sum_for_indexable_dimension
+{
+    BOOST_MPL_ASSERT_MSG(
+        (false),
+        NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE,
+        (sum_for_indexable_dimension));
+};
+
+template <
+    typename Geometry,
+    typename Indexable,
+    typename IndexableTag,
+    typename AlgoTag,
+    size_t N>
+struct sum_for_indexable
+{
+    typedef typename sum_for_indexable_dimension<
+        Geometry, Indexable, IndexableTag, AlgoTag, N - 1
+    >::result_type result_type;
+
+    inline static result_type apply(Geometry const& g, Indexable const& i)
+    {
+        return
+            sum_for_indexable<
+                Geometry, Indexable, IndexableTag, AlgoTag, N - 1
+            >::apply(g, i) +
+            sum_for_indexable_dimension<
+                Geometry, Indexable, IndexableTag, AlgoTag, N - 1
+            >::apply(g, i);
+    }
+};
+
+template <
+    typename Geometry,
+    typename Indexable,
+    typename IndexableTag,
+    typename AlgoTag>
+struct sum_for_indexable<Geometry, Indexable, IndexableTag, AlgoTag, 1>
+{
+    typedef typename sum_for_indexable_dimension<
+        Geometry, Indexable, IndexableTag, AlgoTag, 0
+    >::result_type result_type;
+
+    inline static result_type apply(Geometry const& g, Indexable const& i)
+    {
+        return
+            sum_for_indexable_dimension<
+                Geometry, Indexable, IndexableTag, AlgoTag, 0
+            >::apply(g, i);
+    }
+};
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_ALGORITHMS_DETAIL_SUM_FOR_INDEXABLE_HPP
Added: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/union_content.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/algorithms/union_content.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -0,0 +1,33 @@
+// Boost.Geometry Index
+//
+// boxes union/sum area/volume
+//
+// Copyright (c) 2008 Federico J. Fernandez.
+// Copyright (c) 2011-2012 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_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_UNION_CONTENT_HPP
+#define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_UNION_CONTENT_HPP
+
+#include <boost/geometry/algorithms/expand.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
+
+namespace boost { namespace geometry { namespace index { namespace detail {
+
+/**
+ * \brief Compute the area of the union of b1 and b2
+ */
+template <typename Box, typename Geometry>
+inline typename default_content_result<Box>::type union_content(Box const& b, Geometry const& g)
+{
+    Box expanded_box(b);
+    geometry::expand(expanded_box, g);
+    return detail::content(expanded_box);
+}
+
+}}}} // namespace boost::geometry::index::detail
+
+#endif // BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_ALGORITHMS_UNION_CONTENT_HPP
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/distance_predicates.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/distance_predicates.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/distance_predicates.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -12,9 +12,9 @@
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_DISTANCE_PREDICATES_HPP
 #define BOOST_GEOMETRY_EXTENSIONS_INDEX_DETAIL_DISTANCE_PREDICATES_HPP
 
-#include <boost/geometry/extensions/index/algorithms/comparable_distance_near.hpp>
-#include <boost/geometry/extensions/index/algorithms/comparable_distance_far.hpp>
-#include <boost/geometry/extensions/index/algorithms/comparable_distance_centroid.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/comparable_distance_near.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/comparable_distance_far.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/comparable_distance_centroid.hpp>
 
 #include <boost/geometry/extensions/index/detail/tuples.hpp>
 
@@ -332,7 +332,7 @@
     typename geometry::default_distance_result<Point, Indexable>::type
     static inline apply(Point const& p, Indexable const& i)
     {
-        return index::comparable_distance_near(p, i);
+        return index::detail::comparable_distance_near(p, i);
     }
 };
 
@@ -345,7 +345,7 @@
     typename geometry::default_distance_result<Point, Indexable>::type
     static inline apply(Point const& p, Indexable const& i)
     {
-        return index::comparable_distance_centroid(p, i);
+        return index::detail::comparable_distance_centroid(p, i);
     }
 };
 
@@ -358,7 +358,7 @@
     typename geometry::default_distance_result<Point, Indexable>::type
     static inline apply(Point const& p, Indexable const& i)
     {
-        return index::comparable_distance_far(p, i);
+        return index::detail::comparable_distance_far(p, i);
     }
 };
 
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/linear/redistribute_elements.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/linear/redistribute_elements.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/linear/redistribute_elements.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -14,8 +14,7 @@
 
 #include <boost/type_traits/is_unsigned.hpp>
 
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
-#include <boost/geometry/extensions/index/algorithms/union_content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
 
 #include <boost/geometry/extensions/index/detail/rtree/node/node.hpp>
 #include <boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp>
@@ -23,9 +22,7 @@
 
 namespace boost { namespace geometry { namespace index {
 
-namespace detail { namespace rtree { namespace visitors {
-
-namespace detail {
+namespace detail { namespace rtree {
 
 namespace linear {
 
@@ -215,7 +212,7 @@
         typedef typename elements_type::value_type element_type;
         typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
         typedef typename index::detail::traits::coordinate_type<indexable_type>::type coordinate_type;
-        typedef typename index::default_content_result<Box>::type content_type;
+        typedef typename index::detail::default_content_result<Box>::type content_type;
 
         elements_type & elements1 = rtree::elements(n);
         elements_type & elements2 = rtree::elements(second_node);
@@ -250,8 +247,8 @@
             geometry::convert(rtree::element_indexable(elements_copy[seed2], translator), box2);
 
             // initialize areas
-            content_type content1 = index::content(box1);
-            content_type content2 = index::content(box2);
+            content_type content1 = index::detail::content(box1);
+            content_type content2 = index::detail::content(box2);
 
             BOOST_GEOMETRY_INDEX_ASSERT(2 <= elements1_count, "unexpected elements number");
             size_t remaining = elements1_count - 2;
@@ -270,13 +267,13 @@
                     {
                         elements1.push_back(elem);                                                          // MAY THROW, STRONG (copy)
                         geometry::expand(box1, indexable);
-                        content1 = index::content(box1);
+                        content1 = index::detail::content(box1);
                     }
                     else if ( elements2.size() + remaining <= parameters.get_min_elements() )
                     {
                         elements2.push_back(elem);                                                          // MAY THROW, STRONG (alloc, copy)
                         geometry::expand(box2, indexable);
-                        content2 = index::content(box2);
+                        content2 = index::detail::content(box2);
                     }
                     // choose better node and insert element
                     else
@@ -286,8 +283,8 @@
                         Box enlarged_box2(box2);
                         geometry::expand(enlarged_box1, indexable);
                         geometry::expand(enlarged_box2, indexable);
-                        content_type enlarged_content1 = index::content(enlarged_box1);
-                        content_type enlarged_content2 = index::content(enlarged_box2);
+                        content_type enlarged_content1 = index::detail::content(enlarged_box1);
+                        content_type enlarged_content2 = index::detail::content(enlarged_box2);
 
                         content_type content_increase1 = enlarged_content1 - content1;
                         content_type content_increase2 = enlarged_content2 - content2;
@@ -327,9 +324,7 @@
     }
 };
 
-} // namespace detail
-
-}}} // namespace detail::rtree::visitors
+}} // namespace detail::rtree::visitors
 
 }}} // namespace boost::geometry::index
 
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/options.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/options.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/options.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -58,10 +58,10 @@
 };
 
 template <size_t MaxElements, size_t MinElements>
-struct options_type< linear<MaxElements, MinElements> >
+struct options_type< index::linear<MaxElements, MinElements> >
 {
     typedef options<
-        linear<MaxElements, MinElements>,
+        index::linear<MaxElements, MinElements>,
         insert_default_tag,
         choose_by_content_diff_tag,
         split_default_tag,
@@ -71,10 +71,10 @@
 };
 
 template <size_t MaxElements, size_t MinElements>
-struct options_type< quadratic<MaxElements, MinElements> >
+struct options_type< index::quadratic<MaxElements, MinElements> >
 {
     typedef options<
-        quadratic<MaxElements, MinElements>,
+        index::quadratic<MaxElements, MinElements>,
         insert_default_tag,
         choose_by_content_diff_tag,
         split_default_tag,
@@ -84,10 +84,10 @@
 };
 
 template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold, size_t ReinsertedElements>
-struct options_type< rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
+struct options_type< index::rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
 {
     typedef options<
-        rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
+        index::rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
         insert_reinsert_tag,
         choose_by_overlap_diff_tag,
         split_default_tag,
@@ -110,10 +110,10 @@
 //};
 
 template <>
-struct options_type< runtime::linear >
+struct options_type< index::runtime::linear >
 {
     typedef options<
-        runtime::linear,
+        index::runtime::linear,
         insert_default_tag,
         choose_by_content_diff_tag,
         split_default_tag,
@@ -123,10 +123,10 @@
 };
 
 template <>
-struct options_type< runtime::quadratic >
+struct options_type< index::runtime::quadratic >
 {
     typedef options<
-        runtime::quadratic,
+        index::runtime::quadratic,
         insert_default_tag,
         choose_by_content_diff_tag,
         split_default_tag,
@@ -136,10 +136,10 @@
 };
 
 template <>
-struct options_type< runtime::rstar >
+struct options_type< index::runtime::rstar >
 {
     typedef options<
-        runtime::rstar,
+        index::runtime::rstar,
         insert_reinsert_tag,
         choose_by_overlap_diff_tag,
         split_default_tag,
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/quadratic/redistribute_elements.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/quadratic/redistribute_elements.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/quadratic/redistribute_elements.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -13,8 +13,8 @@
 
 #include <algorithm>
 
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
-#include <boost/geometry/extensions/index/algorithms/union_content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/union_content.hpp>
 
 #include <boost/geometry/extensions/index/detail/rtree/node/node.hpp>
 #include <boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp>
@@ -22,9 +22,7 @@
 
 namespace boost { namespace geometry { namespace index {
 
-namespace detail { namespace rtree { namespace visitors {
-
-namespace detail {
+namespace detail { namespace rtree {
 
 namespace quadratic {
 
@@ -35,7 +33,7 @@
     typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
     typedef typename index::detail::traits::coordinate_type<indexable_type>::type coordinate_type;
     typedef Box box_type;
-    typedef typename index::default_content_result<box_type>::type content_type;
+    typedef typename index::detail::default_content_result<box_type>::type content_type;
 
     static inline void apply(Elements const& elements,
                              Parameters const& parameters,
@@ -62,7 +60,7 @@
                 geometry::convert(ind1, enlarged_box);
                 geometry::expand(enlarged_box, ind2);
 
-                content_type free_content = (index::content(enlarged_box) - index::content(ind1)) - index::content(ind2);
+                content_type free_content = (index::detail::content(enlarged_box) - index::detail::content(ind1)) - index::detail::content(ind2);
                 
                 if ( greatest_free_content < free_content )
                 {
@@ -86,7 +84,7 @@
     typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
     typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
 
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Node>
     static inline void apply(Node & n,
@@ -153,8 +151,8 @@
             }
 
             // initialize areas
-            content_type content1 = index::content(box1);
-            content_type content2 = index::content(box2);
+            content_type content1 = index::detail::content(box1);
+            content_type content2 = index::detail::content(box2);
 
             size_t remaining = elements_copy.size();
 
@@ -207,13 +205,13 @@
                 {
                     elements1.push_back(elem);                                                              // MAY THROW, STRONG (copy)
                     geometry::expand(box1, indexable);
-                    content1 = index::content(box1);
+                    content1 = index::detail::content(box1);
                 }
                 else
                 {
                     elements2.push_back(elem);                                                              // MAY THROW, STRONG (alloc, copy)
                     geometry::expand(box2, indexable);
-                    content2 = index::content(box2);
+                    content2 = index::detail::content(box2);
                 }
 
                 BOOST_GEOMETRY_INDEX_ASSERT(!elements_copy.empty(), "expected more elements");
@@ -265,8 +263,8 @@
             Box enlarged_box2(box2);
             geometry::expand(enlarged_box1, indexable);
             geometry::expand(enlarged_box2, indexable);
-            content_type enlarged_content1 = index::content(enlarged_box1);
-            content_type enlarged_content2 = index::content(enlarged_box2);
+            content_type enlarged_content1 = index::detail::content(enlarged_box1);
+            content_type enlarged_content2 = index::detail::content(enlarged_box2);
 
             content_type content_incrase1 = (enlarged_content1 - content1);
             content_type content_incrase2 = (enlarged_content2 - content2);
@@ -287,9 +285,7 @@
     }
 };
 
-} // namespace detail
-
-}}} // namespace detail::rtree::visitors
+}} // namespace detail::rtree
 
 }}} // namespace boost::geometry::index
 
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/choose_next_node.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/choose_next_node.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/choose_next_node.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -15,18 +15,16 @@
 
 #include <boost/geometry/algorithms/expand.hpp>
 
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
-#include <boost/geometry/extensions/index/algorithms/intersection_content.hpp>
-#include <boost/geometry/extensions/index/algorithms/union_content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/intersection_content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/union_content.hpp>
 
 #include <boost/geometry/extensions/index/detail/rtree/node/node.hpp>
 #include <boost/geometry/extensions/index/detail/rtree/visitors/is_leaf.hpp>
 
 namespace boost { namespace geometry { namespace index {
 
-namespace detail { namespace rtree { namespace visitors {
-
-namespace detail {
+namespace detail { namespace rtree {
 
 template <typename Value, typename Options, typename Box, typename Allocators>
 class choose_next_node<Value, Options, Box, Allocators, choose_by_overlap_diff_tag>
@@ -40,7 +38,7 @@
 
     typedef typename Options::parameters_type parameters_type;
 
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
 public:
     template <typename Indexable>
@@ -88,8 +86,8 @@
             geometry::expand(box_exp, indexable);
 
             // calculate content and content diff
-            content_type content = index::content(ch_i.first);
-            content_type content_diff = index::content(box_exp) - content;
+            content_type content = index::detail::content(ch_i.first);
+            content_type content_diff = index::detail::content(box_exp) - content;
 
             content_type overlap = 0;
             content_type overlap_exp = 0;
@@ -101,8 +99,8 @@
                 {
                     child_type const& ch_j = children[j];
 
-                    overlap += index::intersection_content(ch_i.first, ch_j.first);
-                    overlap_exp += index::intersection_content(box_exp, ch_j.first);
+                    overlap += index::detail::intersection_content(ch_i.first, ch_j.first);
+                    overlap_exp += index::detail::intersection_content(box_exp, ch_j.first);
                 }
             }
 
@@ -141,8 +139,8 @@
             geometry::expand(box_exp, indexable);
 
             // areas difference
-            content_type content = index::content(box_exp);
-            content_type content_diff = content - index::content(ch_i.first);
+            content_type content = index::detail::content(box_exp);
+            content_type content_diff = content - index::detail::content(ch_i.first);
 
             sorted_children[i] = boost::make_tuple(i, content_diff, content);
         }
@@ -178,8 +176,8 @@
                 {
                     child_type const& ch_j = children[j];
 
-                    overlap += index::intersection_content(ch_i.first, ch_j.first);
-                    overlap_exp += index::intersection_content(box_exp, ch_j.first);
+                    overlap += index::detail::intersection_content(ch_i.first, ch_j.first);
+                    overlap_exp += index::detail::intersection_content(box_exp, ch_j.first);
                 }
             }
 
@@ -222,8 +220,8 @@
             geometry::expand(box_exp, indexable);
 
             // areas difference
-            content_type content = index::content(box_exp);
-            content_type content_diff = content - index::content(ch_i.first);
+            content_type content = index::detail::content(box_exp);
+            content_type content_diff = content - index::detail::content(ch_i.first);
 
             // update the result
             if ( content_diff < smallest_content_diff ||
@@ -239,9 +237,7 @@
     }
 };
 
-} // namespace detail
-
-}}} // namespace detail::rtree::visitors
+}} // namespace detail::rtree
 
 }}} // namespace boost::geometry::index
 
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/insert.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/insert.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/insert.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -11,14 +11,12 @@
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RSTAR_INSERT_HPP
 #define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_RSTAR_INSERT_HPP
 
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
 
 namespace boost { namespace geometry { namespace index {
 
 namespace detail { namespace rtree { namespace visitors {
 
-namespace detail {
-
 namespace rstar {
 
 template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
@@ -417,8 +415,6 @@
 
 } // namespace rstar
 
-} // namespace detail
-
 // R*-tree insert visitor
 // After passing the Element to insert visitor the Element is managed by the tree
 // I.e. one should not delete the node passed to the insert visitor after exception is thrown
@@ -451,7 +447,7 @@
     {
         BOOST_GEOMETRY_INDEX_ASSERT(&n == rtree::get<internal_node>(m_root), "current node should be the root");
 
-        detail::rstar::level_insert<0, Element, Value, Options, Translator, Box, Allocators> lins_v(
+        rstar::level_insert<0, Element, Value, Options, Translator, Box, Allocators> lins_v(
             m_root, m_leafs_level, m_element, m_parameters, m_translator, m_allocators, m_relative_level);
 
         rtree::apply_visitor(lins_v, *m_root);                                                              // MAY THROW (V, E: alloc, copy, N: alloc)
@@ -466,7 +462,7 @@
     {
         BOOST_GEOMETRY_INDEX_ASSERT(&n == rtree::get<leaf>(m_root), "current node should be the root");
 
-        detail::rstar::level_insert<0, Element, Value, Options, Translator, Box, Allocators> lins_v(
+        rstar::level_insert<0, Element, Value, Options, Translator, Box, Allocators> lins_v(
             m_root, m_leafs_level, m_element, m_parameters, m_translator, m_allocators, m_relative_level);
 
         rtree::apply_visitor(lins_v, *m_root);                                                              // MAY THROW (V, E: alloc, copy, N: alloc)
@@ -485,7 +481,7 @@
         typename Elements::reverse_iterator it = elements.rbegin();
         for ( ; it != elements.rend() ; ++it)
         {
-            detail::rstar::level_insert<1, element_type, Value, Options, Translator, Box, Allocators> lins_v(
+            rstar::level_insert<1, element_type, Value, Options, Translator, Box, Allocators> lins_v(
                 m_root, m_leafs_level, *it, m_parameters, m_translator, m_allocators, relative_level);
 
             try
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/redistribute_elements.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/redistribute_elements.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/rstar/redistribute_elements.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -13,9 +13,9 @@
 
 #include <boost/geometry/extensions/index/detail/nonassignable.hpp>
 
-#include <boost/geometry/extensions/index/algorithms/intersection_content.hpp>
-#include <boost/geometry/extensions/index/algorithms/union_content.hpp>
-#include <boost/geometry/extensions/index/algorithms/margin.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/intersection_content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/union_content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/margin.hpp>
 
 #include <boost/geometry/extensions/index/detail/rtree/node/node.hpp>
 #include <boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp>
@@ -23,9 +23,7 @@
 
 namespace boost { namespace geometry { namespace index {
 
-namespace detail { namespace rtree { namespace visitors {
-
-namespace detail {
+namespace detail { namespace rtree {
 
 namespace rstar {
 
@@ -51,8 +49,8 @@
 template <typename Parameters, typename Box, size_t Corner, size_t AxisIndex>
 struct choose_split_axis_and_index_for_corner
 {
-    typedef typename index::default_margin_result<Box>::type margin_type;
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_margin_result<Box>::type margin_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Elements, typename Translator>
     static inline void apply(Elements const& elements,
@@ -90,10 +88,10 @@
             Box box1 = rtree::elements_box<Box>(elements_copy.begin(), elements_copy.begin() + i, translator);
             Box box2 = rtree::elements_box<Box>(elements_copy.begin() + i, elements_copy.end(), translator);
             
-            sum_of_margins += index::margin(box1) + index::margin(box2);
+            sum_of_margins += index::detail::margin(box1) + index::detail::margin(box2);
 
-            content_type ovl = index::intersection_content(box1, box2);
-            content_type con = index::content(box1) + index::content(box2);
+            content_type ovl = index::detail::intersection_content(box1, box2);
+            content_type con = index::detail::content(box1) + index::detail::content(box2);
 
             if ( ovl < smallest_overlap || (ovl == smallest_overlap && con <= smallest_content) )
             {
@@ -114,8 +112,8 @@
 template <typename Parameters, typename Box, size_t AxisIndex>
 struct choose_split_axis_and_index_for_axis<Parameters, Box, AxisIndex, box_tag>
 {
-    typedef typename index::default_margin_result<Box>::type margin_type;
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_margin_result<Box>::type margin_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Elements, typename Translator>
     static inline void apply(Elements const& elements,
@@ -169,8 +167,8 @@
 template <typename Parameters, typename Box, size_t AxisIndex>
 struct choose_split_axis_and_index_for_axis<Parameters, Box, AxisIndex, point_tag>
 {
-    typedef typename index::default_margin_result<Box>::type margin_type;
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_margin_result<Box>::type margin_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Elements, typename Translator>
     static inline void apply(Elements const& elements,
@@ -196,8 +194,8 @@
 {
     BOOST_STATIC_ASSERT(0 < Dimension);
 
-    typedef typename index::default_margin_result<Box>::type margin_type;
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_margin_result<Box>::type margin_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Elements, typename Translator>
     static inline void apply(Elements const& elements,
@@ -247,8 +245,8 @@
 template <typename Parameters, typename Box>
 struct choose_split_axis_and_index<Parameters, Box, 1>
 {
-    typedef typename index::default_margin_result<Box>::type margin_type;
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_margin_result<Box>::type margin_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Elements, typename Translator>
     static inline void apply(Elements const& elements,
@@ -327,8 +325,8 @@
 
     static const size_t dimension = index::detail::traits::dimension<Box>::value;
 
-    typedef typename index::default_margin_result<Box>::type margin_type;
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_margin_result<Box>::type margin_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Node>
     static inline void apply(
@@ -403,9 +401,7 @@
     }
 };
 
-} // namespace detail
-
-}}} // namespace detail::rtree::visitors
+}} // namespace detail::rtree
 
 }}} // namespace boost::geometry::index
 
Modified: sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp
==============================================================================
--- sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp	(original)
+++ sandbox-branches/geometry/index/boost/geometry/extensions/index/detail/rtree/visitors/insert.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -11,15 +11,13 @@
 #ifndef BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_INSERT_HPP
 #define BOOST_GEOMETRY_EXTENSIONS_INDEX_RTREE_VISITORS_INSERT_HPP
 
-#include <boost/geometry/extensions/index/algorithms/content.hpp>
+#include <boost/geometry/extensions/index/detail/algorithms/content.hpp>
 
 #include <boost/geometry/extensions/index/detail/rtree/node/node.hpp>
 
 namespace boost { namespace geometry { namespace index {
 
-namespace detail { namespace rtree { namespace visitors {
-
-namespace detail {
+namespace detail { namespace rtree {
 
 // Default choose_next_node
 template <typename Value, typename Options, typename Box, typename Allocators, typename ChooseNextNodeTag>
@@ -37,7 +35,7 @@
 
     typedef typename rtree::elements_type<internal_node>::type children_type;
 
-    typedef typename index::default_content_result<Box>::type content_type;
+    typedef typename index::detail::default_content_result<Box>::type content_type;
 
     template <typename Indexable>
     static inline size_t apply(internal_node & n,
@@ -67,8 +65,8 @@
             geometry::expand(box_exp, indexable);
 
             // areas difference
-            content_type content = index::content(box_exp);
-            content_type content_diff = content - index::content(ch_i.first);
+            content_type content = index::detail::content(box_exp);
+            content_type content_diff = content - index::detail::content(ch_i.first);
 
             // update the result
             if ( content_diff < smallest_content_diff ||
@@ -177,6 +175,8 @@
 
 // ----------------------------------------------------------------------- //
 
+namespace visitors { namespace detail {
+
 template <typename InternalNode>
 struct insert_traverse_data
 {
@@ -260,7 +260,7 @@
     inline void traverse(Visitor & visitor, internal_node & n)
     {
         // choose next node
-        size_t choosen_node_index = detail::choose_next_node<Value, Options, Box, Allocators, typename Options::choose_next_node_tag>::
+        size_t choosen_node_index = rtree::choose_next_node<Value, Options, Box, Allocators, typename Options::choose_next_node_tag>::
             apply(n, rtree::element_indexable(m_element, m_translator), m_parameters, m_leafs_level - m_traverse_data.current_level);
 
         // expand the node to contain value
@@ -309,7 +309,7 @@
     template <typename Node>
     inline void split(Node & n) const
     {
-        typedef detail::split<Value, Options, Translator, Box, Allocators, typename Options::split_tag> split_algo;
+        typedef rtree::split<Value, Options, Translator, Box, Allocators, typename Options::split_tag> split_algo;
 
         typename split_algo::nodes_container_type additional_nodes;
         Box n_box;
Modified: sandbox-branches/geometry/index/test/rtree/test_rtree.hpp
==============================================================================
--- sandbox-branches/geometry/index/test/rtree/test_rtree.hpp	(original)
+++ sandbox-branches/geometry/index/test/rtree/test_rtree.hpp	2013-01-18 20:15:55 EST (Fri, 18 Jan 2013)
@@ -746,7 +746,7 @@
     Value expected_output(generate_value_default<Value>::apply());
     BOOST_FOREACH(Value const& v, input)
     {
-        D d = bgi::comparable_distance_near(pt, rtree.translator()(v));
+        D d = bgi::detail::comparable_distance_near(pt, rtree.translator()(v));
         if ( d < smallest_d )
         {
             smallest_d = d;
@@ -766,8 +766,8 @@
 
         if ( !rtree.translator().equals(output, expected_output) )
         {
-            D d1 = bgi::comparable_distance_near(pt, rtree.translator()(output));
-            D d2 = bgi::comparable_distance_near(pt, rtree.translator()(expected_output));
+            D d1 = bgi::detail::comparable_distance_near(pt, rtree.translator()(output));
+            D d2 = bgi::detail::comparable_distance_near(pt, rtree.translator()(expected_output));
             BOOST_CHECK(d1 == d2);
         }
     }
@@ -810,7 +810,7 @@
     // calculate test output - k closest values pairs
     BOOST_FOREACH(Value const& v, input)
     {
-        D d = bgi::comparable_distance_near(pt, rtree.translator()(v));
+        D d = bgi::detail::comparable_distance_near(pt, rtree.translator()(v));
 
         if ( test_output.size() < k )
             test_output.push_back(std::make_pair(d, v));
@@ -848,7 +848,7 @@
 
             if ( test_find(rtree, expected_output.begin(), expected_output.end(), v) == expected_output.end() )
             {
-                D d = bgi::comparable_distance_near(pt, rtree.translator()(v));
+                D d = bgi::detail::comparable_distance_near(pt, rtree.translator()(v));
                 BOOST_CHECK(d == biggest_d);
             }
         }