From d66251234d7c0feb875b9490ca945ee9d43306c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 29 May 2018 14:07:32 +0200 Subject: [core] don't use floating point versions of pow/log GLIBC 2.27 added new versioned symbols of powf and logf, while the double versions of pow and log remained stable. Prefer the double version to avoid introducing a dependency on a newer version of GLIBC than strictly necessary. See https://lists.gnu.org/archive/html/info-gnu/2018-02/msg00000.html --- src/mbgl/util/interpolate.cpp | 3 ++- src/mbgl/util/tile_coordinate.hpp | 2 +- src/mbgl/util/tile_cover.cpp | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/mbgl/util') diff --git a/src/mbgl/util/interpolate.cpp b/src/mbgl/util/interpolate.cpp index 066fa9c462..6b5736f15f 100644 --- a/src/mbgl/util/interpolate.cpp +++ b/src/mbgl/util/interpolate.cpp @@ -13,7 +13,8 @@ float interpolationFactor(float base, Range range, float z) { } else if (base == 1.0f) { return zoomProgress / zoomDiff; } else { - return (std::pow(base, zoomProgress) - 1) / (std::pow(base, zoomDiff) - 1); + return (std::pow(static_cast(base), zoomProgress) - 1) / + (std::pow(static_cast(base), zoomDiff) - 1); } } diff --git a/src/mbgl/util/tile_coordinate.hpp b/src/mbgl/util/tile_coordinate.hpp index bcd1c8444f..b6bdc5f590 100644 --- a/src/mbgl/util/tile_coordinate.hpp +++ b/src/mbgl/util/tile_coordinate.hpp @@ -20,7 +20,7 @@ public: static TileCoordinate fromLatLng(double zoom, const LatLng& latLng) { const double scale = std::pow(2.0, zoom); - return { Projection::project(latLng, scale) / double(util::tileSize), zoom }; + return { Projection::project(latLng, scale) / util::tileSize, zoom }; } static TileCoordinate fromScreenCoordinate(const TransformState& state, double zoom, const ScreenCoordinate& screenCoordinate) { diff --git a/src/mbgl/util/tile_cover.cpp b/src/mbgl/util/tile_cover.cpp index 488e6b88ce..3f39e53d40 100644 --- a/src/mbgl/util/tile_cover.cpp +++ b/src/mbgl/util/tile_cover.cpp @@ -130,7 +130,7 @@ std::vector tileCover(const Point& tl, } // namespace int32_t coveringZoomLevel(double zoom, style::SourceType type, uint16_t size) { - zoom += std::log(util::tileSize / size) / std::log(2); + zoom += ::log2(util::tileSize / size); if (type == style::SourceType::Raster || type == style::SourceType::Video) { return ::round(zoom); } else { -- cgit v1.2.1