From cd46e228a32032a44e277cc2b6b6bc81f1d81e16 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 9 Jul 2022 20:34:07 +0200 Subject: [PATCH] [projections] Fix compilation errors in pj_generic_inverse and add namespaces --- .../projections/impl/pj_generic_inverse.hpp | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/include/boost/geometry/srs/projections/impl/pj_generic_inverse.hpp b/include/boost/geometry/srs/projections/impl/pj_generic_inverse.hpp index b44da232d..d54dbc40a 100644 --- a/include/boost/geometry/srs/projections/impl/pj_generic_inverse.hpp +++ b/include/boost/geometry/srs/projections/impl/pj_generic_inverse.hpp @@ -1,5 +1,7 @@ // Boost.Geometry +// Copyright (c) 2022 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2022, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle @@ -41,6 +43,9 @@ * DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GENERIC_INVERSE_HPP +#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GENERIC_INVERSE_HPP + #include #include @@ -57,6 +62,13 @@ * Starts with initial guess provided by user in lpInitial */ + +namespace boost { namespace geometry { namespace projections +{ + +namespace detail +{ + template void pj_generic_inverse_2d(T const& xy_x, T const& xy_y, @@ -118,23 +130,23 @@ void pj_generic_inverse_2d(T const& xy_x, { // Limit the amplitude of correction to avoid overshoots due to // bad initial guess - T const delta_lam = std::max( - std::min(deltaX * deriv_lam_X + deltaY * deriv_lam_Y, 0.3), + T const delta_lam = (std::max)( + (std::min)(deltaX * deriv_lam_X + deltaY * deriv_lam_Y, 0.3), -0.3); lp_lat -= delta_lam; - if (lp_lat < -M_PI) - lp_lat = -M_PI; - else if (lp_lat > M_PI) - lp_lat = M_PI; + if (lp_lat < -math::pi()) + lp_lat = -math::pi(); + else if (lp_lat > math::pi()) + lp_lat = math::pi(); } if (xy_y != 0) { - T const delta_phi = std::max( - std::min(deltaX * deriv_phi_X + deltaY * deriv_phi_Y, 0.3), + T const delta_phi = (std::max)( + (std::min)(deltaX * deriv_phi_X + deltaY * deriv_phi_Y, 0.3), -0.3); lp_lon -= delta_phi; - static T const half_pi = boost::math::constants::half_pi(); + static T const half_pi = math::half_pi(); if (lp_lon < -half_pi) lp_lon = -half_pi; else if (lp_lon > half_pi) @@ -143,3 +155,9 @@ void pj_generic_inverse_2d(T const& xy_x, } //pj_ctx_set_errno(P->ctx, PJD_ERR_NON_CONVERGENT); } + +} // namespace detail + +}}} // namespace boost::geometry::projections + +#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GENERIC_INVERSE_HPP