File indexing completed on 2025-01-18 09:35:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
0016 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP
0017
0018 #include <boost/geometry/algorithms/detail/comparable_distance/interface.hpp>
0019 #include <boost/geometry/core/access.hpp>
0020
0021 #include <boost/geometry/index/detail/algorithms/diff_abs.hpp>
0022 #include <boost/geometry/index/detail/algorithms/sum_for_indexable.hpp>
0023
0024 namespace boost { namespace geometry { namespace index { namespace detail {
0025
0026
0027
0028 struct comparable_distance_far_tag {};
0029
0030 template <
0031 typename Point,
0032 typename BoxIndexable,
0033 size_t DimensionIndex>
0034 struct sum_for_indexable_dimension<Point, BoxIndexable, box_tag, comparable_distance_far_tag, DimensionIndex>
0035 {
0036 typedef typename geometry::default_comparable_distance_result<Point, BoxIndexable>::type result_type;
0037
0038 inline static result_type apply(Point const& pt, BoxIndexable const& i)
0039 {
0040 typedef typename coordinate_type<Point>::type point_coord_t;
0041 typedef typename coordinate_type<BoxIndexable>::type indexable_coord_t;
0042
0043 point_coord_t pt_c = geometry::get<DimensionIndex>(pt);
0044 indexable_coord_t ind_c_min = geometry::get<geometry::min_corner, DimensionIndex>(i);
0045 indexable_coord_t ind_c_max = geometry::get<geometry::max_corner, DimensionIndex>(i);
0046
0047 result_type further_diff = 0;
0048
0049 if ( (ind_c_min + ind_c_max) / 2 <= pt_c )
0050 further_diff = pt_c - ind_c_min;
0051 else
0052 further_diff = detail::diff_abs(pt_c, ind_c_max);
0053
0054 return further_diff * further_diff;
0055 }
0056 };
0057
0058 template <typename Point, typename Indexable>
0059 typename geometry::default_comparable_distance_result<Point, Indexable>::type
0060 comparable_distance_far(Point const& pt, Indexable const& i)
0061 {
0062 return detail::sum_for_indexable<
0063 Point,
0064 Indexable,
0065 typename tag<Indexable>::type,
0066 detail::comparable_distance_far_tag,
0067 dimension<Indexable>::value
0068 >::apply(pt, i);
0069 }
0070
0071 }}}}
0072
0073 #endif