| Ellipsoid.hpp | | Ellipsoid.hpp | |
| | | | |
| skipping to change at line 124 | | skipping to change at line 124 | |
| /** \name %Ellipsoid shape | | /** \name %Ellipsoid shape | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| ///@{ | | ///@{ | |
| | | | |
| /** | | /** | |
| * @return \e f = (\e a − \e b) / \e a, the flattening of the | | * @return \e f = (\e a − \e b) / \e a, the flattening of the | |
| * ellipsoid. This is the value used in the constructor. This is ze
ro, | | * ellipsoid. This is the value used in the constructor. This is ze
ro, | |
| * positive, or negative for a sphere, oblate ellipsoid, or prolate | | * positive, or negative for a sphere, oblate ellipsoid, or prolate | |
| * ellipsoid. | | * ellipsoid. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
|
| Math::real Flattening() { return _f; } | | Math::real Flattening() const throw() { return _f; } | |
| | | | |
| /** | | /** | |
| * @return \e f ' = (\e a − \e b) / \e b, the second flattening o
f | | * @return \e f ' = (\e a − \e b) / \e b, the second flattening o
f | |
| * the ellipsoid. This is zero, positive, or negative for a sphere, | | * the ellipsoid. This is zero, positive, or negative for a sphere, | |
| * oblate ellipsoid, or prolate ellipsoid. | | * oblate ellipsoid, or prolate ellipsoid. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
|
| Math::real SecondFlattening() { return _f / (1 - _f); } | | Math::real SecondFlattening() const throw() { return _f / (1 - _f); } | |
| | | | |
| /** | | /** | |
| * @return \e n = (\e a − \e b) / (\e a + \e b), the third flatte
ning | | * @return \e n = (\e a − \e b) / (\e a + \e b), the third flatte
ning | |
| * of the ellipsoid. This is zero, positive, or negative for a spher
e, | | * of the ellipsoid. This is zero, positive, or negative for a spher
e, | |
| * oblate ellipsoid, or prolate ellipsoid. | | * oblate ellipsoid, or prolate ellipsoid. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
|
| Math::real ThirdFlattening() { return _n; } | | Math::real ThirdFlattening() const throw() { return _n; } | |
| | | | |
| /** | | /** | |
| * @return <i>e</i><sup>2</sup> = (<i>a</i><sup>2</sup> − | | * @return <i>e</i><sup>2</sup> = (<i>a</i><sup>2</sup> − | |
| * <i>b</i><sup>2</sup>) / <i>a</i><sup>2</sup>, the eccentricity squ
ared | | * <i>b</i><sup>2</sup>) / <i>a</i><sup>2</sup>, the eccentricity squ
ared | |
| * of the ellipsoid. This is zero, positive, or negative for a spher
e, | | * of the ellipsoid. This is zero, positive, or negative for a spher
e, | |
| * oblate ellipsoid, or prolate ellipsoid. | | * oblate ellipsoid, or prolate ellipsoid. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
|
| Math::real EccentricitySq() { return _e2; } | | Math::real EccentricitySq() const throw() { return _e2; } | |
| | | | |
| /** | | /** | |
| * @return <i>e'</i> <sup>2</sup> = (<i>a</i><sup>2</sup> − | | * @return <i>e'</i> <sup>2</sup> = (<i>a</i><sup>2</sup> − | |
| * <i>b</i><sup>2</sup>) / <i>b</i><sup>2</sup>, the second eccentric
ity | | * <i>b</i><sup>2</sup>) / <i>b</i><sup>2</sup>, the second eccentric
ity | |
| * squared of the ellipsoid. This is zero, positive, or negative for
a | | * squared of the ellipsoid. This is zero, positive, or negative for
a | |
| * sphere, oblate ellipsoid, or prolate ellipsoid. | | * sphere, oblate ellipsoid, or prolate ellipsoid. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
|
| Math::real SecondEccentricitySq() { return _e12; } | | Math::real SecondEccentricitySq() const throw() { return _e12; } | |
| | | | |
| /** | | /** | |
| * @return <i>e''</i> <sup>2</sup> = (<i>a</i><sup>2</sup> − | | * @return <i>e''</i> <sup>2</sup> = (<i>a</i><sup>2</sup> − | |
| * <i>b</i><sup>2</sup>) / (<i>a</i><sup>2</sup> + <i>b</i><sup>2</su
p>), | | * <i>b</i><sup>2</sup>) / (<i>a</i><sup>2</sup> + <i>b</i><sup>2</su
p>), | |
| * the third eccentricity squared of the ellipsoid. This is zero, | | * the third eccentricity squared of the ellipsoid. This is zero, | |
| * positive, or negative for a sphere, oblate ellipsoid, or prolate | | * positive, or negative for a sphere, oblate ellipsoid, or prolate | |
| * ellipsoid. | | * ellipsoid. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
|
| Math::real ThirdEccentricitySq() { return _e2 / (2 - _e2); } | | Math::real ThirdEccentricitySq() const throw() { return _e2 / (2 - _e2)
; } | |
| ///@} | | ///@} | |
| | | | |
| /** \name Latitude conversion. | | /** \name Latitude conversion. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| ///@{ | | ///@{ | |
| | | | |
| /** | | /** | |
| * @param[in] phi the geographic latitude (degrees). | | * @param[in] phi the geographic latitude (degrees). | |
| * @return β the parametric latitude (degrees). | | * @return β the parametric latitude (degrees). | |
| * | | * | |
| | | | |
End of changes. 6 change blocks. |
| 6 lines changed or deleted | | 6 lines changed or added | |
|
| Geodesic.hpp | | Geodesic.hpp | |
| | | | |
| skipping to change at line 35 | | skipping to change at line 35 | |
| class GeodesicLine; | | class GeodesicLine; | |
| | | | |
| /** | | /** | |
| * \brief %Geodesic calculations | | * \brief %Geodesic calculations | |
| * | | * | |
| * The shortest path between two points on a ellipsoid at (\e lat1, \e lo
n1) | | * The shortest path between two points on a ellipsoid at (\e lat1, \e lo
n1) | |
| * and (\e lat2, \e lon2) is called the geodesic. Its length is \e s12 a
nd | | * and (\e lat2, \e lon2) is called the geodesic. Its length is \e s12 a
nd | |
| * the geodesic from point 1 to point 2 has azimuths \e azi1 and \e azi2
at | | * the geodesic from point 1 to point 2 has azimuths \e azi1 and \e azi2
at | |
| * the two end points. (The azimuth is the heading measured clockwise fr
om | | * the two end points. (The azimuth is the heading measured clockwise fr
om | |
| * north. \e azi2 is the "forward" azimuth, i.e., the heading that takes
you | | * north. \e azi2 is the "forward" azimuth, i.e., the heading that takes
you | |
|
| * beyond point 2 not back to point 1.) | | * beyond point 2 not back to point 1.) In the figure below, latitude if | |
| | | * labeled φ, longitude λ (with λ<sub>12</sub> = | |
| | | * λ<sub>2</sub> − λ<sub>1</sub>), and azimuth &alpha | |
| | | ;. | |
| | | * | |
| | | * <img src="http://upload.wikimedia.org/wikipedia/commons/c/cb/Geodesic_ | |
| | | problem_on_an_ellipsoid.svg" width=250 alt="spheroidal triangle"> | |
| * | | * | |
| * Given \e lat1, \e lon1, \e azi1, and \e s12, we can determine \e lat2,
\e | | * Given \e lat1, \e lon1, \e azi1, and \e s12, we can determine \e lat2,
\e | |
| * lon2, and \e azi2. This is the \e direct geodesic problem and its | | * lon2, and \e azi2. This is the \e direct geodesic problem and its | |
| * solution is given by the function Geodesic::Direct. (If \e s12 is | | * solution is given by the function Geodesic::Direct. (If \e s12 is | |
| * sufficiently large that the geodesic wraps more than halfway around th
e | | * sufficiently large that the geodesic wraps more than halfway around th
e | |
| * earth, there will be another geodesic between the points with a smalle
r \e | | * earth, there will be another geodesic between the points with a smalle
r \e | |
| * s12.) | | * s12.) | |
| * | | * | |
| * Given \e lat1, \e lon1, \e lat2, and \e lon2, we can determine \e azi1
, \e | | * Given \e lat1, \e lon1, \e lat2, and \e lon2, we can determine \e azi1
, \e | |
| * azi2, and \e s12. This is the \e inverse geodesic problem, whose solu
tion | | * azi2, and \e s12. This is the \e inverse geodesic problem, whose solu
tion | |
| | | | |
| skipping to change at line 107 | | skipping to change at line 111 | |
| * - \e M13 = \e M12 \e M23 − (1 − \e M12 \e M21) \e m23 / \e
m12 | | * - \e M13 = \e M12 \e M23 − (1 − \e M12 \e M21) \e m23 / \e
m12 | |
| * - \e M31 = \e M32 \e M21 − (1 − \e M23 \e M32) \e m12 / \e
m23 | | * - \e M31 = \e M32 \e M21 − (1 − \e M23 \e M32) \e m12 / \e
m23 | |
| * | | * | |
| * Additional functionality is provided by the GeodesicLine class, which | | * Additional functionality is provided by the GeodesicLine class, which | |
| * allows a sequence of points along a geodesic to be computed. | | * allows a sequence of points along a geodesic to be computed. | |
| * | | * | |
| * The shortest distance returned by the solution of the inverse problem
is | | * The shortest distance returned by the solution of the inverse problem
is | |
| * (obviously) uniquely defined. However, in a few special cases there a
re | | * (obviously) uniquely defined. However, in a few special cases there a
re | |
| * multiple azimuths which yield the same shortest distance. Here is a | | * multiple azimuths which yield the same shortest distance. Here is a | |
| * catalog of those cases: | | * catalog of those cases: | |
|
| * - \e lat1 = −\e lat2 (with neither at a pole). If \e azi1 = \e | | * - \e lat1 = −\e lat2 (with neither point at a pole). If \e azi1 | |
| * azi2, the geodesic is unique. Otherwise there are two geodesics and | | = | |
| the | | * \e azi2, the geodesic is unique. Otherwise there are two geodesics | |
| * second one is obtained by setting [\e azi1, \e azi2] = [\e azi2, \e | | and | |
| | | * the second one is obtained by setting [\e azi1, \e azi2] = [\e azi2, | |
| | | \e | |
| * azi1], [\e M12, \e M21] = [\e M21, \e M12], \e S12 = −\e S12. | | * azi1], [\e M12, \e M21] = [\e M21, \e M12], \e S12 = −\e S12. | |
| * (This occurs when the longitude difference is near ±180°
for | | * (This occurs when the longitude difference is near ±180°
for | |
| * oblate ellipsoids.) | | * oblate ellipsoids.) | |
|
| * - \e lon2 = \e lon1 ± 180° (with neither at a pole). If \e | | * - \e lon2 = \e lon1 ± 180° (with neither point at a pole). | |
| * azi1 = 0° or ±180°, the geodesic is unique. Otherwis | | If | |
| e | | * \e azi1 = 0° or ±180°, the geodesic is unique. Other | |
| | | wise | |
| * there are two geodesics and the second one is obtained by setting [\
e | | * there are two geodesics and the second one is obtained by setting [\
e | |
| * azi1, \e azi2] = [−\e azi1, −\e azi2], \e S12 = −\
e | | * azi1, \e azi2] = [−\e azi1, −\e azi2], \e S12 = −\
e | |
|
| * S12. (This occurs when the \e lat2 is near −\e lat1 for prola
te | | * S12. (This occurs when \e lat2 is near −\e lat1 for prolate | |
| * ellipsoids.) | | * ellipsoids.) | |
| * - Points 1 and 2 at opposite poles. There are infinitely many geodesi
cs | | * - Points 1 and 2 at opposite poles. There are infinitely many geodesi
cs | |
| * which can be generated by setting [\e azi1, \e azi2] = [\e azi1, \e | | * which can be generated by setting [\e azi1, \e azi2] = [\e azi1, \e | |
| * azi2] + [\e d, −\e d], for arbitrary \e d. (For spheres, this | | * azi2] + [\e d, −\e d], for arbitrary \e d. (For spheres, this | |
| * prescription applies when points 1 and 2 are antipodal.) | | * prescription applies when points 1 and 2 are antipodal.) | |
| * - s12 = 0 (coincident points). There are infinitely many geodesics wh
ich | | * - s12 = 0 (coincident points). There are infinitely many geodesics wh
ich | |
| * can be generated by setting [\e azi1, \e azi2] = [\e azi1, \e azi2]
+ | | * can be generated by setting [\e azi1, \e azi2] = [\e azi1, \e azi2]
+ | |
| * [\e d, \e d], for arbitrary \e d. | | * [\e d, \e d], for arbitrary \e d. | |
| * | | * | |
| * The calculations are accurate to better than 15 nm (15 nanometers) for
the | | * The calculations are accurate to better than 15 nm (15 nanometers) for
the | |
| | | | |
End of changes. 4 change blocks. |
| 9 lines changed or deleted | | 18 lines changed or added | |
|
| GeodesicExact.hpp | | GeodesicExact.hpp | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| namespace GeographicLib { | | namespace GeographicLib { | |
| | | | |
| class GeodesicLineExact; | | class GeodesicLineExact; | |
| | | | |
| /** | | /** | |
| * \brief Exact %Geodesic calculations | | * \brief Exact %Geodesic calculations | |
| * | | * | |
| * The equations for geodesics on an ellipsoid can be expressed in terms
of | | * The equations for geodesics on an ellipsoid can be expressed in terms
of | |
| * incomplete elliptic integrals. The Geodesic class expands these integ
rals | | * incomplete elliptic integrals. The Geodesic class expands these integ
rals | |
| * in a series in the flattening \e f and this provides an accurate solut
ion | | * in a series in the flattening \e f and this provides an accurate solut
ion | |
|
| * for \e f &isin [-0.01, 0.01]. The GeodesicExact class computes the | | * for \e f ∈ [-0.01, 0.01]. The GeodesicExact class computes the | |
| * ellitpic integrals directly and so provides a solution which is valid
for | | * ellitpic integrals directly and so provides a solution which is valid
for | |
| * all \e f. However, in practice, its use should be limited to about \e | | * all \e f. However, in practice, its use should be limited to about \e | |
| * b/\e a ∈ [0.01, 100] or \e f ∈ [-99, 0.99]. | | * b/\e a ∈ [0.01, 100] or \e f ∈ [-99, 0.99]. | |
| * | | * | |
| * For the WGS84 ellipsoid, these classes are 2--3 times \e slower than t
he | | * For the WGS84 ellipsoid, these classes are 2--3 times \e slower than t
he | |
| * series solution and 2--3 times \e less \e accurate (because it's less
easy | | * series solution and 2--3 times \e less \e accurate (because it's less
easy | |
| * to control round-off errors with the elliptic integral formulation); i
.e., | | * to control round-off errors with the elliptic integral formulation); i
.e., | |
| * the error is about 40 nm (40 nanometers) instead of 15 nm. However th
e | | * the error is about 40 nm (40 nanometers) instead of 15 nm. However th
e | |
| * error in the series solution scales as <i>f</i><sup>7</sup> while the | | * error in the series solution scales as <i>f</i><sup>7</sup> while the | |
| * error in the elliptic integral solution depends weakly on \e f. If th
e | | * error in the elliptic integral solution depends weakly on \e f. If th
e | |
| | | | |
End of changes. 1 change blocks. |
| 1 lines changed or deleted | | 1 lines changed or added | |
|
| Geohash.hpp | | Geohash.hpp | |
| | | | |
| skipping to change at line 102 | | skipping to change at line 102 | |
| | | | |
| /** | | /** | |
| * The latitude resolution of a geohash. | | * The latitude resolution of a geohash. | |
| * | | * | |
| * @param[in] len the length of the geohash. | | * @param[in] len the length of the geohash. | |
| * @return the latitude resolution (degrees). | | * @return the latitude resolution (degrees). | |
| * | | * | |
| * Internally, \e len is first put in the range [0, 18]. | | * Internally, \e len is first put in the range [0, 18]. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| static Math::real LatitudeResolution(int len) throw() { | | static Math::real LatitudeResolution(int len) throw() { | |
|
| len = std::max(0, std::min(int(maxlen_), len)); | | len = (std::max)(0, (std::min)(int(maxlen_), len)); | |
| return 180 * std::pow(0.5, 5 * len / 2); | | return 180 * std::pow(0.5, 5 * len / 2); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * The longitude resolution of a geohash. | | * The longitude resolution of a geohash. | |
| * | | * | |
| * @param[in] len the length of the geohash. | | * @param[in] len the length of the geohash. | |
| * @return the longitude resolution (degrees). | | * @return the longitude resolution (degrees). | |
| * | | * | |
| * Internally, \e len is first put in the range [0, 18]. | | * Internally, \e len is first put in the range [0, 18]. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| static Math::real LongitudeResolution(int len) throw() { | | static Math::real LongitudeResolution(int len) throw() { | |
|
| len = std::max(0, std::min(int(maxlen_), len)); | | len = (std::max)(0, (std::min)(int(maxlen_), len)); | |
| return 360 * std::pow(0.5, 5 * len - 5 * len / 2); | | return 360 * std::pow(0.5, 5 * len - 5 * len / 2); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * The geohash length required to meet a given geographic resolution. | | * The geohash length required to meet a given geographic resolution. | |
| * | | * | |
| * @param[in] res the minimum of resolution in latitude and longitude | | * @param[in] res the minimum of resolution in latitude and longitude | |
| * (degrees). | | * (degrees). | |
| * @return geohash length. | | * @return geohash length. | |
| * | | * | |
| | | | |
End of changes. 2 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| MGRS.hpp | | MGRS.hpp | |
| | | | |
| skipping to change at line 109 | | skipping to change at line 109 | |
| static int LatitudeBand(real lat) throw() { | | static int LatitudeBand(real lat) throw() { | |
| int ilat = int(std::floor(lat)); | | int ilat = int(std::floor(lat)); | |
| return (std::max)(-10, (std::min)(9, (ilat + 80)/8 - 10)); | | return (std::max)(-10, (std::min)(9, (ilat + 80)/8 - 10)); | |
| } | | } | |
| // Return approximate latitude band number [-10, 10) for the given nort
hing | | // Return approximate latitude band number [-10, 10) for the given nort
hing | |
| // (meters). With this rule, each 100km tile would have a unique band | | // (meters). With this rule, each 100km tile would have a unique band | |
| // letter corresponding to the latitude at the center of the tile. Thi
s | | // letter corresponding to the latitude at the center of the tile. Thi
s | |
| // function isn't currently used. | | // function isn't currently used. | |
| static int ApproxLatitudeBand(real y) throw() { | | static int ApproxLatitudeBand(real y) throw() { | |
| // northing at tile center in units of tile = 100km | | // northing at tile center in units of tile = 100km | |
|
| real ya = std::floor( std::min(real(88), std::abs(y/tile_)) ) + real( | | real ya = std::floor( (std::min)(real(88), std::abs(y/tile_)) ) + | |
| 0.5); | | real(0.5); | |
| // convert to lat (mult by 90/100) and then to band (divide by 8) | | // convert to lat (mult by 90/100) and then to band (divide by 8) | |
| // the +1 fine tunes the boundary between bands 3 and 4 | | // the +1 fine tunes the boundary between bands 3 and 4 | |
| int b = int(std::floor( ((ya * 9 + 1) / 10) / 8 )); | | int b = int(std::floor( ((ya * 9 + 1) / 10) / 8 )); | |
| // For the northern hemisphere we have | | // For the northern hemisphere we have | |
| // band rows num | | // band rows num | |
| // N 0 0:8 9 | | // N 0 0:8 9 | |
| // P 1 9:17 9 | | // P 1 9:17 9 | |
| // Q 2 18:26 9 | | // Q 2 18:26 9 | |
| // R 3 27:34 8 | | // R 3 27:34 8 | |
| // S 4 35:43 9 | | // S 4 35:43 9 | |
| | | | |
End of changes. 1 change blocks. |
| 2 lines changed or deleted | | 2 lines changed or added | |
|
| Math.hpp | | Math.hpp | |
| | | | |
| skipping to change at line 163 | | skipping to change at line 163 | |
| * | | * | |
| * @tparam T the type of the arguments and the returned value. | | * @tparam T the type of the arguments and the returned value. | |
| * @param[in] x | | * @param[in] x | |
| * @param[in] y | | * @param[in] y | |
| * @return sqrt(<i>x</i><sup>2</sup> + <i>y</i><sup>2</sup>). | | * @return sqrt(<i>x</i><sup>2</sup> + <i>y</i><sup>2</sup>). | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| template<typename T> static inline T hypot(T x, T y) throw() { | | template<typename T> static inline T hypot(T x, T y) throw() { | |
| x = std::abs(x); y = std::abs(y); | | x = std::abs(x); y = std::abs(y); | |
| T a = (std::max)(x, y), b = (std::min)(x, y) / (a ? a : 1); | | T a = (std::max)(x, y), b = (std::min)(x, y) / (a ? a : 1); | |
| return a * std::sqrt(1 + b * b); | | return a * std::sqrt(1 + b * b); | |
|
| // For an alternative method see | | // For an alternative (square-root free) method see | |
| // C. Moler and D. Morrision (1983) http://dx.doi.org/10.1147/rd.276.
0577 | | // C. Moler and D. Morrision (1983) http://dx.doi.org/10.1147/rd.276.
0577 | |
| // and A. A. Dubrulle (1983) http://dx.doi.org/10.1147/rd.276.0582 | | // and A. A. Dubrulle (1983) http://dx.doi.org/10.1147/rd.276.0582 | |
| } | | } | |
|
| #elif GEOGRAPHICLIB_CPLUSPLUS11_MATH | | #elif GEOGRAPHICLIB_CPLUSPLUS11_MATH || (defined(_MSC_VER) && _MSC_VER >= 1
700) | |
| template<typename T> static inline T hypot(T x, T y) throw() | | template<typename T> static inline T hypot(T x, T y) throw() | |
| { return std::hypot(x, y); } | | { return std::hypot(x, y); } | |
|
| | | # if HAVE_LONG_DOUBLE && defined(_MSC_VER) | |
| | | // Visual C++ 11&12 don't have a long double overload for std::hypot -- | |
| | | // reported to MS on 2013-07-18 | |
| | | // http://connect.microsoft.com/VisualStudio/feedback/details/794416 | |
| | | // suppress the resulting "loss of data warning" with | |
| | | static inline long double hypot(long double x, long double y) throw() | |
| | | { return std::hypot(double(x), double(y)); } | |
| | | # endif | |
| #elif defined(_MSC_VER) | | #elif defined(_MSC_VER) | |
| static inline double hypot(double x, double y) throw() | | static inline double hypot(double x, double y) throw() | |
| { return _hypot(x, y); } | | { return _hypot(x, y); } | |
| # if _MSC_VER < 1400 | | # if _MSC_VER < 1400 | |
| // Visual C++ 7.1/VS .NET 2003 does not have _hypotf() | | // Visual C++ 7.1/VS .NET 2003 does not have _hypotf() | |
| static inline float hypot(float x, float y) throw() | | static inline float hypot(float x, float y) throw() | |
| { return float(_hypot(x, y)); } | | { return float(_hypot(x, y)); } | |
| # else | | # else | |
| static inline float hypot(float x, float y) throw() | | static inline float hypot(float x, float y) throw() | |
| { return _hypotf(x, y); } | | { return _hypotf(x, y); } | |
| | | | |
End of changes. 3 change blocks. |
| 2 lines changed or deleted | | 10 lines changed or added | |
|
| OSGB.hpp | | OSGB.hpp | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| | | | |
| namespace GeographicLib { | | namespace GeographicLib { | |
| | | | |
| /** | | /** | |
| * \brief Ordnance Survey grid system for Great Britain | | * \brief Ordnance Survey grid system for Great Britain | |
| * | | * | |
| * The class implements the coordinate system used by the Ordnance Survey
for | | * The class implements the coordinate system used by the Ordnance Survey
for | |
| * maps of Great Britain and conversions to the grid reference system. | | * maps of Great Britain and conversions to the grid reference system. | |
| * | | * | |
| * See | | * See | |
|
| * - <a href="http://www.ordnancesurvey.co.uk/oswebsite/gps/docs/A_Guide_ | | * - <a href="http://www.ordnancesurvey.co.uk/docs/support/guide-coordina | |
| to_Coordinate_Systems_in_Great_Britain.pdf"> | | te-systems-great-britain.pdf"> | |
| * A guide to coordinate systems in Great Britain</a> | | * A guide to coordinate systems in Great Britain</a> | |
| * - <a href="http://www.ordnancesurvey.co.uk/oswebsite/gps/information/c | | * - <a href="http://www.ordnancesurvey.co.uk/docs/support/national-grid. | |
| oordinatesystemsinfo/guidetonationalgrid/page1.html"> | | pdf"> | |
| * Guide to National Grid</a> | | * Guide to the National Grid</a> | |
| * | | * | |
| * \b WARNING: the latitudes and longitudes for the Ordnance Survey grid | | * \b WARNING: the latitudes and longitudes for the Ordnance Survey grid | |
| * system do not use the WGS84 datum. Do not use the values returned by
this | | * system do not use the WGS84 datum. Do not use the values returned by
this | |
| * class in the UTMUPS, MGRS, or Geoid classes without first converting t
he | | * class in the UTMUPS, MGRS, or Geoid classes without first converting t
he | |
| * datum (and vice versa). | | * datum (and vice versa). | |
| * | | * | |
| * Example of use: | | * Example of use: | |
| * \include example-OSGB.cpp | | * \include example-OSGB.cpp | |
| **********************************************************************/ | | **********************************************************************/ | |
| class GEOGRAPHIC_EXPORT OSGB { | | class GEOGRAPHIC_EXPORT OSGB { | |
| private: | | private: | |
| typedef Math::real real; | | typedef Math::real real; | |
| static const std::string letters_; | | static const std::string letters_; | |
| static const std::string digits_; | | static const std::string digits_; | |
| static const TransverseMercator OSGBTM_; | | static const TransverseMercator OSGBTM_; | |
|
| static const real northoffset_; | | static real northoffset_; | |
| | | static bool init_; | |
| enum { | | enum { | |
| base_ = 10, | | base_ = 10, | |
| tile_ = 100000, | | tile_ = 100000, | |
| tilelevel_ = 5, | | tilelevel_ = 5, | |
| tilegrid_ = 5, | | tilegrid_ = 5, | |
| tileoffx_ = 2 * tilegrid_, | | tileoffx_ = 2 * tilegrid_, | |
| tileoffy_ = 1 * tilegrid_, | | tileoffy_ = 1 * tilegrid_, | |
| minx_ = - tileoffx_ * tile_, | | minx_ = - tileoffx_ * tile_, | |
| miny_ = - tileoffy_ * tile_, | | miny_ = - tileoffy_ * tile_, | |
| maxx_ = (tilegrid_*tilegrid_ - tileoffx_) * tile_, | | maxx_ = (tilegrid_*tilegrid_ - tileoffx_) * tile_, | |
| maxy_ = (tilegrid_*tilegrid_ - tileoffy_) * tile_, | | maxy_ = (tilegrid_*tilegrid_ - tileoffy_) * tile_, | |
| // Maximum precision is um | | // Maximum precision is um | |
| maxprec_ = 5 + 6, | | maxprec_ = 5 + 6, | |
| }; | | }; | |
| static real computenorthoffset() throw(); | | static real computenorthoffset() throw(); | |
| static void CheckCoords(real x, real y); | | static void CheckCoords(real x, real y); | |
| OSGB(); // Disable constructor | | OSGB(); // Disable constructor | |
|
| | | | |
| public: | | public: | |
| | | | |
| /** | | /** | |
| * Forward projection, from geographic to OSGB coordinates. | | * Forward projection, from geographic to OSGB coordinates. | |
| * | | * | |
| * @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] 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. | |
| * | | * | |
| * \e lat should be in the range [−90°, 90°]; \e lon | | * \e lat should be in the range [−90°, 90°]; \e lon | |
| * should be in the range [−540°, 540°). | | * should be in the range [−540°, 540°). | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| static void Forward(real lat, real lon, | | static void Forward(real lat, real lon, | |
| real& x, real& y, real& gamma, real& k) throw() { | | real& x, real& y, real& gamma, real& k) throw() { | |
| OSGBTM_.Forward(OriginLongitude(), lat, lon, x, y, gamma, k); | | OSGBTM_.Forward(OriginLongitude(), lat, lon, x, y, gamma, k); | |
| x += FalseEasting(); | | x += FalseEasting(); | |
|
| y += northoffset_; | | y += computenorthoffset(); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * Reverse projection, from OSGB coordinates to geographic. | | * Reverse projection, from OSGB coordinates to geographic. | |
| * | | * | |
| * @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. | |
| * | | * | |
| * The value of \e lon returned is in the range [−180°, | | * The value of \e lon returned is in the range [−180°, | |
| * 180°). | | * 180°). | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| | | | |
| static void Reverse(real x, real y, | | static void Reverse(real x, real y, | |
| real& lat, real& lon, real& gamma, real& k) throw()
{ | | real& lat, real& lon, real& gamma, real& k) throw()
{ | |
| x -= FalseEasting(); | | x -= FalseEasting(); | |
|
| y -= northoffset_; | | y -= computenorthoffset(); | |
| OSGBTM_.Reverse(OriginLongitude(), x, y, lat, lon, gamma, k); | | OSGBTM_.Reverse(OriginLongitude(), x, y, lat, lon, gamma, k); | |
| } | | } | |
| | | | |
| /** | | /** | |
| * OSGB::Forward without returning the convergence and scale. | | * OSGB::Forward without returning the convergence and scale. | |
| **********************************************************************
/ | | **********************************************************************
/ | |
| static void Forward(real lat, real lon, real& x, real& y) throw() { | | static void Forward(real lat, real lon, real& x, real& y) throw() { | |
| real gamma, k; | | real gamma, k; | |
| Forward(lat, lon, x, y, gamma, k); | | Forward(lat, lon, x, y, gamma, k); | |
| } | | } | |
| | | | |
End of changes. 5 change blocks. |
| 10 lines changed or deleted | | 10 lines changed or added | |
|
| PolygonArea.hpp | | PolygonArea.hpp | |
| | | | |
| skipping to change at line 22 | | skipping to change at line 22 | |
| | | | |
| #include <GeographicLib/Geodesic.hpp> | | #include <GeographicLib/Geodesic.hpp> | |
| #include <GeographicLib/Constants.hpp> | | #include <GeographicLib/Constants.hpp> | |
| #include <GeographicLib/Accumulator.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 polygon whose edges are geodesics using th | |
| * Section 6 of | | e | |
| | | * method given in Section 6 of | |
| * - C. F. F. Karney, | | * - C. F. F. Karney, | |
| * <a href="http://dx.doi.org/10.1007/s00190-012-0578-z"> | | * <a href="http://dx.doi.org/10.1007/s00190-012-0578-z"> | |
| * Algorithms for geodesics</a>, | | * Algorithms for geodesics</a>, | |
| * J. Geodesy <b>87</b>, 43--55 (2013); | | * J. Geodesy <b>87</b>, 43--55 (2013); | |
| * DOI: <a href="http://dx.doi.org/10.1007/s00190-012-0578-z"> | | * DOI: <a href="http://dx.doi.org/10.1007/s00190-012-0578-z"> | |
| * 10.1007/s00190-012-0578-z</a>; | | * 10.1007/s00190-012-0578-z</a>; | |
| * addenda: <a href="http://geographiclib.sf.net/geod-addenda.html"> | | * addenda: <a href="http://geographiclib.sf.net/geod-addenda.html"> | |
| * geod-addenda.html</a>. | | * geod-addenda.html</a>. | |
| * | | * | |
|
| * This class lets you add vertices one at a time to the polygon. The ar | | * This class lets you add vertices and edges one at a time to the polygo | |
| ea | | n. | |
| * and perimeter are accumulated in two times the standard floating point | | * The sequence must start with a vertex and thereafter vertices and edge | |
| * precision to guard against the loss of accuracy with many-sided polygo | | s | |
| ns. | | * can be added in any order. Any vertex after the first creates a new e | |
| * At any point you can ask for the perimeter and area so far. There's a | | dge | |
| n | | * which is the ''shortest'' geodesic from the previous vertex. In some | |
| * option to treat the points as defining a polyline instead of a polygon | | * cases there may be two or many such shortest geodesics and the area is | |
| ; in | | * then not uniquely defined. In this case, either add an intermediate | |
| * that case, only the perimeter is computed. | | * vertex or add the edge ''as'' an edge (by defining its direction and | |
| | | * length). | |
| | | * | |
| | | * The area and perimeter are accumulated in two times the standard float | |
| | | ing | |
| | | * point precision to guard against the loss of accuracy with many-sided | |
| | | * polygons. At any point you can ask for the perimeter and area so far. | |
| | | * There's an option to treat the points as defining a polyline instead o | |
| | | f a | |
| | | * polygon; in that case, only the perimeter is computed. | |
| * | | * | |
| * Example of use: | | * Example of use: | |
| * \include example-PolygonArea.cpp | | * \include example-PolygonArea.cpp | |
| * | | * | |
| * <a href="Planimeter.1.html">Planimeter</a> is a command-line utility | | * <a href="Planimeter.1.html">Planimeter</a> is a command-line utility | |
| * providing access to the functionality of PolygonArea. | | * providing access to the functionality of PolygonArea. | |
| **********************************************************************/ | | **********************************************************************/ | |
| | | | |
| class GEOGRAPHIC_EXPORT PolygonArea { | | class GEOGRAPHIC_EXPORT PolygonArea { | |
| private: | | private: | |
| | | | |
End of changes. 2 change blocks. |
| 12 lines changed or deleted | | 22 lines changed or added | |
|