Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2013-2022.
0006 // Modifications copyright (c) 2013-2022 Oracle and/or its affiliates.
0007 
0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0009 
0010 // Use, modification and distribution is subject to the Boost Software License,
0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
0013 
0014 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATION_INTERFACE_HPP
0015 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATION_INTERFACE_HPP
0016 
0017 
0018 #include <boost/geometry/algorithms/detail/relate/interface.hpp>
0019 
0020 
0021 namespace boost { namespace geometry
0022 {
0023 
0024 #ifndef DOXYGEN_NO_DETAIL
0025 namespace detail { namespace relate
0026 {
0027 
0028 template <typename Geometry1, typename Geometry2>
0029 struct result_handler_type<Geometry1, Geometry2, geometry::de9im::matrix>
0030 {
0031     typedef matrix_handler<geometry::de9im::matrix> type;
0032 };
0033 
0034 
0035 }} // namespace detail::relate
0036 #endif // DOXYGEN_NO_DETAIL
0037 
0038 namespace resolve_dynamic
0039 {
0040 
0041 template
0042 <
0043     typename Geometry1, typename Geometry2,
0044     typename Tag1 = typename geometry::tag<Geometry1>::type,
0045     typename Tag2 = typename geometry::tag<Geometry2>::type
0046 >
0047 struct relation
0048 {
0049     template <typename Matrix, typename Strategy>
0050     static inline Matrix apply(Geometry1 const& geometry1,
0051                                Geometry2 const& geometry2,
0052                                Strategy const& strategy)
0053     {
0054         concepts::check<Geometry1 const>();
0055         concepts::check<Geometry2 const>();
0056         assert_dimension_equal<Geometry1, Geometry2>();
0057 
0058         typename detail::relate::result_handler_type
0059             <
0060                 Geometry1,
0061                 Geometry2,
0062                 Matrix
0063             >::type handler;
0064 
0065         resolve_strategy::relate
0066             <
0067                 Strategy
0068             >::apply(geometry1, geometry2, handler, strategy);
0069 
0070         return handler.result();
0071     }
0072 };
0073 
0074 template <typename Geometry1, typename Geometry2, typename Tag2>
0075 struct relation<Geometry1, Geometry2, dynamic_geometry_tag, Tag2>
0076 {
0077     template <typename Matrix, typename Strategy>
0078     static inline Matrix apply(Geometry1 const& geometry1,
0079                                Geometry2 const& geometry2,
0080                                Strategy const& strategy)
0081     {
0082         Matrix result;
0083         traits::visit<Geometry1>::apply([&](auto const& g1)
0084         {
0085             result = relation
0086                 <
0087                     util::remove_cref_t<decltype(g1)>,
0088                     Geometry2
0089                 >::template apply<Matrix>(g1, geometry2, strategy);
0090         }, geometry1);
0091         return result;
0092     }
0093 };
0094 
0095 template <typename Geometry1, typename Geometry2, typename Tag1>
0096 struct relation<Geometry1, Geometry2, Tag1, dynamic_geometry_tag>
0097 {
0098     template <typename Matrix, typename Strategy>
0099     static inline Matrix apply(Geometry1 const& geometry1,
0100                                Geometry2 const& geometry2,
0101                                Strategy const& strategy)
0102     {
0103         Matrix result;
0104         traits::visit<Geometry2>::apply([&](auto const& g2)
0105         {
0106             result = relation
0107                 <
0108                     Geometry1,
0109                     util::remove_cref_t<decltype(g2)>
0110                 >::template apply<Matrix>(geometry1, g2, strategy);
0111         }, geometry2);
0112         return result;
0113     }
0114 };
0115 
0116 template <typename Geometry1, typename Geometry2>
0117 struct relation<Geometry1, Geometry2, dynamic_geometry_tag, dynamic_geometry_tag>
0118 {
0119     template <typename Matrix, typename Strategy>
0120     static inline Matrix apply(Geometry1 const& geometry1,
0121                                Geometry2 const& geometry2,
0122                                Strategy const& strategy)
0123     {
0124         Matrix result;
0125         traits::visit<Geometry1, Geometry2>::apply([&](auto const& g1, auto const& g2)
0126         {
0127             result = relation
0128                 <
0129                     util::remove_cref_t<decltype(g1)>,
0130                     util::remove_cref_t<decltype(g2)>
0131                 >::template apply<Matrix>(g1, g2, strategy);
0132         }, geometry1, geometry2);
0133         return result;
0134     }
0135 };
0136 
0137 } // namespace resolve_dynamic
0138 
0139 
0140 /*!
0141 \brief Calculates the relation between a pair of geometries as defined in DE-9IM.
0142 \ingroup relation
0143 \tparam Geometry1 \tparam_geometry
0144 \tparam Geometry2 \tparam_geometry
0145 \tparam Strategy \tparam_strategy{Relation}
0146 \param geometry1 \param_geometry
0147 \param geometry2 \param_geometry
0148 \param strategy \param_strategy{relation}
0149 \return The DE-9IM matrix expressing the relation between geometries.
0150 
0151 \qbk{distinguish,with strategy}
0152 \qbk{[include reference/algorithms/relation.qbk]}
0153  */
0154 template <typename Geometry1, typename Geometry2, typename Strategy>
0155 inline de9im::matrix relation(Geometry1 const& geometry1,
0156                               Geometry2 const& geometry2,
0157                               Strategy const& strategy)
0158 {
0159     return resolve_dynamic::relation
0160         <
0161             Geometry1,
0162             Geometry2
0163         >::template apply<de9im::matrix>(geometry1, geometry2, strategy);
0164 }
0165 
0166 
0167 /*!
0168 \brief Calculates the relation between a pair of geometries as defined in DE-9IM.
0169 \ingroup relation
0170 \tparam Geometry1 \tparam_geometry
0171 \tparam Geometry2 \tparam_geometry
0172 \param geometry1 \param_geometry
0173 \param geometry2 \param_geometry
0174 \return The DE-9IM matrix expressing the relation between geometries.
0175 
0176 \qbk{[include reference/algorithms/relation.qbk]}
0177  */
0178 template <typename Geometry1, typename Geometry2>
0179 inline de9im::matrix relation(Geometry1 const& geometry1,
0180                               Geometry2 const& geometry2)
0181 {
0182     return resolve_dynamic::relation
0183         <
0184             Geometry1,
0185             Geometry2
0186         >::template apply<de9im::matrix>(geometry1, geometry2, default_strategy());
0187 }
0188 
0189 
0190 }} // namespace boost::geometry
0191 
0192 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_INTERFACE_HPP