From 01a0f5464d8c4b376a30144499dcc44d4006b9f4 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 31 Mar 2016 16:22:41 +0300 Subject: [PATCH] [glfw] Fix random point generation --- platform/default/glfw_view.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index e65693c4c..6bd5f4e19 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -211,13 +211,9 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, } mbgl::LatLng GLFWView::makeRandomPoint() const { - const auto nw = map->latLngForPixel({ 0, 0 }); - const auto se = map->latLngForPixel({ double(width), double(height) }); - - const double lon = nw.longitude + (se.longitude - nw.longitude) * (double(std::rand()) / RAND_MAX); - const double lat = se.latitude + (nw.latitude - se.latitude) * (double(std::rand()) / RAND_MAX); - - return { lat, lon }; + const double x = width * double(std::rand()) / RAND_MAX; + const double y = height * double(std::rand()) / RAND_MAX; + return map->latLngForPixel({ x, y }); } std::shared_ptr