[core] fix circle querying for scale and alignment

This fixes circle querying for cases where either
    circle-pitch-alignment=map
or
    circle-pitch-scaling=viewport
This commit is contained in:
Chris Loer
2018-04-02 17:41:55 -07:00
committed by Ansis Brammanis
parent f7d20a5871
commit f86fe44dbd
39 changed files with 186 additions and 68 deletions

View File

@@ -421,4 +421,17 @@ float TransformState::getCameraToTileDistance(const UnwrappedTileID& tileID) con
return projectedCenter[3];
}
float TransformState::maxPitchScaleFactor() const {
if (size.isEmpty()) {
return {};
}
auto latLng = screenCoordinateToLatLng({ 0, static_cast<float>(getSize().height) });
mat4 mat = coordinatePointMatrix(getZoom());
Point<double> pt = Projection::project(latLng, scale) / double(util::tileSize);
vec4 p = {{ pt.x, pt.y, 0, 1 }};
vec4 topPoint;
matrix::transformMat4(topPoint, p, mat);
return topPoint[3] / getCameraToCenterDistance();
}
} // namespace mbgl