Constants.hpp   Constants.hpp 
/** /**
* \file Constants.hpp * \file Constants.hpp
* \brief Header for GeographicLib::Constants class * \brief Header for GeographicLib::Constants class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com>
* and licensed under the LGPL. For more information, see * and licensed under the LGPL. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_CONSTANTS_HPP) #if !defined(GEOGRAPHICLIB_CONSTANTS_HPP)
#define GEOGRAPHICLIB_CONSTANTS_HPP "$Id: Constants.hpp 6827 2010-05-20 19: 56:18Z karney $" #define GEOGRAPHICLIB_CONSTANTS_HPP "$Id: Constants.hpp 6842 2010-07-16 20: 51:06Z karney $"
/** /**
* A simple compile-time assert. This is designed to be compatible with th e * A simple compile-time assert. This is designed to be compatible with th e
* C++0X static_assert. * C++0X static_assert.
**********************************************************************/ **********************************************************************/
#if !defined(STATIC_ASSERT) #if !defined(STATIC_ASSERT)
#define STATIC_ASSERT(cond,reason) { enum{ STATIC_ASSERT_ENUM=1/int(cond) } ; } #define STATIC_ASSERT(cond,reason) { enum{ STATIC_ASSERT_ENUM=1/int(cond) } ; }
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
// Suppress "defined but not used" warnings // Suppress "defined but not used" warnings
#define RCSID_DECL(x) namespace \ #define RCSID_DECL(x) namespace \
{ char VAR_ ## x [] __attribute__((unused)) = x; } { char VAR_ ## x [] __attribute__((used)) = x; }
#else #else
/** /**
* Insertion of RCS Id strings into the object file. * Insertion of RCS Id strings into the object file.
**********************************************************************/ **********************************************************************/
#define RCSID_DECL(x) namespace { char VAR_ ## x [] = x; } #define RCSID_DECL(x) namespace { char VAR_ ## x [] = x; }
#endif #endif
RCSID_DECL(GEOGRAPHICLIB_CONSTANTS_HPP) RCSID_DECL(GEOGRAPHICLIB_CONSTANTS_HPP)
#if !defined(GEOGRAPHICLIB_PREC) #if !defined(GEOGRAPHICLIB_PREC)
skipping to change at line 108 skipping to change at line 108
real real
a = std::max(x, y), a = std::max(x, y),
b = std::min(x, y) / a; b = std::min(x, y) / a;
return a * std::sqrt(1 + b * b); return a * std::sqrt(1 + b * b);
} }
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
static inline double hypot(double x, double y) throw() static inline double hypot(double x, double y) throw()
{ return _hypot(x, y); } { return _hypot(x, y); }
static inline float hypot(float x, float y) throw() static inline float hypot(float x, float y) throw()
{ return _hypotf(x, y); } { return _hypotf(x, y); }
#if !defined(__NO_LONG_DOUBLE_MATH)
static inline long double hypot(long double x, long double y) throw()
{ return _hypot(x, y); }
#endif
#else #else
// Use overloading to define generic versions // Use overloading to define generic versions
static inline double hypot(double x, double y) throw() static inline double hypot(double x, double y) throw()
{ return ::hypot(x, y); } { return ::hypot(x, y); }
static inline float hypot(float x, float y) throw() static inline float hypot(float x, float y) throw()
{ return ::hypotf(x, y); } { return ::hypotf(x, y); }
#if !defined(__NO_LONG_DOUBLE_MATH) #if !defined(__NO_LONG_DOUBLE_MATH)
static inline long double hypot(long double x, long double y) throw() static inline long double hypot(long double x, long double y) throw()
{ return ::hypotl(x, y); } { return ::hypotl(x, y); }
#endif #endif
skipping to change at line 241 skipping to change at line 245
********************************************************************** / ********************************************************************** /
static inline bool isfinite(real x) throw() { static inline bool isfinite(real x) throw() {
#if defined(DOXYGEN) #if defined(DOXYGEN)
return std::abs(x) <= std::numeric_limits<real>::max(); return std::abs(x) <= std::numeric_limits<real>::max();
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
return _finite(x) != 0; return _finite(x) != 0;
#else #else
return std::isfinite(x) != 0; return std::isfinite(x) != 0;
#endif #endif
} }
/**
* Return a NaN if available, otherwise return the max real.
**********************************************************************
/
static inline real NaN() throw() {
return std::numeric_limits<real>::has_quiet_NaN ?
std::numeric_limits<real>::quiet_NaN() :
std::numeric_limits<real>::max();
}
}; };
/** /**
* \brief %Constants needed by %GeographicLib * \brief %Constants needed by %GeographicLib
* *
* Define constants specifying the WGS84 ellipsoid, the UTM and UPS * Define constants specifying the WGS84 ellipsoid, the UTM and UPS
* projections, and various unit conversions. * projections, and various unit conversions.
**********************************************************************/ **********************************************************************/
class Constants { class Constants {
private: private:
 End of changes. 4 change blocks. 
2 lines changed or deleted 16 lines changed or added


