Makes viewport immune to inf and nans

This commit is contained in:
Daniel J. Hofmann 2016-03-21 15:10:52 +01:00 committed by Patrick Niklaus
parent f8bd22dc6f
commit cecb0c547b

View File

@ -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<unsigned>(detail::MIN_ZOOM, zoom);
if (std::isfinite(zoom))
return std::max<unsigned>(detail::MIN_ZOOM, zoom);
else
return detail::MIN_ZOOM;
}
}