Render map with a copy of TransformState

This commit is contained in:
John Firebaugh
2014-10-21 15:00:44 -07:00
parent 4f7bc80664
commit da8aa391d0
12 changed files with 248 additions and 233 deletions

View File

@@ -3,6 +3,8 @@
using namespace mbgl;
const double R2D = 180.0 / M_PI;
#pragma mark - Matrix
void TransformState::matrixFor(mat4& matrix, const Tile::ID& id) const {
@@ -108,6 +110,15 @@ std::array<float, 2> TransformState::locationCoordinate(float lon, float lat) co
}};
}
void TransformState::getLonLat(double &lon, double &lat) const {
const double s = scale * util::tileSize;
const double Bc = s / 360;
const double Cc = s / (2 * M_PI);
lon = -x / Bc;
lat = R2D * (2 * std::atan(std::exp(y / Cc)) - 0.5 * M_PI);
}
#pragma mark - Zoom