summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-12 13:33:29 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-08-13 15:20:46 +0300
commitf660e1be2ddae94c795ac92ef4585dac45f5b2d5 (patch)
treefb88f63e45d2c228f2046808865cb0a5c0ca56e0
parentead71325489b16b8b256d3e9c826394c5dbc9bbb (diff)
downloadqtlocation-mapboxgl-f660e1be2ddae94c795ac92ef4585dac45f5b2d5.tar.gz
[core] Enable variable placement with allowed text overlap
-rw-r--r--src/mbgl/text/placement.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 320cc0fbfa..23d460889d 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -274,7 +274,11 @@ void Placement::placeBucket(
const float height = textBox.y2 - textBox.y1;
const float textBoxScale = symbolInstance.textBoxScale;
std::pair<bool, bool> placedFeature = {false, false};
- for (auto anchor : variableTextAnchors) {
+ const size_t anchorsSize = variableTextAnchors.size();
+ const size_t placementAttempts = textAllowOverlap ? anchorsSize * 2 : anchorsSize;
+ for (size_t i = 0u; i < placementAttempts; ++i) {
+ auto anchor = variableTextAnchors[i % anchorsSize];
+ const bool allowOverlap = (i >= anchorsSize);
Point<float> shift = calculateVariableLayoutOffset(anchor, width, height, symbolInstance.radialTextOffset, textBoxScale);
if (rotateWithMap) {
float angle = pitchWithMap ? state.getBearing() : -state.getBearing();
@@ -285,7 +289,7 @@ void Placement::placeBucket(
placedFeature = collisionIndex.placeFeature(collisionFeature, shift,
posMatrix, mat4(), pixelRatio,
placedSymbol, scale, fontSize,
- layout.get<style::TextAllowOverlap>(),
+ allowOverlap,
pitchWithMap,
params.showCollisionBoxes, avoidEdges, collisionGroup.second, textBoxes);
if (placedFeature.first) {