diff options
Diffstat (limited to 'boost/geometry/formulas')
-rw-r--r-- | boost/geometry/formulas/andoyer_inverse.hpp | 9 | ||||
-rw-r--r-- | boost/geometry/formulas/elliptic_arc_length.hpp | 56 | ||||
-rw-r--r-- | boost/geometry/formulas/sjoberg_intersection.hpp | 1 | ||||
-rw-r--r-- | boost/geometry/formulas/thomas_direct.hpp | 1 | ||||
-rw-r--r-- | boost/geometry/formulas/thomas_inverse.hpp | 8 | ||||
-rw-r--r-- | boost/geometry/formulas/vertex_latitude.hpp | 4 | ||||
-rw-r--r-- | boost/geometry/formulas/vertex_longitude.hpp | 12 | ||||
-rw-r--r-- | boost/geometry/formulas/vincenty_direct.hpp | 5 | ||||
-rw-r--r-- | boost/geometry/formulas/vincenty_inverse.hpp | 9 |
9 files changed, 61 insertions, 44 deletions
diff --git a/boost/geometry/formulas/andoyer_inverse.hpp b/boost/geometry/formulas/andoyer_inverse.hpp index d0056d16c6..7513e3b70d 100644 --- a/boost/geometry/formulas/andoyer_inverse.hpp +++ b/boost/geometry/formulas/andoyer_inverse.hpp @@ -1,5 +1,7 @@ // Boost.Geometry +// Copyright (c) 2018 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2015-2017 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -15,7 +17,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> @@ -116,7 +117,7 @@ public: CT const dd = -(f/CT(4))*(H*K+G*L); - CT const a = get_radius<0>(spheroid); + CT const a = CT(get_radius<0>(spheroid)); result.distance = a * (d + dd); } @@ -219,10 +220,12 @@ public: if (BOOST_GEOMETRY_CONDITION(CalcQuantities)) { + CT const b = CT(get_radius<2>(spheroid)); + typedef differential_quantities<CT, EnableReducedLength, EnableGeodesicScale, 1> quantities; quantities::apply(dlon, sin_lat1, cos_lat1, sin_lat2, cos_lat2, result.azimuth, result.reverse_azimuth, - get_radius<2>(spheroid), f, + b, f, result.reduced_length, result.geodesic_scale); } diff --git a/boost/geometry/formulas/elliptic_arc_length.hpp b/boost/geometry/formulas/elliptic_arc_length.hpp index 75881f3d0d..65c8f60226 100644 --- a/boost/geometry/formulas/elliptic_arc_length.hpp +++ b/boost/geometry/formulas/elliptic_arc_length.hpp @@ -14,7 +14,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> @@ -46,14 +45,45 @@ public : bool meridian; }; + template <typename T> + static bool meridian_not_crossing_pole(T lat1, T lat2, CT diff) + { + CT half_pi = math::pi<CT>()/CT(2); + return math::equals(diff, CT(0)) || + (math::equals(lat2, half_pi) && math::equals(lat1, -half_pi)); + } + + static bool meridian_crossing_pole(CT diff) + { + return math::equals(math::abs(diff), math::pi<CT>()); + } + + + template <typename T, typename Spheroid> + static CT meridian_not_crossing_pole_dist(T lat1, T lat2, Spheroid const& spheroid) + { + return math::abs(apply(lat2, spheroid) - apply(lat1, spheroid)); + } + + template <typename T, typename Spheroid> + static CT meridian_crossing_pole_dist(T lat1, T lat2, Spheroid const& spheroid) + { + CT c0 = 0; + CT half_pi = math::pi<CT>()/CT(2); + CT lat_sign = 1; + if (lat1+lat2 < c0) + { + lat_sign = CT(-1); + } + return math::abs(lat_sign * CT(2) * apply(half_pi, spheroid) + - apply(lat1, spheroid) - apply(lat2, spheroid)); + } + template <typename T, typename Spheroid> static result apply(T lon1, T lat1, T lon2, T lat2, Spheroid const& spheroid) { result res; - CT c0 = 0; - CT pi = math::pi<CT>(); - CT half_pi = pi/CT(2); CT diff = geometry::math::longitude_distance_signed<geometry::radian>(lon1, lon2); if (lat1 > lat2) @@ -61,24 +91,14 @@ public : std::swap(lat1, lat2); } - if ( math::equals(diff, c0) || - (math::equals(lat2, half_pi) && math::equals(lat1, -half_pi)) ) + if ( meridian_not_crossing_pole(lat1, lat2, diff) ) { - // single meridian not crossing pole - res.distance = apply(lat2, spheroid) - apply(lat1, spheroid); + res.distance = meridian_not_crossing_pole_dist(lat1, lat2, spheroid); res.meridian = true; } - - if (math::equals(math::abs(diff), pi)) + else if ( meridian_crossing_pole(diff) ) { - // meridian crosses pole - CT lat_sign = 1; - if (lat1+lat2 < c0) - { - lat_sign = CT(-1); - } - res.distance = math::abs(lat_sign * CT(2) * apply(half_pi, spheroid) - - apply(lat1, spheroid) - apply(lat2, spheroid)); + res.distance = meridian_crossing_pole_dist(lat1, lat2, spheroid); res.meridian = true; } return res; diff --git a/boost/geometry/formulas/sjoberg_intersection.hpp b/boost/geometry/formulas/sjoberg_intersection.hpp index 665d90308e..54478e3062 100644 --- a/boost/geometry/formulas/sjoberg_intersection.hpp +++ b/boost/geometry/formulas/sjoberg_intersection.hpp @@ -15,7 +15,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> diff --git a/boost/geometry/formulas/thomas_direct.hpp b/boost/geometry/formulas/thomas_direct.hpp index 748960b01b..6a7ac3e414 100644 --- a/boost/geometry/formulas/thomas_direct.hpp +++ b/boost/geometry/formulas/thomas_direct.hpp @@ -15,7 +15,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> diff --git a/boost/geometry/formulas/thomas_inverse.hpp b/boost/geometry/formulas/thomas_inverse.hpp index 0853a36980..cf69c9df1d 100644 --- a/boost/geometry/formulas/thomas_inverse.hpp +++ b/boost/geometry/formulas/thomas_inverse.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2015-2016 Oracle and/or its affiliates. +// Copyright (c) 2015-2018 Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -15,7 +16,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> @@ -178,7 +178,7 @@ public: CT const pi = math::pi<CT>(); - if (BOOST_GEOMETRY_CONDITION(EnableAzimuth)) + if (BOOST_GEOMETRY_CONDITION(CalcFwdAzimuth)) { CT alpha1 = v + u; if (alpha1 > pi) @@ -189,7 +189,7 @@ public: result.azimuth = alpha1; } - if (BOOST_GEOMETRY_CONDITION(EnableReverseAzimuth)) + if (BOOST_GEOMETRY_CONDITION(CalcRevAzimuth)) { CT alpha2 = pi - (v - u); if (alpha2 > pi) diff --git a/boost/geometry/formulas/vertex_latitude.hpp b/boost/geometry/formulas/vertex_latitude.hpp index 755067b08d..92822e01a3 100644 --- a/boost/geometry/formulas/vertex_latitude.hpp +++ b/boost/geometry/formulas/vertex_latitude.hpp @@ -12,11 +12,13 @@ #ifndef BOOST_GEOMETRY_FORMULAS_MAXIMUM_LATITUDE_HPP #define BOOST_GEOMETRY_FORMULAS_MAXIMUM_LATITUDE_HPP -#include <boost/geometry/core/srs.hpp> + #include <boost/geometry/formulas/flattening.hpp> #include <boost/geometry/formulas/spherical.hpp> + #include <boost/mpl/assert.hpp> + namespace boost { namespace geometry { namespace formula { diff --git a/boost/geometry/formulas/vertex_longitude.hpp b/boost/geometry/formulas/vertex_longitude.hpp index 00f2fd4e7a..cf63c10a0a 100644 --- a/boost/geometry/formulas/vertex_longitude.hpp +++ b/boost/geometry/formulas/vertex_longitude.hpp @@ -14,7 +14,7 @@ #include <boost/geometry/formulas/spherical.hpp> #include <boost/geometry/formulas/flattening.hpp> -#include <boost/geometry/core/srs.hpp> + #include <boost/mpl/assert.hpp> #include <boost/math/special_functions/hypot.hpp> @@ -209,12 +209,10 @@ public: + C31 * (sin2_sig3 - sin2_sig1) + C32 * (sin4_sig3 - sin4_sig1)); - int sign = c1; - if (bet3 < c0) - { - sign = cminus1; - } - + CT const sign = bet3 >= c0 + ? c1 + : cminus1; + CT const dlon_max = omg13 - sign * f * sin_alp0 * I3; return dlon_max; diff --git a/boost/geometry/formulas/vincenty_direct.hpp b/boost/geometry/formulas/vincenty_direct.hpp index 1697e5fb63..b72379defe 100644 --- a/boost/geometry/formulas/vincenty_direct.hpp +++ b/boost/geometry/formulas/vincenty_direct.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2014, 2016. -// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates. +// This file was modified by Oracle on 2014, 2016, 2017. +// Modifications copyright (c) 2014-2017 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -18,7 +18,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> diff --git a/boost/geometry/formulas/vincenty_inverse.hpp b/boost/geometry/formulas/vincenty_inverse.hpp index 032e16e291..7bfcf69a9d 100644 --- a/boost/geometry/formulas/vincenty_inverse.hpp +++ b/boost/geometry/formulas/vincenty_inverse.hpp @@ -1,6 +1,7 @@ // Boost.Geometry // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2018 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014, 2016, 2017. // Modifications copyright (c) 2014-2017 Oracle and/or its affiliates. @@ -18,7 +19,6 @@ #include <boost/math/constants/constants.hpp> #include <boost/geometry/core/radius.hpp> -#include <boost/geometry/core/srs.hpp> #include <boost/geometry/util/condition.hpp> #include <boost/geometry/util/math.hpp> @@ -79,6 +79,7 @@ public: return result; } + CT const c0 = 0; CT const c1 = 1; CT const c2 = 2; CT const c3 = 3; @@ -145,7 +146,7 @@ public: CT cos_sigma = sin_U1 * sin_U2 + cos_U1 * cos_U2 * cos_lambda; // (15) sin_alpha = cos_U1 * cos_U2 * sin_lambda / sin_sigma; // (17) cos2_alpha = c1 - math::sqr(sin_alpha); - cos_2sigma_m = math::equals(cos2_alpha, 0) ? 0 : cos_sigma - c2 * sin_U1 * sin_U2 / cos2_alpha; // (18) + cos_2sigma_m = math::equals(cos2_alpha, c0) ? c0 : cos_sigma - c2 * sin_U1 * sin_U2 / cos2_alpha; // (18) cos2_2sigma_m = math::sqr(cos_2sigma_m); CT C = f/c16 * cos2_alpha * (c4 + f * (c4 - c3 * cos2_alpha)); // (10) @@ -163,10 +164,6 @@ public: { // Oops getting hard here // (again, problem is that ttmath cannot divide by doubles, which is OK) - CT const c1 = 1; - CT const c2 = 2; - CT const c3 = 3; - CT const c4 = 4; CT const c6 = 6; CT const c47 = 47; CT const c74 = 74; |