summaryrefslogtreecommitdiff
path: root/src/mbgl/map/transform_state.cpp
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-02-09 17:42:38 +0200
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-03-01 20:58:54 +0000
commit411a562061f404fa7174222f38a1a9a13a396fd9 (patch)
treefcbc295f48d48d86f75ced98b8a9ad137cf5bce0 /src/mbgl/map/transform_state.cpp
parent9955087767d226c09816d562be39be1f1a1e84c5 (diff)
downloadqtlocation-mapboxgl-411a562061f404fa7174222f38a1a9a13a396fd9.tar.gz
[core] Enforce constants usage
Use 'LATITUDE_MAX', 'LONGITUDE_MAX', 'DEG2RAD' and 'RAD2DEG' whenever possible.
Diffstat (limited to 'src/mbgl/map/transform_state.cpp')
-rw-r--r--src/mbgl/map/transform_state.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index 087defabda..1a0704b0a3 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -96,8 +96,8 @@ LatLng TransformState::getLatLng() const {
ll.latitude = util::RAD2DEG * (2 * std::atan(std::exp(y / Cc)) - 0.5 * M_PI);
// adjust for world wrap
- while (ll.longitude > 180) ll.longitude -= 180;
- while (ll.longitude < -180) ll.longitude += 180;
+ while (ll.longitude > util::LONGITUDE_MAX) ll.longitude -= util::LONGITUDE_MAX;
+ while (ll.longitude < -util::LONGITUDE_MAX) ll.longitude += util::LONGITUDE_MAX;
// adjust for date line
double w = util::tileSize * scale / 2;
@@ -106,18 +106,18 @@ LatLng TransformState::getLatLng() const {
while (x_ > w) {
x_ -= w;
if (ll.longitude < 0) {
- ll.longitude += 180;
+ ll.longitude += util::LONGITUDE_MAX;
} else if (ll.longitude > 0) {
- ll.longitude -= 180;
+ ll.longitude -= util::LONGITUDE_MAX;
}
}
} else if (x_ < -w) {
while (x_ < -w) {
x_ += w;
if (ll.longitude < 0) {
- ll.longitude -= 180;
+ ll.longitude -= util::LONGITUDE_MAX;
} else if (ll.longitude > 0) {
- ll.longitude -= 180;
+ ll.longitude -= util::LONGITUDE_MAX;
}
}
}
@@ -220,21 +220,21 @@ bool TransformState::isGestureInProgress() const {
#pragma mark - Projection
double TransformState::lngX(double lng) const {
- return (180.0f + lng) * worldSize() / 360.0f;
+ return (util::LONGITUDE_MAX + lng) * worldSize() / 360.0f;
}
double TransformState::latY(double lat) const {
- double y_ = 180.0f / M_PI * std::log(std::tan(M_PI / 4 + lat * M_PI / 360.0f));
- return (180.0f - y_) * worldSize() / 360.0f;
+ double y_ = util::RAD2DEG * std::log(std::tan(M_PI / 4 + lat * M_PI / 360.0f));
+ return (util::LONGITUDE_MAX - y_) * worldSize() / 360.0f;
}
double TransformState::xLng(double x_, double worldSize_) const {
- return x_ * 360.0f / worldSize_ - 180.0f;
+ return x_ * 360.0f / worldSize_ - util::LONGITUDE_MAX;
}
double TransformState::yLat(double y_, double worldSize_) const {
- double y2 = 180.0f - y_ * 360.0f / worldSize_;
- return 360.0f / M_PI * std::atan(std::exp(y2 * M_PI / 180.0f)) - 90.0f;
+ double y2 = util::LONGITUDE_MAX - y_ * 360.0f / worldSize_;
+ return 360.0f / M_PI * std::atan(std::exp(y2 * util::DEG2RAD)) - 90.0f;
}
double TransformState::zoomScale(double zoom) const {
@@ -271,8 +271,8 @@ LatLng TransformState::coordinateToLatLng(const TileCoordinate& coord) const {
yLat(coord.row, worldSize_),
xLng(coord.column, worldSize_)
};
- while (latLng.longitude < -180.0f) latLng.longitude += 360.0f;
- while (latLng.longitude > 180.0f) latLng.longitude -= 360.0f;
+ while (latLng.longitude < -util::LONGITUDE_MAX) latLng.longitude += 360.0f;
+ while (latLng.longitude > util::LONGITUDE_MAX) latLng.longitude -= 360.0f;
return latLng;
}