summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-06-10 19:04:07 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-06-10 19:36:47 +0300
commit6583204e69938372fe13f99b2028f9a46dde818d (patch)
tree42a1193e9fe9e5987ec76e36b7899886056f3b6b
parent1edebf00356642cba87cf0574c1def309fa4602d (diff)
downloadqtlocation-mapboxgl-6583204e69938372fe13f99b2028f9a46dde818d.tar.gz
[core] TilePyramind uses TransformState::getScale()
-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);