Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2014-2022.
0009 // Modifications copyright (c) 2014-2022 Oracle and/or its affiliates.
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0012 
0013 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0014 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0015 
0016 // Use, modification and distribution is subject to the Boost Software License,
0017 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0018 // http://www.boost.org/LICENSE_1_0.txt)
0019 
0020 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_INTERFACE_HPP
0021 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_INTERFACE_HPP
0022 
0023 
0024 #include <cstddef>
0025 
0026 #include <boost/geometry/core/coordinate_dimension.hpp>
0027 #include <boost/geometry/core/reverse_dispatch.hpp>
0028 #include <boost/geometry/core/tag.hpp>
0029 #include <boost/geometry/core/tag_cast.hpp>
0030 
0031 #include <boost/geometry/geometries/adapted/boost_variant.hpp>
0032 #include <boost/geometry/geometries/concepts/check.hpp>
0033 
0034 #include <boost/geometry/algorithms/not_implemented.hpp>
0035 
0036 #include <boost/geometry/strategies/default_strategy.hpp>
0037 #include <boost/geometry/strategies/detail.hpp>
0038 #include <boost/geometry/strategies/relate/services.hpp>
0039 
0040 
0041 namespace boost { namespace geometry
0042 {
0043 
0044 #ifndef DOXYGEN_NO_DISPATCH
0045 namespace dispatch
0046 {
0047 
0048 template
0049 <
0050     typename Geometry1,
0051     typename Geometry2,
0052     typename Tag1 = typename tag<Geometry1>::type,
0053     typename Tag2 = typename tag<Geometry2>::type,
0054     typename CastedTag1 = typename tag_cast<Tag1, pointlike_tag, linear_tag, areal_tag>::type,
0055     typename CastedTag2 = typename tag_cast<Tag2, pointlike_tag, linear_tag, areal_tag>::type,
0056     std::size_t DimensionCount = dimension<Geometry1>::type::value,
0057     bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
0058 >
0059 struct equals: not_implemented<Tag1, Tag2>
0060 {};
0061 
0062 
0063 // If reversal is needed, perform it
0064 template
0065 <
0066     typename Geometry1, typename Geometry2,
0067     typename Tag1, typename Tag2,
0068     typename CastedTag1, typename CastedTag2,
0069     std::size_t DimensionCount
0070 >
0071 struct equals<Geometry1, Geometry2, Tag1, Tag2, CastedTag1, CastedTag2, DimensionCount, true>
0072     : equals<Geometry2, Geometry1, Tag2, Tag1, CastedTag2, CastedTag1, DimensionCount, false>
0073 {
0074     template <typename Strategy>
0075     static inline bool apply(Geometry1 const& g1, Geometry2 const& g2, Strategy const& strategy)
0076     {
0077         return equals
0078             <
0079                 Geometry2, Geometry1,
0080                 Tag2, Tag1,
0081                 CastedTag2, CastedTag1,
0082                 DimensionCount,
0083                 false
0084             >::apply(g2, g1, strategy);
0085     }
0086 };
0087 
0088 
0089 } // namespace dispatch
0090 #endif // DOXYGEN_NO_DISPATCH
0091 
0092 
0093 namespace resolve_strategy
0094 {
0095 
0096 template
0097 <
0098     typename Strategy,
0099     bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
0100 >
0101 struct equals
0102 {
0103     template <typename Geometry1, typename Geometry2>
0104     static inline bool apply(Geometry1 const& geometry1,
0105                              Geometry2 const& geometry2,
0106                              Strategy const& strategy)
0107     {
0108         return dispatch::equals
0109             <
0110                 Geometry1, Geometry2
0111             >::apply(geometry1, geometry2, strategy);
0112     }
0113 };
0114 
0115 template <typename Strategy>
0116 struct equals<Strategy, false>
0117 {
0118     template <typename Geometry1, typename Geometry2>
0119     static inline bool apply(Geometry1 const& geometry1,
0120                              Geometry2 const& geometry2,
0121                              Strategy const& strategy)
0122     {
0123         using strategies::relate::services::strategy_converter;
0124 
0125         return dispatch::equals
0126             <
0127                 Geometry1, Geometry2
0128             >::apply(geometry1, geometry2,
0129                      strategy_converter<Strategy>::get(strategy));
0130     }
0131 };
0132 
0133 template <>
0134 struct equals<default_strategy, false>
0135 {
0136     template <typename Geometry1, typename Geometry2>
0137     static inline bool apply(Geometry1 const& geometry1,
0138                              Geometry2 const& geometry2,
0139                              default_strategy)
0140     {
0141         typedef typename strategies::relate::services::default_strategy
0142             <
0143                 Geometry1,
0144                 Geometry2
0145             >::type strategy_type;
0146 
0147         return dispatch::equals
0148             <
0149                 Geometry1, Geometry2
0150             >::apply(geometry1, geometry2, strategy_type());
0151     }
0152 };
0153 
0154 } // namespace resolve_strategy
0155 
0156 
0157 namespace resolve_dynamic {
0158 
0159 template
0160 <
0161     typename Geometry1, typename Geometry2,
0162     typename Tag1 = typename geometry::tag<Geometry1>::type,
0163     typename Tag2 = typename geometry::tag<Geometry2>::type
0164 >
0165 struct equals
0166 {
0167     template <typename Strategy>
0168     static inline bool apply(Geometry1 const& geometry1,
0169                              Geometry2 const& geometry2,
0170                              Strategy const& strategy)
0171     {
0172         concepts::check_concepts_and_equal_dimensions
0173             <
0174                 Geometry1 const,
0175                 Geometry2 const
0176             >();
0177 
0178         return resolve_strategy::equals
0179             <
0180                 Strategy
0181             >::apply(geometry1, geometry2, strategy);
0182     }
0183 };
0184 
0185 template <typename Geometry1, typename Geometry2, typename Tag2>
0186 struct equals<Geometry1, Geometry2, dynamic_geometry_tag, Tag2>
0187 {
0188     template <typename Strategy>
0189     static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
0190                              Strategy const& strategy)
0191     {
0192         bool result = false;
0193         traits::visit<Geometry1>::apply([&](auto const& g1)
0194         {
0195             result = equals
0196                 <
0197                     util::remove_cref_t<decltype(g1)>,
0198                     Geometry2
0199                 >::apply(g1, geometry2, strategy);
0200         }, geometry1);
0201         return result;
0202     }
0203 };
0204 
0205 template <typename Geometry1, typename Geometry2, typename Tag1>
0206 struct equals<Geometry1, Geometry2, Tag1, dynamic_geometry_tag>
0207 {
0208     template <typename Strategy>
0209     static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
0210                              Strategy const& strategy)
0211     {
0212         bool result = false;
0213         traits::visit<Geometry2>::apply([&](auto const& g2)
0214         {
0215             result = equals
0216                 <
0217                     Geometry1,
0218                     util::remove_cref_t<decltype(g2)>
0219                 >::apply(geometry1, g2, strategy);
0220         }, geometry2);
0221         return result;
0222     }
0223 };
0224 
0225 template <typename Geometry1, typename Geometry2>
0226 struct equals<Geometry1, Geometry2, dynamic_geometry_tag, dynamic_geometry_tag>
0227 {
0228     template <typename Strategy>
0229     static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2,
0230                              Strategy const& strategy)
0231     {
0232         bool result = false;
0233         traits::visit<Geometry1, Geometry2>::apply([&](auto const& g1, auto const& g2)
0234         {
0235             result = equals
0236                 <
0237                     util::remove_cref_t<decltype(g1)>,
0238                     util::remove_cref_t<decltype(g2)>
0239                 >::apply(g1, g2, strategy);
0240         }, geometry1, geometry2);
0241         return result;
0242     }
0243 };
0244 
0245 } // namespace resolve_dynamic
0246 
0247 
0248 /*!
0249 \brief \brief_check{are spatially equal}
0250 \details \details_check12{equals, is spatially equal}. Spatially equal means
0251     that the same point set is included. A box can therefore be spatially equal
0252     to a ring or a polygon, or a linestring can be spatially equal to a
0253     multi-linestring or a segment. This only works theoretically, not all
0254     combinations are implemented yet.
0255 \ingroup equals
0256 \tparam Geometry1 \tparam_geometry
0257 \tparam Geometry2 \tparam_geometry
0258 \tparam Strategy \tparam_strategy{Equals}
0259 \param geometry1 \param_geometry
0260 \param geometry2 \param_geometry
0261 \param strategy \param_strategy{equals}
0262 \return \return_check2{are spatially equal}
0263 
0264 \qbk{distinguish,with strategy}
0265 \qbk{[include reference/algorithms/equals.qbk]}
0266  */
0267 template <typename Geometry1, typename Geometry2, typename Strategy>
0268 inline bool equals(Geometry1 const& geometry1,
0269                    Geometry2 const& geometry2,
0270                    Strategy const& strategy)
0271 {
0272     return resolve_dynamic::equals
0273         <
0274             Geometry1, Geometry2
0275         >::apply(geometry1, geometry2, strategy);
0276 }
0277 
0278 
0279 /*!
0280 \brief \brief_check{are spatially equal}
0281 \details \details_check12{equals, is spatially equal}. Spatially equal means
0282     that the same point set is included. A box can therefore be spatially equal
0283     to a ring or a polygon, or a linestring can be spatially equal to a
0284     multi-linestring or a segment. This only works theoretically, not all
0285     combinations are implemented yet.
0286 \ingroup equals
0287 \tparam Geometry1 \tparam_geometry
0288 \tparam Geometry2 \tparam_geometry
0289 \param geometry1 \param_geometry
0290 \param geometry2 \param_geometry
0291 \return \return_check2{are spatially equal}
0292 
0293 \qbk{[include reference/algorithms/equals.qbk]}
0294  */
0295 template <typename Geometry1, typename Geometry2>
0296 inline bool equals(Geometry1 const& geometry1, Geometry2 const& geometry2)
0297 {
0298     return resolve_dynamic::equals
0299         <
0300             Geometry1, Geometry2
0301         >::apply(geometry1, geometry2, default_strategy());
0302 }
0303 
0304 
0305 }} // namespace boost::geometry
0306 
0307 
0308 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_INTERFACE_HPP
0309