Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77184 - trunk/boost/geometry/extensions/gis/projections/impl
From: barend.gehrels_at_[hidden]
Date: 2012-03-03 14:53:05


Author: barendgehrels
Date: 2012-03-03 14:53:05 EST (Sat, 03 Mar 2012)
New Revision: 77184
URL: http://svn.boost.org/trac/boost/changeset/77184

Log:
Boost.Geometry Projections now use Boost.Math constants
Text files modified:
   trunk/boost/geometry/extensions/gis/projections/impl/adjlon.hpp | 23 ++++++++++-------------
   trunk/boost/geometry/extensions/gis/projections/impl/projects.hpp | 13 +++++++------
   2 files changed, 17 insertions(+), 19 deletions(-)

Modified: trunk/boost/geometry/extensions/gis/projections/impl/adjlon.hpp
==============================================================================
--- trunk/boost/geometry/extensions/gis/projections/impl/adjlon.hpp (original)
+++ trunk/boost/geometry/extensions/gis/projections/impl/adjlon.hpp 2012-03-03 14:53:05 EST (Sat, 03 Mar 2012)
@@ -35,13 +35,9 @@
 #ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
 #define BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
 
-#include <cmath>
-
 #include <boost/math/constants/constants.hpp>
 #include <boost/geometry/util/math.hpp>
 
-#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
-
 namespace boost { namespace geometry { namespace projection
 {
 
@@ -49,20 +45,21 @@
 {
 
 /* reduce argument to range +/- PI */
-inline double adjlon (double lon)
+template <typename T>
+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<T>())
     {
         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<T>();
+ /* remove integral # of 'revolutions'*/
+ lon -= boost::math::constants::two_pi<T>() *
+ std::floor(lon / boost::math::constants::two_pi<T>());
+ /* adjust back to -pi..pi rad */
+ lon -= boost::math::constants::pi<T>();
 
     return lon;
 }

Modified: trunk/boost/geometry/extensions/gis/projections/impl/projects.hpp
==============================================================================
--- trunk/boost/geometry/extensions/gis/projections/impl/projects.hpp (original)
+++ trunk/boost/geometry/extensions/gis/projections/impl/projects.hpp 2012-03-03 14:53:05 EST (Sat, 03 Mar 2012)
@@ -40,6 +40,7 @@
 #include <vector>
 
 #include <boost/concept_check.hpp>
+#include <boost/math/constants/constants.hpp>
 
 namespace boost { namespace geometry { namespace projection
 {
@@ -49,13 +50,13 @@
 {
 
 /* 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<double>();
+static const double FORTPI = boost::math::constants::pi<double>() / 4.0;
+static const double PI = boost::math::constants::pi<double>();
+static const double TWOPI = boost::math::constants::two_pi<double>();
 
-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<double>();
+static const double DEG_TO_RAD = boost::math::constants::degree<double>();
 
 static const int PJD_UNKNOWN =0;
 static const int PJD_3PARAM = 1;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk