diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-31 16:22:41 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-04-01 10:21:59 +0300 |
commit | 01a0f5464d8c4b376a30144499dcc44d4006b9f4 (patch) | |
tree | 29afab2578df18971f0da6d7ba37eb4396700061 /platform/default | |
parent | 77b07234762474b45ec902b556bb96e3a1057867 (diff) | |
download | qtlocation-mapboxgl-01a0f5464d8c4b376a30144499dcc44d4006b9f4.tar.gz |
[glfw] Fix random point generation
Diffstat (limited to 'platform/default')
-rw-r--r-- | platform/default/glfw_view.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index e65693c4c0..6bd5f4e196 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<const mbgl::SpriteImage> |