AlbersEqualArea.hpp   AlbersEqualArea.hpp 
/** /**
* \file AlbersEqualArea.hpp * \file AlbersEqualArea.hpp
* \brief Header for GeographicLib::AlbersEqualArea class * \brief Header for GeographicLib::AlbersEqualArea class
* *
* Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed * Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed
* under the MIT/X11 License. For more information, see * under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_ALBERSEQUALAREA_HPP) #if !defined(GEOGRAPHICLIB_ALBERSEQUALAREA_HPP)
#define GEOGRAPHICLIB_ALBERSEQUALAREA_HPP "$Id: e29eed8bc763c20ae10131ef13f 243c3b99bd37b $" #define GEOGRAPHICLIB_ALBERSEQUALAREA_HPP "$Id: eee2b79bf8f65888c9a3b75a6b5 be04ada04e985 $"
#include <algorithm> #include <algorithm>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Albers Equal Area Conic Projection * \brief Albers Equal Area Conic Projection
* *
* Implementation taken from the report, * Implementation taken from the report,
skipping to change at line 57 skipping to change at line 57
* aligned with the cardinal directions is projected to a rectangle with * aligned with the cardinal directions is projected to a rectangle with
* dimensions \e k (in the E-W direction) and 1/\e k (in the N-S directio n). * dimensions \e k (in the E-W direction) and 1/\e k (in the N-S directio n).
* The E-W sides of the rectangle are oriented \e gamma degrees * The E-W sides of the rectangle are oriented \e gamma degrees
* counter-clockwise from the \e x axis. There is no provision in this c lass * counter-clockwise from the \e x axis. There is no provision in this c lass
* for specifying a false easting or false northing or a different latitu de * for specifying a false easting or false northing or a different latitu de
* of origin. * of origin.
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT AlbersEqualArea { class GEOGRAPHIC_EXPORT AlbersEqualArea {
private: private:
typedef Math::real real; typedef Math::real real;
const real _a, _f, _r, _fm, _e2, _e, _e2m, _qZ, _qx; real _a, _f, _fm, _e2, _e, _e2m, _qZ, _qx;
real _sign, _lat0, _k0; real _sign, _lat0, _k0;
real _n0, _m02, _nrho0, _k2, _txi0, _scxi0, _sxi0; real _n0, _m02, _nrho0, _k2, _txi0, _scxi0, _sxi0;
static const real eps_; static const real eps_;
static const real epsx_; static const real epsx_;
static const real epsx2_; static const real epsx2_;
static const real tol_; static const real tol_;
static const real tol0_; static const real tol0_;
static const real ahypover_; static const real ahypover_;
static const int numit_ = 5; // Newton iterations in Reverse static const int numit_ = 5; // Newton iterations in Reverse
static const int numit0_ = 20; // Newton iterations in Init static const int numit0_ = 20; // Newton iterations in Init
skipping to change at line 260 skipping to change at line 260
/** /**
* @return \e f the flattening of the ellipsoid. This is the value use d in * @return \e f the flattening of the ellipsoid. This is the value use d in
* the constructor. * the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
/** /**
* @return latitude of the origin for the projection (degrees). * @return latitude of the origin for the projection (degrees).
* *
* This is the latitude of minimum azimuthal scale and equals the \e st dlat * This is the latitude of minimum azimuthal scale and equals the \e st dlat
* in the 1-parallel constructor and lies between \e stdlat1 and \e std lat2 * in the 1-parallel constructor and lies between \e stdlat1 and \e std lat2
* in the 2-parallel constructors. * in the 2-parallel constructors.
********************************************************************** / ********************************************************************** /
Math::real OriginLatitude() const throw() { return _lat0; } Math::real OriginLatitude() const throw() { return _lat0; }
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 AzimuthalEquidistant.hpp   AzimuthalEquidistant.hpp 
/** /**
* \file AzimuthalEquidistant.hpp * \file AzimuthalEquidistant.hpp
* \brief Header for GeographicLib::AzimuthalEquidistant class * \brief Header for GeographicLib::AzimuthalEquidistant class
* *
* Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> and * Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> and
* licensed under the MIT/X11 License. For more information, see * licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP) #if !defined(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP)
#define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP "$Id: f711f34c879ebd191d3aa2 7530964550336dd248 $" #define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP "$Id: 48f5a84645ea5925a2e782 6adb07a42fe091d09f $"
#include <GeographicLib/Geodesic.hpp> #include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Azimuthal Equidistant Projection. * \brief Azimuthal Equidistant Projection.
* *
* Azimuthal equidistant projection centered at an arbitrary position on the * Azimuthal equidistant projection centered at an arbitrary position on the
skipping to change at line 38 skipping to change at line 38
* completely the local affine transformation between geographic and * completely the local affine transformation between geographic and
* projected coordinates. * projected coordinates.
* *
* The conversions all take place using a Geodesic object (by default * The conversions all take place using a Geodesic object (by default
* Geodesic::WGS84). For more information on geodesics see \ref geodesic . * Geodesic::WGS84). For more information on geodesics see \ref geodesic .
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT AzimuthalEquidistant { class GEOGRAPHIC_EXPORT AzimuthalEquidistant {
private: private:
typedef Math::real real; typedef Math::real real;
const Geodesic _earth; Geodesic _earth;
static const real eps_; static const real eps_;
public: public:
/** /**
* Constructor for AzimuthalEquidistant. * Constructor for AzimuthalEquidistant.
* *
* @param[in] earth the Geodesic object to use for geodesic calculation s. * @param[in] earth the Geodesic object to use for geodesic calculation s.
* By default this uses the WGS84 ellipsoid. * By default this uses the WGS84 ellipsoid.
********************************************************************** / ********************************************************************** /
explicit AzimuthalEquidistant(const Geodesic& earth = Geodesic::WGS84) explicit AzimuthalEquidistant(const Geodesic& earth = Geodesic::WGS84)
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 CassiniSoldner.hpp   CassiniSoldner.hpp 
/** /**
* \file CassiniSoldner.hpp * \file CassiniSoldner.hpp
* \brief Header for GeographicLib::CassiniSoldner class * \brief Header for GeographicLib::CassiniSoldner class
* *
* Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> and * Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> and
* licensed under the MIT/X11 License. For more information, see * licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_CASSINISOLDNER_HPP) #if !defined(GEOGRAPHICLIB_CASSINISOLDNER_HPP)
#define GEOGRAPHICLIB_CASSINISOLDNER_HPP "$Id: ffa72d53546c2066064723afc1f0 a4c6dfadc2f0 $" #define GEOGRAPHICLIB_CASSINISOLDNER_HPP "$Id: 2527a0e24486c29c443a79173a18 def243c091c3 $"
#include <GeographicLib/Geodesic.hpp> #include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/GeodesicLine.hpp> #include <GeographicLib/GeodesicLine.hpp>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Cassini-Soldner Projection. * \brief Cassini-Soldner Projection.
* *
skipping to change at line 65 skipping to change at line 65
* obtained by reflection in the meridional plane. The scale is found by * obtained by reflection in the meridional plane. The scale is found by
* determining where two neighboring geodesics intersecting the central * determining where two neighboring geodesics intersecting the central
* meridan at \e lat1 and \e lat1 + \e dlat1 intersect and taking the rat io * meridan at \e lat1 and \e lat1 + \e dlat1 intersect and taking the rat io
* of the reduced lengths for the two geodesics between that point and, * of the reduced lengths for the two geodesics between that point and,
* respectively, (\e lat1, \e lon1) and (\e lat, \e lon). * respectively, (\e lat1, \e lon1) and (\e lat, \e lon).
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT CassiniSoldner { class GEOGRAPHIC_EXPORT CassiniSoldner {
private: private:
typedef Math::real real; typedef Math::real real;
const Geodesic _earth; Geodesic _earth;
GeodesicLine _meridian; GeodesicLine _meridian;
real _sbet0, _cbet0; real _sbet0, _cbet0;
static const real eps1_; static const real eps1_;
static const real tiny_; static const real tiny_;
static const unsigned maxit_ = 10; static const unsigned maxit_ = 10;
// The following private helper functions are copied from Geodesic. // The following private helper functions are copied from Geodesic.
static inline real AngNormalize(real x) throw() { static inline real AngNormalize(real x) throw() {
// Place angle in [-180, 180). Assumes x is in [-540, 540). // Place angle in [-180, 180). Assumes x is in [-540, 540).
return x >= 180 ? x - 360 : x < -180 ? x + 360 : x; return x >= 180 ? x - 360 : (x < -180 ? x + 360 : x);
} }
static inline real AngRound(real x) throw() { static inline real AngRound(real x) throw() {
// The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^ 57 // The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^ 57
// for reals = 0.7 pm on the earth if x is an angle in degrees. (Thi s // for reals = 0.7 pm on the earth if x is an angle in degrees. (Thi s
// is about 1000 times more resolution than we get with angles around 90 // is about 1000 times more resolution than we get with angles around 90
// degrees.) We use this to avoid having to deal with near singular // degrees.) We use this to avoid having to deal with near singular
// cases when x is non-zero but tiny (e.g., 1.0e-200). // cases when x is non-zero but tiny (e.g., 1.0e-200).
const real z = real(0.0625); // 1/16 const real z = real(0.0625); // 1/16
volatile real y = std::abs(x); volatile real y = std::abs(x);
// The compiler mustn't "simplify" z - (z - y) to y // The compiler mustn't "simplify" z - (z - y) to y
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 Config.h   Config.h 
#define HAVE_LONG_DOUBLE 1 #define HAVE_LONG_DOUBLE 1
#define GEOGRAPHICLIB_VERSION_STRING "1.12" #define GEOGRAPHICLIB_VERSION_STRING "1.13"
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added


 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, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. 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: d38ac71ad012dd3652e229545db677f1a 5e24899 $" #define GEOGRAPHICLIB_CONSTANTS_HPP "$Id: 0ca861c6aa90824636e1f47472a8a8fee ab268d0 $"
#include <GeographicLib/Config.h> #include <GeographicLib/Config.h>
/** /**
* Are C++0X math functions available?
**********************************************************************/
#if !defined(GEOGRAPHICLIB_CPLUSPLUS0X_MATH)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define GEOGRAPHICLIB_CPLUSPLUS0X_MATH 1
# else
# define GEOGRAPHICLIB_CPLUSPLUS0X_MATH 0
# endif
#endif
/**
* A compile-time assert. Use C++0X static_assert, if available. * A compile-time assert. Use C++0X static_assert, if available.
**********************************************************************/ **********************************************************************/
#if !defined(STATIC_ASSERT) #if !defined(STATIC_ASSERT)
# if defined(__GXX_EXPERIMENTAL_CXX0X__) # if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define STATIC_ASSERT static_assert # define STATIC_ASSERT static_assert
# elif defined(_MSC_VER) && _MSC_VER >= 1600 # elif defined(_MSC_VER) && _MSC_VER >= 1600
# define STATIC_ASSERT static_assert # define STATIC_ASSERT static_assert
# else # else
# define STATIC_ASSERT(cond,reason) \ # define STATIC_ASSERT(cond,reason) \
{ enum{ STATIC_ASSERT_ENUM = 1/int(cond) }; } { enum{ STATIC_ASSERT_ENUM = 1/int(cond) }; }
# endif # endif
#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__((used)) = 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
#if defined(_WIN32) && defined(GEOGRAPHIC_SHARED_LIB) #if defined(_WIN32) && defined(GEOGRAPHIC_SHARED_LIB)
# if defined(Geographic_EXPORTS) # if defined(Geographic_EXPORTS)
# define GEOGRAPHIC_EXPORT __declspec(dllexport) # define GEOGRAPHIC_EXPORT __declspec(dllexport)
# else # else
# define GEOGRAPHIC_EXPORT __declspec(dllimport) # define GEOGRAPHIC_EXPORT __declspec(dllimport)
# endif # endif
#else #else
# define GEOGRAPHIC_EXPORT # define GEOGRAPHIC_EXPORT
#endif #endif
RCSID_DECL(GEOGRAPHICLIB_CONSTANTS_HPP) RCSID_DECL(GEOGRAPHICLIB_CONSTANTS_HPP)
#if !defined(GEOGRAPHICLIB_PREC)
/**
* The precision of floating point numbers used in %GeographicLib. 0 means
* float; 1 (default) means double; 2 means long double. Nearly all the
* testing has been carried out with doubles and that's the recommended
* configuration. In order for long double to be used, HAVE_LONG_DOUBLE ne
eds
* to be defined. Note that with Microsoft Visual Studio, long double is t
he
* same as double.
**********************************************************************/
#define GEOGRAPHICLIB_PREC 1
#endif
#include <cmath>
#include <limits>
#include <algorithm>
#include <stdexcept> #include <stdexcept>
#include <GeographicLib/Math.hpp>
/** /**
* \brief Namespace for %GeographicLib * \brief Namespace for %GeographicLib
* *
* All of %GeographicLib is defined within the GeographicLib namespace. In * All of %GeographicLib is defined within the GeographicLib namespace. In
* addtion all the header files are included via %GeographicLib/filename. This * addtion all the header files are included via %GeographicLib/filename. This
* minimizes the likelihood of conflicts with other packages. * minimizes the likelihood of conflicts with other packages.
**********************************************************************/ **********************************************************************/
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Mathematical functions needed by %GeographicLib
*
* Define mathematical functions in order to localize system dependencies
and
* to provide generic versions of the functions. In addition define a re
al
* type to be used by %GeographicLib.
**********************************************************************/
class GEOGRAPHIC_EXPORT Math {
private:
void dummy() {
STATIC_ASSERT((GEOGRAPHICLIB_PREC) >= 0 && (GEOGRAPHICLIB_PREC) <= 2,
"Bad value of precision");
}
Math(); // Disable constructor
public:
#if defined(HAVE_LONG_DOUBLE)
/**
* The extended precision type for real numbers, used for some testing.
* This is long double on computers with this type; otherwise it is dou
ble.
**********************************************************************
/
typedef long double extended;
#else
typedef double extended;
#endif
#if GEOGRAPHICLIB_PREC == 1
/**
* The real type for %GeographicLib. Nearly all the testing has been do
ne
* with \e real = double. However, the algorithms should also work wit
h
* float and long double (where available).
**********************************************************************
/
typedef double real;
#elif GEOGRAPHICLIB_PREC == 0
typedef float real;
#elif GEOGRAPHICLIB_PREC == 2
typedef extended real;
#else
typedef double real;
#endif
/**
* @return \e pi.
**********************************************************************
/
template<typename T>
static inline T pi() throw() { return std::atan2(T(0), -T(1)); }
/**
* A synonym for pi<real>().
**********************************************************************
/
static inline real pi() throw() { return pi<real>(); }
/// \cond DEPRECATED
/**
* <b>DEPRECATED</b> A synonym for pi<extened>().
**********************************************************************
/
static inline extended epi() throw() { return pi<extended>(); }
/// \endcond
/**
* @return the number of radians in a degree.
**********************************************************************
/
template<typename T>
static inline T degree() throw() { return pi<T>() / T(180); }
/**
* A synonym for degree<real>().
**********************************************************************
/
static inline real degree() throw() { return degree<real>(); }
/// \cond DEPRECATED
/**
* <b>DEPRECATED</b> A synonym for degree<extened>().
**********************************************************************
/
static inline extended edegree() throw() { return degree<extended>(); }
/// \endcond
/**
* Square a number.
* @param[in] x
* @return \e x<sup>2</sup>.
**********************************************************************
/
template<typename T>
static inline T sq(T x) throw() { return x * x; }
#if defined(DOXYGEN)
/**
* The hypotenuse function avoiding underflow and overflow.
*
* @param[in] x
* @param[in] y
* @return sqrt(\e x<sup>2</sup> + \e y<sup>2</sup>).
**********************************************************************
/
template<typename T>
static inline T hypot(T x, T y) throw() {
x = std::abs(x);
y = std::abs(y);
T a = (std::max)(x, y),
b = (std::min)(x, y) / (a ? a : 1);
return a * std::sqrt(1 + b * b);
}
#elif GEOGRAPHICLIB_CPLUSPLUS0X_MATH
template<typename T>
static inline T hypot(T x, T y) throw() { return std::hypot(x, y); }
#elif defined(_MSC_VER)
static inline double hypot(double x, double y) throw()
{ return _hypot(x, y); }
#if (_MSC_VER < 1400)
// Visual C++ 7.1/VS .NET 2003 does not have _hypotf()
static inline float hypot(float x, float y) throw()
{ return float(_hypot(x, y)); }
#else
static inline float hypot(float x, float y) throw()
{ return _hypotf(x, y); }
#endif
#if defined(HAVE_LONG_DOUBLE)
static inline long double hypot(long double x, long double y) throw()
{ return _hypot(x, y); }
#endif
#else
// Use overloading to define generic versions
static inline double hypot(double x, double y) throw()
{ return ::hypot(x, y); }
static inline float hypot(float x, float y) throw()
{ return ::hypotf(x, y); }
#if defined(HAVE_LONG_DOUBLE)
static inline long double hypot(long double x, long double y) throw()
{ return ::hypotl(x, y); }
#endif
#endif
#if defined(DOXYGEN) || (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MA
TH)
/**
* exp(\e x) - 1 accurate near \e x = 0. This is taken from
* N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd
* Edition (SIAM, 2002), Sec 1.14.1, p 19.
*
* @param[in] x
* @return exp(\e x) - 1.
**********************************************************************
/
template<typename T>
static inline T expm1(T x) throw() {
volatile T
y = std::exp(x),
z = y - 1;
// The reasoning here is similar to that for log1p. The expression
// mathematically reduces to exp(x) - 1, and the factor z/log(y) = (y
-
// 1)/log(y) is a slowly varying quantity near y = 1 and is accuratel
y
// computed.
return std::abs(x) > 1 ? z : z == 0 ? x : x * z / std::log(y);
}
#elif GEOGRAPHICLIB_CPLUSPLUS0X_MATH
template<typename T>
static inline T expm1(T x) throw() { return std::expm1(x); }
#else
static inline double expm1(double x) throw() { return ::expm1(x); }
static inline float expm1(float x) throw() { return ::expm1f(x); }
#if defined(HAVE_LONG_DOUBLE)
static inline long double expm1(long double x) throw()
{ return ::expm1l(x); }
#endif
#endif
#if defined(DOXYGEN) || (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MA
TH)
/**
* log(\e x + 1) accurate near \e x = 0.
*
* This is taken from D. Goldberg,
* <a href="http://dx.doi.org/10.1145/103162.103163">What every compute
r
* scientist should know about floating-point arithmetic</a> (1991),
* Theorem 4. See also, Higham (op. cit.), Answer to Problem 1.5, p 52
8.
*
* @param[in] x
* @return log(\e x + 1).
**********************************************************************
/
template<typename T>
static inline T log1p(T x) throw() {
volatile T
y = 1 + x,
z = y - 1;
// Here's the explanation for this magic: y = 1 + z, exactly, and z
// approx x, thus log(y)/z (which is nearly constant near z = 0) retu
rns
// a good approximation to the true log(1 + x)/x. The multiplication
x *
// (log(y)/z) introduces little additional error.
return z == 0 ? x : x * std::log(y) / z;
}
#elif GEOGRAPHICLIB_CPLUSPLUS0X_MATH
template<typename T>
static inline T log1p(T x) throw() { return std::log1p(x); }
#else
static inline double log1p(double x) throw() { return ::log1p(x); }
static inline float log1p(float x) throw() { return ::log1pf(x); }
#if defined(HAVE_LONG_DOUBLE)
static inline long double log1p(long double x) throw()
{ return ::log1pl(x); }
#endif
#endif
#if defined(DOXYGEN) || (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MA
TH)
/**
* The inverse hyperbolic sine function. This is defined in terms of
* Math::log1p(\e x) in order to maintain accuracy near \e x = 0. In
* addition, the odd parity of the function is enforced.
*
* @param[in] x
* @return asinh(\e x).
**********************************************************************
/
template<typename T>
static inline T asinh(T x) throw() {
T y = std::abs(x); // Enforce odd parity
y = log1p(y * (1 + y/(hypot(T(1), y) + 1)));
return x < 0 ? -y : y;
}
#elif GEOGRAPHICLIB_CPLUSPLUS0X_MATH
template<typename T>
static inline T asinh(T x) throw() { return std::asinh(x); }
#else
static inline double asinh(double x) throw() { return ::asinh(x); }
static inline float asinh(float x) throw() { return ::asinhf(x); }
#if defined(HAVE_LONG_DOUBLE)
static inline long double asinh(long double x) throw()
{ return ::asinhl(x); }
#endif
#endif
#if defined(DOXYGEN) || (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MA
TH)
/**
* The inverse hyperbolic tangent function. This is defined in terms o
f
* Math::log1p(\e x) in order to maintain accuracy near \e x = 0. In
* addition, the odd parity of the function is enforced.
*
* @param[in] x
* @return atanh(\e x).
**********************************************************************
/
template<typename T>
static inline T atanh(T x) throw() {
T y = std::abs(x); // Enforce odd parity
y = log1p(2 * y/(1 - y))/2;
return x < 0 ? -y : y;
}
#elif GEOGRAPHICLIB_CPLUSPLUS0X_MATH
template<typename T>
static inline T atanh(T x) throw() { return std::atanh(x); }
#else
static inline double atanh(double x) throw() { return ::atanh(x); }
static inline float atanh(float x) throw() { return ::atanhf(x); }
#if defined(HAVE_LONG_DOUBLE)
static inline long double atanh(long double x) throw()
{ return ::atanhl(x); }
#endif
#endif
#if defined(DOXYGEN) || (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MA
TH)
/**
* The cube root function.
*
* @param[in] x
* @return the real cube root of \e x.
**********************************************************************
/
template<typename T>
static inline T cbrt(T x) throw() {
T y = std::pow(std::abs(x), 1/T(3)); // Return the real cube root
return x < 0 ? -y : y;
}
#elif GEOGRAPHICLIB_CPLUSPLUS0X_MATH
template<typename T>
static inline T cbrt(T x) throw() { return std::cbrt(x); }
#else
static inline double cbrt(double x) throw() { return ::cbrt(x); }
static inline float cbrt(float x) throw() { return ::cbrtf(x); }
#if defined(HAVE_LONG_DOUBLE)
static inline long double cbrt(long double x) throw() { return ::cbrtl(
x); }
#endif
#endif
/**
* Test for finiteness.
*
* @param[in] x
* @return true if number is finite, false if NaN or infinite.
**********************************************************************
/
template<typename T>
static inline bool isfinite(T x) throw() {
#if defined(DOXYGEN)
return std::abs(x) <= (std::numeric_limits<T>::max)();
#elif (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MATH)
return _finite(x) != 0;
#else
return std::isfinite(x);
#endif
}
/**
* The NaN (not a number)
*
* @return NaN if available, otherwise return the max real.
**********************************************************************
/
template<typename T>
static inline T NaN() throw() {
return std::numeric_limits<T>::has_quiet_NaN ?
std::numeric_limits<T>::quiet_NaN() :
(std::numeric_limits<T>::max)();
}
/**
* A synonym for NaN<real>().
**********************************************************************
/
static inline real NaN() throw() { return NaN<real>(); }
/**
* Test for NaN.
*
* @param[in] x
* @return true if argument is a NaN.
**********************************************************************
/
template<typename T>
static inline bool isnan(T x) throw() {
#if defined(DOXYGEN) || (defined(_MSC_VER) && !GEOGRAPHICLIB_CPLUSPLUS0X_MA
TH)
return x != x;
#else
return std::isnan(x);
#endif
}
/**
* Infinity
*
* @return infinity if available, otherwise return the max real.
**********************************************************************
/
template<typename T>
static inline T infinity() throw() {
return std::numeric_limits<T>::has_infinity ?
std::numeric_limits<T>::infinity() :
(std::numeric_limits<T>::max)();
}
/**
* A synonym for infinity<real>().
**********************************************************************
/
static inline real infinity() throw() { return infinity<real>(); }
};
/**
* \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 GEOGRAPHIC_EXPORT Constants { class GEOGRAPHIC_EXPORT Constants {
private: private:
typedef Math::real real; typedef Math::real real;
Constants(); // Disable constructor Constants(); // Disable constructor
public: public:
/// \cond DEPRECATED
/**
* <b>DEPRECATED</b> A synonym for Math::pi<real>().
**********************************************************************
/
static inline Math::real pi() throw() { return Math::pi<real>(); }
/// \endcond
/** /**
* A synonym for Math::degree<real>(). * A synonym for Math::degree<real>().
********************************************************************** / ********************************************************************** /
static inline Math::real degree() throw() { return Math::degree<real>() ; } static inline Math::real degree() throw() { return Math::degree<real>() ; }
/** /**
* @return the number of radians in an arcminute. * @return the number of radians in an arcminute.
********************************************************************** / ********************************************************************** /
static inline Math::real arcminute() throw() static inline Math::real arcminute() throw()
{ return Math::degree<real>() / 60; } { return Math::degree<real>() / 60; }
/** /**
skipping to change at line 538 skipping to change at line 171
* @return the number of meters in a kilometer. * @return the number of meters in a kilometer.
********************************************************************** / ********************************************************************** /
static inline Math::real kilometer() throw() static inline Math::real kilometer() throw()
{ return 1000 * meter<real>(); } { return 1000 * meter<real>(); }
/** /**
* @return the number of meters in a nautical mile (approximately 1 arc * @return the number of meters in a nautical mile (approximately 1 arc
* minute) * minute)
********************************************************************** / ********************************************************************** /
static inline Math::real nauticalmile() throw() static inline Math::real nauticalmile() throw()
{ return 1852 * meter<real>(); } { return 1852 * meter<real>(); }
/**
* @return the number of square meters in a square meter.
*
* This is unity, but this lets the internal system of units be changed
if
* necessary.
**********************************************************************
/
template<typename T>
static inline T square_meter() throw()
{ return meter<real>() * meter<real>(); }
/**
* A synonym for square_meter<real>().
**********************************************************************
/
static inline Math::real square_meter() throw()
{ return square_meter<real>(); }
/**
* @return the number of square meters in a hectare.
**********************************************************************
/
static inline Math::real hectare() throw()
{ return 10000 * square_meter<real>(); }
/**
* @return the number of square meters in a square kilometer.
**********************************************************************
/
static inline Math::real square_kilometer() throw()
{ return kilometer() * kilometer(); }
/**
* @return the number of square meters in a square nautical mile.
**********************************************************************
/
static inline Math::real square_nauticalmile() throw()
{ return nauticalmile() * nauticalmile(); }
///@} ///@}
/** \name Anachronistic British units /** \name Anachronistic British units
********************************************************************** / ********************************************************************** /
///@{ ///@{
/** /**
* @return the number of meters in an international foot. * @return the number of meters in an international foot.
********************************************************************** / ********************************************************************** /
static inline Math::real foot() throw() static inline Math::real foot() throw()
{ return real(0.0254L) * 12 * meter<real>(); } { return real(0.0254L) * 12 * meter<real>(); }
skipping to change at line 568 skipping to change at line 231
********************************************************************** / ********************************************************************** /
static inline Math::real chain() throw() { return 22 * yard(); } static inline Math::real chain() throw() { return 22 * yard(); }
/** /**
* @return the number of meters in a furlong. * @return the number of meters in a furlong.
********************************************************************** / ********************************************************************** /
static inline Math::real furlong() throw() { return 10 * chain(); } static inline Math::real furlong() throw() { return 10 * chain(); }
/** /**
* @return the number of meters in a statute mile. * @return the number of meters in a statute mile.
********************************************************************** / ********************************************************************** /
static inline Math::real mile() throw() { return 8 * furlong(); } static inline Math::real mile() throw() { return 8 * furlong(); }
/**
* @return the number of square meters in an acre.
**********************************************************************
/
static inline Math::real acre() throw() { return chain() * furlong(); }
/**
* @return the number of square meters in a square statute mile.
**********************************************************************
/
static inline Math::real square_mile() throw() { return mile() * mile()
; }
///@} ///@}
/** \name Anachronistic US units /** \name Anachronistic US units
********************************************************************** / ********************************************************************** /
///@{ ///@{
/** /**
* @return the number of meters in a US survey foot. * @return the number of meters in a US survey foot.
********************************************************************** / ********************************************************************** /
static inline Math::real surveyfoot() throw() static inline Math::real surveyfoot() throw()
{ return real(1200) / real(3937) * meter<real>(); } { return real(1200) / real(3937) * meter<real>(); }
///@} ///@}
}; };
/** /**
* \brief An accumulator for sums.
*
* This allow many numbers of floating point type \e T to be added togeth
er
* with twice the normal precision. Thus if \e T is double, the effectiv
e
* precision of the sum is 106 bits or about 32 decimal places. The core
* idea is the error free transformation of a sum, D. E. Knuth, TAOCP, Vo
l 2,
* 4.2.2, Theorem B.
*
* Two implementations are provided. The "fast" one is an implementation
of
* Algorithm 4.1, of T. Ogita, S. M. Rump, S. Oishi,
* <a href="http://dx.doi.org/10.1137/030601818"> Accurate sum and dot
* product</a>, SIAM J. Sci. Comp., 26(6) 1955-1988 (2005). The accumula
tor
* is represented by a two numbers _s + _t where _s is the result of the
* normal sum and _t accumulates (approximately) the exact roundoff error
s in
* the summation of _s.
*
* The slow "non-fast" implementation follows J. R. Shewchuk,
* <a href="http://dx.doi.org/10.1007/PL00009321"> Adaptive Precision
* Floating-Point Arithmetic and Fast Robust Geometric Predicates</a>,
* Discrete & Computational Geometry 18(3) 305-363 (1997). In this case,
* with each addition of a number to the accumulator, _s and _t are adjus
ted
* so that _s represents the sum to an accuracy of 1 ulp. This may resul
t in
* considerably greater accuracy than the fast implementation (depending
on
* the input data).
*
* Approximate timings (summing vector<double> per addition)
* - double: 2ns = 1
* - Accumulator<double, true>: 7ns = 3.5
* - Accumulator<double, true>: 21ns = 10 -- Optimize() on each addition
* - Accumulator<double, false>: 23ns = 11
* .
* Thus the slow method is about 3 times slower than the fast method.
* However all times are negligible with the typical timings for geodesic
* calculations which are roughly 2us. Thus the default mode is taken to
be
* slow, \e fast = false.
*
* In the documentation of the member functions, \e sum stands for the va
lue
* currently held in the accumulator.
**********************************************************************/
template<typename T = Math::real, bool fast = false>
class Accumulator {
private:
// _s accumulates for the straight sum
// _t accumulates the errors.
T _s, _t;
// Error free transformation of a sum. Note that t can be the same as
one
// of the first two arguments.
static inline T sum(T u, T v, T& t) {
volatile T s = u + v;
volatile T up = s - v;
volatile T vpp = s - up;
up -= u;
vpp -= v;
t = -(up + vpp);
// u + v = s + t
// = round(u + v) + t
return s;
}
// Same as sum, but requires abs(u) >= abs(v). This isn't currently us
ed.
static inline T fastsum(T u, T v, T& t) {
volatile T s = u + v;
volatile T vp = s - u;
t = v - vp;
return s;
}
void Add(T y) throw() {
if (fast) {
_s = sum(_s, y, y); // Accumulate sum to _s with error in y;
_t += y; // accumulate y in _t
} else { // Here's Shewchuk's solution...
T u; // hold exact sum as [s, t, u]
y = sum(y, _t, u); // Accumulate starting at least significant
end
_s = sum(y, _s, _t);
// Start is _s, _t decreasing and non-adjacent. Sum is now (s + t
+ u)
// exactly with s, t, u non-adjacent and in decreasing order (excep
t
// for possible zeros). The following code tries to normalize the
// result. Ideally, we want _s = round(s+t+u) and _u = round(s+t+u
-
// _s). The follow does an approximate job (and maintains the
// decreasing non-adjacent property). Here are two "failures" usin
g
// 3-bit floats:
//
// Case 1: _s is not equal to round(s+t+u) -- off by 1 ulp
// [12, -1] - 8 -> [4, 0, -1] -> [4, -1] = 3 should be [3, 0] = 3
//
// Case 2: _s+_t is not as close to s+t+u as it shold be
// [64, 5] + 4 -> [64, 8, 1] -> [64, 8] = 72 (off by 1)
// should be [80, -7] = 73 (exact)
//
// "Fixing" these problems is probably not worth the expense. The
// representation inevitably leads to small errors in the accumulat
ed
// values. The additional errors illustrated here amount to 1 ulp
of
// the less significant word during each addition to the Accumulato
r
// and an additional possible error of 1 ulp in the reported sum.
//
// Incidentally, the "ideal" representation described above is not
// canonical, because _s = round(_s + _t) may not be true. For
// example, with 3-bit floats:
//
// [128, 16] + 1 -> [160, -16] -- 160 = round(145).
// But [160, 0] - 16 -> [128, 16] -- 128 = round(144).
//
if (_s == 0) // This implies t == 0,
_s = u; // so result is u
else
_t += u; // otherwise just accumulate u to t.
}
}
// Perhaps these should both be _s + _t?
T Sum() const throw() { return fast ? _s + _t : _s; }
T Sum(T y) const throw() {
Accumulator a(*this);
a.Add(y);
return a.Sum();
}
public:
/**
* Construct from a \e T. This is not declared explicit, so that you c
an
* write <code>Accumulator<double> a = 5;</code>.
*
* @param[in] y set \e sum = \e y.
**********************************************************************
/
Accumulator(T y = T(0)) throw() : _s(y), _t(0) {
STATIC_ASSERT(!std::numeric_limits<T>::is_integer,
"Accumulator type is not floating point");
};
/**
* Set the accumulator to a number.
*
* @param[in] y set \e sum = \e y.
**********************************************************************
/
Accumulator& operator=(T y) throw() { _s = y; _t = 0; return *this; }
/**
* Return the value held in the accumulator.
*
* @return \e sum.
**********************************************************************
/
T operator()() const throw() { return Sum(); }
/**
* Return the result of adding a number to \e sum (but don't change \e
sum).
*
* @param[in] y the number to be added to the sum.
* @return \e sum + \e y.
**********************************************************************
/
T operator()(T y) const throw() { return Sum(y); }
/**
* Add a number to the accumulator.
*
* @param[in] y set \e sum += \e y.
**********************************************************************
/
Accumulator& operator+=(T y) throw() { Add(y); return *this; }
/**
* Subtract a number from the accumulator.
*
* @param[in] y set \e sum -= \e y.
**********************************************************************
/
Accumulator& operator-=(T y) throw() { Add(-y); return *this; }
/**
* Multiply accumulator by an integer. To avoid loss of accuracy, use
only
* integers such that \e n * \e T is exactly representable as a \e T (i
.e.,
* +/- powers of two). Use \e n = -1 to negate \e sum.
*
* @param[in] n set \e sum *= \e n.
**********************************************************************
/
Accumulator& operator*=(int n) throw() { _s *= n; _t *= n; return *this
; }
/**
* Optimize how \e sum is stored in the accumulator. This is a no-op f
or
* the non-fast implementation. It is rarely necessary to do this; how
ever
* the accuracy might be improved if this function is called every time
a
* million numbers (for example) have been added to the accumulator.
**********************************************************************
/
void Optimize() throw() { if (fast) _s = sum(_s, _t, _t); }
/**
* Test equality of an Accumulator with a number.
**********************************************************************
/
bool operator==(T y) const throw() { return Sum() == y; }
/**
* Test inequality of an Accumulator with a number.
**********************************************************************
/
bool operator!=(T y) const throw() { return Sum() != y; }
/**
* Less operator on an Accumulator and a number.
**********************************************************************
/
bool operator<(T y) const throw() { return Sum() < y; }
/**
* Less or equal operator on an Accumulator and a number.
**********************************************************************
/
bool operator<=(T y) const throw() { return Sum() <= y; }
/**
* Greater operator on an Accumulator and a number.
**********************************************************************
/
bool operator>(T y) const throw() { return Sum() > y; }
/**
* Greater or equal operator on an Accumulator and a number.
**********************************************************************
/
bool operator>=(T y) const throw() { return Sum() >= y; }
};
/**
* \brief Exception handling for %GeographicLib * \brief Exception handling for %GeographicLib
* *
* A class to handle exceptions. It's derived from std::runtime_error so it * A class to handle exceptions. It's derived from std::runtime_error so it
* can be caught by the usual catch clauses. * can be caught by the usual catch clauses.
**********************************************************************/ **********************************************************************/
class GeographicErr : public std::runtime_error { class GeographicErr : public std::runtime_error {
public: public:
/** /**
* Constructor * Constructor
 End of changes. 10 change blocks. 
654 lines changed or deleted 50 lines changed or added


 DMS.hpp   DMS.hpp 
/** /**
* \file DMS.hpp * \file DMS.hpp
* \brief Header for GeographicLib::DMS class * \brief Header for GeographicLib::DMS class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_DMS_HPP) #if !defined(GEOGRAPHICLIB_DMS_HPP)
#define GEOGRAPHICLIB_DMS_HPP "$Id: 3d0c051c53cf51014788621dda01462bb08e2d8 c $" #define GEOGRAPHICLIB_DMS_HPP "$Id: 16d1a2985b695804891175f5537abff45cd2459 2 $"
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Squelch warnings about dll vs string // Squelch warnings about dll vs string
#pragma warning (push) #pragma warning (push)
#pragma warning (disable: 4251) #pragma warning (disable: 4251)
#endif #endif
skipping to change at line 42 skipping to change at line 42
class GEOGRAPHIC_EXPORT DMS { class GEOGRAPHIC_EXPORT DMS {
private: private:
typedef Math::real real; typedef Math::real real;
static int lookup(const std::string& s, char c) throw() { static int lookup(const std::string& s, char c) throw() {
std::string::size_type r = s.find(toupper(c)); std::string::size_type r = s.find(toupper(c));
return r == std::string::npos ? -1 : int(r); return r == std::string::npos ? -1 : int(r);
} }
template<typename T> static std::string str(T x) { template<typename T> static std::string str(T x) {
std::ostringstream s; s << x; return s.str(); std::ostringstream s; s << x; return s.str();
} }
// Replace all occurrences of pat by c
static void replace(std::string& s, const std::string& pat, char c) {
std::string::size_type p = 0;
while (true) {
p = s.find(pat, p);
if (p == std::string::npos)
break;
s.replace(p, pat.length(), 1, c);
}
}
static const std::string hemispheres_; static const std::string hemispheres_;
static const std::string signs_; static const std::string signs_;
static const std::string digits_; static const std::string digits_;
static const std::string dmsindicators_; static const std::string dmsindicators_;
static const std::string components_[3]; static const std::string components_[3];
static Math::real NumMatch(const std::string& s); static Math::real NumMatch(const std::string& s);
DMS(); // Disable constructor DMS(); // Disable constructor
public: public:
skipping to change at line 110 skipping to change at line 120
* Trailing unit is arc seconds. * Trailing unit is arc seconds.
* @hideinitializer * @hideinitializer
******************************************************************** **/ ******************************************************************** **/
SECOND = 2, SECOND = 2,
}; };
/** /**
* Convert a string in DMS to an angle. * Convert a string in DMS to an angle.
* *
* @param[in] dms string input. * @param[in] dms string input.
* @param[out] ind a DMS::flag value indicating the presence of a * @param[out] ind a DMS::flag value signalling the presence of a
* hemisphere indicator. * hemisphere indicator.
* @return angle (degrees). * @return angle (degrees).
* *
* Degrees, minutes, and seconds are indicated by the letters d, ', &qu * Degrees, minutes, and seconds are indicated by the characters d, '
ot;, * (single quote), &quot; (double quote), and these components may only
* and these components_ may only be given in this order. Any (but not be
all) * given in this order. Any (but not all) components may be omitted an
* components_ may be omitted. The last component indicator may be omi d
tted * other symbols (e.g., the <sup>o</sup> symbol for degrees and the uni
* and is assumed to be tbe next smallest unit (thus 33d10 is interpret code
ed * prime and double prime symbols for minutes and seconds) may be
* as 33d10'). The final component may be a decimal fraction but the * substituted. The last component indicator may be omitted and is ass
* non-final components_ must be integers. The integer parts of the mi umed
nutes * to be the next smallest unit (thus 33d10 is interpreted as 33d10').
* and seconds components_ must be less than 60. A single leading sign The
is * final component may be a decimal fraction but the non-final componen
* permitted. A hemisphere designator (N, E, W, S) may be added to tbe ts
* beginning or end of the string. The result is multiplied by the imp * must be integers. Instead of using d, ', and &quot; to indicate
lied * degrees, minutes, and seconds, : (colon) may be used to <i>separate<
* signed of the hemisphere designator (negative for S and W). In addi /i>
tion * these components (numbers must appear before and after each colon);
* \e ind is set to DMS::LATITUDE if N or S is present, to DMS::LONGITU thus
DE * 50d30'10.3&quot; may be written as 50:30:10.3, 5.5' may be written
* if E or W is present, and to DMS::NONE otherwise. Throws an error o * 0:5.5, and so on. The integer parts of the minutes and seconds
n a * components must be less than 60. A single leading sign is permitted
* malformed string. No check is performed on the range of the result. . A
* hemisphere designator (N, E, W, S) may be added to the beginning or
end
* of the string. The result is multiplied by the implied sign of the
* hemisphere designator (negative for S and W). In addition \e ind is
set
* to DMS::LATITUDE if N or S is present, to DMS::LONGITUDE if E or W i
s
* present, and to DMS::NONE otherwise. Throws an error on a malformed
* string. No check is performed on the range of the result. Examples
of
* legal and illegal strings are
* - <i>LEGAL</i> (all the entries on each line are equivalent)
* - -20.51125, 20d30'40.5&quot;S, -20d30'40.5, -20d30.675,
* N-20d30'40.5&quot;, -20:30:40.5
* - 4d0'9, 4d9", 4d9'', 4:0:9, 004:00:09, 4.0025, 4.0025d, 4d0.15,
* 04:.15
* - <i>ILLEGAL</i> (the exception thrown explains the problem)
* - 4d5"4', 4::5, 4:5:, :4:5, 4d4.5'4", -N20.5, 1.8e2d, 4:60,
* 4d-5'
*
* <b>NOTE:</b> At present, all the string handling in the C++
* implementation %GeographicLib is with 8-bit characters. The support
for
* unicode symbols for degrees, minutes, and seconds is therefore via t
he
* <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> encoding. (T
he
* Javascript implementation of this class uses unicode natively, of
* course.)
********************************************************************** / ********************************************************************** /
static Math::real Decode(const std::string& dms, flag& ind); static Math::real Decode(const std::string& dms, flag& ind);
/** /**
* Convert DMS to an angle. * Convert DMS to an angle.
* *
* @param[in] d degrees. * @param[in] d degrees.
* @param[in] m arc minutes. * @param[in] m arc minutes.
* @param[in] s arc seconds. * @param[in] s arc seconds.
* @return angle (degrees) * @return angle (degrees)
* *
* This does not propagate the sign on \e d to the other components_, s o * This does not propagate the sign on \e d to the other components, so
* -3d20' would need to be represented as - DMS::Decode(3.0, 20.0) or * -3d20' would need to be represented as - DMS::Decode(3.0, 20.0) or
* DMS::Decode(-3.0, -20.0). * DMS::Decode(-3.0, -20.0).
********************************************************************** / ********************************************************************** /
static Math::real Decode(real d, real m = 0, real s = 0) throw() static Math::real Decode(real d, real m = 0, real s = 0) throw()
{ return d + (m + s/real(60))/real(60); } { return d + (m + s/real(60))/real(60); }
/** /**
* Convert a string to a real number. * Convert a string to a real number.
* *
* @param[in] str string input. * @param[in] str string input.
skipping to change at line 169 skipping to change at line 202
********************************************************************** / ********************************************************************** /
static Math::real DecodeFraction(const std::string& str); static Math::real DecodeFraction(const std::string& str);
/** /**
* Convert a pair of strings to latitude and longitude. * Convert a pair of strings to latitude and longitude.
* *
* @param[in] dmsa first string. * @param[in] dmsa first string.
* @param[in] dmsb second string. * @param[in] dmsb second string.
* @param[out] lat latitude. * @param[out] lat latitude.
* @param[out] lon longitude. * @param[out] lon longitude.
* @param[in] swaplatlong if true assume longitude is given before lati
tude
* in the absence of hemisphere designators (default false).
* *
* By default, the \e lat (resp., \e lon) is assigned to the results of * By default, the \e lat (resp., \e lon) is assigned to the results of
* decoding \e dmsa (resp., \e dmsb). However this is overridden if ei ther * decoding \e dmsa (resp., \e dmsb). However this is overridden if ei ther
* \e dmsa or \e dmsb contain a latitude or longitude hemisphere design ator * \e dmsa or \e dmsb contain a latitude or longitude hemisphere design ator
* (N, S, E, W). Throws an error if the decoded numbers are out of the * (N, S, E, W). Throws an error if the decoded numbers are out of the
* ranges [-90<sup>o</sup>, 90<sup>o</sup>] for latitude and * ranges [-90<sup>o</sup>, 90<sup>o</sup>] for latitude and
* [-180<sup>o</sup>, 360<sup>o</sup>] for longitude and, in which case \e * [-180<sup>o</sup>, 360<sup>o</sup>] for longitude and, in which case \e
* lat and \e lon are unchanged. Finally the longitude is reduced to t he * lat and \e lon are unchanged. Finally the longitude is reduced to t he
* range [-180<sup>o</sup>, 180<sup>o</sup>). * range [-180<sup>o</sup>, 180<sup>o</sup>).
********************************************************************** / ********************************************************************** /
static void DecodeLatLon(const std::string& dmsa, const std::string& dm sb, static void DecodeLatLon(const std::string& dmsa, const std::string& dm sb,
real& lat, real& lon); real& lat, real& lon, bool swaplatlong = false );
/** /**
* Convert a string to an angle in degrees. * Convert a string to an angle in degrees.
* *
* @param[in] angstr input string. * @param[in] angstr input string.
* @return angle (degrees) * @return angle (degrees)
* *
* No hemisphere designator is allowed and no check is done on the rang e of * No hemisphere designator is allowed and no check is done on the rang e of
* the result. * the result.
********************************************************************** / ********************************************************************** /
skipping to change at line 212 skipping to change at line 247
* the range [-180<sup>o</sup>, 180<sup>o</sup>). * the range [-180<sup>o</sup>, 180<sup>o</sup>).
********************************************************************** / ********************************************************************** /
static Math::real DecodeAzimuth(const std::string& azistr); static Math::real DecodeAzimuth(const std::string& azistr);
/** /**
* Convert angle (in degrees) into a DMS string. * Convert angle (in degrees) into a DMS string.
* *
* @param[in] angle input angle (degrees) * @param[in] angle input angle (degrees)
* @param[in] trailing DMS::component value indicating the trailing uni ts * @param[in] trailing DMS::component value indicating the trailing uni ts
* on the string and this is given as a decimal number if necessary. * on the string and this is given as a decimal number if necessary.
* @param[in] prec the number of digits_ after the decimal point for th e * @param[in] prec the number of digits after the decimal point for the
* trailing component. * trailing component.
* @param[in] ind DMS::flag value indicated additional formatting. * @param[in] ind DMS::flag value indicated additional formatting.
* @return formatted string * @return formatted string
* *
* The interpretation of \e ind is as follows: * The interpretation of \e ind is as follows:
* - ind == DMS::NONE, signed result no leading zeros on degrees except in * - ind == DMS::NONE, signed result no leading zeros on degrees except in
* the units place, e.g., -8d03'. * the units place, e.g., -8d03'.
* - ind == DMS::LATITUDE, trailing N or S hemisphere designator, no si gn, * - ind == DMS::LATITUDE, trailing N or S hemisphere designator, no si gn,
* pad degrees to 2 digits_, e.g., 08d03'S. * pad degrees to 2 digits, e.g., 08d03'S.
* - ind == DMS::LONGITUDE, trailing E or W hemisphere designator, no * - ind == DMS::LONGITUDE, trailing E or W hemisphere designator, no
* sign, pad degrees to 3 digits_, e.g., 008d03'W. * sign, pad degrees to 3 digits, e.g., 008d03'W.
* - ind == DMS::AZIMUTH, convert to the range [0, 360<sup>o</sup>), no * - ind == DMS::AZIMUTH, convert to the range [0, 360<sup>o</sup>), no
* sign, pad degrees to 3 digits_, , e.g., 351d57'. * sign, pad degrees to 3 digits, , e.g., 351d57'.
* . * .
* The integer parts of the minutes and seconds components_ are always * The integer parts of the minutes and seconds components are always g
given iven
* with 2 digits_. * with 2 digits.
********************************************************************** / ********************************************************************** /
static std::string Encode(real angle, component trailing, unsigned prec , static std::string Encode(real angle, component trailing, unsigned prec ,
flag ind = NONE); flag ind = NONE);
/** /**
* Convert angle into a DMS string selecting the trailing component * Convert angle into a DMS string selecting the trailing component
* based on the precision. * based on the precision.
* *
* @param[in] angle input angle (degrees) * @param[in] angle input angle (degrees)
* @param[in] prec the precision relative to 1 degree. * @param[in] prec the precision relative to 1 degree.
 End of changes. 12 change blocks. 
34 lines changed or deleted 76 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, 2011) <charles@karney.com> * Copyright (c) Charles Karney (2008, 2009, 2011) <charles@karney.com>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. 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: d792b6c69cf47621f2fbee0285 4010cebba9feac $" #define GEOGRAPHICLIB_ELLIPTICFUNCTION_HPP "$Id: 1ed2e0020530f29db210a5816b d9990ce5cd05f5 $"
#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 55 skipping to change at line 55
static const real tol_; static const real tol_;
static const real tolRF_; static const real tolRF_;
static const real tolRD_; static const real tolRD_;
static const real tolRG0_; static const real tolRG0_;
static const real tolJAC_; static const real tolJAC_;
static const real tolJAC1_; static const real tolJAC1_;
enum { num_ = 10 }; // Max depth required for sncndn. Probably 5 is en ough. enum { num_ = 10 }; // Max depth required for sncndn. Probably 5 is en ough.
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; 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. * Constructor.
* *
* @param[in] m the parameter which must lie in [0, 1]. (No checking * @param[in] m the parameter which must lie in [0, 1]. (No checking
* is done.) * is done.)
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 GeoCoords.hpp   GeoCoords.hpp 
/** /**
* \file GeoCoords.hpp * \file GeoCoords.hpp
* \brief Header for GeographicLib::GeoCoords class * \brief Header for GeographicLib::GeoCoords class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#ifndef GEOGRAPHICLIB_GEOCOORDS_HPP #ifndef GEOGRAPHICLIB_GEOCOORDS_HPP
#define GEOGRAPHICLIB_GEOCOORDS_HPP "$Id: d7bac63e51ac0d5aeb4b27c87f7f5ebaf 8baa134 $" #define GEOGRAPHICLIB_GEOCOORDS_HPP "$Id: 0498603ef805f63465c670a5ded816492 d3bc631 $"
#include <GeographicLib/UTMUPS.hpp> #include <GeographicLib/UTMUPS.hpp>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Conversion between geographic coordinates * \brief Conversion between geographic coordinates
* *
* This class stores a geographic position which may be set via the * This class stores a geographic position which may be set via the
skipping to change at line 88 skipping to change at line 88
, _zone(0) , _zone(0)
{ CopyToAlt(); } { CopyToAlt(); }
/** /**
* Construct from a string. * Construct from a string.
* *
* @param[in] s 1-element, 2-element, or 3-element string representatio n of * @param[in] s 1-element, 2-element, or 3-element string representatio n of
* the position. * the position.
* @param[in] centerp governs the interpretation of MGRS coordinates (s ee * @param[in] centerp governs the interpretation of MGRS coordinates (s ee
* below). * below).
* @param[in] swaplatlong governs the interpretation of geographic
* coordinates (see below).
* *
* Parse as a string and interpret it as a geographic position. The in put * Parse as a string and interpret it as a geographic position. The in put
* string is broken into space (or comma) separated pieces and Basic * string is broken into space (or comma) separated pieces and Basic
* decision on which format is based on number of components * decision on which format is based on number of components
* -# MGRS * -# MGRS
* -# "Lat Long" or "Long Lat" * -# "Lat Long" or "Long Lat"
* -# "Zone Easting Northing" or "Easting Northing Zone" * -# "Zone Easting Northing" or "Easting Northing Zone"
* *
* The following inputs are approximately the same (Ar Ramadi Bridge, I raq) * The following inputs are approximately the same (Ar Ramadi Bridge, I raq)
* - Latitude and Longitude * - Latitude and Longitude
skipping to change at line 111 skipping to change at line 113
* - MGRS * - MGRS
* - 38SLC301 * - 38SLC301
* - 38SLC391014 * - 38SLC391014
* - 38SLC3918701405 * - 38SLC3918701405
* - 37SHT9708 * - 37SHT9708
* - UTM * - UTM
* - 38N 339188 3701405 * - 38N 339188 3701405
* - 897039 3708229 37N * - 897039 3708229 37N
* *
* Latitude and Longitude parsing. Latitude precedes longitude, unless a * Latitude and Longitude parsing. Latitude precedes longitude, unless a
* N, S, E, W hemisphere designator is used on one or both coordinates. * N, S, E, W hemisphere designator is used on one or both coordinates.
* Thus If
* \e swaplatlong = true (default is false), then longitude precedes
* latitude in the absence of a hemisphere designator. Thus (with \e
* swaplatlong = false)
* - 40 -75 * - 40 -75
* - N40 W75 * - N40 W75
* - -75 N40 * - -75 N40
* - 75W 40N * - 75W 40N
* - E-75 -40S * - E-75 -40S
* . * .
* are all the same position. The coodinates may be given in decimal * are all the same position. The coodinates may be given in decimal
* degrees, degrees and decimal minutes, degrees, minutes, seconds, etc . * degrees, degrees and decimal minutes, degrees, minutes, seconds, etc .
* Use d, ', and " to make off the degrees, minutes and seconds. Thus * Use d, ', and " to make off the degrees, minutes and seconds. Thus
* - 40d30'30" * - 40d30'30"
skipping to change at line 153 skipping to change at line 157
* position; thus: * position; thus:
* - 38SMB = 38N 450000 3650000 * - 38SMB = 38N 450000 3650000
* - 38SMB4484 = 38N 444500 3684500 * - 38SMB4484 = 38N 444500 3684500
* - 38SMB44148470 = 38N 444145 3684705 * - 38SMB44148470 = 38N 444145 3684705
* . * .
* Otherwise, the "south-west" corner of the square is used, i.e., * Otherwise, the "south-west" corner of the square is used, i.e.,
* - 38SMB = 38N 400000 3600000 * - 38SMB = 38N 400000 3600000
* - 38SMB4484 = 38N 444000 3684000 * - 38SMB4484 = 38N 444000 3684000
* - 38SMB44148470 = 38N 444140 3684700 * - 38SMB44148470 = 38N 444140 3684700
********************************************************************** / ********************************************************************** /
explicit GeoCoords(const std::string& s, bool centerp = true) explicit GeoCoords(const std::string& s,
{ Reset(s, centerp); } bool centerp = true, bool swaplatlong = false)
{ Reset(s, centerp, swaplatlong); }
/** /**
* Construct from geographic coordinates. * Construct from geographic coordinates.
* *
* @param[in] latitude (degrees). * @param[in] latitude (degrees).
* @param[in] longitude (degrees). * @param[in] longitude (degrees).
* @param[in] zone if specified, force the UTM/UPS representation to us e a * @param[in] zone if specified, force the UTM/UPS representation to us e a
* specified zone using the rules given in UTMUPS::zonespec. * specified zone using the rules given in UTMUPS::zonespec.
********************************************************************** / ********************************************************************** /
GeoCoords(real latitude, real longitude, int zone = UTMUPS::STANDARD) { GeoCoords(real latitude, real longitude, int zone = UTMUPS::STANDARD) {
skipping to change at line 182 skipping to change at line 187
* @param[in] northp hemisphere (true means north, false means south). * @param[in] northp hemisphere (true means north, false means south).
* @param[in] easting (meters). * @param[in] easting (meters).
* @param[in] northing (meters). * @param[in] northing (meters).
********************************************************************** / ********************************************************************** /
GeoCoords(int zone, bool northp, real easting, real northing) { GeoCoords(int zone, bool northp, real easting, real northing) {
Reset(zone, northp, easting, northing); Reset(zone, northp, easting, northing);
} }
/** /**
* Reset the location from a string. See * Reset the location from a string. See
* GeoCoords(const std::string& s, bool centerp). * GeoCoords(const std::string& s, bool centerp, bool swaplatlong).
********************************************************************** / ********************************************************************** /
void Reset(const std::string& s, bool centerp = true); void Reset(const std::string& s,
bool centerp = true, bool swaplatlong = false);
/** /**
* Reset the location in terms of geographic coordinates. See * Reset the location in terms of geographic coordinates. See
* GeoCoords(real latitude, real longitude, int zone). * GeoCoords(real latitude, real longitude, int zone).
********************************************************************** / ********************************************************************** /
void Reset(real latitude, real longitude, int zone = UTMUPS::STANDARD) { void Reset(real latitude, real longitude, int zone = UTMUPS::STANDARD) {
UTMUPS::Forward(latitude, longitude, UTMUPS::Forward(latitude, longitude,
_zone, _northp, _easting, _northing, _gamma, _k, _zone, _northp, _easting, _northing, _gamma, _k,
zone); zone);
_lat = latitude; _lat = latitude;
skipping to change at line 330 skipping to change at line 336
///@} ///@}
/** \name String representations of the GeoCoords object /** \name String representations of the GeoCoords object
********************************************************************** / ********************************************************************** /
///@{ ///@{
/** /**
* String representation with latitude and longitude as signed decimal * String representation with latitude and longitude as signed decimal
* degrees. * degrees.
* *
* @param[in] prec precision (relative to about 1m). * @param[in] prec precision (relative to about 1m).
* @param[in] swaplatlong if true give longitude first (default = false )
* @return decimal latitude/longitude string representation. * @return decimal latitude/longitude string representation.
* *
* Precision specifies accuracy of representation as follows: * Precision specifies accuracy of representation as follows:
* - prec = -5 (min), 1d * - prec = -5 (min), 1d
* - prec = 0, 10<sup>-5</sup>d (about 1m) * - prec = 0, 10<sup>-5</sup>d (about 1m)
* - prec = 3, 10<sup>-8</sup>d * - prec = 3, 10<sup>-8</sup>d
* - prec = 9 (max), 10<sup>-14</sup>d * - prec = 9 (max), 10<sup>-14</sup>d
********************************************************************** / ********************************************************************** /
std::string GeoRepresentation(int prec = 0) const; std::string GeoRepresentation(int prec = 0, bool swaplatlong = false) c onst;
/** /**
* String representation with latitude and longitude as degrees, minute s, * String representation with latitude and longitude as degrees, minute s,
* seconds, and hemisphere. * seconds, and hemisphere.
* *
* @param[in] prec precision (relative to about 1m) * @param[in] prec precision (relative to about 1m)
* @param[in] swaplatlong if true give longitude first (default = false )
* @return DMS latitude/longitude string representation. * @return DMS latitude/longitude string representation.
* *
* Precision specifies accuracy of representation as follows: * Precision specifies accuracy of representation as follows:
* - prec = -5 (min), 1d * - prec = -5 (min), 1d
* - prec = -4, 0.1d * - prec = -4, 0.1d
* - prec = -3, 1' * - prec = -3, 1'
* - prec = -2, 0.1' * - prec = -2, 0.1'
* - prec = -1, 1" * - prec = -1, 1"
* - prec = 0, 0.1" (about 3m) * - prec = 0, 0.1" (about 3m)
* - prec = 1, 0.01" * - prec = 1, 0.01"
* - prec = 10 (max), 10<sup>-11</sup>" * - prec = 10 (max), 10<sup>-11</sup>"
********************************************************************** / ********************************************************************** /
std::string DMSRepresentation(int prec = 0) const; std::string DMSRepresentation(int prec = 0, bool swaplatlong = false) c onst;
/** /**
* MGRS string. * MGRS string.
* *
* @param[in] prec precision (relative to about 1m). * @param[in] prec precision (relative to about 1m).
* @return MGRS string. * @return MGRS string.
* *
* This gives the coordinates of the enclosing grid square with size gi ven * This gives the coordinates of the enclosing grid square with size gi ven
* by the precision. Thus 38N 444180 3684790 converted to a MGRS * by the precision. Thus 38N 444180 3684790 converted to a MGRS
* coordinate at precision -2 (100m) is 38SMB441847 and not 38SMB442848 . * coordinate at precision -2 (100m) is 38SMB441847 and not 38SMB442848 .
 End of changes. 10 change blocks. 
9 lines changed or deleted 18 lines changed or added


 Geocentric.hpp   Geocentric.hpp 
/** /**
* \file Geocentric.hpp * \file Geocentric.hpp
* \brief Header for GeographicLib::Geocentric class * \brief Header for GeographicLib::Geocentric class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_GEOCENTRIC_HPP) #if !defined(GEOGRAPHICLIB_GEOCENTRIC_HPP)
#define GEOGRAPHICLIB_GEOCENTRIC_HPP "$Id: 8f8b1d77b1719a8254cc7b3a7c148273 1f175b08 $" #define GEOGRAPHICLIB_GEOCENTRIC_HPP "$Id: be669ce9c6549259c44bc2047e890d36 8c09377f $"
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief %Geocentric coordinates * \brief %Geocentric coordinates
* *
skipping to change at line 61 skipping to change at line 61
* outside the ellipsoid), the error is bounded by 7 nm for the WGS84 * outside the ellipsoid), the error is bounded by 7 nm for the WGS84
* ellipsoid. See \ref geocentric for further information on the errors. * ellipsoid. See \ref geocentric for further information on the errors.
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT Geocentric { class GEOGRAPHIC_EXPORT Geocentric {
private: private:
typedef Math::real real; typedef Math::real real;
friend class LocalCartesian; friend class LocalCartesian;
static const size_t dim_ = 3; static const size_t dim_ = 3;
static const size_t dim2_ = dim_ * dim_; static const size_t dim2_ = dim_ * dim_;
const real _a, _f, _r, _e2, _e2m, _e2a, _e4a, _maxrad; real _a, _f, _e2, _e2m, _e2a, _e4a, _maxrad;
// Actually this can be static because it doesn't depend on the ellipso id. // Actually this can be static because it doesn't depend on the ellipso id.
// But let's be more general than that. // But let's be more general than that.
void Rotation(real sphi, real cphi, real slam, real clam, void Rotation(real sphi, real cphi, real slam, real clam,
real M[dim2_]) const throw(); real M[dim2_]) const throw();
void IntForward(real lat, real lon, real h, real& x, real& y, real& z, void IntForward(real lat, real lon, real h, real& x, real& y, real& z,
real M[dim2_]) const throw(); real M[dim2_]) const throw();
void IntReverse(real x, real y, real z, real& lat, real& lon, real& h, void IntReverse(real x, real y, real z, real& lat, real& lon, real& h,
real M[dim2_]) const throw(); real M[dim2_]) const throw();
public: public:
skipping to change at line 214 skipping to change at line 214
/** /**
* @return \e f the flattening of the ellipsoid. This is the * @return \e f the flattening of the ellipsoid. This is the
* value used in the constructor. * value used in the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
///@} ///@}
/** /**
* A global instantiation of Geocentric with the parameters for the WGS 84 * A global instantiation of Geocentric with the parameters for the WGS 84
* ellipsoid. * ellipsoid.
********************************************************************** / ********************************************************************** /
static const Geocentric WGS84; static const Geocentric WGS84;
}; };
} // namespace GeographicLib } // namespace GeographicLib
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 Geodesic.hpp   Geodesic.hpp 
/** /**
* \file Geodesic.hpp * \file Geodesic.hpp
* \brief Header for GeographicLib::Geodesic class * \brief Header for GeographicLib::Geodesic class
* *
* Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> * Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_GEODESIC_HPP) #if !defined(GEOGRAPHICLIB_GEODESIC_HPP)
#define GEOGRAPHICLIB_GEODESIC_HPP "$Id: 08483b14e89af4913976c07a8a2fb1770e a54454 $" #define GEOGRAPHICLIB_GEODESIC_HPP "$Id: a9dc85ae0526d5af9797527673a442036e c47ba7 $"
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
#if !defined(GEOD_ORD) #if !defined(GEOD_ORD)
/** /**
* The order of the expansions used by Geodesic. * The order of the expansions used by Geodesic.
**********************************************************************/ **********************************************************************/
#define GEOD_ORD (GEOGRAPHICLIB_PREC == 1 ? 6 : GEOGRAPHICLIB_PREC == 0 ? 3 #define GEOD_ORD \
: 7) (GEOGRAPHICLIB_PREC == 1 ? 6 : (GEOGRAPHICLIB_PREC == 0 ? 3 : 7))
#endif #endif
namespace GeographicLib { namespace GeographicLib {
class GeodesicLine; class GeodesicLine;
/** /**
* \brief %Geodesic calculations * \brief %Geodesic calculations
* *
skipping to change at line 154 skipping to change at line 155
CAP_C4 = 1U<<4, CAP_C4 = 1U<<4,
CAP_ALL = 0x1FU, CAP_ALL = 0x1FU,
OUT_ALL = 0x7F80U, OUT_ALL = 0x7F80U,
}; };
static real SinCosSeries(bool sinp, static real SinCosSeries(bool sinp,
real sinx, real cosx, const real c[], int n) real sinx, real cosx, const real c[], int n)
throw(); throw();
static inline real AngNormalize(real x) throw() { static inline real AngNormalize(real x) throw() {
// Place angle in [-180, 180). Assumes x is in [-540, 540). // Place angle in [-180, 180). Assumes x is in [-540, 540).
return x >= 180 ? x - 360 : x < -180 ? x + 360 : x; return x >= 180 ? x - 360 : (x < -180 ? x + 360 : x);
} }
static inline real AngRound(real x) throw() { static inline real AngRound(real x) throw() {
// The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^ 57 // The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^ 57
// for reals = 0.7 pm on the earth if x is an angle in degrees. (Thi s // for reals = 0.7 pm on the earth if x is an angle in degrees. (Thi s
// is about 1000 times more resolution than we get with angles around 90 // is about 1000 times more resolution than we get with angles around 90
// degrees.) We use this to avoid having to deal with near singular // degrees.) We use this to avoid having to deal with near singular
// cases when x is non-zero but tiny (e.g., 1.0e-200). // cases when x is non-zero but tiny (e.g., 1.0e-200).
const real z = real(0.0625); // 1/16 const real z = real(0.0625); // 1/16
volatile real y = std::abs(x); volatile real y = std::abs(x);
// The compiler mustn't "simplify" z - (z - y) to y // The compiler mustn't "simplify" z - (z - y) to y
y = y < z ? z - (z - y) : y; y = y < z ? z - (z - y) : y;
return x < 0 ? -y : y; return x < 0 ? -y : y;
} }
static inline void SinCosNorm(real& sinx, real& cosx) throw() { static inline void SinCosNorm(real& sinx, real& cosx) throw() {
real r = Math::hypot(sinx, cosx); real r = Math::hypot(sinx, cosx);
sinx /= r; sinx /= r;
cosx /= r; cosx /= r;
} }
static real Astroid(real x, real y) throw(); static real Astroid(real x, real y) throw();
// _r is OBSOLETE, can be removed real _a, _f, _f1, _e2, _ep2, _n, _b, _c2, _etol2;
const real _a, _f, _r, _f1, _e2, _ep2, _n, _b, _c2, _etol2;
real _A3x[nA3x_], _C3x[nC3x_], _C4x[nC4x_]; real _A3x[nA3x_], _C3x[nC3x_], _C4x[nC4x_];
void Lengths(real eps, real sig12, void Lengths(real eps, real sig12,
real ssig1, real csig1, real ssig2, real csig2, real ssig1, real csig1, real ssig2, real csig2,
real cbet1, real cbet2, real cbet1, real cbet2,
real& s12s, real& m12a, real& m0, real& s12s, real& m12a, real& m0,
bool scalep, real& M12, real& M21, bool scalep, real& M12, real& M21,
real C1a[], real C2a[]) const throw(); real C1a[], real C2a[]) const throw();
real InverseStart(real sbet1, real cbet1, real sbet2, real cbet2, real InverseStart(real sbet1, real cbet1, real sbet2, real cbet2,
real lam12, real lam12,
skipping to change at line 795 skipping to change at line 795
/** /**
* @return \e f the flattening of the ellipsoid. This is the * @return \e f the flattening of the ellipsoid. This is the
* value used in the constructor. * value used in the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
/** /**
* @return total area of ellipsoid in meters<sup>2</sup>. The area of a * @return total area of ellipsoid in meters<sup>2</sup>. The area of a
* polygon encircling a pole can be found by adding * polygon encircling a pole can be found by adding
* Geodesic::EllipsoidArea()/2 to the sum of \e S12 for each side of the * Geodesic::EllipsoidArea()/2 to the sum of \e S12 for each side of the
* polygon. * polygon.
********************************************************************** / ********************************************************************** /
Math::real EllipsoidArea() const throw() Math::real EllipsoidArea() const throw()
{ return 4 * Math::pi<real>() * _c2; } { return 4 * Math::pi<real>() * _c2; }
///@} ///@}
/** /**
* A global instantiation of Geodesic with the parameters for the WGS84 * A global instantiation of Geodesic with the parameters for the WGS84
* ellipsoid. * ellipsoid.
********************************************************************** / ********************************************************************** /
static const Geodesic WGS84; static const Geodesic WGS84;
/// \cond DEPRECATED
/** \name Deprecated function.
**********************************************************************
/
///@{
/**
* <b>DEPRECATED</b> Perform the direct geodesic calculation. Given a
* latitude, \e lat1, longitude, \e lon1, and azimuth \e azi1 (degrees)
for
* point 1 and a range, \e s12 (meters) from point 1 to point 2, return
the
* latitude, \e lat2, longitude, \e lon2, and forward azimuth, \e azi2
* (degrees) for point 2 and the reduced length \e m12 (meters). If ei
ther
* point is at a pole, the azimuth is defined by keeping the longitude
* fixed and writing \e lat = 90 - \e eps or -90 + \e eps and taking th
e
* limit \e eps -> 0 from above. If \e arcmode (default false) is set
to
* true, \e s12 is interpreted as the arc length \e a12 (degrees) on th
e
* auxiliary sphere. An arc length greater that 180 degrees results in
a
* geodesic which is not a shortest path. For a prolate ellipsoid, an
* additional condition is necessary for a shortest path: the longitudi
nal
* extent must not exceed of 180 degrees. Returned value is the arc le
ngth
* \e a12 (degrees) if \e arcmode is false, otherwise it is the distanc
e \e
* s12 (meters).
**********************************************************************
/
Math::real Direct(real lat1, real lon1, real azi1, real s12_a12,
real& lat2, real& lon2, real& azi2, real& m12,
bool arcmode) const throw() {
if (arcmode) {
real a12 = s12_a12, s12;
ArcDirect(lat1, lon1, azi1, a12, lat2, lon2, azi2, s12, m12);
return s12;
} else {
real s12 = s12_a12;
return Direct(lat1, lon1, azi1, s12, lat2, lon2, azi2, m12);
}
}
///@}
/// \endcond
}; };
} // namespace GeographicLib } // namespace GeographicLib
#endif // GEOGRAPHICLIB_GEODESIC_HPP #endif // GEOGRAPHICLIB_GEODESIC_HPP
 End of changes. 6 change blocks. 
54 lines changed or deleted 6 lines changed or added


 GeodesicLine.hpp   GeodesicLine.hpp 
/** /**
* \file GeodesicLine.hpp * \file GeodesicLine.hpp
* \brief Header for GeographicLib::GeodesicLine class * \brief Header for GeographicLib::GeodesicLine class
* *
* Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> * Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_GEODESICLINE_HPP) #if !defined(GEOGRAPHICLIB_GEODESICLINE_HPP)
#define GEOGRAPHICLIB_GEODESICLINE_HPP "$Id: 592ae103b61c941eff6b856e0b20fe 973e5656e1 $" #define GEOGRAPHICLIB_GEODESICLINE_HPP "$Id: c9e1bf8dbc2a53c2dd3f1569b5b7dd c73cd4315e $"
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
#include <GeographicLib/Geodesic.hpp> #include <GeographicLib/Geodesic.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief A geodesic line. * \brief A geodesic line.
* *
* GeodesicLine facilitates the determination of a series of points on a * GeodesicLine facilitates the determination of a series of points on a
skipping to change at line 95 skipping to change at line 95
static const int nC3_ = Geodesic::nC3_; static const int nC3_ = Geodesic::nC3_;
static const int nC4_ = Geodesic::nC4_; static const int nC4_ = Geodesic::nC4_;
real _lat1, _lon1, _azi1; real _lat1, _lon1, _azi1;
real _a, _f, _b, _c2, _f1, _salp0, _calp0, _k2, real _a, _f, _b, _c2, _f1, _salp0, _calp0, _k2,
_salp1, _calp1, _ssig1, _csig1, _stau1, _ctau1, _somg1, _comg1, _salp1, _calp1, _ssig1, _csig1, _stau1, _ctau1, _somg1, _comg1,
_A1m1, _A2m1, _A3c, _B11, _B21, _B31, _A4, _B41; _A1m1, _A2m1, _A3c, _B11, _B21, _B31, _A4, _B41;
// index zero elements of _C1a, _C1pa, _C2a, _C3a are unused // index zero elements of _C1a, _C1pa, _C2a, _C3a are unused
real _C1a[nC1_ + 1], _C1pa[nC1p_ + 1], _C2a[nC2_ + 1], _C3a[nC3_], real _C1a[nC1_ + 1], _C1pa[nC1p_ + 1], _C2a[nC2_ + 1], _C3a[nC3_],
_C4a[nC4_]; // all the elements of _C4a are used _C4a[nC4_]; // all the elements of _C4a are used
bool _areap; // _areap is OBSOLETE, can be removed
unsigned _caps; unsigned _caps;
enum captype { enum captype {
CAP_NONE = Geodesic::CAP_NONE, CAP_NONE = Geodesic::CAP_NONE,
CAP_C1 = Geodesic::CAP_C1, CAP_C1 = Geodesic::CAP_C1,
CAP_C1p = Geodesic::CAP_C1p, CAP_C1p = Geodesic::CAP_C1p,
CAP_C2 = Geodesic::CAP_C2, CAP_C2 = Geodesic::CAP_C2,
CAP_C3 = Geodesic::CAP_C3, CAP_C3 = Geodesic::CAP_C3,
CAP_C4 = Geodesic::CAP_C4, CAP_C4 = Geodesic::CAP_C4,
CAP_ALL = Geodesic::CAP_ALL, CAP_ALL = Geodesic::CAP_ALL,
skipping to change at line 226 skipping to change at line 225
GeodesicLine(const Geodesic& g, real lat1, real lon1, real azi1, GeodesicLine(const Geodesic& g, real lat1, real lon1, real azi1,
unsigned caps = ALL) unsigned caps = ALL)
throw(); throw();
/** /**
* A default constructor. If GeodesicLine::Position is called on the * A default constructor. If GeodesicLine::Position is called on the
* resulting object, it returns immediately (without doing any * resulting object, it returns immediately (without doing any
* calculations). The object can be set with a call to Geodesic::Line. * calculations). The object can be set with a call to Geodesic::Line.
* Use Init() to test whether object is still in this uninitialized sta te. * Use Init() to test whether object is still in this uninitialized sta te.
********************************************************************** / ********************************************************************** /
GeodesicLine() throw() : _caps(0U) {}; GeodesicLine() throw() : _caps(0U) {}
///@} ///@}
/** \name Position in terms of distance /** \name Position in terms of distance
********************************************************************** / ********************************************************************** /
///@{ ///@{
/** /**
* Compute the position of point 2 which is a distance \e s12 (meters) * Compute the position of point 2 which is a distance \e s12 (meters)
* from point 1. * from point 1.
* *
skipping to change at line 605 skipping to change at line 604
/** /**
* @param[in] testcaps a set of bitor'ed GeodesicLine::mask values. * @param[in] testcaps a set of bitor'ed GeodesicLine::mask values.
* @return true if the GeodesicLine object has all these capabilities. * @return true if the GeodesicLine object has all these capabilities.
********************************************************************** / ********************************************************************** /
bool Capabilities(unsigned testcaps) const throw() { bool Capabilities(unsigned testcaps) const throw() {
testcaps &= OUT_ALL; testcaps &= OUT_ALL;
return (_caps & testcaps) == testcaps; return (_caps & testcaps) == testcaps;
} }
///@} ///@}
/// \cond DEPRECATED
/** \name Deprecated Functions
**********************************************************************
/
///@{
/**
* <b>DEPRECATED</b>. Return the latitude, \e lat2, longitude, \e lon2
,
* and forward azimuth, \e azi2 (degrees) of the point 2 which is a
* distance, \e s12 (in meters), from point 1. Also return the reduced
* length \e m12 (meters). \e s12 can be signed. If \e arcmode (defau
lt
* false) is set to true, \e s12 is interpreted as the arc length \e a1
2
* (in degrees) on the auxiliary sphere. Returned value is the arc len
gth
* \e a12 (degrees) if \e arcmode is false, otherwise it is the distanc
e \e
* s12 (meters).
**********************************************************************
/
Math::real Position(real s12, real& lat2, real& lon2,
real& azi2, real &m12, bool arcmode)
const throw() {
if (arcmode) {
real s12x;
ArcPosition(s12, lat2, lon2, azi2, s12x, m12);
return s12x;
} else
return Position(s12, lat2, lon2, azi2, m12);
}
/**
* <b>DEPRECATED</b>. Return the scale of the geodesic line extending
an
* arc length \e a12 (degrees) from point 1 to point 2. \e M12 (a numb
er)
* measures the convergence of initially parallel geodesics. It is def
ined
* by the following construction: starting at point 1 proceed at azimut
h \e
* azi1 + 90<sup>o</sup> a small distance \e dt; turn -90<sup>o</sup> a
nd
* proceed a distance \e s12 (\e not the arc length \e a12); the distan
ce
* to point 2 is given by \e M12 \e dt. \e M21 is defined analogously.
**********************************************************************
/
void Scale(real a12, real& M12, real& M21) const throw() {
real lat2, lon2, azi2, s12;
ArcPosition(a12, lat2, lon2, azi2, s12, M12, M21);
}
///@}
/// \endcond
}; };
} // namespace GeographicLib } // namespace GeographicLib
#endif // GEOGRAPHICLIB_GEODESICLINE_HPP #endif // GEOGRAPHICLIB_GEODESICLINE_HPP
 End of changes. 4 change blocks. 
59 lines changed or deleted 2 lines changed or added


 Geoid.hpp   Geoid.hpp 
/** /**
* \file Geoid.hpp * \file Geoid.hpp
* \brief Header for GeographicLib::Geoid class * \brief Header for GeographicLib::Geoid class
* *
* Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com> * Copyright (c) Charles Karney (2009, 2010, 2011) <charles@karney.com>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_GEOID_HPP) #if !defined(GEOGRAPHICLIB_GEOID_HPP)
#define GEOGRAPHICLIB_GEOID_HPP "$Id: c7fbce09c004d4ffcce66d6d59c7163f2c581 948 $" #define GEOGRAPHICLIB_GEOID_HPP "$Id: 777922a79bee93ab90a258e58a4d2e4fb1b66 5c5 $"
#include <string> #include <string>
#include <vector> #include <vector>
#include <fstream> #include <fstream>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Squelch warnings about dll vs vector // Squelch warnings about dll vs vector
#pragma warning (push) #pragma warning (push)
#pragma warning (disable: 4251) #pragma warning (disable: 4251)
skipping to change at line 203 skipping to change at line 203
bool cubic = true, bool threadsafe = false); bool cubic = true, bool threadsafe = false);
/** /**
* Set up a cache. * Set up a cache.
* *
* @param[in] south latitude (degrees) of the south edge of the cached area. * @param[in] south latitude (degrees) of the south edge of the cached area.
* @param[in] west longitude (degrees) of the west edge of the cached a rea. * @param[in] west longitude (degrees) of the west edge of the cached a rea.
* @param[in] north latitude (degrees) of the north edge of the cached area. * @param[in] north latitude (degrees) of the north edge of the cached area.
* @param[in] east longitude (degrees) of the east edge of the cached a rea. * @param[in] east longitude (degrees) of the east edge of the cached a rea.
* *
* Cache the data for the specified rectangular area . \e east is alwa * Cache the data for the specified "rectangular" area bounded by the
ys * parallels \e south and \e north and the meridians \e west and \e eas
* interpreted as being east of \e west, if necessary by adding t.
* 360<sup>o</sup> to its value. This may throw an error because of * \e east is always interpreted as being east of \e west, if necessary
by
* adding 360<sup>o</sup> to its value. This may throw an error becaus
e of
* insufficent memory or because of an error reading the data from the * insufficent memory or because of an error reading the data from the
* file. In this case, you can catch the error and either do nothing ( you * file. In this case, you can catch the error and either do nothing ( you
* will have no cache in this case) or try again with a smaller area. \e * will have no cache in this case) or try again with a smaller area. \e
* south and \e north should be in the range [-90, 90]; \e west and \e east * south and \e north should be in the range [-90, 90]; \e west and \e east
* should be in the range [-180, 360]. An exception is thrown if this * should be in the range [-180, 360]. An exception is thrown if this
* routine is called on a thread safe Geoid. * routine is called on a thread safe Geoid.
********************************************************************** / ********************************************************************** /
void CacheArea(real south, real west, real north, real east) const; void CacheArea(real south, real west, real north, real east) const;
/** /**
skipping to change at line 452 skipping to change at line 453
/** /**
* @return the default name for the geoid. * @return the default name for the geoid.
* *
* This is the value of the environment variable GEOID_NAME, if set, * This is the value of the environment variable GEOID_NAME, if set,
* otherwise, it is "egm96-5". The Geoid class does not use this funct ion; * otherwise, it is "egm96-5". The Geoid class does not use this funct ion;
* it is just provided as a convenience for a calling program when * it is just provided as a convenience for a calling program when
* constructing a Geoid object. * constructing a Geoid object.
********************************************************************** / ********************************************************************** /
static std::string DefaultGeoidName(); static std::string DefaultGeoidName();
/// \cond DEPRECATED
/**
* <b>DEPRECATED</b> Return the compile-time default path for the geoid
* data files.
**********************************************************************
/
static std::string DefaultPath();
/**
* <b>DEPRECATED</b> Return the value of the environment variable
* GEOID_PATH.
**********************************************************************
/
static std::string GeoidPath();
/// \endcond
}; };
} // namespace GeographicLib } // namespace GeographicLib
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning (pop) #pragma warning (pop)
#endif #endif
#endif // GEOGRAPHICLIB_GEOID_HPP #endif // GEOGRAPHICLIB_GEOID_HPP
 End of changes. 3 change blocks. 
20 lines changed or deleted 8 lines changed or added


 Gnomonic.hpp   Gnomonic.hpp 
/** /**
* \file Gnomonic.hpp * \file Gnomonic.hpp
* \brief Header for GeographicLib::Gnomonic class * \brief Header for GeographicLib::Gnomonic class
* *
* Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed * Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed
* under the MIT/X11 License. For more information, see * under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_GNOMONIC_HPP) #if !defined(GEOGRAPHICLIB_GNOMONIC_HPP)
#define GEOGRAPHICLIB_GNOMONIC_HPP "$Id: 8a8a791b2f8ace09e181271d0988615a3f e28ef0 $" #define GEOGRAPHICLIB_GNOMONIC_HPP "$Id: 6be96232d6e0dbfbeb56fdad884a09cdb8 e82303 $"
#include <GeographicLib/Geodesic.hpp> #include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/GeodesicLine.hpp> #include <GeographicLib/GeodesicLine.hpp>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief %Gnomonic Projection. * \brief %Gnomonic Projection.
* *
skipping to change at line 93 skipping to change at line 93
* in the Alignment of Surface Routes, Geodesy and Aerophotography (5), * in the Alignment of Surface Routes, Geodesy and Aerophotography (5),
* 271-274 (1963). * 271-274 (1963).
* - The projection given here. This causes geodesics close to the cente r * - The projection given here. This causes geodesics close to the cente r
* point to appear as straight lines in the projection; i.e., it * point to appear as straight lines in the projection; i.e., it
* generalizes the spherical great circle to a geodesic. * generalizes the spherical great circle to a geodesic.
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT Gnomonic { class GEOGRAPHIC_EXPORT Gnomonic {
private: private:
typedef Math::real real; typedef Math::real real;
const Geodesic _earth; Geodesic _earth;
real _a, _f; real _a, _f;
static const real eps0_; static const real eps0_;
static const real eps_; static const real eps_;
static const int numit_ = 5; static const int numit_ = 5;
public: public:
/** /**
* Constructor for Gnomonic. * Constructor for Gnomonic.
* *
* @param[in] earth the Geodesic object to use for geodesic calculation s. * @param[in] earth the Geodesic object to use for geodesic calculation s.
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 LambertConformalConic.hpp   LambertConformalConic.hpp 
/** /**
* \file LambertConformalConic.hpp * \file LambertConformalConic.hpp
* \brief Header for GeographicLib::LambertConformalConic class * \brief Header for GeographicLib::LambertConformalConic class
* *
* Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed * Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed
* under the MIT/X11 License. For more information, see * under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP) #if !defined(GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP)
#define GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP "$Id: b2f2b9bc4827fa14f7c09 0daebd1a5429b32791a $" #define GEOGRAPHICLIB_LAMBERTCONFORMALCONIC_HPP "$Id: d07238fb7f335a5bca634 1c8af421bc624e41427 $"
#include <algorithm> #include <algorithm>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Lambert Conformal Conic Projection * \brief Lambert Conformal Conic Projection
* *
* Implementation taken from the report, * Implementation taken from the report,
skipping to change at line 84 skipping to change at line 84
// Sample conversion from PASouth grid to geodetic // Sample conversion from PASouth grid to geodetic
std::cin >> x >> y; std::cin >> x >> y;
x += x0; y += y0; x += x0; y += y0;
PASouth.Reverse(lon0, x, y, lat, lon); PASouth.Reverse(lon0, x, y, lat, lon);
std::cout << lat << " " << lon << "\n"; std::cout << lat << " " << lon << "\n";
\endcode \endcode
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT LambertConformalConic { class GEOGRAPHIC_EXPORT LambertConformalConic {
private: private:
typedef Math::real real; typedef Math::real real;
const real _a, _f, _r, _fm, _e2, _e, _e2m; real _a, _f, _fm, _e2, _e, _e2m;
real _sign, _n, _nc, _t0nm1, _scale, _lat0, _k0; real _sign, _n, _nc, _t0nm1, _scale, _lat0, _k0;
real _scbet0, _tchi0, _scchi0, _psi0, _nrho0; real _scbet0, _tchi0, _scchi0, _psi0, _nrho0;
static const real eps_; static const real eps_;
static const real epsx_; static const real epsx_;
static const real tol_; static const real tol_;
static const real ahypover_; static const real ahypover_;
static const int numit_ = 5; static const int numit_ = 5;
static inline real hyp(real x) throw() { return Math::hypot(real(1), x) ; } static inline real hyp(real x) throw() { return Math::hypot(real(1), x) ; }
// e * atanh(e * x) = log( ((1 + e*x)/(1 - e*x))^(e/2) ) if f >= 0 // e * atanh(e * x) = log( ((1 + e*x)/(1 - e*x))^(e/2) ) if f >= 0
// - sqrt(-e2) * atan( sqrt(-e2) * x) if f < 0 // - sqrt(-e2) * atan( sqrt(-e2) * x) if f < 0
skipping to change at line 318 skipping to change at line 318
/** /**
* @return \e f the flattening of the ellipsoid. This is the * @return \e f the flattening of the ellipsoid. This is the
* value used in the constructor. * value used in the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
/** /**
* @return latitude of the origin for the projection (degrees). * @return latitude of the origin for the projection (degrees).
* *
* This is the latitude of minimum scale and equals the \e stdlat in th e * This is the latitude of minimum scale and equals the \e stdlat in th e
* 1-parallel constructor and lies between \e stdlat1 and \e stdlat2 in the * 1-parallel constructor and lies between \e stdlat1 and \e stdlat2 in the
* 2-parallel constructors. * 2-parallel constructors.
********************************************************************** / ********************************************************************** /
Math::real OriginLatitude() const throw() { return _lat0; } Math::real OriginLatitude() const throw() { return _lat0; }
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 LocalCartesian.hpp   LocalCartesian.hpp 
/** /**
* \file LocalCartesian.hpp * \file LocalCartesian.hpp
* \brief Header for GeographicLib::LocalCartesian class * \brief Header for GeographicLib::LocalCartesian class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_LOCALCARTESIAN_HPP) #if !defined(GEOGRAPHICLIB_LOCALCARTESIAN_HPP)
#define GEOGRAPHICLIB_LOCALCARTESIAN_HPP "$Id: 7ec9e1a810dc0eb527d0e20c69df 60ac1a2ba499 $" #define GEOGRAPHICLIB_LOCALCARTESIAN_HPP "$Id: 6504c3f72ff159d17ddbd6e5bb48 3f0945438b9a $"
#include <GeographicLib/Geocentric.hpp> #include <GeographicLib/Geocentric.hpp>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Local Cartesian coordinates * \brief Local Cartesian coordinates
* *
* Convert between geodetic coordinates latitude = \e lat, longitude = \e * Convert between geodetic coordinates latitude = \e lat, longitude = \e
skipping to change at line 37 skipping to change at line 37
* *
* The conversions all take place via geocentric coordinates using a * The conversions all take place via geocentric coordinates using a
* Geocentric object (by default Geocentric::WGS84). * Geocentric object (by default Geocentric::WGS84).
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT LocalCartesian { class GEOGRAPHIC_EXPORT LocalCartesian {
private: private:
typedef Math::real real; typedef Math::real real;
static const size_t dim_ = 3; static const size_t dim_ = 3;
static const size_t dim2_ = dim_ * dim_; static const size_t dim2_ = dim_ * dim_;
const Geocentric _earth; Geocentric _earth;
real _lat0, _lon0, _h0; real _lat0, _lon0, _h0;
real _x0, _y0, _z0, _r[dim2_]; real _x0, _y0, _z0, _r[dim2_];
void IntForward(real lat, real lon, real h, real& x, real& y, real& z, void IntForward(real lat, real lon, real h, real& x, real& y, real& z,
real M[dim2_]) const throw(); real M[dim2_]) const throw();
void IntReverse(real x, real y, real z, real& lat, real& lon, real& h, void IntReverse(real x, real y, real z, real& lat, real& lon, real& h,
real M[dim2_]) const throw(); real M[dim2_]) const throw();
void MatrixMultiply(real M[dim2_]) const throw(); void MatrixMultiply(real M[dim2_]) const throw();
public: public:
/** /**
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 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, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. 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: ec89e8a2c1c4a41fb7c08b0a9fd287116516f6 a5 $" #define GEOGRAPHICLIB_MGRS_HPP "$Id: b9b6a35bcdd5b270cdc3088be87e422efc9b30 53 $"
#include <sstream> #include <sstream>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
#include <GeographicLib/UTMUPS.hpp> #include <GeographicLib/UTMUPS.hpp>
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Squelch warnings about dll vs string // Squelch warnings about dll vs string
#pragma warning (push) #pragma warning (push)
#pragma warning (disable: 4251) #pragma warning (disable: 4251)
#endif #endif
skipping to change at line 135 skipping to change at line 135
}; };
MGRS(); // Disable constructor MGRS(); // Disable constructor
public: public:
/** /**
* Convert UTM or UPS coordinate to an MGRS coordinate. * Convert UTM or UPS coordinate to an MGRS coordinate.
* *
* @param[in] zone UTM zone (zero means UPS). * @param[in] zone UTM zone (zero means UPS).
* @param[in] northp hemisphere (true means north, false means south). * @param[in] northp hemisphere (true means north, false means south).
* @param[in] x (meters). * @param[in] x easting of point (meters).
* @param[in] y (meters). * @param[in] y northing of point (meters).
* @param[in] prec precision relative to 100 km. * @param[in] prec precision relative to 100 km.
* @param[out] mgrs MGRS string. * @param[out] mgrs MGRS string.
* *
* \e prec specifies the precision of the MSGRS string as follows: * \e prec specifies the precision of the MSGRS string as follows:
* - prec = 0 (min), 100 km * - prec = 0 (min), 100 km
* - prec = 1, 10 km * - prec = 1, 10 km
* - prec = 2, 1 km * - prec = 2, 1 km
* - prec = 3, 100 m * - prec = 3, 100 m
* - prec = 4, 10 m * - prec = 4, 10 m
* - prec = 5, 1 m * - prec = 5, 1 m
skipping to change at line 208 skipping to change at line 208
********************************************************************** / ********************************************************************** /
static void Forward(int zone, bool northp, real x, real y, static void Forward(int zone, bool northp, real x, real y,
int prec, std::string& mgrs); int prec, std::string& mgrs);
/** /**
* Convert UTM or UPS coordinate to an MGRS coordinate when the latitud e is * Convert UTM or UPS coordinate to an MGRS coordinate when the latitud e is
* known. * known.
* *
* @param[in] zone UTM zone (zero means UPS). * @param[in] zone UTM zone (zero means UPS).
* @param[in] northp hemisphere (true means north, false means south). * @param[in] northp hemisphere (true means north, false means south).
* @param[in] x (meters). * @param[in] x easting of point (meters).
* @param[in] y (meters). * @param[in] y northing of point (meters).
* @param[in] lat latitude (degrees). * @param[in] lat latitude (degrees).
* @param[in] prec precision relative to 100 km. * @param[in] prec precision relative to 100 km.
* @param[out] mgrs MGRS string. * @param[out] mgrs MGRS string.
* *
* The latitude is ignored for \e zone = 0 (UPS); otherwise the latitud e is * The latitude is ignored for \e zone = 0 (UPS); otherwise the latitud e is
* used to determine the latitude band and this is checked for consiste ncy * used to determine the latitude band and this is checked for consiste ncy
* using the same tests as Reverse. * using the same tests as Reverse.
********************************************************************** / ********************************************************************** /
static void Forward(int zone, bool northp, real x, real y, real lat, static void Forward(int zone, bool northp, real x, real y, real lat,
int prec, std::string& mgrs); int prec, std::string& mgrs);
/** /**
* Convert a MGRS coordinate to UTM or UPS coordinates. * Convert a MGRS coordinate to UTM or UPS coordinates.
* *
* @param[in] mgrs MGRS string. * @param[in] mgrs MGRS string.
* @param[out] zone UTM zone (zero means UPS). * @param[out] zone UTM zone (zero means UPS).
* @param[out] northp hemisphere (true means north, false means south). * @param[out] northp hemisphere (true means north, false means south).
* @param[out] x (meters). * @param[out] x easting of point (meters).
* @param[out] y (meters). * @param[out] y northing of point (meters).
* @param[out] prec precision relative to 100 km. * @param[out] prec precision relative to 100 km.
* @param[in] centerp if true (default), return center of the MGRS squa re, * @param[in] centerp if true (default), return center of the MGRS squa re,
* else return SW (lower left) corner. * else return SW (lower left) corner.
* *
* All conversions from MGRS to UTM/UPS are permitted provided the MGRS * All conversions from MGRS to UTM/UPS are permitted provided the MGRS
* coordinate is a possible result of a conversion in the other directi on. * coordinate is a possible result of a conversion in the other directi on.
* (The leading 0 may be dropped from an input MGRS coordinate for UTM * (The leading 0 may be dropped from an input MGRS coordinate for UTM
* zones 1&ndash;9.) In addition, MGRS coordinates with a neighboring * zones 1&ndash;9.) In addition, MGRS coordinates with a neighboring
* latitude band letter are permitted provided that some portion of the * latitude band letter are permitted provided that some portion of the
* 100 km block is within the given latitude band. Thus * 100 km block is within the given latitude band. Thus
 End of changes. 4 change blocks. 
7 lines changed or deleted 7 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, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. 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: 461ca662af89d37e5276ab02 9e7c6959d5bbdd74 $" #define GEOGRAPHICLIB_POLARSTEREOGRAPHIC_HPP "$Id: babda3abc04257e799b84de8 aaaec20082b960e0 $"
#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,
skipping to change at line 33 skipping to change at line 33
* 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 GEOGRAPHIC_EXPORT PolarStereographic { class GEOGRAPHIC_EXPORT PolarStereographic {
private: private:
typedef Math::real real; typedef Math::real real;
// _Cx used to be _C but g++ 3.4 has a macro of that name // _Cx used to be _C but g++ 3.4 has a macro of that name
const real _a, _f, _r, _e2, _e, _e2m, _Cx, _c; real _a, _f, _e2, _e, _e2m, _Cx, _c;
real _k0; real _k0;
static const real tol_; static const real tol_;
static const real overflow_; static const real overflow_;
static const int numit_ = 5; static const int numit_ = 5;
// 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:
skipping to change at line 145 skipping to change at line 145
/** /**
* @return \e f the flattening of the ellipsoid. This is the value use d in * @return \e f the flattening of the ellipsoid. This is the value use d in
* the constructor. * the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
/** /**
* The central scale for the projection. This is the value of \e k0 us ed * The central scale for the projection. This is the value of \e k0 us ed
* in the constructor and is the scale at the pole unless overridden by * in the constructor and is the scale at the pole unless overridden by
* PolarStereographic::SetScale. * PolarStereographic::SetScale.
********************************************************************** / ********************************************************************** /
Math::real CentralScale() const throw() { return _k0; } Math::real CentralScale() const throw() { return _k0; }
///@} ///@}
/** /**
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added


 PolygonArea.hpp   PolygonArea.hpp 
/** /**
* \file PolygonArea.hpp * \file PolygonArea.hpp
* \brief Header for GeographicLib::PolygonArea class * \brief Header for GeographicLib::PolygonArea class
* *
* Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed * Copyright (c) Charles Karney (2010, 2011) <charles@karney.com> and licen sed
* under the MIT/X11 License. For more information, see * under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_POLYGONAREA_HPP) #if !defined(GEOGRAPHICLIB_POLYGONAREA_HPP)
#define GEOGRAPHICLIB_POLYGONAREA_HPP "$Id: 5ff09fa5810aa378fb77a57f9b71ad3 7f2fa887b $" #define GEOGRAPHICLIB_POLYGONAREA_HPP "$Id: 04fcbc14351bc33fbfbef89a68cc7bd eddb33e2b $"
#include <GeographicLib/Geodesic.hpp> #include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
#include <GeographicLib/Accumulator.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Polygon Areas. * \brief Polygon Areas.
* *
* This computes the area of a geodesic polygon using the method given * This computes the area of a geodesic polygon using the method given
* Section 15 of * Section 15 of
* - C. F. F. Karney, * - C. F. F. Karney,
* <a href="http://arxiv.org/abs/1102.1215v1">Geodesics * <a href="http://arxiv.org/abs/1102.1215v1">Geodesics
skipping to change at line 41 skipping to change at line 42
* and perimeter are accumulated in two times the standard floating point * and perimeter are accumulated in two times the standard floating point
* precision to guard against the loss of accuracy with many-sided polygo ns. * precision to guard against the loss of accuracy with many-sided polygo ns.
* At any point you can ask for the perimeter and area so far. There's a n * At any point you can ask for the perimeter and area so far. There's a n
* option to treat the points as defining a polyline instead of a polygon ; in * option to treat the points as defining a polyline instead of a polygon ; in
* that case, only the perimeter is computed. * that case, only the perimeter is computed.
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT PolygonArea { class GEOGRAPHIC_EXPORT PolygonArea {
private: private:
typedef Math::real real; typedef Math::real real;
const Geodesic& _earth; Geodesic _earth;
const real _area0; // Full ellipsoid area real _area0; // Full ellipsoid area
const bool _polyline; // Assume polyline (don't close and skip ar bool _polyline; // Assume polyline (don't close and skip ar
ea) ea)
const unsigned _mask; unsigned _mask;
unsigned _num; unsigned _num;
int _crossings; int _crossings;
Accumulator<real> _areasum, _perimetersum; Accumulator<real> _areasum, _perimetersum;
real _lat0, _lon0, _lat1, _lon1; real _lat0, _lon0, _lat1, _lon1;
// Copied from Geodesic class // Copied from Geodesic class
static inline real AngNormalize(real x) throw() { static inline real AngNormalize(real x) throw() {
// Place angle in [-180, 180). Assumes x is in [-540, 540). // Place angle in [-180, 180). Assumes x is in [-540, 540).
// //
// g++ 4.4.4 holds a temporary in an extended register causing an err or // g++ 4.4.4 holds a temporary in an extended register causing an err or
// with the triangle 89,0.1;89,90.1;89,-179.9. The volatile declarat ion // with the triangle 89,0.1;89,90.1;89,-179.9. The volatile declarat ion
// fixes this. (The bug probably triggered because transit and // fixes this. (The bug probably triggered because transit and
// AngNormalize are inline functions. So don't port this change over to // AngNormalize are inline functions. So don't port this change over to
// Geodesic.hpp.) // Geodesic.hpp.)
volatile real y = x; volatile real y = x;
return y >= 180 ? y - 360 : y < -180 ? y + 360 : y; return y >= 180 ? y - 360 : (y < -180 ? y + 360 : y);
} }
static inline int transit(real lon1, real lon2) { static inline int transit(real lon1, real lon2) {
// Return 1 or -1 if crossing prime meridian in east or west directio n. // Return 1 or -1 if crossing prime meridian in east or west directio n.
// Otherwise return zero. // Otherwise return zero.
lon1 = AngNormalize(lon1); lon1 = AngNormalize(lon1);
lon2 = AngNormalize(lon2); lon2 = AngNormalize(lon2);
// treat lon12 = -180 as an eastward geodesic, so convert to 180. // treat lon12 = -180 as an eastward geodesic, so convert to 180.
real lon12 = -AngNormalize(lon1 - lon2); // In (-180, 180] real lon12 = -AngNormalize(lon1 - lon2); // In (-180, 180]
int cross = int cross =
lon1 < 0 && lon2 >= 0 && lon12 > 0 ? 1 : lon1 < 0 && lon2 >= 0 && lon12 > 0 ? 1 :
skipping to change at line 157 skipping to change at line 158
* of the polyline (meters). * of the polyline (meters).
* @param[out] area the approximate area of the polygon (meters^2); onl y * @param[out] area the approximate area of the polygon (meters^2); onl y
* set if polyline is false in the constructor. * set if polyline is false in the constructor.
* @return the number of points. * @return the number of points.
* *
* \e lat should be in the range [-90, 90] and \e lon should be in the * \e lat should be in the range [-90, 90] and \e lon should be in the
* range [-180, 360]. * range [-180, 360].
********************************************************************** / ********************************************************************** /
unsigned TestCompute(real lat, real lon, bool reverse, bool sign, unsigned TestCompute(real lat, real lon, bool reverse, bool sign,
real& perimeter, real& area) const throw(); real& perimeter, real& area) const throw();
/** \name Inspector functions
**********************************************************************
/
///@{
/**
* @return \e a the equatorial radius of the ellipsoid (meters). This
is
* the value inherited from the Geodesic object used in the construct
or.
**********************************************************************
/
Math::real MajorRadius() const throw() { return _earth.MajorRadius(); }
/**
* @return \e f the flattening of the ellipsoid. This is the value
* inherited from the Geodesic object used in the constructor.
**********************************************************************
/
Math::real Flattening() const throw() { return _earth.Flattening(); }
///@}
}; };
} // namespace GeographicLib } // namespace GeographicLib
#endif // GEOGRAPHICLIB_POLYGONAREA_HPP #endif // GEOGRAPHICLIB_POLYGONAREA_HPP
 End of changes. 5 change blocks. 
7 lines changed or deleted 30 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, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. 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: e72f3f875456c5cd776e697a bcb0cdfeca8a7e72 $" #define GEOGRAPHICLIB_TRANSVERSEMERCATOR_HPP "$Id: c59b9988116b53613878bbe2 65ae9fb3afa1d62f $"
#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 TransverseMercator. * The order of the series approximation used in TransverseMercator.
* TM_TX_MAXPOW can be set to any integer in [4, 8]. * TM_TX_MAXPOW can be set to any integer in [4, 8].
**********************************************************************/ **********************************************************************/
#define TM_TX_MAXPOW \ #define TM_TX_MAXPOW \
(GEOGRAPHICLIB_PREC == 1 ? 6 : GEOGRAPHICLIB_PREC == 0 ? 4 : 8) (GEOGRAPHICLIB_PREC == 1 ? 6 : (GEOGRAPHICLIB_PREC == 0 ? 4 : 8))
#endif #endif
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Transverse Mercator Projection * \brief Transverse Mercator Projection
* *
* This uses Kr&uuml;ger's method which evaluates the projection and its * This uses Kr&uuml;ger's method which evaluates the projection and its
* inverse in terms of a series. See * inverse in terms of a series. See
* - L. Kr&uuml;ger, * - L. Kr&uuml;ger,
* <a href="http://dx.doi.org/10.2312/GFZ.b103-krueger28"> Konforme * <a href="http://dx.doi.org/10.2312/GFZ.b103-krueger28"> Konforme
* Abbildung des Erdellipsoids in der Ebene</a> (Conformal mapping of the * Abbildung des Erdellipsoids in der Ebene</a> (Conformal mapping of the
* ellipsoidal earth to the plane), Royal Prussian Geodetic Institute, New * ellipsoidal earth to the plane), Royal Prussian Geodetic Institute, New
* Series 52, 172 pp. (1912). * Series 52, 172 pp. (1912).
* - C. F. F. Karney, * - C. F. F. Karney,
* <a href="http://dx.doi.org/10.1007/s00190-011-0445-3"> * <a href="http://dx.doi.org/10.1007/s00190-011-0445-3">
* Transverse Mercator with an accuracy of a few nanometers,</a> * Transverse Mercator with an accuracy of a few nanometers,</a>
* J. Geodesy (2011); * J. Geodesy 85(8), 475-485 (Aug. 2011);
* preprint * preprint
* <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>. * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>.
* *
* Kr&uuml;ger's method has been extended from 4th to 6th order. The max imum * Kr&uuml;ger's method has been extended from 4th to 6th order. The max imum
* errors is 5 nm (ground distance) for all positions within 35 degrees o f * errors is 5 nm (ground distance) for all positions within 35 degrees o f
* the central meridian. The error in the convergence is 2e-15&quot; and the * the central meridian. The error in the convergence is 2e-15&quot; and the
* relative error in the scale is 6e-12%%. See Sec. 4 of * relative error in the scale is 6e-12%%. See Sec. 4 of
* <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for detai ls. * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for detai ls.
* The speed penalty in going to 6th order is only about 1%. * The speed penalty in going to 6th order is only about 1%.
* TransverseMercatorExact is an alternative implementation of the projec tion * TransverseMercatorExact is an alternative implementation of the projec tion
skipping to change at line 78 skipping to change at line 78
* See \ref transversemercator for a discussion of this projection. * See \ref transversemercator for a discussion of this projection.
**********************************************************************/ **********************************************************************/
class GEOGRAPHIC_EXPORT TransverseMercator { class GEOGRAPHIC_EXPORT TransverseMercator {
private: private:
typedef Math::real real; typedef Math::real real;
static const int maxpow_ = TM_TX_MAXPOW; static const int maxpow_ = TM_TX_MAXPOW;
static const real tol_; static const real tol_;
static const real overflow_; static const real overflow_;
static const int numit_ = 5; static const int numit_ = 5;
const real _a, _f, _r, _k0, _e2, _e, _e2m, _c, _n; real _a, _f, _k0, _e2, _e, _e2m, _c, _n;
// _alp[0] and _bet[0] unused // _alp[0] and _bet[0] unused
real _a1, _b1, _alp[maxpow_ + 1], _bet[maxpow_ + 1]; real _a1, _b1, _alp[maxpow_ + 1], _bet[maxpow_ + 1];
// tan(x) for x in [-pi/2, pi/2] ensuring that the sign is right // tan(x) for x in [-pi/2, pi/2] ensuring that the sign is right
static inline real tanx(real x) throw() { static inline real tanx(real x) throw() {
real t = std::tan(x); real t = std::tan(x);
// Write the tests this way to ensure that tanx(NaN()) is NaN() // Write the tests this way to ensure that tanx(NaN()) is NaN()
return x >= 0 ? (!(t < 0) ? t : overflow_) : (!(t >= 0) ? t : -overfl ow_); return x >= 0 ? (!(t < 0) ? t : overflow_) : (!(t >= 0) ? t : -overfl ow_);
} }
// 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
skipping to change at line 179 skipping to change at line 179
/** /**
* @return \e f the flattening of the ellipsoid. This is the value use d in * @return \e f the flattening of the ellipsoid. This is the value use d in
* the constructor. * the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
/** /**
* @return \e k0 central scale for the projection. This is the value o f \e * @return \e k0 central scale for the projection. This is the value o f \e
* k0 used in the constructor and is the scale on the central meridia n. * k0 used in the constructor and is the scale on the central meridia n.
********************************************************************** / ********************************************************************** /
Math::real CentralScale() const throw() { return _k0; } Math::real CentralScale() const throw() { return _k0; }
///@} ///@}
/** /**
* A global instantiation of TransverseMercator with the WGS84 ellipsoi d * A global instantiation of TransverseMercator with the WGS84 ellipsoi d
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 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, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. 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: 73f66e3f4714382bfde 874d68feccb2c71a2b8af $" #define GEOGRAPHICLIB_TRANSVERSEMERCATOREXACT_HPP "$Id: 1e7fe9ef31424d25589 2679d74ac0ae492c2334a $"
#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 33 skipping to change at line 33
* <a href="http://dx.doi.org/10.3138/X687-1574-4325-WM62"> Conformal * <a href="http://dx.doi.org/10.3138/X687-1574-4325-WM62"> Conformal
* Projections Based On Jacobian Elliptic Functions</a>, Part V of * Projections Based On Jacobian Elliptic Functions</a>, Part V of
* Conformal Projections Based on Elliptic Functions, * Conformal Projections Based on Elliptic Functions,
* (B. V. Gutsell, Toronto, 1976), 128pp., * (B. V. Gutsell, Toronto, 1976), 128pp.,
* ISBN: 0919870163 * ISBN: 0919870163
* (also appeared as: * (also appeared as:
* Monograph 16, Suppl. No. 1 to Canadian Cartographer, Vol 13). * Monograph 16, Suppl. No. 1 to Canadian Cartographer, Vol 13).
* - C. F. F. Karney, * - C. F. F. Karney,
* <a href="http://dx.doi.org/10.1007/s00190-011-0445-3"> * <a href="http://dx.doi.org/10.1007/s00190-011-0445-3">
* Transverse Mercator with an accuracy of a few nanometers,</a> * Transverse Mercator with an accuracy of a few nanometers,</a>
* J. Geodesy (2011); * J. Geodesy 85(8), 475-485 (Aug. 2011);
* preprint * preprint
* <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>. * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a>.
* *
* Lee's gives the correct results for forward and reverse * Lee's gives the correct results for forward and reverse
* transformations subject to the branch cut rules (see the description o f * transformations subject to the branch cut rules (see the description o f
* the \e extendp argument to the constructor). The maximum error is abo ut 8 * the \e extendp argument to the constructor). The maximum error is abo ut 8
* nm (ground distance) for the forward and reverse transformations. The * nm (ground distance) for the forward and reverse transformations. The
* 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 Sec. 3 of * is 7e-12%%. See Sec. 3 of
* <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for detai ls. * <a href="http://arxiv.org/abs/1002.1417">arXiv:1002.1417</a> for detai ls.
skipping to change at line 76 skipping to change at line 76
class GEOGRAPHIC_EXPORT TransverseMercatorExact { class GEOGRAPHIC_EXPORT TransverseMercatorExact {
private: private:
typedef Math::real real; typedef Math::real real;
static const real tol_; static const real tol_;
static const real tol1_; static const real tol1_;
static const real tol2_; static const real tol2_;
static const real taytol_; static const real taytol_;
static const real overflow_; static const real overflow_;
static const int numit_ = 10; static const int numit_ = 10;
const real _a, _f, _r, _k0, _mu, _mv, _e, _ep2; real _a, _f, _k0, _mu, _mv, _e, _ep2;
const bool _extendp; bool _extendp;
const EllipticFunction _Eu, _Ev; EllipticFunction _Eu, _Ev;
// tan(x) for x in [-pi/2, pi/2] ensuring that the sign is right // tan(x) for x in [-pi/2, pi/2] ensuring that the sign is right
static inline real tanx(real x) throw() { static inline real tanx(real x) throw() {
real t = std::tan(x); real t = std::tan(x);
// Write the tests this way to ensure that tanx(NaN()) is NaN() // Write the tests this way to ensure that tanx(NaN()) is NaN()
return x >= 0 ? (!(t < 0) ? t : overflow_) : (!(t >= 0) ? t : -overfl ow_); return x >= 0 ? (!(t < 0) ? t : overflow_) : (!(t >= 0) ? t : -overfl ow_);
} }
real taup(real tau) const throw(); real taup(real tau) const throw();
real taupinv(real taup) const throw(); real taupinv(real taup) const throw();
skipping to change at line 240 skipping to change at line 240
/** /**
* @return \e f the flattening of the ellipsoid. This is the value use d in * @return \e f the flattening of the ellipsoid. This is the value use d in
* the constructor. * the constructor.
********************************************************************** / ********************************************************************** /
Math::real Flattening() const throw() { return _f; } Math::real Flattening() const throw() { return _f; }
/** /**
* <b>DEPRECATED</b> * <b>DEPRECATED</b>
* @return \e r the inverse flattening of the ellipsoid. * @return \e r the inverse flattening of the ellipsoid.
********************************************************************** / ********************************************************************** /
Math::real InverseFlattening() const throw() { return _r; } Math::real InverseFlattening() const throw() { return 1/_f; }
/** /**
* @return \e k0 central scale for the projection. This is the value o f \e * @return \e k0 central scale for the projection. This is the value o f \e
* k0 used in the constructor and is the scale on the central meridia n. * k0 used in the constructor and is the scale on the central meridia n.
********************************************************************** / ********************************************************************** /
Math::real CentralScale() const throw() { return _k0; } Math::real CentralScale() const throw() { return _k0; }
///@} ///@}
/** /**
* A global instantiation of TransverseMercatorExact with the WGS84 * A global instantiation of TransverseMercatorExact with the WGS84
 End of changes. 4 change blocks. 
6 lines changed or deleted 6 lines changed or added


 UTMUPS.hpp   UTMUPS.hpp 
/** /**
* \file UTMUPS.hpp * \file UTMUPS.hpp
* \brief Header for GeographicLib::UTMUPS class * \brief Header for GeographicLib::UTMUPS class
* *
* Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m> * Copyright (c) Charles Karney (2008, 2009, 2010, 2011) <charles@karney.co m>
* and licensed under the MIT/X11 License. For more information, see * and licensed under the MIT/X11 License. For more information, see
* http://geographiclib.sourceforge.net/ * http://geographiclib.sourceforge.net/
**********************************************************************/ **********************************************************************/
#if !defined(GEOGRAPHICLIB_UTMUPS_HPP) #if !defined(GEOGRAPHICLIB_UTMUPS_HPP)
#define GEOGRAPHICLIB_UTMUPS_HPP "$Id: 3f219712008c744df44a62261bbc79683767 6872 $" #define GEOGRAPHICLIB_UTMUPS_HPP "$Id: 5d3bb175628985fddad7d67a028bffc0f049 f515 $"
#include <sstream> #include <sstream>
#include <GeographicLib/Constants.hpp> #include <GeographicLib/Constants.hpp>
namespace GeographicLib { namespace GeographicLib {
/** /**
* \brief Convert between Geographic coordinates and UTM/UPS * \brief Convert between Geographic coordinates and UTM/UPS
* *
* UTM and UPS are defined * UTM and UPS are defined
skipping to change at line 166 skipping to change at line 166
* [UTMUPS::MINPSEUDOZONE, UTMUPS::MAXZONE] = [-4, 60]. * [UTMUPS::MINPSEUDOZONE, UTMUPS::MAXZONE] = [-4, 60].
********************************************************************** / ********************************************************************** /
static int StandardZone(real lat, real lon, int setzone = STANDARD); static int StandardZone(real lat, real lon, int setzone = STANDARD);
/** /**
* Forward projection, from geographic to UTM/UPS. * Forward projection, from geographic to UTM/UPS.
* *
* @param[in] lat latitude of point (degrees). * @param[in] lat latitude of point (degrees).
* @param[in] lon longitude of point (degrees). * @param[in] lon longitude of point (degrees).
* @param[out] zone the UTM zone (zero means UPS). * @param[out] zone the UTM zone (zero means UPS).
* @param[out] northp hemisphere of location (true means northern, fals * @param[out] northp hemisphere (true means north, false means south).
e
* means southern).
* @param[out] x easting of point (meters). * @param[out] x easting of point (meters).
* @param[out] y northing of point (meters). * @param[out] y northing of point (meters).
* @param[out] gamma meridian convergence at point (degrees). * @param[out] gamma meridian convergence at point (degrees).
* @param[out] k scale of projection at point. * @param[out] k scale of projection at point.
* @param[in] setzone zone override. * @param[in] setzone zone override.
* @param[in] mgrslimits if true enforce the stricted MGRS limits on th e * @param[in] mgrslimits if true enforce the stricted MGRS limits on th e
* coordinates (default = false). * coordinates (default = false).
* *
* The prefered zone for the result can be specified with \e setzone, s ee * The prefered zone for the result can be specified with \e setzone, s ee
* UTMUPS::StandardZone. Throw error if the resulting easting or north ing * UTMUPS::StandardZone. Throw error if the resulting easting or north ing
skipping to change at line 191 skipping to change at line 190
********************************************************************** / ********************************************************************** /
static void Forward(real lat, real lon, static void Forward(real lat, real lon,
int& zone, bool& northp, real& x, real& y, int& zone, bool& northp, real& x, real& y,
real& gamma, real& k, real& gamma, real& k,
int setzone = STANDARD, bool mgrslimits = false); int setzone = STANDARD, bool mgrslimits = false);
/** /**
* Reverse projection, from UTM/UPS to geographic. * Reverse projection, from UTM/UPS to geographic.
* *
* @param[in] zone the UTM zone (zero means UPS). * @param[in] zone the UTM zone (zero means UPS).
* @param[in] northp hemisphere of location (true means northern, false * @param[in] northp hemisphere (true means north, false means south).
* means southern).
* @param[in] x easting of point (meters). * @param[in] x easting of point (meters).
* @param[in] y northing of point (meters). * @param[in] y northing of point (meters).
* @param[out] lat latitude of point (degrees). * @param[out] lat latitude of point (degrees).
* @param[out] lon longitude of point (degrees). * @param[out] lon longitude of point (degrees).
* @param[out] gamma meridian convergence at point (degrees). * @param[out] gamma meridian convergence at point (degrees).
* @param[out] k scale of projection at point. * @param[out] k scale of projection at point.
* @param[in] mgrslimits if true enforce the stricted MGRS limits on th e * @param[in] mgrslimits if true enforce the stricted MGRS limits on th e
* coordinates (default = false). * coordinates (default = false).
* *
* Throw error if easting or northing is outside the allowed range (see * Throw error if easting or northing is outside the allowed range (see
skipping to change at line 253 skipping to change at line 251
real& lat, real& lon, bool mgrslimits = false) { real& lat, real& lon, bool mgrslimits = false) {
real gamma, k; real gamma, k;
Reverse(zone, northp, x, y, lat, lon, gamma, k, mgrslimits); Reverse(zone, northp, x, y, lat, lon, gamma, k, mgrslimits);
} }
/** /**
* Decode a UTM/UPS zone string. * Decode a UTM/UPS zone string.
* *
* @param[in] zonestr string represention of zone and hemisphere. * @param[in] zonestr string represention of zone and hemisphere.
* @param[out] zone the UTM zone (zero means UPS). * @param[out] zone the UTM zone (zero means UPS).
* @param[out] northp the hemisphere (true means northern, false * @param[out] northp hemisphere (true means north, false means south).
* means southern).
* *
* For UTM, \e zonestr has the form of a zone number in the range * For UTM, \e zonestr has the form of a zone number in the range
* [UTMUPS::MINUTMZONE, UTMUPS::MAXUTMZONE] = [1, 60] followed by a * [UTMUPS::MINUTMZONE, UTMUPS::MAXUTMZONE] = [1, 60] followed by a
* hemisphere letter, N or S. For UPS, it consists just of the hemisph ere * hemisphere letter, N or S. For UPS, it consists just of the hemisph ere
* letter. The returned value of \e zone is UTMUPS::UPS = 0 for UPS. Note * letter. The returned value of \e zone is UTMUPS::UPS = 0 for UPS. Note
* well that "38S" indicates the southern hemisphere of zone 38 and not * well that "38S" indicates the southern hemisphere of zone 38 and not
* latitude band S, [32, 40]. N, 01S, 2N, 38S are legal. 0N, 001S, 61 N, * latitude band S, [32, 40]. N, 01S, 2N, 38S are legal. 0N, 001S, 61 N,
* 38P are illegal. INV is a special value for which the returned valu e of * 38P are illegal. INV is a special value for which the returned valu e of
* \e is UTMUPS::INVALID. Throws an error is the zone string is malfor med. * \e is UTMUPS::INVALID. Throws an error is the zone string is malfor med.
********************************************************************** / ********************************************************************** /
static void DecodeZone(const std::string& zonestr, int& zone, bool& nor thp); static void DecodeZone(const std::string& zonestr, int& zone, bool& nor thp);
/** /**
* Encode a UTM/UPS zone string. * Encode a UTM/UPS zone string.
* *
* @param[out] zone the UTM zone (zero means UPS). * @param[out] zone the UTM zone (zero means UPS).
* @param[out] northp the hemisphere (true means northern, false * @param[out] northp hemisphere (true means north, false means south).
* means southern).
* @return string represention of zone and hemisphere. * @return string represention of zone and hemisphere.
* *
* \e zone must be in the range [UTMUPS::MINZONE, UTMUPS::MAXZONE] = [0 , * \e zone must be in the range [UTMUPS::MINZONE, UTMUPS::MAXZONE] = [0 ,
* 60] with \e zone = UTMUPS::UPS, 0, indicating UPS (but the resulting * 60] with \e zone = UTMUPS::UPS, 0, indicating UPS (but the resulting
* string does not contain "0"). \e zone may also be UTMUPS::INVALID, in * string does not contain "0"). \e zone may also be UTMUPS::INVALID, in
* which case the returned string is "INV". This reverses * which case the returned string is "INV". This reverses
* UTMUPS::DecodeZone. * UTMUPS::DecodeZone.
********************************************************************** / ********************************************************************** /
static std::string EncodeZone(int zone, bool northp); static std::string EncodeZone(int zone, bool northp);
 End of changes. 5 change blocks. 
10 lines changed or deleted 5 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/