File indexing completed on 2025-01-18 09:35:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
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
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 }
0090 #endif
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 }
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 }
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
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
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
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 }}
0306
0307
0308 #endif
0309