 EllipticFunction.hpp   EllipticFunction.hpp 
/** /**
* \file EllipticFunction.hpp * \file EllipticFunction.hpp
* \brief Header for GeographicLib::EllipticFunction class * \brief Header for GeographicLib::EllipticFunction class
* *
* Copyright (c) Charles Karney (2008, 2009) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009) <charles@karney.com>
* and licensed under the LGPL. For more information, see * and licensed under the LGPL. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP) #if !defined(GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP)
#define GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP "$Id: EllipticFunction.hpp 6720 2009-10-17 23:13:57Z ckarney $" #define GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP "$Id: EllipticFunction.hpp 6838 2010-06-22 21:26:37Z karney $"
#include "GeographicLib/Constants.hpp" #include "GeographicLib/Constants.hpp"
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Elliptic functions needed for TransverseMercatorExact * \brief Elliptic functions needed for TransverseMercatorExact
* *
* This provides the subset of elliptic functions needed for * This provides the subset of elliptic functions needed for
* TransverseMercatorExact. For a given ellipsoid, only parameters \e * TransverseMercatorExact. For a given ellipsoid, only parameters \e
skipping to change at line 57 skipping to change at line 57
static real RF(real x, real y, real z) throw(); static real RF(real x, real y, real z) throw();
static real RD(real x, real y, real z) throw(); static real RD(real x, real y, real z) throw();
static real RG0(real x, real y) throw(); static real RG0(real x, real y) throw();
const real _m, _m1; const real _m, _m1;
mutable bool _init; mutable bool _init;
mutable real _kc, _ec, _kec; mutable real _kc, _ec, _kec;
bool Init() const throw(); bool Init() const throw();
public: public:
/** /**
* Constructor with parameter \e m. * Constructor with parameter \e m which must lie in [0, 1]. (No check
ing
* is done.)
********************************************************************** / ********************************************************************** /
explicit EllipticFunction(real m) throw(); explicit EllipticFunction(real m) throw();
/** /**
* The parameter \e m. * The parameter \e m.
********************************************************************** / ********************************************************************** /
Math::real m() const throw() { return _m; } Math::real m() const throw() { return _m; }
/** /**
* The complementary parameter \e m' = (1 - \e m). * The complementary parameter \e m' = (1 - \e m).
skipping to change at line 94 skipping to change at line 95
Math::real KE() const throw() { _init || Init(); return _kec; } Math::real KE() const throw() { _init || Init(); return _kec; }
/** /**
* The Jacobi elliptic functions sn(<i>x</i>|<i>m</i>), * The Jacobi elliptic functions sn(<i>x</i>|<i>m</i>),
* cn(<i>x</i>|<i>m</i>), and dn(<i>x</i>|<i>m</i>) with argument \e x. * cn(<i>x</i>|<i>m</i>), and dn(<i>x</i>|<i>m</i>) with argument \e x.
* The results are returned in \e sn, \e cn, and \e dn. * The results are returned in \e sn, \e cn, and \e dn.
********************************************************************** / ********************************************************************** /
void sncndn(real x, real& sn, real& cn, real& dn) const throw(); void sncndn(real x, real& sn, real& cn, real& dn) const throw();
/** /**
* The incomplete integral of the second kind = int sqrt(1 - \e m
* sin<sup>2</sup>(\e phi)) \e dphi.
**********************************************************************
/
Math::real E(real phi) const throw();
/**
* The incomplete integral of the second kind = int dn(\e w)<sup>2</sup > \e * The incomplete integral of the second kind = int dn(\e w)<sup>2</sup > \e
* dw (A+S 17.2.10). Instead of specifying the ampltiude \e phi, we * dw (A+S 17.2.10). Instead of specifying the ampltiude \e phi, we
* provide \e sn = sin(\e phi), \e cn = cos(\e phi), \e dn = sqrt(1 - \ e m * provide \e sn = sin(\e phi), \e cn = cos(\e phi), \e dn = sqrt(1 - \ e m
* sin<sup>2</sup>(\e phi)). * sin<sup>2</sup>(\e phi)).
********************************************************************** / ********************************************************************** /
Math::real E(real sn, real cn, real dn) const throw(); Math::real E(real sn, real cn, real dn) const throw();
}; };
} // namespace GeographicLib } // namespace GeographicLib
 End of changes. 3 change blocks. 
2 lines changed or deleted 11 lines changed or added


 MGRS.hpp   MGRS.hpp 
/** /**
* \file MGRS.hpp * \file MGRS.hpp
* \brief Header for GeographicLib::MGRS class * \brief Header for GeographicLib::MGRS class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com>
* and licensed under the LGPL. For more information, see * and licensed under the LGPL. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_MGRS_HPP) #if !defined(GEOGRAPHICLIB_MGRS_HPP)
#define GEOGRAPHICLIB_MGRS_HPP "$Id: MGRS.hpp 6785 2010-01-05 22:15:42Z kar ney $" #define GEOGRAPHICLIB_MGRS_HPP "$Id: MGRS.hpp 6843 2010-07-18 21:18:17Z kar ney $"
#include "GeographicLib/Constants.hpp" #include "GeographicLib/Constants.hpp"
#include "GeographicLib/UTMUPS.hpp" #include "GeographicLib/UTMUPS.hpp"
#include <sstream> #include <sstream>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Convert between UTM/UPS and %MGRS * \brief Convert between UTM/UPS and %MGRS
* *
skipping to change at line 46 skipping to change at line 46
* coordinates.) * coordinates.)
* - All MGRS coordinates truncate to legal 100km blocks. All MGRS * - All MGRS coordinates truncate to legal 100km blocks. All MGRS
* coordinates with a legal 100km block prefix are legal (even though t he * coordinates with a legal 100km block prefix are legal (even though t he
* latitude band letter may now belong to a neighboring band). * latitude band letter may now belong to a neighboring band).
* - The range of UTM/UPS coordinates allowed for conversion to MGRS * - The range of UTM/UPS coordinates allowed for conversion to MGRS
* coordinates is the maximum consistent with staying within the letter * coordinates is the maximum consistent with staying within the letter
* ranges of the MGRS scheme. * ranges of the MGRS scheme.
* *
* The <a href="http://www.nga.mil">NGA</a> software package * The <a href="http://www.nga.mil">NGA</a> software package
* <a href="http://earth-info.nga.mil/GandG/geotrans/index.html">geotrans </a> * <a href="http://earth-info.nga.mil/GandG/geotrans/index.html">geotrans </a>
* also provides conversions to and from MGRS. Version 2.4.2 (and earlie r) * also provides conversions to and from MGRS. Version 3.0 (and earlier)
* suffers from some drawbacks: * suffers from some drawbacks:
* - Conversions to MGRS coordinate return the closest grid corner. This
is
* contrary to the normal standard of grid systems (which is to return
the
* coordinates of the enclosing square) and results in illegal MGRS
* coordinates being returned
* - Inconsistent rules are used to determine the whether a particular MG RS * - Inconsistent rules are used to determine the whether a particular MG RS
* coordinate is legal. A more systematic approach is taken here. * coordinate is legal. A more systematic approach is taken here.
* - The underlying projections are not very accurately implemented. * - The underlying projections are not very accurately implemented.
**********************************************************************/ **********************************************************************/
class MGRS { class MGRS {
private: private:
typedef Math::real real; typedef Math::real real;
// The smallest length s.t., 1.0e7 - eps < 1.0e7 (approx 1.9 nm) // The smallest length s.t., 1.0e7 - eps < 1.0e7 (approx 1.9 nm)
static const real eps; static const real eps;
// The smallest angle s.t., 90 - eps < 90 (approx 50e-12 arcsec) // The smallest angle s.t., 90 - eps < 90 (approx 50e-12 arcsec)
 End of changes. 3 change blocks. 
8 lines changed or deleted 2 lines changed or added


