diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-02 14:51:47 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-03 17:02:15 +0200 |
commit | bb434aa9e4cbe89598f68d8d4f5f8fa182a43333 (patch) | |
tree | 9789b54f4ef8ab8c80c8e739fbab50ca39e3d551 /src | |
parent | 27b798da91a591351562c037607fc3e25907c974 (diff) | |
download | qtlocation-mapboxgl-bb434aa9e4cbe89598f68d8d4f5f8fa182a43333.tar.gz |
[core] Use TransformState::worldSize() whenever possible
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 8ffc191f86..006a8d5d3a 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -15,7 +15,7 @@ TransformState::TransformState(ConstrainMode constrainMode_) void TransformState::matrixFor(mat4& matrix, const TileID& id, const int8_t z) const { const double tile_scale = std::pow(2, z); - double s = util::tileSize * scale / tile_scale; + double s = worldSize() / tile_scale; matrix::identity(matrix); matrix::translate(matrix, matrix, id.x * s, id.y * s, 0); @@ -98,7 +98,7 @@ LatLng TransformState::getLatLng(LatLng::WrapMode wrapMode) const { if (wrapMode == LatLng::Unwrapped) return ll; // adjust for date line - double w = util::tileSize * scale / 2; + double w = worldSize() / 2; double x_ = x; if (x_ > w) { while (x_ > w) { @@ -124,12 +124,12 @@ LatLng TransformState::getLatLng(LatLng::WrapMode wrapMode) const { } double TransformState::pixel_x() const { - const double center = (width - scale * util::tileSize) / 2; + const double center = (width - worldSize()) / 2; return center + x; } double TransformState::pixel_y() const { - const double center = (height - scale * util::tileSize) / 2; + const double center = (height - worldSize()) / 2; return center + y; } @@ -297,7 +297,7 @@ LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, L mat4 TransformState::coordinatePointMatrix(double z) const { mat4 proj; getProjMatrix(proj); - float s = util::tileSize * scale / std::pow(2, z); + float s = worldSize() / std::pow(2, z); matrix::scale(proj, proj, s, s, 1); matrix::multiply(proj, getPixelMatrix(), proj); return proj; diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index 4c8c9f37b5..797a28692e 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -115,8 +115,8 @@ private: double pitch = 0.0; // cache values for spherical mercator math - double Bc = (scale * util::tileSize) / util::DEGREES_MAX; - double Cc = (scale * util::tileSize) / util::M2PI; + double Bc = worldSize() / util::DEGREES_MAX; + double Cc = worldSize() / util::M2PI; }; } // namespace mbgl |