Commit f312d14a authored by xueyimeng's avatar xueyimeng

清理代码

parent 039ce4f2
/**
* \file Accumulator.hpp
* \brief Header for GeographicLib::Accumulator class
*
* Copyright (c) Charles Karney (2010-2019) <charles@karney.com> and licensed
* under the MIT/X11 License. For more information, see
* https://geographiclib.sourceforge.io/
**********************************************************************/
#if !defined(GEOGRAPHICLIB_ACCUMULATOR_HPP)
#define GEOGRAPHICLIB_ACCUMULATOR_HPP 1
#include <GeographicLib/Constants.hpp>
namespace GeographicLib {
/**
* \brief An accumulator for sums
*
* This allows many numbers of floating point type \e T to be added together
* with twice the normal precision. Thus if \e T is double, the effective
* precision of the sum is 106 bits or about 32 decimal places.
*
* The implementation follows J. R. Shewchuk,
* <a href="https://doi.org/10.1007/PL00009321"> Adaptive Precision
* Floating-Point Arithmetic and Fast Robust Geometric Predicates</a>,
* Discrete & Computational Geometry 18(3) 305--363 (1997).
*
* Approximate timings (summing a vector<double>)
* - double: 2ns
* - Accumulator<double>: 23ns
*
* In the documentation of the member functions, \e sum stands for the value
* currently held in the accumulator.
*
* Example of use:
* \include example-Accumulator.cpp
**********************************************************************/
template<typename T = Math::real>
class GEOGRAPHICLIB_EXPORT Accumulator {
private:
// _s + _t accumulators for the sum.
T _s, _t;
// Same as Math::sum, but requires abs(u) >= abs(v). This isn't currently
// used.
static T fastsum(T u, T v, T& t) {
GEOGRAPHICLIB_VOLATILE T s = u + v;
GEOGRAPHICLIB_VOLATILE T vp = s - u;
t = v - vp;
return s;
}
void Add(T y) {
// Here's Shewchuk's solution...
T u; // hold exact sum as [s, t, u]
// Accumulate starting at least significant end
y = Math::sum(y, _t, u);
_s = Math::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 (except 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
// following does an approximate job (and maintains the decreasing
// non-adjacent property). Here are two "failures" using 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 accumulated
// values. The additional errors illustrated here amount to 1 ulp of the
// less significant word during each addition to the Accumulator 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.
}
T Sum(T y) const {
Accumulator a(*this);
a.Add(y);
return a._s;
}
public:
/**
* Construct from a \e T. This is not declared explicit, so that you can
* write <code>Accumulator<double> a = 5;</code>.
*
* @param[in] y set \e sum = \e y.
**********************************************************************/
Accumulator(T y = T(0)) : _s(y), _t(0) {
GEOGRAPHICLIB_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) { _s = y; _t = 0; return *this; }
/**
* Return the value held in the accumulator.
*
* @return \e sum.
**********************************************************************/
T operator()() const { return _s; }
/**
* 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 { return Sum(y); }
/**
* Add a number to the accumulator.
*
* @param[in] y set \e sum += \e y.
**********************************************************************/
Accumulator& operator+=(T y) { Add(y); return *this; }
/**
* Subtract a number from the accumulator.
*
* @param[in] y set \e sum -= \e y.
**********************************************************************/
Accumulator& operator-=(T y) { Add(-y); return *this; }
/**
* Multiply accumulator by an integer. To avoid loss of accuracy, use only
* integers such that \e n &times; \e T is exactly representable as a \e T
* (i.e., &plusmn; powers of two). Use \e n = &minus;1 to negate \e sum.
*
* @param[in] n set \e sum *= \e n.
**********************************************************************/
Accumulator& operator*=(int n) { _s *= n; _t *= n; return *this; }
/**
* Multiply accumulator by a number. The fma (fused multiply and add)
* instruction is used (if available) in order to maintain accuracy.
*
* @param[in] y set \e sum *= \e y.
**********************************************************************/
Accumulator& operator*=(T y) {
T d = _s; _s *= y;
d = Math::fma(y, d, -_s); // the error in the first multiplication
_t = Math::fma(y, _t, d); // add error to the second term
return *this;
}
/**
* Reduce accumulator to the range [-y/2, y/2].
*
* @param[in] y the modulus.
**********************************************************************/
Accumulator& remainder(T y) {
_s = Math::remainder(_s, y);
Add(0); // This renormalizes the result.
return *this;
}
/**
* Test equality of an Accumulator with a number.
**********************************************************************/
bool operator==(T y) const { return _s == y; }
/**
* Test inequality of an Accumulator with a number.
**********************************************************************/
bool operator!=(T y) const { return _s != y; }
/**
* Less operator on an Accumulator and a number.
**********************************************************************/
bool operator<(T y) const { return _s < y; }
/**
* Less or equal operator on an Accumulator and a number.
**********************************************************************/
bool operator<=(T y) const { return _s <= y; }
/**
* Greater operator on an Accumulator and a number.
**********************************************************************/
bool operator>(T y) const { return _s > y; }
/**
* Greater or equal operator on an Accumulator and a number.
**********************************************************************/
bool operator>=(T y) const { return _s >= y; }
};
} // namespace GeographicLib
#endif // GEOGRAPHICLIB_ACCUMULATOR_HPP
/**
* \file AzimuthalEquidistant.hpp
* \brief Header for GeographicLib::AzimuthalEquidistant class
*
* Copyright (c) Charles Karney (2009-2019) <charles@karney.com> and licensed
* under the MIT/X11 License. For more information, see
* https://geographiclib.sourceforge.io/
**********************************************************************/
#if !defined(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP)
#define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP 1
#include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/Constants.hpp>
namespace GeographicLib {
/**
* \brief Azimuthal equidistant projection
*
* Azimuthal equidistant projection centered at an arbitrary position on the
* ellipsoid. For a point in projected space (\e x, \e y), the geodesic
* distance from the center position is hypot(\e x, \e y) and the azimuth of
* the geodesic from the center point is atan2(\e x, \e y). The Forward and
* Reverse methods also return the azimuth \e azi of the geodesic at (\e x,
* \e y) and reciprocal scale \e rk in the azimuthal direction which,
* together with the basic properties of the projection, serve to specify
* completely the local affine transformation between geographic and
* projected coordinates.
*
* The conversions all take place using a Geodesic object (by default
* Geodesic::WGS84()). For more information on geodesics see \ref geodesic.
*
* Example of use:
* \include example-AzimuthalEquidistant.cpp
*
* <a href="GeodesicProj.1.html">GeodesicProj</a> is a command-line utility
* providing access to the functionality of AzimuthalEquidistant, Gnomonic,
* and CassiniSoldner.
**********************************************************************/
class GEOGRAPHICLIB_EXPORT AzimuthalEquidistant {
private:
typedef Math::real real;
real eps_;
Geodesic _earth;
public:
/**
* Constructor for AzimuthalEquidistant.
*
* @param[in] earth the Geodesic object to use for geodesic calculations.
* By default this uses the WGS84 ellipsoid.
**********************************************************************/
explicit AzimuthalEquidistant(const Geodesic& earth = Geodesic::WGS84());
/**
* Forward projection, from geographic to azimuthal equidistant.
*
* @param[in] lat0 latitude of center point of projection (degrees).
* @param[in] lon0 longitude of center point of projection (degrees).
* @param[in] lat latitude of point (degrees).
* @param[in] lon longitude of point (degrees).
* @param[out] x easting of point (meters).
* @param[out] y northing of point (meters).
* @param[out] azi azimuth of geodesic at point (degrees).
* @param[out] rk reciprocal of azimuthal scale at point.
*
* \e lat0 and \e lat should be in the range [&minus;90&deg;, 90&deg;].
* The scale of the projection is 1 in the "radial" direction, \e azi
* clockwise from true north, and is 1/\e rk in the direction perpendicular
* to this. A call to Forward followed by a call to Reverse will return
* the original (\e lat, \e lon) (to within roundoff).
**********************************************************************/
void Forward(real lat0, real lon0, real lat, real lon,
real& x, real& y, real& azi, real& rk) const;
/**
* Reverse projection, from azimuthal equidistant to geographic.
*
* @param[in] lat0 latitude of center point of projection (degrees).
* @param[in] lon0 longitude of center point of projection (degrees).
* @param[in] x easting of point (meters).
* @param[in] y northing of point (meters).
* @param[out] lat latitude of point (degrees).
* @param[out] lon longitude of point (degrees).
* @param[out] azi azimuth of geodesic at point (degrees).
* @param[out] rk reciprocal of azimuthal scale at point.
*
* \e lat0 should be in the range [&minus;90&deg;, 90&deg;]. \e lat will
* be in the range [&minus;90&deg;, 90&deg;] and \e lon will be in the
* range [&minus;180&deg;, 180&deg;]. The scale of the projection is 1 in
* the "radial" direction, \e azi clockwise from true north, and is 1/\e rk
* in the direction perpendicular to this. A call to Reverse followed by a
* call to Forward will return the original (\e x, \e y) (to roundoff) only
* if the geodesic to (\e x, \e y) is a shortest path.
**********************************************************************/
void Reverse(real lat0, real lon0, real x, real y,
real& lat, real& lon, real& azi, real& rk) const;
/**
* AzimuthalEquidistant::Forward without returning the azimuth and scale.
**********************************************************************/
void Forward(real lat0, real lon0, real lat, real lon,
real& x, real& y) const {
real azi, rk;
Forward(lat0, lon0, lat, lon, x, y, azi, rk);
}
/**
* AzimuthalEquidistant::Reverse without returning the azimuth and scale.
**********************************************************************/
void Reverse(real lat0, real lon0, real x, real y,
real& lat, real& lon) const {
real azi, rk;
Reverse(lat0, lon0, x, y, lat, lon, azi, rk);
}
/** \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 constructor.
**********************************************************************/
Math::real EquatorialRadius() const { return _earth.EquatorialRadius(); }
/**
* @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 { return _earth.Flattening(); }
/**
* \deprecated An old name for EquatorialRadius().
**********************************************************************/
// GEOGRAPHICLIB_DEPRECATED("Use EquatorialRadius()")
Math::real MajorRadius() const { return EquatorialRadius(); }
///@}
};
} // namespace GeographicLib
#endif // GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP
/**
* \file CassiniSoldner.hpp
* \brief Header for GeographicLib::CassiniSoldner class
*
* Copyright (c) Charles Karney (2009-2019) <charles@karney.com> and licensed
* under the MIT/X11 License. For more information, see
* https://geographiclib.sourceforge.io/
**********************************************************************/
#if !defined(GEOGRAPHICLIB_CASSINISOLDNER_HPP)
#define GEOGRAPHICLIB_CASSINISOLDNER_HPP 1
#include <GeographicLib/Geodesic.hpp>
#include <GeographicLib/GeodesicLine.hpp>
#include <GeographicLib/Constants.hpp>
namespace GeographicLib {
/**
* \brief Cassini-Soldner projection
*
* Cassini-Soldner projection centered at an arbitrary position, \e lat0, \e
* lon0, on the ellipsoid. This projection is a transverse cylindrical
* equidistant projection. The projection from (\e lat, \e lon) to easting
* and northing (\e x, \e y) is defined by geodesics as follows. Go north
* along a geodesic a distance \e y from the central point; then turn
* clockwise 90&deg; and go a distance \e x along a geodesic.
* (Although the initial heading is north, this changes to south if the pole
* is crossed.) This procedure uniquely defines the reverse projection. The
* forward projection is constructed as follows. Find the point (\e lat1, \e
* lon1) on the meridian closest to (\e lat, \e lon). Here we consider the
* full meridian so that \e lon1 may be either \e lon0 or \e lon0 +
* 180&deg;. \e x is the geodesic distance from (\e lat1, \e lon1) to
* (\e lat, \e lon), appropriately signed according to which side of the
* central meridian (\e lat, \e lon) lies. \e y is the shortest distance
* along the meridian from (\e lat0, \e lon0) to (\e lat1, \e lon1), again,
* appropriately signed according to the initial heading. [Note that, in the
* case of prolate ellipsoids, the shortest meridional path from (\e lat0, \e
* lon0) to (\e lat1, \e lon1) may not be the shortest path.] This procedure
* uniquely defines the forward projection except for a small class of points
* for which there may be two equally short routes for either leg of the
* path.
*
* Because of the properties of geodesics, the (\e x, \e y) grid is
* orthogonal. The scale in the easting direction is unity. The scale, \e
* k, in the northing direction is unity on the central meridian and
* increases away from the central meridian. The projection routines return
* \e azi, the true bearing of the easting direction, and \e rk = 1/\e k, the
* reciprocal of the scale in the northing direction.
*
* The conversions all take place using a Geodesic object (by default
* Geodesic::WGS84()). For more information on geodesics see \ref geodesic.
* The determination of (\e lat1, \e lon1) in the forward projection is by
* solving the inverse geodesic problem for (\e lat, \e lon) and its twin
* obtained by reflection in the meridional plane. The scale is found by
* determining where two neighboring geodesics intersecting the central
* meridian at \e lat1 and \e lat1 + \e dlat1 intersect and taking the ratio
* of the reduced lengths for the two geodesics between that point and,
* respectively, (\e lat1, \e lon1) and (\e lat, \e lon).
*
* Example of use:
* \include example-CassiniSoldner.cpp
*
* <a href="GeodesicProj.1.html">GeodesicProj</a> is a command-line utility
* providing access to the functionality of AzimuthalEquidistant, Gnomonic,
* and CassiniSoldner.
**********************************************************************/
class GEOGRAPHICLIB_EXPORT CassiniSoldner {
private:
typedef Math::real real;
Geodesic _earth;
GeodesicLine _meridian;
real _sbet0, _cbet0;
static const unsigned maxit_ = 10;
public:
/**
* Constructor for CassiniSoldner.
*
* @param[in] earth the Geodesic object to use for geodesic calculations.
* By default this uses the WGS84 ellipsoid.
*
* This constructor makes an "uninitialized" object. Call Reset to set the
* central latitude and longitude, prior to calling Forward and Reverse.
**********************************************************************/
explicit CassiniSoldner(const Geodesic& earth = Geodesic::WGS84());
/**
* Constructor for CassiniSoldner specifying a center point.
*
* @param[in] lat0 latitude of center point of projection (degrees).
* @param[in] lon0 longitude of center point of projection (degrees).
* @param[in] earth the Geodesic object to use for geodesic calculations.
* By default this uses the WGS84 ellipsoid.
*
* \e lat0 should be in the range [&minus;90&deg;, 90&deg;].
**********************************************************************/
CassiniSoldner(real lat0, real lon0,
const Geodesic& earth = Geodesic::WGS84());
/**
* Set the central point of the projection
*
* @param[in] lat0 latitude of center point of projection (degrees).
* @param[in] lon0 longitude of center point of projection (degrees).
*
* \e lat0 should be in the range [&minus;90&deg;, 90&deg;].
**********************************************************************/
void Reset(real lat0, real lon0);
/**
* Forward projection, from geographic to Cassini-Soldner.
*
* @param[in] lat latitude of point (degrees).
* @param[in] lon longitude of point (degrees).
* @param[out] x easting of point (meters).
* @param[out] y northing of point (meters).
* @param[out] azi azimuth of easting direction at point (degrees).
* @param[out] rk reciprocal of azimuthal northing scale at point.
*
* \e lat should be in the range [&minus;90&deg;, 90&deg;]. A call to
* Forward followed by a call to Reverse will return the original (\e lat,
* \e lon) (to within roundoff). The routine does nothing if the origin
* has not been set.
**********************************************************************/
void Forward(real lat, real lon,
real& x, real& y, real& azi, real& rk) const;
/**
* Reverse projection, from Cassini-Soldner to geographic.
*
* @param[in] x easting of point (meters).
* @param[in] y northing of point (meters).
* @param[out] lat latitude of point (degrees).
* @param[out] lon longitude of point (degrees).
* @param[out] azi azimuth of easting direction at point (degrees).
* @param[out] rk reciprocal of azimuthal northing scale at point.
*
* A call to Reverse followed by a call to Forward will return the original
* (\e x, \e y) (to within roundoff), provided that \e x and \e y are
* sufficiently small not to "wrap around" the earth. The routine does
* nothing if the origin has not been set.
**********************************************************************/
void Reverse(real x, real y,
real& lat, real& lon, real& azi, real& rk) const;
/**
* CassiniSoldner::Forward without returning the azimuth and scale.
**********************************************************************/
void Forward(real lat, real lon,
real& x, real& y) const {
real azi, rk;
Forward(lat, lon, x, y, azi, rk);
}
/**
* CassiniSoldner::Reverse without returning the azimuth and scale.
**********************************************************************/
void Reverse(real x, real y,
real& lat, real& lon) const {
real azi, rk;
Reverse(x, y, lat, lon, azi, rk);
}
/** \name Inspector functions
**********************************************************************/
///@{
/**
* @return true if the object has been initialized.
**********************************************************************/
bool Init() const { return _meridian.Init(); }
/**
* @return \e lat0 the latitude of origin (degrees).
**********************************************************************/
Math::real LatitudeOrigin() const
{ return _meridian.Latitude(); }
/**
* @return \e lon0 the longitude of origin (degrees).
**********************************************************************/
Math::real LongitudeOrigin() const
{ return _meridian.Longitude(); }
/**
* @return \e a the equatorial radius of the ellipsoid (meters). This is
* the value inherited from the Geodesic object used in the constructor.
**********************************************************************/
Math::real EquatorialRadius() const { return _earth.EquatorialRadius(); }
/**
* @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 { return _earth.Flattening(); }
/**
* \deprecated An old name for EquatorialRadius().
**********************************************************************/
// GEOGRAPHICLIB_DEPRECATED("Use EquatorialRadius()")
Math::real MajorRadius() const { return EquatorialRadius(); }
///@}
};
} // namespace GeographicLib
#endif // GEOGRAPHICLIB_CASSINISOLDNER_HPP
/**
* \file CircularEngine.hpp
* \brief Header for GeographicLib::CircularEngine class
*
* Copyright (c) Charles Karney (2011-2015) <charles@karney.com> and licensed
* under the MIT/X11 License. For more information, see
* https://geographiclib.sourceforge.io/
**********************************************************************/
#if !defined(GEOGRAPHICLIB_CIRCULARENGINE_HPP)
#define GEOGRAPHICLIB_CIRCULARENGINE_HPP 1
#include <vector>
#include <GeographicLib/Constants.hpp>
#include <GeographicLib/SphericalEngine.hpp>
#if defined(_MSC_VER)
// Squelch warnings about dll vs vector
# pragma warning (push)
# pragma warning (disable: 4251)
#endif
namespace GeographicLib {
/**
* \brief Spherical harmonic sums for a circle
*
* The class is a companion to SphericalEngine. If the results of a
* spherical harmonic sum are needed for several points on a circle of
* constant latitude \e lat and height \e h, then SphericalEngine::Circle can
* compute the inner sum, which is independent of longitude \e lon, and
* produce a CircularEngine object. CircularEngine::operator()() can
* then be used to perform the outer sum for particular vales of \e lon.
* This can lead to substantial improvements in computational speed for high
* degree sum (approximately by a factor of \e N / 2 where \e N is the
* maximum degree).
*
* CircularEngine is tightly linked to the internals of SphericalEngine. For
* that reason, the constructor for this class is private. Use
* SphericalHarmonic::Circle, SphericalHarmonic1::Circle, and
* SphericalHarmonic2::Circle to create instances of this class.
*
* CircularEngine stores the coefficients needed to allow the summation over
* order to be performed in 2 or 6 vectors of length \e M + 1 (depending on
* whether gradients are to be calculated). For this reason the constructor
* may throw a std::bad_alloc exception.
*
* Example of use:
* \include example-CircularEngine.cpp
**********************************************************************/
class GEOGRAPHICLIB_EXPORT CircularEngine {
private:
typedef Math::real real;
enum normalization {
FULL = SphericalEngine::FULL,
SCHMIDT = SphericalEngine::SCHMIDT,
};
int _M;
bool _gradp;
unsigned _norm;
real _a, _r, _u, _t;
std::vector<real> _wc, _ws, _wrc, _wrs, _wtc, _wts;
real _q, _uq, _uq2;
Math::real Value(bool gradp, real sl, real cl,
real& gradx, real& grady, real& gradz) const;
friend class SphericalEngine;
CircularEngine(int M, bool gradp, unsigned norm,
real a, real r, real u, real t)
: _M(M)
, _gradp(gradp)
, _norm(norm)
, _a(a)
, _r(r)
, _u(u)
, _t(t)
, _wc(std::vector<real>(_M + 1, 0))
, _ws(std::vector<real>(_M + 1, 0))
, _wrc(std::vector<real>(_gradp ? _M + 1 : 0, 0))
, _wrs(std::vector<real>(_gradp ? _M + 1 : 0, 0))
, _wtc(std::vector<real>(_gradp ? _M + 1 : 0, 0))
, _wts(std::vector<real>(_gradp ? _M + 1 : 0, 0))
{
_q = _a / _r;
_uq = _u * _q;
_uq2 = Math::sq(_uq);
}
void SetCoeff(int m, real wc, real ws)
{ _wc[m] = wc; _ws[m] = ws; }
void SetCoeff(int m, real wc, real ws,
real wrc, real wrs, real wtc, real wts) {
_wc[m] = wc; _ws[m] = ws;
if (_gradp) {
_wrc[m] = wrc; _wrs[m] = wrs;
_wtc[m] = wtc; _wts[m] = wts;
}
}
public:
/**
* A default constructor. CircularEngine::operator()() on the resulting
* object returns zero. The resulting object can be assigned to the result
* of SphericalHarmonic::Circle.
**********************************************************************/
CircularEngine()
: _M(-1)
, _gradp(true)
, _u(0)
, _t(1)
{}
/**
* Evaluate the sum for a particular longitude given in terms of its
* sine and cosine.
*
* @param[in] sinlon the sine of the longitude.
* @param[in] coslon the cosine of the longitude.
* @return \e V the value of the sum.
*
* The arguments must satisfy <i>sinlon</i><sup>2</sup> +
* <i>coslon</i><sup>2</sup> = 1.
**********************************************************************/
Math::real operator()(real sinlon, real coslon) const {
real dummy;
return Value(false, sinlon, coslon, dummy, dummy, dummy);
}
/**
* Evaluate the sum for a particular longitude.
*
* @param[in] lon the longitude (degrees).
* @return \e V the value of the sum.
**********************************************************************/
Math::real operator()(real lon) const {
real sinlon, coslon;
Math::sincosd(lon, sinlon, coslon);
return (*this)(sinlon, coslon);
}
/**
* Evaluate the sum and its gradient for a particular longitude given in
* terms of its sine and cosine.
*
* @param[in] sinlon the sine of the longitude.
* @param[in] coslon the cosine of the longitude.
* @param[out] gradx \e x component of the gradient.
* @param[out] grady \e y component of the gradient.
* @param[out] gradz \e z component of the gradient.
* @return \e V the value of the sum.
*
* The gradients will only be computed if the CircularEngine object was
* created with this capability (e.g., via \e gradp = true in
* SphericalHarmonic::Circle). If not, \e gradx, etc., will not be
* touched. The arguments must satisfy <i>sinlon</i><sup>2</sup> +
* <i>coslon</i><sup>2</sup> = 1.
**********************************************************************/
Math::real operator()(real sinlon, real coslon,
real& gradx, real& grady, real& gradz) const {
return Value(true, sinlon, coslon, gradx, grady, gradz);
}
/**
* Evaluate the sum and its gradient for a particular longitude.
*
* @param[in] lon the longitude (degrees).
* @param[out] gradx \e x component of the gradient.
* @param[out] grady \e y component of the gradient.
* @param[out] gradz \e z component of the gradient.
* @return \e V the value of the sum.
*
* The gradients will only be computed if the CircularEngine object was
* created with this capability (e.g., via \e gradp = true in
* SphericalHarmonic::Circle). If not, \e gradx, etc., will not be
* touched.
**********************************************************************/
Math::real operator()(real lon,
real& gradx, real& grady, real& gradz) const {
real sinlon, coslon;
Math::sincosd(lon, sinlon, coslon);
return (*this)(sinlon, coslon, gradx, grady, gradz);
}
};
} // namespace GeographicLib
#if defined(_MSC_VER)
# pragma warning (pop)
#endif
#endif // GEOGRAPHICLIB_CIRCULARENGINE_HPP
#define GEOGRAPHICLIB_VERSION_STRING "1.50.1"
#define GEOGRAPHICLIB_VERSION_MAJOR 1
#define GEOGRAPHICLIB_VERSION_MINOR 50
#define GEOGRAPHICLIB_VERSION_PATCH 1
#define GEOGRAPHICLIB_DATA "/usr/local/share/GeographicLib"
// These are macros which affect the building of the library
#define GEOGRAPHICLIB_HAVE_LONG_DOUBLE 1
#define GEOGRAPHICLIB_WORDS_BIGENDIAN 0
#define GEOGRAPHICLIB_PRECISION 2
// Specify whether GeographicLib is a shared or static library. When compiling
// under Visual Studio it is necessary to specify whether GeographicLib is a
// shared library. This is done with the macro GEOGRAPHICLIB_SHARED_LIB, which
// cmake will correctly define as 0 or 1 when only one type of library is in
// the package. If both shared and static libraries are available,
// GEOGRAPHICLIB_SHARED_LIB is set to 2 which triggers a preprocessor error in
// Constants.hpp. In this case, the appropriate value (0 or 1) for
// GEOGRAPHICLIB_SHARED_LIB must be specified when compiling any program that
// includes GeographicLib headers. This is done automatically if GeographicLib
// and the user's code were built with cmake version 2.8.11 (which introduced
// the command target_compile_definitions) or later.
#if !defined(GEOGRAPHICLIB_SHARED_LIB)
#define GEOGRAPHICLIB_SHARED_LIB 1
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* \file GARS.hpp
* \brief Header for GeographicLib::GARS class
*
* Copyright (c) Charles Karney (2015-2017) <charles@karney.com> and licensed
* under the MIT/X11 License. For more information, see
* https://geographiclib.sourceforge.io/
**********************************************************************/
#if !defined(GEOGRAPHICLIB_GARS_HPP)
#define GEOGRAPHICLIB_GARS_HPP 1
#include <GeographicLib/Constants.hpp>
#if defined(_MSC_VER)
// Squelch warnings about dll vs string
# pragma warning (push)
# pragma warning (disable: 4251)
#endif
namespace GeographicLib {
/**
* \brief Conversions for the Global Area Reference System (GARS)
*
* The Global Area Reference System is described in
* - https://en.wikipedia.org/wiki/Global_Area_Reference_System
* - http://earth-info.nga.mil/GandG/coordsys/grids/gars.html
* .
* It provides a compact string representation of a geographic area
* (expressed as latitude and longitude). The classes Georef and Geohash
* implement similar compact representations.
*
* Example of use:
* \include example-GARS.cpp
**********************************************************************/
class GEOGRAPHICLIB_EXPORT GARS {
private:
typedef Math::real real;
static const char* const digits_;
static const char* const letters_;
enum {
lonorig_ = -180, // Origin for longitude
latorig_ = -90, // Origin for latitude
baselon_ = 10, // Base for longitude tiles
baselat_ = 24, // Base for latitude tiles
lonlen_ = 3,
latlen_ = 2,
baselen_ = lonlen_ + latlen_,
mult1_ = 2, // base precision = 1/2 degree
mult2_ = 2, // 6th char gives 2x more precision
mult3_ = 3, // 7th char gives 3x more precision
m_ = mult1_ * mult2_ * mult3_,
maxprec_ = 2,
maxlen_ = baselen_ + maxprec_,
};
GARS(); // Disable constructor
public:
/**
* Convert from geographic coordinates to GARS.
*
* @param[in] lat latitude of point (degrees).
* @param[in] lon longitude of point (degrees).
* @param[in] prec the precision of the resulting GARS.
* @param[out] gars the GARS string.
* @exception GeographicErr if \e lat is not in [&minus;90&deg;,
* 90&deg;].
* @exception std::bad_alloc if memory for \e gars can't be allocated.
*
* \e prec specifies the precision of \e gars as follows:
* - \e prec = 0 (min), 30' precision, e.g., 006AG;
* - \e prec = 1, 15' precision, e.g., 006AG3;
* - \e prec = 2 (max), 5' precision, e.g., 006AG39.
*
* If \e lat or \e lon is NaN, then \e gars is set to "INVALID".
**********************************************************************/
static void Forward(real lat, real lon, int prec, std::string& gars);
/**
* Convert from GARS to geographic coordinates.
*
* @param[in] gars the GARS.
* @param[out] lat latitude of point (degrees).
* @param[out] lon longitude of point (degrees).
* @param[out] prec the precision of \e gars.
* @param[in] centerp if true (the default) return the center of the
* \e gars, otherwise return the south-west corner.
* @exception GeographicErr if \e gars is illegal.
*
* The case of the letters in \e gars is ignored. \e prec is in the range
* [0, 2] and gives the precision of \e gars as follows:
* - \e prec = 0 (min), 30' precision, e.g., 006AG;
* - \e prec = 1, 15' precision, e.g., 006AG3;
* - \e prec = 2 (max), 5' precision, e.g., 006AG39.
*
* If the first 3 characters of \e gars are "INV", then \e lat and \e lon
* are set to NaN and \e prec is unchanged.
**********************************************************************/
static void Reverse(const std::string& gars, real& lat, real& lon,
int& prec, bool centerp = true);
/**
* The angular resolution of a GARS.
*
* @param[in] prec the precision of the GARS.
* @return the latitude-longitude resolution (degrees).
*
* Internally, \e prec is first put in the range [0, 2].
**********************************************************************/
static Math::real Resolution(int prec) {
return 1/real(prec <= 0 ? mult1_ : (prec == 1 ? mult1_ * mult2_ :
mult1_ * mult2_ * mult3_));
}
/**
* The GARS precision required to meet a given geographic resolution.
*
* @param[in] res the minimum of resolution in latitude and longitude
* (degrees).
* @return GARS precision.
*
* The returned length is in the range [0, 2].
**********************************************************************/
static int Precision(real res) {
using std::abs; res = abs(res);
for (int prec = 0; prec < maxprec_; ++prec)
if (Resolution(prec) <= res)
return prec;
return maxprec_;
}
};
} // namespace GeographicLib
#if defined(_MSC_VER)
# pragma warning (pop)
#endif
#endif // GEOGRAPHICLIB_GARS_HPP
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# Version checking for GeographicLib
set (PACKAGE_VERSION "1.50.1")
set (PACKAGE_VERSION_MAJOR "1")
set (PACKAGE_VERSION_MINOR "50")
set (PACKAGE_VERSION_PATCH "1")
# These variable definitions parallel those in GeographicLib's
# cmake/CMakeLists.txt.
if (MSVC)
# For checking the compatibility of MSVC_TOOLSET_VERSION; see
# https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp
# Assume major version number is obtained by dropping the last decimal
# digit.
math (EXPR MSVC_TOOLSET_MAJOR "${MSVC_TOOLSET_VERSION}/10")
endif ()
if (CMAKE_CROSSCOMPILING)
# Ensure that all "true" (resp. "false") settings are represented by
# the same string.
set (CMAKE_CROSSCOMPILING_STR "ON")
else ()
set (CMAKE_CROSSCOMPILING_STR "OFF")
endif ()
if (NOT PACKAGE_FIND_NAME STREQUAL "GeographicLib")
# Check package name (in particular, because of the way cmake finds
# package config files, the capitalization could easily be "wrong").
# This is necessary to ensure that the automatically generated
# variables, e.g., <package>_FOUND, are consistently spelled.
set (REASON "package = GeographicLib, NOT ${PACKAGE_FIND_NAME}")
set (PACKAGE_VERSION_UNSUITABLE TRUE)
elseif (NOT (APPLE OR (NOT DEFINED CMAKE_SIZEOF_VOID_P) OR
CMAKE_SIZEOF_VOID_P EQUAL 8))
# Reject if there's a 32-bit/64-bit mismatch (not necessary with Apple
# since a multi-architecture library is built for that platform).
set (REASON "sizeof(*void) = 8")
set (PACKAGE_VERSION_UNSUITABLE TRUE)
elseif (MSVC AND NOT (
# toolset version must be at least as great as GeographicLib's
MSVC_TOOLSET_VERSION GREATER_EQUAL 0
# and major versions must match
AND MSVC_TOOLSET_MAJOR EQUAL 0 ))
# Reject if there's a mismatch in MSVC compiler versions
set (REASON "MSVC_TOOLSET_VERSION = 0")
set (PACKAGE_VERSION_UNSUITABLE TRUE)
elseif (NOT CMAKE_CROSSCOMPILING_STR STREQUAL "OFF")
# Reject if there's a mismatch in ${CMAKE_CROSSCOMPILING}
set (REASON "cross-compiling = FALSE")
set (PACKAGE_VERSION_UNSUITABLE TRUE)
elseif (CMAKE_CROSSCOMPILING AND
NOT (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))
# Reject if cross-compiling and there's a mismatch in the target system
set (REASON "target = Linux-x86_64")
set (PACKAGE_VERSION_UNSUITABLE TRUE)
elseif (PACKAGE_FIND_VERSION)
if (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
set (PACKAGE_VERSION_EXACT TRUE)
elseif (PACKAGE_FIND_VERSION VERSION_LESS PACKAGE_VERSION
AND PACKAGE_FIND_VERSION_MAJOR EQUAL PACKAGE_VERSION_MAJOR)
set (PACKAGE_VERSION_COMPATIBLE TRUE)
endif ()
endif ()
set (GeographicLib_SHARED_FOUND ON)
set (GeographicLib_STATIC_FOUND OFF)
set (GeographicLib_NETGeographicLib_FOUND OFF)
# Check for the components requested. The convention is that
# GeographicLib_${comp}_FOUND should be true for all the required
# components.
if (GeographicLib_FIND_COMPONENTS)
foreach (comp ${GeographicLib_FIND_COMPONENTS})
if (GeographicLib_FIND_REQUIRED_${comp} AND
NOT GeographicLib_${comp}_FOUND)
set (REASON "without ${comp}")
set (PACKAGE_VERSION_UNSUITABLE TRUE)
endif ()
endforeach ()
endif ()
# If unsuitable, append the reason to the package version so that it's
# visible to the user.
if (PACKAGE_VERSION_UNSUITABLE)
set (PACKAGE_VERSION "${PACKAGE_VERSION} (${REASON})")
endif ()
libGeographic.so.19
\ No newline at end of file
libGeographic.so.19.0.1
\ No newline at end of file
The MIT License (MIT); this license applies to GeographicLib,
versions 1.12 and later.
Copyright (c) 2008-2019, Charles Karney
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
This diff is collapsed.
prefix=/media/xueyimeng/common/code/geographiclib-code/bin
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
bindir=${exec_prefix}/bin
Name: GeographicLib
Description: A library for geographic projections
Version: 1.50.1
URL: https://geographiclib.sourceforge.io
Requires:
Libs: -L${libdir} -lGeographic
Cflags: -I${includedir}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment