From 4156da7bbf51afeb3dbc43d5cf67fa037822bf4c Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 3 Mar 2012 19:53:05 +0000 Subject: [PATCH] Boost.Geometry Projections now use Boost.Math constants [SVN r77184] --- .../gis/projections/impl/adjlon.hpp | 23 ++++++++----------- .../gis/projections/impl/projects.hpp | 13 ++++++----- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/adjlon.hpp b/include/boost/geometry/extensions/gis/projections/impl/adjlon.hpp index 8b286f116..8d5822846 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/adjlon.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/adjlon.hpp @@ -35,13 +35,9 @@ #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP #define BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP -#include - #include #include -#include - namespace boost { namespace geometry { namespace projection { @@ -49,20 +45,21 @@ namespace detail { /* reduce argument to range +/- PI */ -inline double adjlon (double lon) +template +inline T adjlon (T lon) { - const double SPI = 3.14159265359; - const double TWOPI = 6.2831853071795864769; - const double ONEPI = 3.14159265358979323846; - - if (geometry::math::abs(lon) <= SPI) + if (geometry::math::abs(lon) <= boost::math::constants::pi()) { return lon; } - lon += ONEPI; /* adjust to 0..2pi rad */ - lon -= TWOPI * std::floor(lon / TWOPI); /* remove integral # of 'revolutions'*/ - lon -= ONEPI; /* adjust back to -pi..pi rad */ + /* adjust to 0..2pi rad */ + lon += boost::math::constants::pi(); + /* remove integral # of 'revolutions'*/ + lon -= boost::math::constants::two_pi() * + std::floor(lon / boost::math::constants::two_pi()); + /* adjust back to -pi..pi rad */ + lon -= boost::math::constants::pi(); return lon; } diff --git a/include/boost/geometry/extensions/gis/projections/impl/projects.hpp b/include/boost/geometry/extensions/gis/projections/impl/projects.hpp index c9d17e250..2149eb52e 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/projects.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/projects.hpp @@ -40,6 +40,7 @@ #include #include +#include namespace boost { namespace geometry { namespace projection { @@ -49,13 +50,13 @@ namespace detail { /* some useful constants */ -static const double HALFPI = 1.5707963267948966; -static const double FORTPI = 0.78539816339744833; -static const double PI = 3.14159265358979323846; -static const double TWOPI = 6.2831853071795864769; +static const double HALFPI = boost::math::constants::half_pi(); +static const double FORTPI = boost::math::constants::pi() / 4.0; +static const double PI = boost::math::constants::pi(); +static const double TWOPI = boost::math::constants::two_pi(); -static const double RAD_TO_DEG = 57.29577951308232; -static const double DEG_TO_RAD = .0174532925199432958; +static const double RAD_TO_DEG = boost::math::constants::radian(); +static const double DEG_TO_RAD = boost::math::constants::degree(); static const int PJD_UNKNOWN =0; static const int PJD_3PARAM = 1;