summaryrefslogtreecommitdiff
path: root/src/mbgl/text/placement.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/text/placement.cpp')
-rw-r--r--src/mbgl/text/placement.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 8740e4b021..b87e921a91 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -356,8 +356,9 @@ void Placement::placeBucket(const SymbolBucket& bucket,
textBoxes.clear();
if (mapMode == MapMode::Tile && !isFirstAnchor &&
- collisionIndex.featureIntersectsTileBorders(
- textCollisionFeature, shift, posMatrix, pixelRatio, *tileBorders)) {
+ (FeatureLocation::IntersectsTileBorder ==
+ collisionIndex.getFeatureLocation(
+ textCollisionFeature, shift, posMatrix, pixelRatio, *tileBorders))) {
continue;
}
@@ -561,17 +562,16 @@ void Placement::placeBucket(const SymbolBucket& bucket,
} else if (mapMode == MapMode::Tile && !avoidEdges) {
// In this case we first try to place symbols, which intersects the tile borders, so that
// those symbols will remain even if each tile is handled independently.
- const auto& symbolInstances = bucket.symbolInstances;
+ const auto& symbolInstances = bucket.getSortedSymbols(state.getBearing());
std::vector<std::reference_wrapper<const SymbolInstance>> sorted(symbolInstances.begin(),
symbolInstances.end());
optional<style::TextVariableAnchorType> variableAnchor;
if (!variableTextAnchors.empty()) variableAnchor = variableTextAnchors.front();
- std::unordered_map<uint32_t, bool> sortedCache;
- sortedCache.reserve(sorted.size());
- auto intersectsTileBorder = [&](const SymbolInstance& symbol) -> bool {
- if (symbol.textCollisionFeature.alongLine || symbol.textCollisionFeature.boxes.empty()) return false;
+ std::unordered_map<uint32_t, FeatureLocation> sortedCache;
+ sortedCache.reserve(sorted.size());
+ auto getFeatureLocation = [&](const SymbolInstance& symbol) -> FeatureLocation {
auto it = sortedCache.find(symbol.crossTileID);
if (it != sortedCache.end()) return it->second;
@@ -589,15 +589,21 @@ void Placement::placeBucket(const SymbolBucket& bucket,
pitchTextWithMap,
state.getBearing());
}
- bool result = collisionIndex.featureIntersectsTileBorders(
+ FeatureLocation result = collisionIndex.getFeatureLocation(
symbol.textCollisionFeature, offset, posMatrix, pixelRatio, *tileBorders);
sortedCache.insert(std::make_pair(symbol.crossTileID, result));
return result;
};
std::stable_sort(
- sorted.begin(), sorted.end(), [&intersectsTileBorder](const SymbolInstance& a, const SymbolInstance& b) {
- return intersectsTileBorder(a) && !intersectsTileBorder(b);
+ sorted.begin(), sorted.end(), [&getFeatureLocation](const SymbolInstance& a, const SymbolInstance& b) {
+ if (a.textCollisionFeature.alongLine || a.textCollisionFeature.boxes.empty()) return false;
+ if (b.textCollisionFeature.alongLine || b.textCollisionFeature.boxes.empty()) return false;
+
+ auto locationA = getFeatureLocation(a);
+ auto locationB = getFeatureLocation(b);
+ return (locationA == FeatureLocation::IntersectsTileBorder) &&
+ (locationB == FeatureLocation::InsideTile);
});
for (const SymbolInstance& symbol : sorted) {