diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-18 11:29:58 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-19 08:11:41 +0300 |
commit | f01a829dc9e076abeb7df90259e8e5c7d9cfbad6 (patch) | |
tree | d852d68a4629044c138ad4445c4d7e3c37079af0 /src/mbgl/map/transform_state.cpp | |
parent | 3a12dd2d4fec398bc84f88cfddc2ac4a37c3a7f1 (diff) | |
download | qtlocation-mapboxgl-f01a829dc9e076abeb7df90259e8e5c7d9cfbad6.tar.gz |
[core] Move TransformState::worldSize() to Projection
Diffstat (limited to 'src/mbgl/map/transform_state.cpp')
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index eb66513626..6256c7d0fe 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -17,7 +17,7 @@ TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewpo void TransformState::matrixFor(mat4& matrix, const UnwrappedTileID& tileID) const { const uint64_t tileScale = 1ull << tileID.canonical.z; - const double s = worldSize() / tileScale; + const double s = Projection::worldSize(scale) / tileScale; matrix::identity(matrix); matrix::translate(matrix, matrix, @@ -108,12 +108,12 @@ LatLng TransformState::getLatLng(LatLng::WrapMode wrapMode) const { } double TransformState::pixel_x() const { - const double center = (width - worldSize()) / 2; + const double center = (width - Projection::worldSize(scale)) / 2; return center + x; } double TransformState::pixel_y() const { - const double center = (height - worldSize()) / 2; + const double center = (height - Projection::worldSize(scale)) / 2; return center + y; } @@ -205,7 +205,7 @@ Point<double> TransformState::project(const LatLng& ll) const { return Point<double>( (util::LONGITUDE_MAX + ll.longitude), (util::LONGITUDE_MAX - util::RAD2DEG * std::log(std::tan(M_PI / 4 + ll.latitude * M_PI / util::DEGREES_MAX))) - ) * worldSize() / util::DEGREES_MAX; + ) * Projection::worldSize(scale) / util::DEGREES_MAX; } LatLng TransformState::unproject(const Point<double>& p, double worldSize, LatLng::WrapMode wrapMode) const { @@ -225,10 +225,6 @@ double TransformState::scaleZoom(double s) const { return util::log2(s); } -double TransformState::worldSize() const { - return scale * util::tileSize; -} - ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) const { if (width == 0 || height == 0) { return {}; @@ -284,7 +280,7 @@ LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, L mat4 TransformState::coordinatePointMatrix(double z) const { mat4 proj; getProjMatrix(proj); - float s = worldSize() / std::pow(2, z); + float s = Projection::worldSize(scale) / std::pow(2, z); matrix::scale(proj, proj, s, s, 1); matrix::multiply(proj, getPixelMatrix(), proj); return proj; @@ -328,7 +324,7 @@ void TransformState::moveLatLng(const LatLng& latLng, const ScreenCoordinate& an auto centerCoord = project(getLatLng(LatLng::Unwrapped)); auto latLngCoord = project(latLng); auto anchorCoord = project(screenCoordinateToLatLng(anchor)); - setLatLngZoom(unproject(centerCoord + latLngCoord - anchorCoord, worldSize()), getZoom()); + setLatLngZoom(unproject(centerCoord + latLngCoord - anchorCoord, Projection::worldSize(scale)), getZoom()); } void TransformState::setLatLngZoom(const LatLng &latLng, double zoom) { @@ -355,8 +351,8 @@ void TransformState::setScalePoint(const double newScale, const ScreenCoordinate scale = constrainedScale; x = constrainedPoint.x; y = constrainedPoint.y; - Bc = worldSize() / util::DEGREES_MAX; - Cc = worldSize() / util::M2PI; + Bc = Projection::worldSize(scale) / util::DEGREES_MAX; + Cc = Projection::worldSize(scale) / util::M2PI; } } // namespace mbgl |