diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-02-09 17:42:38 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-01 20:58:54 +0000 |
commit | 411a562061f404fa7174222f38a1a9a13a396fd9 (patch) | |
tree | fcbc295f48d48d86f75ced98b8a9ad137cf5bce0 /src/mbgl/util/geo.cpp | |
parent | 9955087767d226c09816d562be39be1f1a1e84c5 (diff) | |
download | qtlocation-mapboxgl-411a562061f404fa7174222f38a1a9a13a396fd9.tar.gz |
[core] Enforce constants usage
Use 'LATITUDE_MAX', 'LONGITUDE_MAX', 'DEG2RAD' and 'RAD2DEG' whenever
possible.
Diffstat (limited to 'src/mbgl/util/geo.cpp')
-rw-r--r-- | src/mbgl/util/geo.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mbgl/util/geo.cpp b/src/mbgl/util/geo.cpp index 25e795e4ef..6a279c823d 100644 --- a/src/mbgl/util/geo.cpp +++ b/src/mbgl/util/geo.cpp @@ -7,9 +7,9 @@ namespace mbgl { LatLng::LatLng(const TileID& id) { - longitude = id.x / std::pow(2.0, id.z) * 360.0 - 180; + longitude = id.x / std::pow(2.0, id.z) * 360.0 - util::LONGITUDE_MAX; const double n = M_PI - 2.0 * M_PI * id.y / std::pow(2.0, id.z); - latitude = 180.0 / M_PI * std::atan(0.5 * (std::exp(n) - std::exp(-n))); + latitude = util::RAD2DEG * std::atan(0.5 * (std::exp(n) - std::exp(-n))); } PrecisionPoint LatLng::project() const { @@ -17,7 +17,7 @@ PrecisionPoint LatLng::project() const { const double constrainedLatitude = ::fmin(::fmax(latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); // Project a coordinate into unit space in a square map. - const double sine = std::sin(constrainedLatitude * M_PI / 180.0); + const double sine = std::sin(constrainedLatitude * util::DEG2RAD); const double x = longitude / 360.0 + 0.5; const double y = 0.5 - 0.25 * std::log((1.0 + sine) / (1.0 - sine)) / M_PI; return { x, y }; |