summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-07-23 17:28:10 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-07-23 17:28:10 +0200
commit2be561ed4ace7440b9c135906f4685d824c8955a (patch)
tree0fb191c2f2d142eeb4e9db4f5b3e396ada94fe39
parent346e0510fa8b0fe7732ad7f49fe77cfc7e2e63c0 (diff)
downloadqtlocation-mapboxgl-2be561ed4ace7440b9c135906f4685d824c8955a.tar.gz
reduce maxPlacementScale
implements https://github.com/mapbox/mapbox-gl-js/commit/871883d569c932137d00b045eb47e14f4798ebc5
-rw-r--r--include/mbgl/text/placement.hpp2
-rw-r--r--src/map/tile_parser.cpp2
-rw-r--r--src/text/placement.cpp6
3 files changed, 6 insertions, 4 deletions
diff --git a/include/mbgl/text/placement.hpp b/include/mbgl/text/placement.hpp
index 69a1a10b72..aa03712e30 100644
--- a/include/mbgl/text/placement.hpp
+++ b/include/mbgl/text/placement.hpp
@@ -14,7 +14,7 @@ class StyleBucketText;
class Placement {
public:
- Placement(int8_t zoom);
+ Placement(int8_t zoom, float placementDepth);
void addFeature(TextBucket &bucket, const std::vector<Coordinate> &line,
const StyleBucketText &info,
diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp
index 23d819db0b..807e827972 100644
--- a/src/map/tile_parser.cpp
+++ b/src/map/tile_parser.cpp
@@ -42,7 +42,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile,
glyphAtlas(glyphAtlas),
glyphStore(glyphStore),
spriteAtlas(spriteAtlas),
- placement(tile.id.z) {
+ placement(tile.id.z, tile.id.z >= tile.source.max_zoom ? tile.source.max_zoom - tile.id.z : 1) {
}
void TileParser::parse() {
diff --git a/src/text/placement.cpp b/src/text/placement.cpp
index 40732765f3..b278a8bfb8 100644
--- a/src/text/placement.cpp
+++ b/src/text/placement.cpp
@@ -14,7 +14,7 @@ const int Placement::glyphSize =
24; // size in pixels of this glyphs in the tile
const float Placement::minScale = 0.5; // underscale by 1 zoom level
-Placement::Placement(int8_t zoom)
+Placement::Placement(int8_t zoom, float placementDepth)
: zoom(zoom),
zOffset(log(512.0 / util::tileSize) / log(2)),
@@ -27,7 +27,9 @@ Placement::Placement(int8_t zoom)
// glyphs be placed, slowing down collision checking. Only place labels if
// they will show up within the intended zoom range of the tile.
// TODO make this not hardcoded to 3
- maxPlacementScale(std::exp(log(2) * util::min((25.5 - zoom), 3.0))) {}
+ maxPlacementScale(std::exp(
+ log(2) *
+ util::min(3.0f, util::min(placementDepth > 0 ? placementDepth : 1.0f, 25.5f - zoom)))) {}
bool byScale(const Anchor &a, const Anchor &b) { return a.scale < b.scale; }