diff --git a/include/mbgl/text/placement.hpp b/include/mbgl/text/placement.hpp index 69a1a10b7..aa03712e3 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 &line, const StyleBucketText &info, diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 23d819db0..807e82797 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 40732765f..b278a8bfb 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; }