diff --git a/include/boost/geometry/algorithms/convert.hpp b/include/boost/geometry/algorithms/convert.hpp index 2d07ce2b7..e61b50c30 100644 --- a/include/boost/geometry/algorithms/convert.hpp +++ b/include/boost/geometry/algorithms/convert.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -45,6 +44,7 @@ #include +#include #include #include @@ -80,7 +80,7 @@ struct point_to_box typedef typename coordinate_type::type coordinate_type; set(box, - boost::numeric_cast(get(point))); + util::numeric_cast(get(point))); point_to_box < Point, Box, diff --git a/include/boost/geometry/algorithms/detail/assign_indexed_point.hpp b/include/boost/geometry/algorithms/detail/assign_indexed_point.hpp index 560dc67f3..9ae46768e 100644 --- a/include/boost/geometry/algorithms/detail/assign_indexed_point.hpp +++ b/include/boost/geometry/algorithms/detail/assign_indexed_point.hpp @@ -21,12 +21,11 @@ #include -#include - #include #include #include #include +#include namespace boost { namespace geometry @@ -60,7 +59,7 @@ inline void assign_point_to_index(Point const& point, Geometry& geometry) detail::for_each_dimension([&](auto dimension) { geometry::set(geometry, - boost::numeric_cast + util::numeric_cast < typename coordinate_type::type >(geometry::get(point))); @@ -92,7 +91,7 @@ inline void assign_point_from_index(Geometry const& geometry, Point& point) detail::for_each_dimension([&](auto dimension) { geometry::set(point, - boost::numeric_cast + util::numeric_cast < typename coordinate_type::type >(geometry::get(geometry))); diff --git a/include/boost/geometry/algorithms/detail/assign_values.hpp b/include/boost/geometry/algorithms/detail/assign_values.hpp index f20a2041e..628c788e0 100644 --- a/include/boost/geometry/algorithms/detail/assign_values.hpp +++ b/include/boost/geometry/algorithms/detail/assign_values.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -40,6 +39,7 @@ #include #include +#include namespace boost { namespace geometry @@ -117,8 +117,8 @@ inline void assign_box_2d_corner(Box const& box, Point& point) // Copy coordinates typedef typename coordinate_type::type coordinate_type; - geometry::set<0>(point, boost::numeric_cast(get(box))); - geometry::set<1>(point, boost::numeric_cast(get(box))); + geometry::set<0>(point, util::numeric_cast(get(box))); + geometry::set<1>(point, util::numeric_cast(get(box))); } @@ -136,10 +136,10 @@ struct assign_2d_box_or_segment static inline void apply(Geometry& geometry, Type const& x1, Type const& y1, Type const& x2, Type const& y2) { - geometry::set<0, 0>(geometry, boost::numeric_cast(x1)); - geometry::set<0, 1>(geometry, boost::numeric_cast(y1)); - geometry::set<1, 0>(geometry, boost::numeric_cast(x2)); - geometry::set<1, 1>(geometry, boost::numeric_cast(y2)); + geometry::set<0, 0>(geometry, util::numeric_cast(x1)); + geometry::set<0, 1>(geometry, util::numeric_cast(y1)); + geometry::set<1, 0>(geometry, util::numeric_cast(x2)); + geometry::set<1, 1>(geometry, util::numeric_cast(y2)); } }; @@ -167,8 +167,8 @@ struct assign template static inline void apply(Point& point, T const& c1, T const& c2) { - set<0>(point, boost::numeric_cast(c1)); - set<1>(point, boost::numeric_cast(c2)); + set<0>(point, util::numeric_cast(c1)); + set<1>(point, util::numeric_cast(c2)); } }; @@ -180,9 +180,9 @@ struct assign template static inline void apply(Point& point, T const& c1, T const& c2, T const& c3) { - set<0>(point, boost::numeric_cast(c1)); - set<1>(point, boost::numeric_cast(c2)); - set<2>(point, boost::numeric_cast(c3)); + set<0>(point, util::numeric_cast(c1)); + set<1>(point, util::numeric_cast(c2)); + set<2>(point, util::numeric_cast(c3)); } }; diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 5e8635c3d..a3be2858e 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp b/include/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp index fccdf4bb1..607fdae00 100644 --- a/include/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp +++ b/include/boost/geometry/algorithms/detail/convert_indexed_to_indexed.hpp @@ -17,10 +17,10 @@ #include -#include #include #include #include +#include namespace boost { namespace geometry @@ -45,10 +45,10 @@ struct indexed_to_indexed typedef typename coordinate_type::type coordinate_type; geometry::set(destination, - boost::numeric_cast( + util::numeric_cast( geometry::get(source))); geometry::set(destination, - boost::numeric_cast( + util::numeric_cast( geometry::get(source))); indexed_to_indexed diff --git a/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp b/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp index 8762cd668..a29ca3fcf 100644 --- a/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp +++ b/include/boost/geometry/algorithms/detail/convert_point_to_point.hpp @@ -18,10 +18,10 @@ #include -#include #include #include #include +#include namespace boost { namespace geometry @@ -45,7 +45,7 @@ struct point_to_point { typedef typename coordinate_type::type coordinate_type; - set(destination, boost::numeric_cast(get(source))); + set(destination, util::numeric_cast(get(source))); point_to_point::apply(source, destination); } }; diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp index 09f3cc4f6..b3304136f 100644 --- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp +++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp @@ -18,7 +18,6 @@ #include #include -#include #include #include @@ -44,6 +43,7 @@ #include #include #include +#include #include #include @@ -285,7 +285,7 @@ private: template static inline Result apply(T const& t) { - return boost::numeric_cast(t); + return util::numeric_cast(t); } }; diff --git a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp index 40ea1e424..f74cbd8b3 100644 --- a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp +++ b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp @@ -20,7 +20,6 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EQUALS_COLLECT_VECTORS_HPP -#include #include #include @@ -35,6 +34,7 @@ #include #include +#include #include #include @@ -77,7 +77,7 @@ struct collected_vector_cartesian bool normalize() { - T magnitude = math::sqrt(boost::numeric_cast(dx * dx + dy * dy)); + T magnitude = math::sqrt(util::numeric_cast(dx * dx + dy * dy)); // NOTE: shouldn't here math::equals() be called? if (magnitude > 0) diff --git a/include/boost/geometry/algorithms/detail/recalculate.hpp b/include/boost/geometry/algorithms/detail/recalculate.hpp index eb633c9c2..79f6a4eb1 100644 --- a/include/boost/geometry/algorithms/detail/recalculate.hpp +++ b/include/boost/geometry/algorithms/detail/recalculate.hpp @@ -21,8 +21,6 @@ #include #include -#include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/relate/areal_areal.hpp b/include/boost/geometry/algorithms/detail/relate/areal_areal.hpp index 41366e316..3a2b30785 100644 --- a/include/boost/geometry/algorithms/detail/relate/areal_areal.hpp +++ b/include/boost/geometry/algorithms/detail/relate/areal_areal.hpp @@ -31,6 +31,8 @@ #include +#include + namespace boost { namespace geometry { @@ -836,7 +838,7 @@ struct areal_areal segment_identifier const& seg_id = turn.operations[OpId].seg_id; signed_size_type - count = boost::numeric_cast( + count = util::numeric_cast( geometry::num_interior_rings( detail::single_geometry(analyser.geometry, seg_id))); diff --git a/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp b/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp index d6d0417c3..b53626b4b 100644 --- a/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp +++ b/include/boost/geometry/algorithms/detail/within/within_no_turns.hpp @@ -18,6 +18,9 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_WITHIN_WITHIN_NO_TURNS_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_WITHIN_WITHIN_NO_TURNS_HPP + +#include + #include #include @@ -142,8 +145,8 @@ template ::type, typename Tag2 = typename geometry::tag::type, - bool IsMulti1 = boost::is_base_of::value, - bool IsMulti2 = boost::is_base_of::value> + bool IsMulti1 = std::is_base_of::value, + bool IsMulti2 = std::is_base_of::value> struct within_no_turns_multi { template static inline diff --git a/include/boost/geometry/arithmetic/determinant.hpp b/include/boost/geometry/arithmetic/determinant.hpp index 59c596b12..63974a9ea 100644 --- a/include/boost/geometry/arithmetic/determinant.hpp +++ b/include/boost/geometry/arithmetic/determinant.hpp @@ -16,9 +16,9 @@ #include #include +#include #include -#include namespace boost { namespace geometry { @@ -33,7 +33,7 @@ class calculate_determinant template static inline ReturnType rt(T const& v) { - return boost::numeric_cast(v); + return util::numeric_cast(v); } public : diff --git a/include/boost/geometry/core/radian_access.hpp b/include/boost/geometry/core/radian_access.hpp index c2f00552d..ef87701ba 100644 --- a/include/boost/geometry/core/radian_access.hpp +++ b/include/boost/geometry/core/radian_access.hpp @@ -23,13 +23,12 @@ #include -#include - #include #include #include #include +#include @@ -48,7 +47,7 @@ struct degree_radian_converter static inline coordinate_type get(Geometry const& geometry) { - return boost::numeric_cast + return util::numeric_cast < coordinate_type >(geometry::get(geometry) @@ -57,7 +56,7 @@ struct degree_radian_converter static inline void set(Geometry& geometry, coordinate_type const& radians) { - geometry::set(geometry, boost::numeric_cast + geometry::set(geometry, util::numeric_cast < coordinate_type >(radians * math::r2d())); @@ -113,7 +112,7 @@ struct degree_radian_converter_box_segment static inline coordinate_type get(Geometry const& geometry) { - return boost::numeric_cast + return util::numeric_cast < coordinate_type >(geometry::get(geometry) @@ -122,7 +121,7 @@ struct degree_radian_converter_box_segment static inline void set(Geometry& geometry, coordinate_type const& radians) { - geometry::set(geometry, boost::numeric_cast + geometry::set(geometry, util::numeric_cast < coordinate_type >(radians * math::r2d())); diff --git a/include/boost/geometry/policies/relate/intersection_ratios.hpp b/include/boost/geometry/policies/relate/intersection_ratios.hpp index 81ecba0b5..59822fd96 100644 --- a/include/boost/geometry/policies/relate/intersection_ratios.hpp +++ b/include/boost/geometry/policies/relate/intersection_ratios.hpp @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp index 5e1dd5e4d..aabf3d356 100644 --- a/include/boost/geometry/policies/robustness/get_rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/get_rescale_policy.hpp @@ -38,6 +38,7 @@ #include #include #include +#include #include // TEMP @@ -70,7 +71,7 @@ inline void scale_box_to_integer_range(Box const& box, < typename geometry::coordinate_type::type >::type num_type; - num_type const diff = boost::numeric_cast(detail::get_max_size(box)); + num_type const diff = util::numeric_cast(detail::get_max_size(box)); num_type const range = 10000000.0; // Define a large range to get precise integer coordinates num_type const half = 0.5; if (math::equals(diff, num_type()) @@ -81,8 +82,8 @@ inline void scale_box_to_integer_range(Box const& box, } else { - factor = boost::numeric_cast( - boost::numeric_cast(half + range / diff)); + factor = util::numeric_cast( + util::numeric_cast(half + range / diff)); BOOST_GEOMETRY_ASSERT(factor >= 1); } @@ -90,7 +91,7 @@ inline void scale_box_to_integer_range(Box const& box, detail::assign_point_from_index<0>(box, min_point); num_type const two = 2; boost::long_long_type const min_coordinate - = boost::numeric_cast(-range / two); + = util::numeric_cast(-range / two); assign_values(min_robust_point, min_coordinate, min_coordinate); } diff --git a/include/boost/geometry/policies/robustness/segment_ratio.hpp b/include/boost/geometry/policies/robustness/segment_ratio.hpp index 5a75fad01..5b09f6c4e 100644 --- a/include/boost/geometry/policies/robustness/segment_ratio.hpp +++ b/include/boost/geometry/policies/robustness/segment_ratio.hpp @@ -21,6 +21,8 @@ #include #include #include +#include + namespace boost { namespace geometry { @@ -227,8 +229,8 @@ public: m_approximation = m_denominator == zero_instance() ? floating_point_type{0} : ( - boost::numeric_cast(m_numerator) * scale() - / boost::numeric_cast(m_denominator) + util::numeric_cast(m_numerator) * scale() + / util::numeric_cast(m_denominator) ); } diff --git a/include/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp b/include/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp index d4713da92..45138b9da 100644 --- a/include/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp +++ b/include/boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp @@ -22,13 +22,13 @@ #include #include -#include #include #include #include #include #include +#include #include @@ -190,10 +190,10 @@ public : typedef typename calculation_type::type calc_type; // Get coordinates and promote them to calculation_type - calc_type const x1 = boost::numeric_cast(get<0>(p1)); - calc_type const y1 = boost::numeric_cast(get<1>(p1)); - calc_type const x2 = boost::numeric_cast(get<0>(p2)); - calc_type const y2 = boost::numeric_cast(get<1>(p2)); + calc_type const x1 = util::numeric_cast(get<0>(p1)); + calc_type const y1 = util::numeric_cast(get<1>(p1)); + calc_type const x2 = util::numeric_cast(get<0>(p2)); + calc_type const y2 = util::numeric_cast(get<1>(p2)); calc_type const ai = geometry::detail::determinant(p1, p2); state.count++; state.sum_a2 += ai; @@ -225,9 +225,9 @@ public : // which means that the centroid can still be filled with INF // if e.g. calculation_type is double and centroid contains floats set<0>(centroid, - boost::numeric_cast(state.sum_x / a3)); + util::numeric_cast(state.sum_x / a3)); set<1>(centroid, - boost::numeric_cast(state.sum_y / a3)); + util::numeric_cast(state.sum_y / a3)); return true; } } diff --git a/include/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp b/include/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp index 477d68b89..3bf16a4c0 100644 --- a/include/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp +++ b/include/boost/geometry/strategies/cartesian/centroid_weighted_length.hpp @@ -19,7 +19,6 @@ #define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_WEIGHTED_LENGTH_HPP #include -#include #include @@ -32,6 +31,7 @@ #include #include +#include #include @@ -132,7 +132,7 @@ public : typedef typename geometry::coordinate_type::type coordinate_type; geometry::set( centroid, - boost::numeric_cast( + util::numeric_cast( geometry::get(state.average_sum) / state.length ) ); diff --git a/include/boost/geometry/strategies/cartesian/densify.hpp b/include/boost/geometry/strategies/cartesian/densify.hpp index a6bc0a793..4d18e1f0c 100644 --- a/include/boost/geometry/strategies/cartesian/densify.hpp +++ b/include/boost/geometry/strategies/cartesian/densify.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -68,8 +69,8 @@ public: // dir01 = p1 - p0 geometry::detail::for_each_dimension([&](auto index) { - calc_t const coord0 = boost::numeric_cast(get(p0)); - calc_t const coord1 = boost::numeric_cast(get(p1)); + calc_t const coord0 = util::numeric_cast(get(p0)); + calc_t const coord1 = util::numeric_cast(get(p1)); set(cp0, coord0); set(dir01, coord1 - coord0); }); @@ -96,7 +97,7 @@ public: // out = p0 + d * dir01 calc_t const coord = get(cp0) + get(dir01) * num / den; - set(out, boost::numeric_cast(coord)); + set(out, util::numeric_cast(coord)); }); policy.apply(out); diff --git a/include/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp b/include/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp index d903f2100..ee041d254 100644 --- a/include/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp +++ b/include/boost/geometry/strategies/cartesian/disjoint_segment_box.hpp @@ -23,11 +23,6 @@ #include #include -#include - -#include -#include - #include #include #include @@ -38,6 +33,9 @@ #include #include +#include +#include +#include namespace boost { namespace geometry { namespace strategy { namespace disjoint { @@ -62,22 +60,22 @@ struct compute_tmin_tmax_per_dim SegmentPoint >::type point_coordinate_type; - RelativeDistance c_p0 = boost::numeric_cast + RelativeDistance c_p0 = util::numeric_cast < point_coordinate_type >( geometry::get(p0) ); - RelativeDistance c_p1 = boost::numeric_cast + RelativeDistance c_p1 = util::numeric_cast < point_coordinate_type >( geometry::get(p1) ); - RelativeDistance c_b_min = boost::numeric_cast + RelativeDistance c_b_min = util::numeric_cast < box_coordinate_type >( geometry::get(box) ); - RelativeDistance c_b_max = boost::numeric_cast + RelativeDistance c_b_max = util::numeric_cast < box_coordinate_type >( geometry::get(box) ); diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp index 8d8b95436..c7e77bb1d 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras.hpp @@ -26,8 +26,9 @@ #include -#include #include +#include +#include namespace boost { namespace geometry @@ -46,8 +47,8 @@ struct compute_pythagoras template static inline T apply(Point1 const& p1, Point2 const& p2) { - T const c1 = boost::numeric_cast(get(p1)); - T const c2 = boost::numeric_cast(get(p2)); + T const c1 = util::numeric_cast(get(p1)); + T const c2 = util::numeric_cast(get(p2)); T const d = c1 - c2; return d * d + compute_pythagoras::apply(p1, p2); } @@ -59,7 +60,7 @@ struct compute_pythagoras<0, T> template static inline T apply(Point1 const&, Point2 const&) { - return boost::numeric_cast(0); + return util::numeric_cast(0); } }; @@ -163,7 +164,7 @@ public : // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call return math::sqrt ( - boost::numeric_cast::type> + util::numeric_cast::type> ( comparable::pythagoras::apply(p1, p2) ) diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp index 96a4ef027..61545fa2a 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_box_box.hpp @@ -28,9 +28,9 @@ #include -#include #include - +#include +#include namespace boost { namespace geometry @@ -50,14 +50,14 @@ struct compute_pythagoras_box_box static inline void apply(Box1 const& box1, Box2 const& box2, T& result) { T const b1_min_coord = - boost::numeric_cast(geometry::get(box1)); + util::numeric_cast(geometry::get(box1)); T const b1_max_coord = - boost::numeric_cast(geometry::get(box1)); + util::numeric_cast(geometry::get(box1)); T const b2_min_coord = - boost::numeric_cast(geometry::get(box2)); + util::numeric_cast(geometry::get(box2)); T const b2_max_coord = - boost::numeric_cast(geometry::get(box2)); + util::numeric_cast(geometry::get(box2)); if ( b1_max_coord < b2_min_coord ) { @@ -187,7 +187,7 @@ public : // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call return math::sqrt ( - boost::numeric_cast::type> diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp index 719569d55..c9115a6cb 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp @@ -28,9 +28,9 @@ #include -#include #include - +#include +#include namespace boost { namespace geometry @@ -49,11 +49,11 @@ struct compute_pythagoras_point_box template static inline void apply(Point const& point, Box const& box, T& result) { - T const p_coord = boost::numeric_cast(geometry::get(point)); + T const p_coord = util::numeric_cast(geometry::get(point)); T const b_min_coord = - boost::numeric_cast(geometry::get(box)); + util::numeric_cast(geometry::get(box)); T const b_max_coord = - boost::numeric_cast(geometry::get(box)); + util::numeric_cast(geometry::get(box)); if ( p_coord < b_min_coord ) { @@ -182,7 +182,7 @@ public : // The cast is necessary for MSVC which considers sqrt __int64 as an ambiguous call return math::sqrt ( - boost::numeric_cast::type> diff --git a/include/boost/geometry/strategies/cartesian/intersection.hpp b/include/boost/geometry/strategies/cartesian/intersection.hpp index 94d33401c..bfa1830a7 100644 --- a/include/boost/geometry/strategies/cartesian/intersection.hpp +++ b/include/boost/geometry/strategies/cartesian/intersection.hpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -177,17 +178,17 @@ struct cartesian_segments typedef typename promote_integral::type calc_type; calc_type const numerator - = boost::numeric_cast(ratio.numerator()); + = util::numeric_cast(ratio.numerator()); calc_type const denominator - = boost::numeric_cast(ratio.denominator()); - calc_type const dx_calc = boost::numeric_cast(dx); - calc_type const dy_calc = boost::numeric_cast(dy); + = util::numeric_cast(ratio.denominator()); + calc_type const dx_calc = util::numeric_cast(dx); + calc_type const dy_calc = util::numeric_cast(dy); set<0>(point, get<0, 0>(segment) - + boost::numeric_cast( + + util::numeric_cast( math::divide(numerator * dx_calc, denominator))); set<1>(point, get<0, 1>(segment) - + boost::numeric_cast( + + util::numeric_cast( math::divide(numerator * dy_calc, denominator))); } diff --git a/include/boost/geometry/strategies/cartesian/line_interpolate.hpp b/include/boost/geometry/strategies/cartesian/line_interpolate.hpp index bc55da8fa..a63cb8548 100644 --- a/include/boost/geometry/strategies/cartesian/line_interpolate.hpp +++ b/include/boost/geometry/strategies/cartesian/line_interpolate.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -67,10 +68,10 @@ public: // NOTE: numeric_cast is a leftover from convert, it could probably be ommited. // NOTE: the order of points is different than in the formula above // this is also a leftover from the previous implementation - calc_t coord0 = boost::numeric_cast(get(p0)); - calc_t coord1 = boost::numeric_cast(get(p1)); + calc_t coord0 = util::numeric_cast(get(p0)); + calc_t coord1 = util::numeric_cast(get(p1)); calc_t result = calc_t(coord1 * fraction) + calc_t(coord0 * one_minus_fraction); - set(p, boost::numeric_cast(result)); + set(p, util::numeric_cast(result)); }); } }; diff --git a/include/boost/geometry/strategies/geographic/disjoint_segment_box.hpp b/include/boost/geometry/strategies/geographic/disjoint_segment_box.hpp index d7ea122a3..e62e5a3d7 100644 --- a/include/boost/geometry/strategies/geographic/disjoint_segment_box.hpp +++ b/include/boost/geometry/strategies/geographic/disjoint_segment_box.hpp @@ -16,8 +16,6 @@ #include #include -#include - #include #include diff --git a/include/boost/geometry/strategies/normalize.hpp b/include/boost/geometry/strategies/normalize.hpp index a722b1fe0..0b4506998 100644 --- a/include/boost/geometry/strategies/normalize.hpp +++ b/include/boost/geometry/strategies/normalize.hpp @@ -14,8 +14,6 @@ #include #include -#include - #include #include #include @@ -25,6 +23,7 @@ #include #include +#include #include @@ -57,7 +56,7 @@ struct assign_loop PointIn const& point_in, PointOut& point_out) { - geometry::set(point_out, boost::numeric_cast + geometry::set(point_out, util::numeric_cast < typename coordinate_type::type >(geometry::get(point_in))); @@ -90,7 +89,7 @@ struct assign_loop<0, DimensionCount> PointIn const& point_in, PointOut& point_out) { - geometry::set<0>(point_out, boost::numeric_cast + geometry::set<0>(point_out, util::numeric_cast < typename coordinate_type::type >(longitude)); @@ -111,7 +110,7 @@ struct assign_loop<1, DimensionCount> PointIn const& point_in, PointOut& point_out) { - geometry::set<1>(point_out, boost::numeric_cast + geometry::set<1>(point_out, util::numeric_cast < typename coordinate_type::type >(latitude)); diff --git a/include/boost/geometry/strategies/spherical/disjoint_segment_box.hpp b/include/boost/geometry/strategies/spherical/disjoint_segment_box.hpp index 29b6bdaf5..dbb7fe8f6 100644 --- a/include/boost/geometry/strategies/spherical/disjoint_segment_box.hpp +++ b/include/boost/geometry/strategies/spherical/disjoint_segment_box.hpp @@ -16,11 +16,6 @@ #include #include -#include - -#include -#include - #include #include #include @@ -36,6 +31,9 @@ #include #include +#include +#include + namespace boost { namespace geometry { namespace strategy { namespace disjoint { diff --git a/include/boost/geometry/strategies/spherical/distance_segment_box.hpp b/include/boost/geometry/strategies/spherical/distance_segment_box.hpp index c48377d77..32ce3bcaa 100644 --- a/include/boost/geometry/strategies/spherical/distance_segment_box.hpp +++ b/include/boost/geometry/strategies/spherical/distance_segment_box.hpp @@ -25,6 +25,9 @@ #include // spherical #include +#include + + namespace boost { namespace geometry { @@ -148,7 +151,7 @@ struct generic_segment_box if (less_equal(geometry::get_as_radian<0>(bottom_left), geometry::get_as_radian<0>(p_max))) { - result = boost::numeric_cast( + result = util::numeric_cast( strategies.distance(bottom_left, seg).apply(bottom_left, p0, p1)); } else diff --git a/include/boost/geometry/strategies/strategy_transform.hpp b/include/boost/geometry/strategies/strategy_transform.hpp index ee2216ac7..d095a374d 100644 --- a/include/boost/geometry/strategies/strategy_transform.hpp +++ b/include/boost/geometry/strategies/strategy_transform.hpp @@ -23,8 +23,6 @@ #include #include -#include - #include #include #include @@ -34,6 +32,7 @@ #include #include +#include #include namespace boost { namespace geometry @@ -60,7 +59,7 @@ struct transform_coordinates typedef typename select_coordinate_type::type coordinate_type; F function; - set(dest, boost::numeric_cast(function(get(source), value))); + set(dest, util::numeric_cast(function(get(source), value))); transform_coordinates::transform(source, dest, value); } }; diff --git a/include/boost/geometry/strategies/transform/map_transformer.hpp b/include/boost/geometry/strategies/transform/map_transformer.hpp index 01ea6168c..101be83f2 100644 --- a/include/boost/geometry/strategies/transform/map_transformer.hpp +++ b/include/boost/geometry/strategies/transform/map_transformer.hpp @@ -18,6 +18,8 @@ #include #include +#include + namespace boost { namespace geometry { @@ -117,8 +119,8 @@ private : // Scale is in PIXELS/MAPUNITS (meters) W wdx = wx2 - wx1; W wdy = wy2 - wy1; - type sx = (px2 - px1) / boost::numeric_cast(wdx); - type sy = (py2 - py1) / boost::numeric_cast(wdy); + type sx = (px2 - px1) / util::numeric_cast(wdx); + type sy = (py2 - py1) / util::numeric_cast(wdy); if (SameScale) { diff --git a/include/boost/geometry/strategies/transform/matrix_transformers.hpp b/include/boost/geometry/strategies/transform/matrix_transformers.hpp index 70f11b889..937cc1489 100644 --- a/include/boost/geometry/strategies/transform/matrix_transformers.hpp +++ b/include/boost/geometry/strategies/transform/matrix_transformers.hpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,7 @@ struct set_point_from_vec static inline void apply(Point & p, Vector const& v) { typedef typename geometry::coordinate_type::type coord_t; - set(p, boost::numeric_cast(qvm::A(v))); + set(p, util::numeric_cast(qvm::A(v))); set_point_from_vec::apply(p, v); } }; @@ -197,8 +198,8 @@ public : ct const& c2 = get<1>(p1); typedef typename geometry::coordinate_type::type ct2; - set<0>(p2, boost::numeric_cast(c1 * qvm::A<0,0>(this->m_matrix) + c2 * qvm::A<0,1>(this->m_matrix) + qvm::A<0,2>(this->m_matrix))); - set<1>(p2, boost::numeric_cast(c1 * qvm::A<1,0>(this->m_matrix) + c2 * qvm::A<1,1>(this->m_matrix) + qvm::A<1,2>(this->m_matrix))); + set<0>(p2, util::numeric_cast(c1 * qvm::A<0,0>(this->m_matrix) + c2 * qvm::A<0,1>(this->m_matrix) + qvm::A<0,2>(this->m_matrix))); + set<1>(p2, util::numeric_cast(c1 * qvm::A<1,0>(this->m_matrix) + c2 * qvm::A<1,1>(this->m_matrix) + qvm::A<1,2>(this->m_matrix))); return true; } @@ -241,9 +242,9 @@ public : typedef typename geometry::coordinate_type::type ct2; - set<0>(p2, boost::numeric_cast( + set<0>(p2, util::numeric_cast( c1 * qvm::A<0,0>(this->m_matrix) + c2 * qvm::A<0,1>(this->m_matrix) + c3 * qvm::A<0,2>(this->m_matrix) + qvm::A<0,3>(this->m_matrix))); - set<1>(p2, boost::numeric_cast( + set<1>(p2, util::numeric_cast( c1 * qvm::A<1,0>(this->m_matrix) + c2 * qvm::A<1,1>(this->m_matrix) + c3 * qvm::A<1,2>(this->m_matrix) + qvm::A<1,3>(this->m_matrix))); return true; @@ -290,11 +291,11 @@ public : typedef typename geometry::coordinate_type::type ct2; - set<0>(p2, boost::numeric_cast( + set<0>(p2, util::numeric_cast( c1 * qvm::A<0,0>(this->m_matrix) + c2 * qvm::A<0,1>(this->m_matrix) + c3 * qvm::A<0,2>(this->m_matrix) + qvm::A<0,3>(this->m_matrix))); - set<1>(p2, boost::numeric_cast( + set<1>(p2, util::numeric_cast( c1 * qvm::A<1,0>(this->m_matrix) + c2 * qvm::A<1,1>(this->m_matrix) + c3 * qvm::A<1,2>(this->m_matrix) + qvm::A<1,3>(this->m_matrix))); - set<2>(p2, boost::numeric_cast( + set<2>(p2, util::numeric_cast( c1 * qvm::A<2,0>(this->m_matrix) + c2 * qvm::A<2,1>(this->m_matrix) + c3 * qvm::A<2,2>(this->m_matrix) + qvm::A<2,3>(this->m_matrix))); return true; diff --git a/include/boost/geometry/strategy/spherical/envelope_segment.hpp b/include/boost/geometry/strategy/spherical/envelope_segment.hpp index 428f0f71a..49b36192f 100644 --- a/include/boost/geometry/strategy/spherical/envelope_segment.hpp +++ b/include/boost/geometry/strategy/spherical/envelope_segment.hpp @@ -16,7 +16,6 @@ #include #include -#include #include @@ -40,6 +39,7 @@ #include #include +#include namespace boost { namespace geometry { namespace strategy { namespace envelope { @@ -288,22 +288,22 @@ private: geometry::set < min_corner, 0 - >(helper_mbr, boost::numeric_cast(lon1)); + >(helper_mbr, util::numeric_cast(lon1)); geometry::set < min_corner, 1 - >(helper_mbr, boost::numeric_cast(lat1)); + >(helper_mbr, util::numeric_cast(lat1)); geometry::set < max_corner, 0 - >(helper_mbr, boost::numeric_cast(lon2)); + >(helper_mbr, util::numeric_cast(lon2)); geometry::set < max_corner, 1 - >(helper_mbr, boost::numeric_cast(lat2)); + >(helper_mbr, util::numeric_cast(lat2)); geometry::detail::envelope::transform_units(helper_mbr, mbr); } diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index edd0f412c..ed011da72 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -31,10 +31,10 @@ #include #include //#include -#include #include +#include #include namespace boost { namespace geometry @@ -351,7 +351,7 @@ struct square_root return square_root_for_fundamental_fp < double - >::apply(boost::numeric_cast(value)); + >::apply(util::numeric_cast(value)); } }; @@ -499,7 +499,7 @@ struct rounding_cast { static inline Result apply(Source const& v) { - return boost::numeric_cast(v); + return util::numeric_cast(v); } }; @@ -519,7 +519,7 @@ struct rounding_cast { static inline Result apply(Source const& v) { - return boost::numeric_cast(v < Source(0) ? + return util::numeric_cast(v < Source(0) ? v - Source(0.5) : v + Source(0.5)); } diff --git a/include/boost/geometry/util/numeric_cast.hpp b/include/boost/geometry/util/numeric_cast.hpp new file mode 100644 index 000000000..565c6e880 --- /dev/null +++ b/include/boost/geometry/util/numeric_cast.hpp @@ -0,0 +1,60 @@ +// Boost.Geometry + +// Copyright (c) 2024 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_UTIL_NUMERIC_CAST_HPP +#define BOOST_GEOMETRY_UTIL_NUMERIC_CAST_HPP + +#include +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +/// brief calls numeric cast +template +struct numeric_caster +{ + static inline Target apply(Source const& source) + { + return boost::numeric_cast(source); + } +}; + +// Specialization for Boost.Rational +template +struct numeric_caster> +{ + static inline Target apply(rational const& source) + { + return boost::rational_cast(source); + } +}; + +} // namespace detail +#endif + +namespace util +{ + +// Calls either boost::numeric_cast, or functionality specific for Boost.Geometry +// such as rational_cast for Boost.Rational +template +inline Target numeric_cast(Source const& source) +{ + return detail::numeric_caster::apply(source); +} + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_NUMERIC_CAST_HPP diff --git a/include/boost/geometry/util/rational.hpp b/include/boost/geometry/util/rational.hpp index 2e8b751ad..ee63d48b8 100644 --- a/include/boost/geometry/util/rational.hpp +++ b/include/boost/geometry/util/rational.hpp @@ -18,6 +18,7 @@ #include #include +#include #include @@ -134,46 +135,4 @@ struct bounds > }} // namespace boost::numeric -// Support for boost::numeric_cast to int and to double (necessary for SVG-mapper) -namespace boost { namespace numeric -{ - -template -< - typename T, - typename Traits, - typename OverflowHandler, - typename Float2IntRounder, - typename RawConverter, - typename UserRangeChecker -> -struct converter, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker> -{ - static inline int convert(rational const& arg) - { - return int(rational_cast(arg)); - } -}; - -template -< - typename T, - typename Traits, - typename OverflowHandler, - typename Float2IntRounder, - typename RawConverter, - typename UserRangeChecker -> -struct converter, Traits, OverflowHandler, Float2IntRounder, RawConverter, UserRangeChecker> -{ - static inline double convert(rational const& arg) - { - return rational_cast(arg); - } -}; - - -}} - - #endif // BOOST_GEOMETRY_UTIL_RATIONAL_HPP diff --git a/test/algorithms/overlay/overlay.cpp b/test/algorithms/overlay/overlay.cpp index 8162a848c..25d027a5a 100644 --- a/test/algorithms/overlay/overlay.cpp +++ b/test/algorithms/overlay/overlay.cpp @@ -318,9 +318,9 @@ struct map_visitor // Create a rounded off point std::pair p = std::make_pair( - boost::numeric_cast(half + util::numeric_cast(half + ten * bg::get<0>(turn.point)), - boost::numeric_cast(half + util::numeric_cast(half + ten * bg::get<1>(turn.point)) ); m_mapper.text(turn.point, text, style, margin, m_offsets[p], lineheight); diff --git a/test/algorithms/overlay/traverse.cpp b/test/algorithms/overlay/traverse.cpp index 6d58b08cf..b1dfba1c9 100644 --- a/test/algorithms/overlay/traverse.cpp +++ b/test/algorithms/overlay/traverse.cpp @@ -246,9 +246,9 @@ struct test_traverse // Create a rounded off point std::pair p = std::make_pair( - boost::numeric_cast(half + util::numeric_cast(half + ten * bg::get<0>(turn.point)), - boost::numeric_cast(half + util::numeric_cast(half + ten * bg::get<1>(turn.point)) ); std::string style = "fill:rgb(0,0,0);font-family:Arial;font-size:8px"; @@ -303,8 +303,8 @@ struct test_traverse /*out << std::setprecision(3) - << "dist: " << boost::numeric_cast(turn.operations[0].enriched.distance) - << " / " << boost::numeric_cast(turn.operations[1].enriched.distance) + << "dist: " << util::numeric_cast(turn.operations[0].enriched.distance) + << " / " << util::numeric_cast(turn.operations[1].enriched.distance) << std::endl << "vis: " << bg::visited_char(turn.operations[0].visited) << " / " << bg::visited_char(turn.operations[1].visited); diff --git a/test/algorithms/overlay/traverse_ccw.cpp b/test/algorithms/overlay/traverse_ccw.cpp index a3f643606..3e90e8d07 100644 --- a/test/algorithms/overlay/traverse_ccw.cpp +++ b/test/algorithms/overlay/traverse_ccw.cpp @@ -144,8 +144,8 @@ intersect(Geometry1 const& g1, Geometry2 const& g2, std::string const& name, // Create a rounded off point std::pair p = std::make_pair( - boost::numeric_cast(0.5 + 10 * bg::get<0>(turn.point)), - boost::numeric_cast(0.5 + 10 * bg::get<1>(turn.point)) + util::numeric_cast(0.5 + 10 * bg::get<0>(turn.point)), + util::numeric_cast(0.5 + 10 * bg::get<1>(turn.point)) ); std::string style = "fill:rgb(0,0,0);font-family:Arial;font-size:10px"; diff --git a/test/to_svg.hpp b/test/to_svg.hpp index 8b6e9ebe6..99b6c19a6 100644 --- a/test/to_svg.hpp +++ b/test/to_svg.hpp @@ -53,9 +53,9 @@ inline void turns_to_svg(Turns const& turns, Mapper& mapper) // Create a rounded off point std::pair p = std::make_pair( - boost::numeric_cast(half + util::numeric_cast(half + ten * bg::get<0>(turn.point)), - boost::numeric_cast(half + util::numeric_cast(half + ten * bg::get<1>(turn.point)) ); std::string style = "fill:rgb(0,0,0);font-family:Arial;font-size:12px"; diff --git a/test/util/rational.cpp b/test/util/rational.cpp index 8ec47eb9c..01b1691ec 100644 --- a/test/util/rational.cpp +++ b/test/util/rational.cpp @@ -17,6 +17,7 @@ #include #include +#include #include void test_coordinate_cast(std::string const& s, int expected_nom, int expected_denom) @@ -26,6 +27,15 @@ void test_coordinate_cast(std::string const& s, int expected_nom, int expected_d BOOST_CHECK_EQUAL(a.denominator(), expected_denom); } +void test_numeric_cast() +{ + const boost::rational r1(3, 4); + BOOST_CHECK_CLOSE(bg::detail::numeric_cast(r1), 0.75, 0.00001); + + const boost::rational r2(10, 4); + BOOST_CHECK_CLOSE(bg::detail::numeric_cast(r2), 2.5, 0.00001); + BOOST_CHECK_EQUAL(bg::detail::numeric_cast(r2), 2); +} void test_wkt(std::string const& wkt, std::string const expected_wkt) { @@ -52,6 +62,8 @@ int test_main(int, char* []) test_coordinate_cast("3/2", 3, 2); test_coordinate_cast("-3/2", -3, 2); + test_numeric_cast(); + test_wkt("POINT(1.5 2.75)", "POINT(3/2 11/4)"); test_wkt("POINT(3/2 11/4)", "POINT(3/2 11/4)"); test_wkt("POINT(-1.5 2.75)", "POINT(-3/2 11/4)");