Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core][tile mode] Support variable placement + icon-text-fit
Browse files Browse the repository at this point in the history
  • Loading branch information
pozdnyakov committed Apr 8, 2020
1 parent 7f53cec commit f2a2e6e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/mbgl/text/placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,7 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se
variableAnchor,
pitchTextWithMap = ctx.pitchTextWithMap,
rotateTextWithMap = ctx.rotateTextWithMap,
variableIconPlacement = ctx.hasIconTextFit && !ctx.iconAllowOverlap,
bearing = ctx.getTransformState().getBearing()
](const SymbolInstance& symbol) noexcept->IntersectStatus {
IntersectStatus result;
Expand All @@ -1430,7 +1431,20 @@ void TilePlacement::placeSymbolBucket(const BucketPlacementData& params, std::se

if (!symbol.iconCollisionFeature.boxes.empty()) {
const auto& iconCollisionBox = symbol.iconCollisionFeature.boxes.front();
auto iconIntersects = collisionBoxIntersectsTileEdges(iconCollisionBox, {});
Point<float> offset{};
if (variableAnchor && variableIconPlacement) {
float width = iconCollisionBox.x2 - iconCollisionBox.x1;
float height = iconCollisionBox.y2 - iconCollisionBox.y1;
offset = calculateVariableLayoutOffset(*variableAnchor,
width,
height,
symbol.variableTextOffset,
symbol.textBoxScale,
rotateTextWithMap,
pitchTextWithMap,
bearing);
}
auto iconIntersects = collisionBoxIntersectsTileEdges(iconCollisionBox, offset);
result.flags |= iconIntersects.flags;
result.minSectionLength = std::max(result.minSectionLength, iconIntersects.minSectionLength);
}
Expand Down

0 comments on commit f2a2e6e

Please sign in to comment.