From 8e477437a6ba76e2a66ed7c167bb5947146d380a Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Mon, 21 Mar 2016 15:10:52 +0100 Subject: [PATCH] Makes viewport immune to inf and nans --- include/util/viewport.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/util/viewport.hpp b/include/util/viewport.hpp index d16ba1462..fd0ac73f6 100644 --- a/include/util/viewport.hpp +++ b/include/util/viewport.hpp @@ -38,7 +38,10 @@ unsigned getFittedZoom(util::Coordinate south_west, util::Coordinate north_east) const double height_ratio = (max_y - min_y) / detail::VIEWPORT_HEIGHT; const auto zoom = detail::MAX_ZOOM - std::max(std::log(width_ratio), std::log(height_ratio)) * detail::INV_LOG_2; - return std::max(detail::MIN_ZOOM, zoom); + if (std::isfinite(zoom)) + return std::max(detail::MIN_ZOOM, zoom); + else + return detail::MIN_ZOOM; } }