File indexing completed on 2025-09-18 08:43: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_CORE_RADIUS_HPP
0022 #define BOOST_GEOMETRY_CORE_RADIUS_HPP
0023
0024
0025 #include <cstddef>
0026
0027 #include <boost/geometry/core/static_assert.hpp>
0028 #include <boost/geometry/core/tag.hpp>
0029 #include <boost/geometry/core/tags.hpp>
0030 #include <boost/geometry/util/type_traits_std.hpp>
0031
0032
0033 namespace boost { namespace geometry
0034 {
0035
0036 namespace traits
0037 {
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 template <typename Geometry, std::size_t Dimension>
0057 struct radius_access {};
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069 template <typename Geometry>
0070 struct radius_type {};
0071
0072 }
0073
0074
0075 #ifndef DOXYGEN_NO_DISPATCH
0076 namespace core_dispatch
0077 {
0078
0079 template <typename Tag, typename Geometry>
0080 struct radius_type
0081 {
0082 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0083 "Not implemented for this Geometry Tag type.",
0084 Geometry, Tag);
0085
0086 };
0087
0088
0089
0090
0091 template
0092 <
0093 typename Tag,
0094 typename Geometry,
0095 std::size_t Dimension,
0096 bool IsPointer
0097 >
0098 struct radius_access
0099 {
0100 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0101 "Not implemented for this Geometry Tag type.",
0102 Geometry, Tag);
0103
0104
0105 };
0106
0107 }
0108 #endif
0109
0110
0111
0112
0113
0114
0115
0116 template <typename Geometry>
0117 struct radius_type
0118 {
0119 using type = typename core_dispatch::radius_type
0120 <
0121 tag_t<Geometry>,
0122 util::remove_cptrref_t<Geometry>
0123 >::type;
0124 };
0125
0126
0127 template <typename Geometry>
0128 using radius_type_t = typename radius_type<Geometry>::type;
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 template <std::size_t I, typename Geometry>
0139 inline radius_type_t<Geometry> get_radius(Geometry const& geometry)
0140 {
0141 return core_dispatch::radius_access
0142 <
0143 tag_t<Geometry>,
0144 util::remove_cptrref_t<Geometry>,
0145 I,
0146 std::is_pointer<Geometry>::value
0147 >::get(geometry);
0148 }
0149
0150
0151
0152
0153
0154
0155
0156
0157 template <std::size_t I, typename Geometry>
0158 inline void set_radius(Geometry& geometry,
0159 radius_type_t<Geometry> const& radius)
0160 {
0161 core_dispatch::radius_access
0162 <
0163 tag_t<Geometry>,
0164 util::remove_cptrref_t<Geometry>,
0165 I,
0166 std::is_pointer<Geometry>::value
0167 >::set(geometry, radius);
0168 }
0169
0170
0171
0172 #ifndef DOXYGEN_NO_DETAIL
0173 namespace detail
0174 {
0175
0176 template <typename Tag, typename Geometry, std::size_t Dimension>
0177 struct radius_access
0178 {
0179 static inline radius_type_t<Geometry> get(Geometry const& geometry)
0180 {
0181 return traits::radius_access<Geometry, Dimension>::get(geometry);
0182 }
0183 static inline void set(Geometry& geometry,
0184 radius_type_t<Geometry> const& value)
0185 {
0186 traits::radius_access<Geometry, Dimension>::set(geometry, value);
0187 }
0188 };
0189
0190 }
0191 #endif
0192
0193
0194 #ifndef DOXYGEN_NO_DISPATCH
0195 namespace core_dispatch
0196 {
0197
0198 template
0199 <
0200 typename Tag,
0201 typename Geometry,
0202 std::size_t Dimension
0203 >
0204 struct radius_access<Tag, Geometry, Dimension, true>
0205 {
0206 static inline radius_type_t<Geometry> get(const Geometry * geometry)
0207 {
0208 return radius_access
0209 <
0210 Tag,
0211 Geometry,
0212 Dimension,
0213 std::is_pointer<Geometry>::value
0214 >::get(*geometry);
0215 }
0216
0217 static inline void set(Geometry * geometry, radius_type_t<Geometry> const& value)
0218 {
0219 return radius_access
0220 <
0221 Tag,
0222 Geometry,
0223 Dimension,
0224 std::is_pointer<Geometry>::value
0225 >::set(*geometry, value);
0226 }
0227 };
0228
0229
0230 template <typename Geometry>
0231 struct radius_type<srs_sphere_tag, Geometry>
0232 {
0233 using type = typename traits::radius_type<Geometry>::type;
0234 };
0235
0236 template <typename Geometry, std::size_t Dimension>
0237 struct radius_access<srs_sphere_tag, Geometry, Dimension, false>
0238 : detail::radius_access<srs_sphere_tag, Geometry, Dimension>
0239 {
0240
0241 BOOST_STATIC_ASSERT(Dimension < 3);
0242 };
0243
0244 template <typename Geometry>
0245 struct radius_type<srs_spheroid_tag, Geometry>
0246 {
0247 using type = typename traits::radius_type<Geometry>::type;
0248 };
0249
0250 template <typename Geometry, std::size_t Dimension>
0251 struct radius_access<srs_spheroid_tag, Geometry, Dimension, false>
0252 : detail::radius_access<srs_spheroid_tag, Geometry, Dimension>
0253 {
0254
0255 BOOST_STATIC_ASSERT(Dimension < 3);
0256 };
0257
0258 }
0259 #endif
0260
0261
0262 }}
0263
0264
0265 #endif