From a0697a6ce73907f8dca15af3d69bcc777b7e42a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 26 Feb 2019 22:16:05 +0100 Subject: [PATCH] Fixed broken equations --- src/common/rectc.cpp | 4 ++-- src/map/albersequal.cpp | 8 ++++---- src/map/geocentric.cpp | 2 +- src/map/lambertconic.cpp | 10 +++++----- src/map/mercator.cpp | 12 ++++++------ src/map/transversemercator.cpp | 14 +++++++------- 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/common/rectc.cpp b/src/common/rectc.cpp index 67f035fb..9cd42daf 100644 --- a/src/common/rectc.cpp +++ b/src/common/rectc.cpp @@ -20,10 +20,10 @@ RectC::RectC(const Coordinates ¢er, double radius) double deltaLon = asin(sin(radDist) / cos(radlat)); minLon = radLon - deltaLon; if (minLon < MIN_LON) - minLon += M_2_PI; + minLon += 2 * M_PI; maxLon = radLon + deltaLon; if (maxLon > MAX_LON) - maxLon -= M_2_PI; + maxLon -= 2 * M_PI; } else { // a pole is within the distance minLat = qMax(minLat, MIN_LAT); diff --git a/src/map/albersequal.cpp b/src/map/albersequal.cpp index 2aa94730..e79b4c15 100644 --- a/src/map/albersequal.cpp +++ b/src/map/albersequal.cpp @@ -123,9 +123,9 @@ PointD AlbersEqual::ll2xy(const Coordinates &c) const dlam = deg2rad(c.lon()) - _longitudeOrigin; if (dlam > M_PI) - dlam -= M_2_PI; + dlam -= 2 * M_PI; if (dlam < -M_PI) - dlam += M_2_PI; + dlam += 2 * M_PI; sin_lat = sin(deg2rad(c.lat())); e_sin = _e * sin_lat; @@ -211,9 +211,9 @@ Coordinates AlbersEqual::xy2ll(const PointD &p) const lon = _longitudeOrigin + theta / _n; if (lon > M_PI) - lon -= M_2_PI; + lon -= 2 * M_PI; if (lon < -M_PI) - lon += M_2_PI; + lon += 2 * M_PI; if (lon > M_PI) lon = M_PI; diff --git a/src/map/geocentric.cpp b/src/map/geocentric.cpp index 040b85c5..4a66c8b7 100644 --- a/src/map/geocentric.cpp +++ b/src/map/geocentric.cpp @@ -57,7 +57,7 @@ Point3D Geocentric::fromGeodetic(const Coordinates &c, const Ellipsoid *e) double Rn = e->radius() / (sqrt(1.0 - e->es() * slat2)); if (lon > M_PI) - lon -= M_2_PI; + lon -= 2 * M_PI; return Point3D(Rn * clat * cos(lon), Rn * clat * sin(lon), (Rn * (1 - e->es())) * slat); diff --git a/src/map/lambertconic.cpp b/src/map/lambertconic.cpp index a8523cd4..30c4ba25 100644 --- a/src/map/lambertconic.cpp +++ b/src/map/lambertconic.cpp @@ -65,7 +65,7 @@ LambertConic1::LambertConic1(const Ellipsoid *ellipsoid, double latitudeOrigin, lat_orig = deg2rad(latitudeOrigin); _longitudeOrigin = deg2rad(longitudeOrigin); if (_longitudeOrigin > M_PI) - _longitudeOrigin -= M_2_PI; + _longitudeOrigin -= 2 * M_PI; _falseEasting = falseEasting; _falseNorthing = falseNorthing; @@ -102,9 +102,9 @@ PointD LambertConic1::ll2xy(const Coordinates &c) const dlam = deg2rad(c.lon()) - _longitudeOrigin; if (dlam > M_PI) - dlam -= M_2_PI; + dlam -= 2 * M_PI; if (dlam < -M_PI) - dlam += M_2_PI; + dlam += 2 * M_PI; theta = _n * dlam; @@ -168,13 +168,13 @@ Coordinates LambertConic1::xy2ll(const PointD &p) const if (lon - M_PI < 3.5e-6) lon = M_PI; else - lon -= M_2_PI; + lon -= 2 * M_PI; } if (lon < -M_PI) { if (fabs(lon + M_PI) < 3.5e-6) lon = -M_PI; else - lon += M_2_PI; + lon += 2 * M_PI; } if (fabs(lon) < 2.0e-7) diff --git a/src/map/mercator.cpp b/src/map/mercator.cpp index c42b3fec..dd891c72 100644 --- a/src/map/mercator.cpp +++ b/src/map/mercator.cpp @@ -56,7 +56,7 @@ Mercator::Mercator(const Ellipsoid *ellipsoid, double latitudeOrigin, _latitudeOrigin = deg2rad(latitudeOrigin); _longitudeOrigin = deg2rad(longitudeOrigin); if (_longitudeOrigin > M_PI) - _longitudeOrigin -= M_2_PI; + _longitudeOrigin -= 2 * M_PI; _falseNorthing = falseNorthing; _falseEasting = falseEasting; @@ -86,16 +86,16 @@ PointD Mercator::ll2xy(const Coordinates &c) const double pow_temp; if (lon > M_PI) - lon -= M_2_PI; + lon -= 2 * M_PI; e_x_sinlat = _e * sin(lat); tan_temp = tan(M_PI_4 + lat / 2.e0); pow_temp = pow((1.e0 - e_x_sinlat) / (1.e0 + e_x_sinlat), _e / 2.e0); ctanz2 = tan_temp * pow_temp; delta_lon = lon - _longitudeOrigin; if (delta_lon > M_PI) - delta_lon -= M_2_PI; + delta_lon -= 2 * M_PI; if (delta_lon < -M_PI) - delta_lon += M_2_PI; + delta_lon += 2 * M_PI; return PointD(_scaleFactor * _a * delta_lon + _falseEasting, _scaleFactor * _a * log(ctanz2) + _falseNorthing); @@ -115,9 +115,9 @@ Coordinates Mercator::xy2ll(const PointD &p) const lat = xphi + _ab * sin(2.e0 * xphi) + _bb * sin(4.e0 * xphi) + _cb * sin(6.e0 * xphi) + _db * sin(8.e0 * xphi); if (lon > M_PI) - lon -= M_2_PI; + lon -= 2 * M_PI; if (lon < -M_PI) - lon += M_2_PI; + lon += 2 * M_PI; return Coordinates(rad2deg(lon), rad2deg(lat)); } diff --git a/src/map/transversemercator.cpp b/src/map/transversemercator.cpp index 65f084a2..4edd8944 100644 --- a/src/map/transversemercator.cpp +++ b/src/map/transversemercator.cpp @@ -107,9 +107,9 @@ PointD TransverseMercator::ll2xy(const Coordinates &c) const dlam = deg2rad(c.lon()) - _longitudeOrigin; if (dlam > M_PI) - dlam -= M_2_PI; + dlam -= 2 * M_PI; if (dlam < -M_PI) - dlam += M_2_PI; + dlam += 2 * M_PI; if (fabs(dlam) < 2.e-10) dlam = 0.0; @@ -235,20 +235,20 @@ Coordinates TransverseMercator::xy2ll(const PointD &p) const lat = M_PI - lat; lon += M_PI; if (lon > M_PI) - lon -= M_2_PI; + lon -= 2 * M_PI; } while (lat < deg2rad(-90.0)) { lat = - (lat + M_PI); lon += M_PI; if (lon > M_PI) - lon -= M_2_PI; + lon -= 2 * M_PI; } - if (lon > M_2_PI) - lon -= M_2_PI; + if (lon > 2 * M_PI) + lon -= 2 * M_PI; if (lon < -M_PI) - lon += M_2_PI; + lon += 2 * M_PI; return Coordinates(rad2deg(lon), rad2deg(lat)); }