Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:04

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2014-2021, Oracle and/or its affiliates.
0004 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0005 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0006 
0007 // Licensed under the Boost Software License version 1.0.
0008 // http://www.boost.org/users/license.html
0009 
0010 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_GEOMETRY_RTREE_HPP
0011 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_GEOMETRY_RTREE_HPP
0012 
0013 #include <iterator>
0014 #include <utility>
0015 
0016 #include <boost/geometry/algorithms/detail/closest_feature/range_to_range.hpp>
0017 #include <boost/geometry/algorithms/detail/distance/is_comparable.hpp>
0018 #include <boost/geometry/algorithms/detail/distance/iterator_selector.hpp>
0019 #include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp>
0020 #include <boost/geometry/algorithms/dispatch/distance.hpp>
0021 
0022 #include <boost/geometry/core/assert.hpp>
0023 #include <boost/geometry/core/point_type.hpp>
0024 
0025 #include <boost/geometry/iterators/detail/has_one_element.hpp>
0026 
0027 #include <boost/geometry/strategies/distance.hpp>
0028 
0029 
0030 namespace boost { namespace geometry
0031 {
0032 
0033 
0034 #ifndef DOXYGEN_NO_DETAIL
0035 namespace detail { namespace distance
0036 {
0037 
0038 
0039 template
0040 <
0041     typename PointOrSegmentIterator,
0042     typename Geometry,
0043     typename Strategies
0044 >
0045 class point_or_segment_range_to_geometry_rtree
0046 {
0047 private:
0048     typedef typename std::iterator_traits
0049         <
0050             PointOrSegmentIterator
0051         >::value_type point_or_segment_type;
0052 
0053     typedef iterator_selector<Geometry const> selector_type;
0054 
0055     typedef detail::closest_feature::range_to_range_rtree range_to_range;
0056 
0057     typedef distance::strategy_t<point_or_segment_type, Geometry, Strategies> strategy_type;
0058 
0059 public:
0060     typedef distance::return_t<point_or_segment_type, Geometry, Strategies> return_type;
0061 
0062     static inline return_type apply(PointOrSegmentIterator first,
0063                                     PointOrSegmentIterator last,
0064                                     Geometry const& geometry,
0065                                     Strategies const& strategies)
0066     {
0067         BOOST_GEOMETRY_ASSERT( first != last );
0068 
0069         if ( detail::has_one_element(first, last) )
0070         {
0071             return dispatch::distance
0072                 <
0073                     point_or_segment_type, Geometry, Strategies
0074                 >::apply(*first, geometry, strategies);
0075         }
0076 
0077         distance::creturn_t<point_or_segment_type, Geometry, Strategies> cd_min;
0078 
0079         std::pair
0080             <
0081                 point_or_segment_type,
0082                 typename selector_type::iterator_type
0083             > closest_features
0084             = range_to_range::apply(first,
0085                                     last,
0086                                     selector_type::begin(geometry),
0087                                     selector_type::end(geometry),
0088                                     strategies,
0089                                     cd_min);
0090 
0091         return
0092             is_comparable<strategy_type>::value
0093             ?
0094             cd_min
0095             :
0096             dispatch::distance
0097                 <
0098                     point_or_segment_type,
0099                     typename std::iterator_traits
0100                         <
0101                             typename selector_type::iterator_type
0102                         >::value_type,
0103                     Strategies
0104                 >::apply(closest_features.first,
0105                          *closest_features.second,
0106                          strategies);
0107     }
0108 };
0109 
0110 
0111 }} // namespace detail::distance
0112 #endif // DOXYGEN_NO_DETAIL
0113 
0114 
0115 }} // namespace boost::geometry
0116 
0117 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_RANGE_TO_GEOMETRY_RTREE_HPP