[core] Tighten geo.hpp ctors

This commit is contained in:
Bruno de Oliveira Abinader
2017-04-11 17:07:25 +03:00
committed by John Firebaugh
parent 8877452ec3
commit 2f4d162deb
12 changed files with 171 additions and 75 deletions

View File

@@ -600,8 +600,8 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed
if (width > 0 || height > 0) {
double scaleX = double(getSize().width) / width;
double scaleY = double(getSize().height) / height;
scaleX -= (padding.left + padding.right) / width;
scaleY -= (padding.top + padding.bottom) / height;
scaleX -= (padding.left() + padding.right()) / width;
scaleY -= (padding.top() + padding.bottom()) / height;
minScale = util::min(scaleX, scaleY);
}
double zoom = getZoom() + util::log2(minScale);
@@ -610,12 +610,12 @@ CameraOptions Map::cameraForLatLngs(const std::vector<LatLng>& latLngs, const Ed
// Calculate the center point of a virtual bounds that is extended in all directions by padding.
ScreenCoordinate centerPixel = nePixel + swPixel;
ScreenCoordinate paddedNEPixel = {
padding.right / minScale,
padding.top / minScale,
padding.right() / minScale,
padding.top() / minScale,
};
ScreenCoordinate paddedSWPixel = {
padding.left / minScale,
padding.bottom / minScale,
padding.left() / minScale,
padding.bottom() / minScale,
};
centerPixel = centerPixel + paddedNEPixel - paddedSWPixel;
centerPixel /= 2.0;

View File

@@ -200,8 +200,8 @@ void Transform::flyTo(const CameraOptions &camera, const AnimationOptions &anima
/// w₀: Initial visible span, measured in pixels at the initial scale.
/// Known henceforth as a <i>screenful</i>.
double w0 = std::max(state.size.width - padding.left - padding.right,
state.size.height - padding.top - padding.bottom);
double w0 = std::max(state.size.width - padding.left() - padding.right(),
state.size.height - padding.top() - padding.bottom());
/// w₁: Final visible span, measured in pixels with respect to the initial
/// scale.
double w1 = w0 / state.zoomScale(zoom - startZoom);

View File

@@ -34,8 +34,8 @@ LatLngBounds::LatLngBounds(const CanonicalTileID& id)
ScreenCoordinate EdgeInsets::getCenter(uint16_t width, uint16_t height) const {
return {
(width - left - right) / 2.0f + left,
(height - top - bottom) / 2.0f + top,
(width - left() - right()) / 2.0 + left(),
(height - top() - bottom()) / 2.0 + top(),
};
}