 PolarStereographic.hpp   PolarStereographic.hpp 
/** /**
* \file PolarStereographic.hpp * \file PolarStereographic.hpp
* \brief Header for GeographicLib::PolarStereographic class * \brief Header for GeographicLib::PolarStereographic class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com>
* and licensed under the LGPL. For more information, see * and licensed under the LGPL. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP) #if !defined(GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP)
#define GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP "$Id: PolarStereographic.hpp 6 807 2010-02-01 11:26:34Z karney $" #define GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP "$Id: PolarStereographic.hpp 6 841 2010-07-11 20:46:32Z karney $"
#include "GeographicLib/Constants.hpp" #include "GeographicLib/Constants.hpp"
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Polar Stereographic Projection * \brief Polar Stereographic Projection
* *
* Implementation taken from the report, * Implementation taken from the report,
* - J. P. Snyder, * - J. P. Snyder,
* <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projection s: A * <a href="http://pubs.er.usgs.gov/usgspubs/pp/pp1395"> Map Projection s: A
* Working Manual</a>, USGS Professional Paper 1395 (1987), * Working Manual</a>, USGS Professional Paper 1395 (1987),
* pp. 160&ndash;163. * pp. 160&ndash;163.
* *
* This is a straightforward implementation of the equations in Snyder ex cept * This is a straightforward implementation of the equations in Snyder ex cept
* that Newton's method is used to invert the projection. * that Newton's method is used to invert the projection.
**********************************************************************/ **********************************************************************/
class PolarStereographic { class PolarStereographic {
private: private:
typedef Math::real real; typedef Math::real real;
const real _a, _r, _f, _e2, _e, _e2m, _c; const real _a, _r, _f, _e2, _e, _e2m, _C, _c;
real _k0; real _k0;
static const real tol; static const real tol, overflow;
static const int numit = 5; static const int numit = 5;
static inline real sq(real x) throw() { return x * x; } static inline real sq(real x) throw() { return x * x; }
// Return e * atanh(e * x) for f >= 0, else return // Return e * atanh(e * x) for f >= 0, else return
// - sqrt(-e2) * atan( sqrt(-e2) * x) for f < 0 // - sqrt(-e2) * atan( sqrt(-e2) * x) for f < 0
inline real eatanhe(real x) const throw() { inline real eatanhe(real x) const throw() {
return _f >= 0 ? _e * Math::atanh(_e * x) : - _e * std::atan(_e * x); return _f >= 0 ? _e * Math::atanh(_e * x) : - _e * std::atan(_e * x);
} }
public: public:
/** /**
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 TransverseMercator.hpp   TransverseMercator.hpp 
/** /**
* \file TransverseMercator.hpp * \file TransverseMercator.hpp
* \brief Header for GeographicLib::TransverseMercator class * \brief Header for GeographicLib::TransverseMercator class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com>
* and licensed under the LGPL. For more information, see * and licensed under the LGPL. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_TRANSVERSEMERCATOR_HPP) #if !defined(GEOGRAPHICLIB_TRANSVERSEMERCATOR_HPP)
#define GEOGRAPHICLIB_TRANSVERSEMERCATOR_HPP "$Id: TransverseMercator.hpp 6 824 2010-04-19 14:25:10Z karney $" #define GEOGRAPHICLIB_TRANSVERSEMERCATOR_HPP "$Id: TransverseMercator.hpp 6 843 2010-07-18 21:18:17Z karney $"
#include "GeographicLib/Constants.hpp" #include "GeographicLib/Constants.hpp"
#if !defined(TM_TX_MAXPOW) #if !defined(TM_TX_MAXPOW)
/** /**
* The order of the series approximation used in * The order of the series approximation used in
* GeographicLib::TransverseMercator. TM_TX_MAXPOW can be set to any integ er * GeographicLib::TransverseMercator. TM_TX_MAXPOW can be set to any integ er
* in [4, 8]. * in [4, 8].
**********************************************************************/ **********************************************************************/
#define TM_TX_MAXPOW \ #define TM_TX_MAXPOW \
 End of changes. 1 change blocks. 
1 lines changed or deleted 1 lines changed or added


