Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2021-2023, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, 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_CLOSEST_POINTS_RANGE_TO_GEOMETRY_RTREE_HPP
0011 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_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/closest_points/utilities.hpp>
0018 #include <boost/geometry/algorithms/detail/distance/is_comparable.hpp>
0019 #include <boost/geometry/algorithms/detail/distance/iterator_selector.hpp>
0020 #include <boost/geometry/algorithms/detail/distance/strategy_utils.hpp>
0021 #include <boost/geometry/algorithms/dispatch/closest_points.hpp>
0022 
0023 #include <boost/geometry/core/assert.hpp>
0024 #include <boost/geometry/core/point_type.hpp>
0025 
0026 #include <boost/geometry/iterators/detail/has_one_element.hpp>
0027 
0028 #include <boost/geometry/strategies/distance.hpp>
0029 
0030 
0031 namespace boost { namespace geometry
0032 {
0033 
0034 
0035 #ifndef DOXYGEN_NO_DETAIL
0036 namespace detail { namespace closest_points
0037 {
0038 
0039 class point_or_segment_range_to_geometry_rtree
0040 {
0041 public:
0042 
0043     template
0044     <
0045         typename PointOrSegmentIterator,
0046         typename Geometry,
0047         typename Segment,
0048         typename Strategies
0049     >
0050     static inline void apply(PointOrSegmentIterator first,
0051                              PointOrSegmentIterator last,
0052                              Geometry const& geometry,
0053                              Segment& shortest_seg,
0054                              Strategies const& strategies)
0055     {
0056         typedef typename std::iterator_traits
0057         <
0058             PointOrSegmentIterator
0059         >::value_type point_or_segment_type;
0060 
0061         typedef distance::iterator_selector<Geometry const> selector_type;
0062 
0063         typedef detail::closest_feature::range_to_range_rtree range_to_range;
0064 
0065         BOOST_GEOMETRY_ASSERT( first != last );
0066 
0067         //TODO: Is this special case needed?
0068         //if ( detail::has_one_element(first, last) )
0069         //{
0070         //    dispatch::closest_points
0071         //        <
0072         //            point_or_segment_type, Geometry
0073         //        >::apply(*first, geometry, shortest_seg, strategies);
0074         //}
0075 
0076         closest_points::creturn_t<point_or_segment_type, Geometry, Strategies> cd;
0077 
0078         std::pair
0079             <
0080                 point_or_segment_type,
0081                 typename selector_type::iterator_type
0082             > closest_features
0083             = range_to_range::apply(first,
0084                                     last,
0085                                     selector_type::begin(geometry),
0086                                     selector_type::end(geometry),
0087                                     strategies,
0088                                     cd);
0089         dispatch::closest_points
0090                 <
0091                     point_or_segment_type,
0092                     typename std::iterator_traits
0093                         <
0094                             typename selector_type::iterator_type
0095                         >::value_type
0096                 >::apply(closest_features.first,
0097                          *closest_features.second,
0098                          shortest_seg,
0099                          strategies);
0100     }
0101 };
0102 
0103 
0104 }} // namespace detail::closest_points
0105 #endif // DOXYGEN_NO_DETAIL
0106 
0107 
0108 }} // namespace boost::geometry
0109 
0110 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CLOSEST_POINTS_RANGE_TO_GEOMETRY_RTREE_HPP