diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp index 841876eb3..c4e44cae1 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp @@ -2,7 +2,7 @@ // // squared distance between point and centroid of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -24,7 +24,7 @@ template < size_t N> struct sum_for_indexable { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, PointIndexable const& i) { @@ -38,7 +38,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -59,7 +59,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_centroid(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp index 07dfcfc0f..214fbf6aa 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp @@ -2,7 +2,7 @@ // // squared distance between point and furthest point of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -26,7 +26,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -49,7 +49,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_far(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp index 5584bf85e..15368a7d2 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp @@ -2,7 +2,7 @@ // // squared distance between point and nearest point of the box or point // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -23,7 +23,7 @@ template < size_t N> struct sum_for_indexable { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, PointIndexable const& i) { @@ -37,7 +37,7 @@ template < size_t DimensionIndex> struct sum_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i) { @@ -60,7 +60,7 @@ struct sum_for_indexable_dimension -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type comparable_distance_near(Point const& pt, Indexable const& i) { return detail::sum_for_indexable< diff --git a/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp b/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp index 680fb202b..ab6291504 100644 --- a/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp +++ b/include/boost/geometry/index/detail/algorithms/minmaxdist.hpp @@ -2,7 +2,7 @@ // // minmaxdist used in R-tree k nearest neighbors query // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -28,7 +28,7 @@ template < size_t DimensionIndex> struct smallest_for_indexable_dimension { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, BoxIndexable const& i, result_type const& maxd) { @@ -73,7 +73,7 @@ struct minmaxdist_impl template struct minmaxdist_impl { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, Indexable const& i) { @@ -84,7 +84,7 @@ struct minmaxdist_impl template struct minmaxdist_impl { - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; inline static result_type apply(Point const& pt, Indexable const& i) { @@ -104,7 +104,7 @@ struct minmaxdist_impl * This is comparable distace. */ template -typename geometry::default_distance_result::type +typename geometry::default_comparable_distance_result::type minmaxdist(Point const& pt, Indexable const& i) { return detail::minmaxdist_impl< diff --git a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp index a9e0f3dcb..fe92596ba 100644 --- a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp @@ -2,7 +2,7 @@ // // n-dimensional box-linestring intersection // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -23,6 +23,11 @@ struct path_intersection BOOST_MPL_ASSERT_MSG((false), NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_OR_INDEXABLE, (path_intersection)); }; +// TODO: FP type must be used as a relative distance type! +// and default_distance_result can be some user-defined int type +// BUT! This code is experimental and probably won't be released at all +// since more flexible user-defined-nearest predicate should be added instead + template struct path_intersection { diff --git a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp index a6ad30181..ec7a88f49 100644 --- a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp @@ -2,7 +2,7 @@ // // n-dimensional box-segment intersection // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -110,6 +110,9 @@ struct segment_intersection template static inline bool apply(Indexable const& b, Point const& p0, Point const& p1, RelativeDistance & relative_distance) { + +// TODO: this ASSERT CHECK is wrong for user-defined CoordinateTypes! + static const bool check = !::boost::is_integral::value; BOOST_MPL_ASSERT_MSG(check, RELATIVE_DISTANCE_MUST_BE_FLOATING_POINT_TYPE, (RelativeDistance)); diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index a8980cc41..3e057290a 100644 --- a/include/boost/geometry/index/detail/distance_predicates.hpp +++ b/include/boost/geometry/index/detail/distance_predicates.hpp @@ -3,7 +3,7 @@ // Spatial index distance predicates, calculators and checkers // used in nearest query - specialized for envelopes // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -108,7 +108,7 @@ struct calculate_distance< nearest, Indexable, Tag > { typedef detail::relation relation; typedef typename relation::value_type point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest const& p, Indexable const& i, result_type & result) { @@ -121,7 +121,7 @@ template struct calculate_distance< nearest< to_centroid >, Indexable, value_tag> { typedef Point point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest< to_centroid > const& p, Indexable const& i, result_type & result) { @@ -134,7 +134,7 @@ template struct calculate_distance< nearest< to_furthest >, Indexable, value_tag> { typedef Point point_type; - typedef typename geometry::default_distance_result::type result_type; + typedef typename geometry::default_comparable_distance_result::type result_type; static inline bool apply(nearest< to_furthest > const& p, Indexable const& i, result_type & result) { diff --git a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp index 37bc31efa..c903d6ca2 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp @@ -2,7 +2,7 @@ // // R-tree R*-tree insert algorithm implementation // -// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2011-2014 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 @@ -45,7 +45,9 @@ public: typedef typename elements_type::value_type element_type; typedef typename geometry::point_type::type point_type; // TODO: awulkiew - change second point_type to the point type of the Indexable? - typedef typename geometry::default_distance_result::type distance_type; + typedef typename + geometry::default_comparable_distance_result::type + comparable_distance_type; elements_type & elements = rtree::elements(n); @@ -63,8 +65,9 @@ public: // fill the container of centers' distances of children from current node's center typedef typename index::detail::rtree::container_from_elements_type< elements_type, - std::pair + std::pair >::type sorted_elements_type; + sorted_elements_type sorted_elements; // If constructor is used instead of resize() MS implementation leaks here sorted_elements.reserve(elements_count); // MAY THROW, STRONG (V, E: alloc, copy) @@ -84,7 +87,7 @@ public: sorted_elements.begin(), sorted_elements.begin() + reinserted_elements_count, sorted_elements.end(), - distances_dsc); // MAY THROW, BASIC (V, E: copy) + distances_dsc); // MAY THROW, BASIC (V, E: copy) // copy elements which will be reinserted result_elements.clear();