mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-11 11:52:11 +00:00
[index] Use default_comparable_distance_result whenever possible
This commit is contained in:
@@ -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<Point, PointIndexable, point_tag, comparable_distance_centroid_tag, N>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, PointIndexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, PointIndexable>::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<Point, BoxIndexable, box_tag, comparable_distance_centroid_tag, DimensionIndex>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, BoxIndexable>::type result_type;
|
||||
|
||||
inline static result_type apply(Point const& pt, BoxIndexable const& i)
|
||||
{
|
||||
@@ -59,7 +59,7 @@ struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_dist
|
||||
};
|
||||
|
||||
template <typename Point, typename Indexable>
|
||||
typename geometry::default_distance_result<Point, Indexable>::type
|
||||
typename geometry::default_comparable_distance_result<Point, Indexable>::type
|
||||
comparable_distance_centroid(Point const& pt, Indexable const& i)
|
||||
{
|
||||
return detail::sum_for_indexable<
|
||||
|
||||
@@ -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<Point, BoxIndexable, box_tag, comparable_distance_far_tag, DimensionIndex>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, BoxIndexable>::type result_type;
|
||||
|
||||
inline static result_type apply(Point const& pt, BoxIndexable const& i)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_dist
|
||||
};
|
||||
|
||||
template <typename Point, typename Indexable>
|
||||
typename geometry::default_distance_result<Point, Indexable>::type
|
||||
typename geometry::default_comparable_distance_result<Point, Indexable>::type
|
||||
comparable_distance_far(Point const& pt, Indexable const& i)
|
||||
{
|
||||
return detail::sum_for_indexable<
|
||||
|
||||
@@ -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<Point, PointIndexable, point_tag, comparable_distance_near_tag, N>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, PointIndexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, PointIndexable>::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<Point, BoxIndexable, box_tag, comparable_distance_near_tag, DimensionIndex>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, BoxIndexable>::type result_type;
|
||||
|
||||
inline static result_type apply(Point const& pt, BoxIndexable const& i)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_dist
|
||||
};
|
||||
|
||||
template <typename Point, typename Indexable>
|
||||
typename geometry::default_distance_result<Point, Indexable>::type
|
||||
typename geometry::default_comparable_distance_result<Point, Indexable>::type
|
||||
comparable_distance_near(Point const& pt, Indexable const& i)
|
||||
{
|
||||
return detail::sum_for_indexable<
|
||||
|
||||
@@ -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<Point, BoxIndexable, box_tag, minmaxdist_tag, DimensionIndex>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, BoxIndexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, BoxIndexable>::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 <typename Point, typename Indexable>
|
||||
struct minmaxdist_impl<Point, Indexable, point_tag>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, Indexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, Indexable>::type result_type;
|
||||
|
||||
inline static result_type apply(Point const& pt, Indexable const& i)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ struct minmaxdist_impl<Point, Indexable, point_tag>
|
||||
template <typename Point, typename Indexable>
|
||||
struct minmaxdist_impl<Point, Indexable, box_tag>
|
||||
{
|
||||
typedef typename geometry::default_distance_result<Point, Indexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<Point, Indexable>::type result_type;
|
||||
|
||||
inline static result_type apply(Point const& pt, Indexable const& i)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ struct minmaxdist_impl<Point, Indexable, box_tag>
|
||||
* This is comparable distace.
|
||||
*/
|
||||
template <typename Point, typename Indexable>
|
||||
typename geometry::default_distance_result<Point, Indexable>::type
|
||||
typename geometry::default_comparable_distance_result<Point, Indexable>::type
|
||||
minmaxdist(Point const& pt, Indexable const& i)
|
||||
{
|
||||
return detail::minmaxdist_impl<
|
||||
|
||||
@@ -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 <typename Indexable, typename Segment>
|
||||
struct path_intersection<Indexable, Segment, box_tag, segment_tag>
|
||||
{
|
||||
|
||||
@@ -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<Indexable, Point, box_tag>
|
||||
template <typename RelativeDistance>
|
||||
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<RelativeDistance>::value;
|
||||
BOOST_MPL_ASSERT_MSG(check, RELATIVE_DISTANCE_MUST_BE_FLOATING_POINT_TYPE, (RelativeDistance));
|
||||
|
||||
|
||||
@@ -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<PointRelation>, Indexable, Tag >
|
||||
{
|
||||
typedef detail::relation<PointRelation> relation;
|
||||
typedef typename relation::value_type point_type;
|
||||
typedef typename geometry::default_distance_result<point_type, Indexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<point_type, Indexable>::type result_type;
|
||||
|
||||
static inline bool apply(nearest<PointRelation> const& p, Indexable const& i, result_type & result)
|
||||
{
|
||||
@@ -121,7 +121,7 @@ template <typename Point, typename Indexable>
|
||||
struct calculate_distance< nearest< to_centroid<Point> >, Indexable, value_tag>
|
||||
{
|
||||
typedef Point point_type;
|
||||
typedef typename geometry::default_distance_result<point_type, Indexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<point_type, Indexable>::type result_type;
|
||||
|
||||
static inline bool apply(nearest< to_centroid<Point> > const& p, Indexable const& i, result_type & result)
|
||||
{
|
||||
@@ -134,7 +134,7 @@ template <typename Point, typename Indexable>
|
||||
struct calculate_distance< nearest< to_furthest<Point> >, Indexable, value_tag>
|
||||
{
|
||||
typedef Point point_type;
|
||||
typedef typename geometry::default_distance_result<point_type, Indexable>::type result_type;
|
||||
typedef typename geometry::default_comparable_distance_result<point_type, Indexable>::type result_type;
|
||||
|
||||
static inline bool apply(nearest< to_furthest<Point> > const& p, Indexable const& i, result_type & result)
|
||||
{
|
||||
|
||||
@@ -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<Box>::type point_type;
|
||||
// TODO: awulkiew - change second point_type to the point type of the Indexable?
|
||||
typedef typename geometry::default_distance_result<point_type>::type distance_type;
|
||||
typedef typename
|
||||
geometry::default_comparable_distance_result<point_type>::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<distance_type, element_type>
|
||||
std::pair<comparable_distance_type, element_type>
|
||||
>::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<distance_type, element_type>); // MAY THROW, BASIC (V, E: copy)
|
||||
distances_dsc<comparable_distance_type, element_type>); // MAY THROW, BASIC (V, E: copy)
|
||||
|
||||
// copy elements which will be reinserted
|
||||
result_elements.clear();
|
||||
|
||||
Reference in New Issue
Block a user