// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2014, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_GEOMETRY_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_GEOMETRY_HPP #include #include #include #include #include #include #include #include #include namespace boost { namespace geometry { #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace distance { template struct multipoint_to_multipoint { typedef typename strategy::distance::services::return_type < Strategy, typename point_type::type, typename point_type::type >::type return_type; static inline return_type apply(MultiPoint1 const& multipoint1, MultiPoint2 const& multipoint2, Strategy const& strategy) { if (boost::size(multipoint2) < boost::size(multipoint1)) { return point_or_segment_range_to_geometry_rtree < typename boost::range_iterator::type, MultiPoint1, Strategy >::apply(boost::begin(multipoint2), boost::end(multipoint2), multipoint1, strategy); } return point_or_segment_range_to_geometry_rtree < typename boost::range_iterator::type, MultiPoint2, Strategy >::apply(boost::begin(multipoint1), boost::end(multipoint1), multipoint2, strategy); } }; template struct multipoint_to_linear { typedef typename strategy::distance::services::return_type < Strategy, typename point_type::type, typename point_type::type >::type return_type; static inline return_type apply(MultiPoint const& multipoint, Linear const& linear, Strategy const& strategy) { return detail::distance::point_or_segment_range_to_geometry_rtree < typename boost::range_iterator::type, Linear, Strategy >::apply(boost::begin(multipoint), boost::end(multipoint), linear, strategy); } static inline return_type apply(Linear const& linear, MultiPoint const& multipoint, Strategy const& strategy) { return apply(multipoint, linear, strategy); } }; template class multipoint_to_areal { private: struct not_covered_by_areal { not_covered_by_areal(Areal const& areal) : m_areal(areal) {} template inline bool apply(Point const& point) const { return !geometry::covered_by(point, m_areal); } Areal const& m_areal; }; public: typedef typename strategy::distance::services::return_type < Strategy, typename point_type::type, typename point_type::type >::type return_type; static inline return_type apply(MultiPoint const& multipoint, Areal const& areal, Strategy const& strategy) { not_covered_by_areal predicate(areal); if (check_iterator_range < not_covered_by_areal, false >::apply(boost::begin(multipoint), boost::end(multipoint), predicate)) { return detail::distance::point_or_segment_range_to_geometry_rtree < typename boost::range_iterator::type, Areal, Strategy >::apply(boost::begin(multipoint), boost::end(multipoint), areal, strategy); } return 0; } static inline return_type apply(Areal const& areal, MultiPoint const& multipoint, Strategy const& strategy) { return apply(multipoint, areal, strategy); } }; }} // namespace detail::distance #endif // DOXYGEN_NO_DETAIL #ifndef DOXYGEN_NO_DISPATCH namespace dispatch { template struct distance < MultiPoint1, MultiPoint2, Strategy, multi_point_tag, multi_point_tag, strategy_tag_distance_point_point, false > : detail::distance::multipoint_to_multipoint < MultiPoint1, MultiPoint2, Strategy > {}; template struct distance < MultiPoint, Linear, Strategy, multi_point_tag, linear_tag, strategy_tag_distance_point_segment, false > : detail::distance::multipoint_to_linear {}; template struct distance < Linear, MultiPoint, Strategy, linear_tag, multi_point_tag, strategy_tag_distance_point_segment, false > : detail::distance::multipoint_to_linear {}; template struct distance < MultiPoint, Areal, Strategy, multi_point_tag, areal_tag, strategy_tag_distance_point_segment, false > : detail::distance::multipoint_to_areal {}; template struct distance < Areal, MultiPoint, Strategy, areal_tag, multi_point_tag, strategy_tag_distance_point_segment, false > : detail::distance::multipoint_to_areal {}; } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH }} // namespace boost::geometry #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISTANCE_MULTIPOINT_TO_GEOMETRY_HPP