[core] Clamp to scale boundaries in TransformState::setLatLngZoom
This commit is contained in:
@@ -358,7 +358,7 @@ void TransformState::setLatLngZoom(const LatLng& latLng, double zoom) {
|
||||
constrained = bounds->constrain(latLng);
|
||||
}
|
||||
|
||||
double newScale = zoomScale(zoom);
|
||||
double newScale = util::clamp(zoomScale(zoom), min_scale, max_scale);
|
||||
const double newWorldSize = newScale * util::tileSize;
|
||||
Bc = newWorldSize / util::DEGREES_MAX;
|
||||
Cc = newWorldSize / util::M2PI;
|
||||
|
||||
@@ -28,6 +28,22 @@ TEST(Transform, InvalidZoom) {
|
||||
ASSERT_DOUBLE_EQ(0, transform.getLatLng().latitude());
|
||||
ASSERT_DOUBLE_EQ(0, transform.getLatLng().longitude());
|
||||
ASSERT_DOUBLE_EQ(1, transform.getZoom());
|
||||
|
||||
transform.setZoom(transform.getState().getMaxZoom() + 0.1);
|
||||
ASSERT_DOUBLE_EQ(transform.getZoom(), transform.getState().getMaxZoom());
|
||||
|
||||
CameraOptions cameraOptions;
|
||||
cameraOptions.center = LatLng { util::LATITUDE_MAX, util::LONGITUDE_MAX };
|
||||
cameraOptions.zoom = transform.getState().getMaxZoom();
|
||||
|
||||
// Executing flyTo with maximum zoom level to the same zoom level causes
|
||||
// frameZoom to be bigger than maximum zoom.
|
||||
transform.resize(Size { 100, 100 });
|
||||
transform.flyTo(cameraOptions);
|
||||
transform.updateTransitions(transform.getTransitionStart() + transform.getTransitionDuration());
|
||||
|
||||
ASSERT_TRUE(transform.getState().valid());
|
||||
ASSERT_DOUBLE_EQ(transform.getState().getMaxZoom(), transform.getZoom());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user