 TransverseMercatorExact.hpp   TransverseMercatorExact.hpp 
/** /**
* \file TransverseMercatorExact.hpp * \file TransverseMercatorExact.hpp
* \brief Header for GeographicLib::TransverseMercatorExact class * \brief Header for GeographicLib::TransverseMercatorExact class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009, 2010) <charles@karney.com>
* and licensed under the LGPL. For more information, see * and licensed under the LGPL. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_TRANSVERSEMERCATOREXACT_HPP) #if !defined(GEOGRAPHICLIB_TRANSVERSEMERCATOREXACT_HPP)
#define GEOGRAPHICLIB_TRANSVERSEMERCATOREXACT_HPP "$Id: TransverseMercatorE xact.hpp 6824 2010-04-19 14:25:10Z karney $" #define GEOGRAPHICLIB_TRANSVERSEMERCATOREXACT_HPP "$Id: TransverseMercatorE xact.hpp 6835 2010-06-15 21:37:16Z karney $"
#include "GeographicLib/Constants.hpp" #include "GeographicLib/Constants.hpp"
#include "GeographicLib/EllipticFunction.hpp" #include "GeographicLib/EllipticFunction.hpp"
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief An exact implementation of the Transverse Mercator Projection * \brief An exact implementation of the Transverse Mercator Projection
* *
* Implementation of the Transverse Mercator Projection given in * Implementation of the Transverse Mercator Projection given in
skipping to change at line 45 skipping to change at line 45
* error in the convergence is 2e-15&quot;, the relative error in the sca le * error in the convergence is 2e-15&quot;, the relative error in the sca le
* is 7e-12%%. (See \ref tmerrors for the weasel words.) The method is * is 7e-12%%. (See \ref tmerrors for the weasel words.) The method is
* "exact" in the sense that the errors are close to the round-off limit and * "exact" in the sense that the errors are close to the round-off limit and
* that no changes are needed in the algorithms for them to be used with * that no changes are needed in the algorithms for them to be used with
* reals of a higher precision. Thus the errors using long double (with a * reals of a higher precision. Thus the errors using long double (with a
* 64-bit fraction) are about 2000 times smaller than using double (with a * 64-bit fraction) are about 2000 times smaller than using double (with a
* 53-bit fraction). * 53-bit fraction).
* *
* This algorithm is about 4.5 times slower than the 6th-order Kr&uuml;ge r * This algorithm is about 4.5 times slower than the 6th-order Kr&uuml;ge r
* method, GeographicLib::TransverseMercator, taking about 11 us for a * method, GeographicLib::TransverseMercator, taking about 11 us for a
* combined forward and reverse projection on a 2.6 GHz Intel machine (g+ +, * combined forward and reverse projection on a 2.66 GHz Intel machine (g ++,
* version 4.3.0, -O3). * version 4.3.0, -O3).
* *
* The ellipsoid parameters and the central scale are set in the construc tor. * The ellipsoid parameters and the central scale are set in the construc tor.
* The central meridian (which is a trivial shift of the longitude) is * The central meridian (which is a trivial shift of the longitude) is
* specified as the \e lon0 argument of the TransverseMercatorExact::Forw ard * specified as the \e lon0 argument of the TransverseMercatorExact::Forw ard
* and TransverseMercatorExact::Reverse functions. The latitude of origi n is * and TransverseMercatorExact::Reverse functions. The latitude of origi n is
* taken to be the equator. See the documentation on * taken to be the equator. See the documentation on
* GeographicLib::TransverseMercator for how to include a false easting, * GeographicLib::TransverseMercator for how to include a false easting,
* false northing, or a latitude of origin. * false northing, or a latitude of origin.
* *
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/