summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mbgl/map/transform_state.hpp3
-rw-r--r--src/mbgl/renderer/sources/render_tile_source.cpp1
-rw-r--r--src/mbgl/renderer/tile_pyramid.cpp2
3 files changed, 5 insertions, 1 deletions
diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp
index 9e501d600f..187d266c8a 100644
--- a/src/mbgl/map/transform_state.hpp
+++ b/src/mbgl/map/transform_state.hpp
@@ -54,6 +54,9 @@ public:
uint8_t getIntegerZoom() const;
double getZoomFraction() const;
+ // Scale
+ double getScale() const { return scale; }
+
// Bounds
void setLatLngBounds(LatLngBounds);
LatLngBounds getLatLngBounds() const;
diff --git a/src/mbgl/renderer/sources/render_tile_source.cpp b/src/mbgl/renderer/sources/render_tile_source.cpp
index 8d3d97f708..1037a2f78e 100644
--- a/src/mbgl/renderer/sources/render_tile_source.cpp
+++ b/src/mbgl/renderer/sources/render_tile_source.cpp
@@ -28,6 +28,7 @@ void RenderTileSource::upload(gfx::UploadPass& parameters) {
void RenderTileSource::prepare(const SourcePrepareParameters& parameters) {
renderTiles.clear();
+ renderTiles.reserve(tilePyramid.getRenderedTiles().size());
for (auto& entry : tilePyramid.getRenderedTiles()) {
renderTiles.emplace_back(entry.first, entry.second);
renderTiles.back().prepare(parameters);
diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp
index 81da42b526..dee84c4e32 100644
--- a/src/mbgl/renderer/tile_pyramid.cpp
+++ b/src/mbgl/renderer/tile_pyramid.cpp
@@ -314,7 +314,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered
const UnwrappedTileID& id = entry.first;
Tile& tile = entry.second;
- const float scale = std::pow(2, transformState.getZoom() - id.canonical.z);
+ const float scale = transformState.getScale() / (1 << id.canonical.z); // equivalent to std::pow(2, transformState.getZoom() - id.canonical.z);
auto queryPadding = maxPitchScaleFactor * tile.getQueryPadding(layers) * util::EXTENT / util::tileSize / scale;
GeometryCoordinate tileSpaceBoundsMin = TileCoordinate::toGeometryCoordinate(id, box.min);