Warning, file /include/boost/geometry/strategies/normalize.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_GEOMETRY_STRATEGIES_NORMALIZE_HPP
0012 #define BOOST_GEOMETRY_STRATEGIES_NORMALIZE_HPP
0013
0014 #include <cstddef>
0015 #include <type_traits>
0016
0017 #include <boost/geometry/core/access.hpp>
0018 #include <boost/geometry/core/coordinate_system.hpp>
0019 #include <boost/geometry/core/coordinate_type.hpp>
0020 #include <boost/geometry/core/cs.hpp>
0021 #include <boost/geometry/core/tag.hpp>
0022 #include <boost/geometry/core/tags.hpp>
0023
0024 #include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
0025 #include <boost/geometry/util/normalize_spheroidal_box_coordinates.hpp>
0026 #include <boost/geometry/util/numeric_cast.hpp>
0027
0028 #include <boost/geometry/views/detail/indexed_point_view.hpp>
0029
0030
0031 namespace boost { namespace geometry
0032 {
0033
0034 namespace strategy { namespace normalize
0035 {
0036
0037 #ifndef DOXYGEN_NO_DETAIL
0038 namespace detail
0039 {
0040
0041 struct do_nothing
0042 {
0043 template <typename GeometryIn, typename GeometryOut>
0044 static inline void apply(GeometryIn const&, GeometryOut&)
0045 {
0046 }
0047 };
0048
0049
0050 template <std::size_t Dimension, std::size_t DimensionCount>
0051 struct assign_loop
0052 {
0053 template <typename CoordinateType, typename PointIn, typename PointOut>
0054 static inline void apply(CoordinateType const& longitude,
0055 CoordinateType const& latitude,
0056 PointIn const& point_in,
0057 PointOut& point_out)
0058 {
0059 geometry::set<Dimension>(point_out, util::numeric_cast
0060 <
0061 typename coordinate_type<PointOut>::type
0062 >(geometry::get<Dimension>(point_in)));
0063
0064 assign_loop
0065 <
0066 Dimension + 1, DimensionCount
0067 >::apply(longitude, latitude, point_in, point_out);
0068 }
0069 };
0070
0071 template <std::size_t DimensionCount>
0072 struct assign_loop<DimensionCount, DimensionCount>
0073 {
0074 template <typename CoordinateType, typename PointIn, typename PointOut>
0075 static inline void apply(CoordinateType const&,
0076 CoordinateType const&,
0077 PointIn const&,
0078 PointOut&)
0079 {
0080 }
0081 };
0082
0083 template <std::size_t DimensionCount>
0084 struct assign_loop<0, DimensionCount>
0085 {
0086 template <typename CoordinateType, typename PointIn, typename PointOut>
0087 static inline void apply(CoordinateType const& longitude,
0088 CoordinateType const& latitude,
0089 PointIn const& point_in,
0090 PointOut& point_out)
0091 {
0092 geometry::set<0>(point_out, util::numeric_cast
0093 <
0094 typename coordinate_type<PointOut>::type
0095 >(longitude));
0096
0097 assign_loop
0098 <
0099 1, DimensionCount
0100 >::apply(longitude, latitude, point_in, point_out);
0101 }
0102 };
0103
0104 template <std::size_t DimensionCount>
0105 struct assign_loop<1, DimensionCount>
0106 {
0107 template <typename CoordinateType, typename PointIn, typename PointOut>
0108 static inline void apply(CoordinateType const& longitude,
0109 CoordinateType const& latitude,
0110 PointIn const& point_in,
0111 PointOut& point_out)
0112 {
0113 geometry::set<1>(point_out, util::numeric_cast
0114 <
0115 typename coordinate_type<PointOut>::type
0116 >(latitude));
0117
0118 assign_loop
0119 <
0120 2, DimensionCount
0121 >::apply(longitude, latitude, point_in, point_out);
0122 }
0123 };
0124
0125
0126 template <typename PointIn, typename PointOut, bool IsEquatorial = true>
0127 struct normalize_point
0128 {
0129 static inline void apply(PointIn const& point_in, PointOut& point_out)
0130 {
0131 typedef typename coordinate_type<PointIn>::type in_coordinate_type;
0132
0133 in_coordinate_type longitude = geometry::get<0>(point_in);
0134 in_coordinate_type latitude = geometry::get<1>(point_in);
0135
0136 math::normalize_spheroidal_coordinates
0137 <
0138 typename geometry::detail::cs_angular_units<PointIn>::type,
0139 IsEquatorial,
0140 in_coordinate_type
0141 >(longitude, latitude);
0142
0143 assign_loop
0144 <
0145 0, dimension<PointIn>::value
0146 >::apply(longitude, latitude, point_in, point_out);
0147 }
0148 };
0149
0150
0151 template <typename BoxIn, typename BoxOut, bool IsEquatorial = true>
0152 class normalize_box
0153 {
0154 template <typename UnitsIn, typename UnitsOut, typename CoordinateInType>
0155 static inline void apply_to_coordinates(CoordinateInType& lon_min,
0156 CoordinateInType& lat_min,
0157 CoordinateInType& lon_max,
0158 CoordinateInType& lat_max,
0159 BoxIn const& box_in,
0160 BoxOut& box_out)
0161 {
0162 geometry::detail::indexed_point_view<BoxOut, min_corner> p_min_out(box_out);
0163 assign_loop
0164 <
0165 0, dimension<BoxIn>::value
0166 >::apply(lon_min,
0167 lat_min,
0168 geometry::detail::indexed_point_view
0169 <
0170 BoxIn const, min_corner
0171 >(box_in),
0172 p_min_out);
0173
0174 geometry::detail::indexed_point_view<BoxOut, max_corner> p_max_out(box_out);
0175 assign_loop
0176 <
0177 0, dimension<BoxIn>::value
0178 >::apply(lon_max,
0179 lat_max,
0180 geometry::detail::indexed_point_view
0181 <
0182 BoxIn const, max_corner
0183 >(box_in),
0184 p_max_out);
0185 }
0186
0187 public:
0188 static inline void apply(BoxIn const& box_in, BoxOut& box_out)
0189 {
0190 typedef typename coordinate_type<BoxIn>::type in_coordinate_type;
0191
0192 in_coordinate_type lon_min = geometry::get<min_corner, 0>(box_in);
0193 in_coordinate_type lat_min = geometry::get<min_corner, 1>(box_in);
0194 in_coordinate_type lon_max = geometry::get<max_corner, 0>(box_in);
0195 in_coordinate_type lat_max = geometry::get<max_corner, 1>(box_in);
0196
0197 math::normalize_spheroidal_box_coordinates
0198 <
0199 typename geometry::detail::cs_angular_units<BoxIn>::type,
0200 IsEquatorial,
0201 in_coordinate_type
0202 >(lon_min, lat_min, lon_max, lat_max);
0203
0204 apply_to_coordinates
0205 <
0206 typename geometry::detail::cs_angular_units<BoxIn>::type,
0207 typename geometry::detail::cs_angular_units<BoxOut>::type
0208 >(lon_min, lat_min, lon_max, lat_max, box_in, box_out);
0209 }
0210 };
0211
0212
0213 }
0214 #endif
0215
0216 struct cartesian_point
0217 : detail::do_nothing
0218 {};
0219
0220 struct cartesian_box
0221 : detail::do_nothing
0222 {};
0223
0224 struct spherical_point
0225 {
0226 template <typename PointIn, typename PointOut>
0227 static inline void apply(PointIn const& point_in, PointOut& point_out)
0228 {
0229 detail::normalize_point
0230 <
0231 PointIn, PointOut,
0232 (! std::is_same
0233 <
0234 typename cs_tag<PointIn>::type,
0235 spherical_polar_tag
0236 >::value)
0237 >::apply(point_in, point_out);
0238 }
0239 };
0240
0241 struct spherical_box
0242 {
0243 template <typename BoxIn, typename BoxOut>
0244 static inline void apply(BoxIn const& box_in, BoxOut& box_out)
0245 {
0246 detail::normalize_box
0247 <
0248 BoxIn, BoxOut,
0249 (! std::is_same
0250 <
0251 typename cs_tag<BoxIn>::type,
0252 spherical_polar_tag
0253 >::value)
0254 >::apply(box_in, box_out);
0255 }
0256 };
0257
0258 }}
0259
0260 }}
0261
0262 #endif