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
0021 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INTERFACE_HPP
0022 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INTERFACE_HPP
0023
0024
0025 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
0026
0027 #include <boost/geometry/core/coordinate_system.hpp>
0028 #include <boost/geometry/core/tag.hpp>
0029 #include <boost/geometry/core/tags.hpp>
0030 #include <boost/geometry/core/visit.hpp>
0031
0032 #include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility
0033 #include <boost/geometry/geometries/concepts/check.hpp>
0034
0035 #include <boost/geometry/strategies/default_strategy.hpp>
0036 #include <boost/geometry/strategies/detail.hpp>
0037 #include <boost/geometry/strategies/envelope/services.hpp>
0038
0039 #include <boost/geometry/util/select_most_precise.hpp>
0040 #include <boost/geometry/util/type_traits_std.hpp>
0041
0042
0043 namespace boost { namespace geometry
0044 {
0045
0046 namespace resolve_strategy
0047 {
0048
0049 template
0050 <
0051 typename Strategy,
0052 bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value
0053 >
0054 struct envelope
0055 {
0056 template <typename Geometry, typename Box>
0057 static inline void apply(Geometry const& geometry,
0058 Box& box,
0059 Strategy const& strategy)
0060 {
0061 dispatch::envelope<Geometry>::apply(geometry, box, strategy);
0062 }
0063 };
0064
0065 template <typename Strategy>
0066 struct envelope<Strategy, false>
0067 {
0068 template <typename Geometry, typename Box>
0069 static inline void apply(Geometry const& geometry,
0070 Box& box,
0071 Strategy const& strategy)
0072 {
0073 using strategies::envelope::services::strategy_converter;
0074 return dispatch::envelope
0075 <
0076 Geometry
0077 >::apply(geometry, box, strategy_converter<Strategy>::get(strategy));
0078 }
0079 };
0080
0081 template <>
0082 struct envelope<default_strategy, false>
0083 {
0084 template <typename Geometry, typename Box>
0085 static inline void apply(Geometry const& geometry,
0086 Box& box,
0087 default_strategy)
0088 {
0089 typedef typename strategies::envelope::services::default_strategy
0090 <
0091 Geometry, Box
0092 >::type strategy_type;
0093
0094 dispatch::envelope<Geometry>::apply(geometry, box, strategy_type());
0095 }
0096 };
0097
0098 }
0099
0100 namespace resolve_dynamic
0101 {
0102
0103 template <typename Geometry, typename Tag = typename tag<Geometry>::type>
0104 struct envelope
0105 {
0106 template <typename Box, typename Strategy>
0107 static inline void apply(Geometry const& geometry,
0108 Box& box,
0109 Strategy const& strategy)
0110 {
0111 concepts::check<Geometry const>();
0112 concepts::check<Box>();
0113
0114 resolve_strategy::envelope<Strategy>::apply(geometry, box, strategy);
0115 }
0116 };
0117
0118
0119 template <typename Geometry>
0120 struct envelope<Geometry, dynamic_geometry_tag>
0121 {
0122 template <typename Box, typename Strategy>
0123 static inline void apply(Geometry const& geometry,
0124 Box& box,
0125 Strategy const& strategy)
0126 {
0127 traits::visit<Geometry>::apply([&](auto const& g)
0128 {
0129 envelope<util::remove_cref_t<decltype(g)>>::apply(g, box, strategy);
0130 }, geometry);
0131 }
0132 };
0133
0134 }
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 template<typename Geometry, typename Box, typename Strategy>
0156 inline void envelope(Geometry const& geometry, Box& mbr, Strategy const& strategy)
0157 {
0158 resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, strategy);
0159 }
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176 template<typename Geometry, typename Box>
0177 inline void envelope(Geometry const& geometry, Box& mbr)
0178 {
0179 resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, default_strategy());
0180 }
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 template<typename Box, typename Geometry, typename Strategy>
0202 inline Box return_envelope(Geometry const& geometry, Strategy const& strategy)
0203 {
0204 Box mbr;
0205 resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, strategy);
0206 return mbr;
0207 }
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224 template<typename Box, typename Geometry>
0225 inline Box return_envelope(Geometry const& geometry)
0226 {
0227 Box mbr;
0228 resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, default_strategy());
0229 return mbr;
0230 }
0231
0232 }}
0233
0234 #endif