From f751d2c46528ac4301ef3753c468950051937940 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 19 May 2016 19:03:41 +0300 Subject: [core] Avoid NaNs in TransformState unit conversions Fix cases where e.g. state has either zero width or height, causing the unit convertion functions would return NaNs. --- src/mbgl/map/transform_state.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/mbgl/map/transform_state.cpp') diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index ad41c9eea2..ac8b6396c7 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -230,6 +230,10 @@ double TransformState::worldSize() const { } ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) const { + if (width == 0 || height == 0) { + return {}; + } + mat4 mat = coordinatePointMatrix(getZoom()); vec4 p; Point pt = project(latLng) / double(util::tileSize); @@ -239,6 +243,10 @@ ScreenCoordinate TransformState::latLngToScreenCoordinate(const LatLng& latLng) } LatLng TransformState::screenCoordinateToLatLng(const ScreenCoordinate& point, LatLng::WrapMode wrapMode) const { + if (width == 0 || height == 0) { + return {}; + } + float targetZ = 0; mat4 mat = coordinatePointMatrix(getZoom()); -- cgit v1.2.1