@@ -592,7 +592,8 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
592592 {collisionIndex, UnwrappedTileID (z, x + 1 , y), {-util::EXTENT, 0 .0f }} // right
593593 }};
594594
595- auto collisionBoxIntersectsTileEdges = [&](const CollisionBox& collisionBox, Point<float > shift) -> bool {
595+ auto collisionBoxIntersectsTileEdges = [&](const CollisionBox& collisionBox,
596+ Point<float > shift) noexcept ->bool {
596597 bool intersects =
597598 collisionIndex.intersectsTileEdges (collisionBox, shift, renderTile.matrix , pixelRatio, *tileBorders);
598599 // Check if this symbol intersects the neighbor tile borders. If so, it also shall be placed with priority.
@@ -604,7 +605,14 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
604605 return intersects;
605606 };
606607
607- auto symbolIntersectsTileEdges = [&](const SymbolInstance& symbol) -> bool {
608+ auto symbolIntersectsTileEdges = [
609+ &locationCache,
610+ &collisionBoxIntersectsTileEdges,
611+ variableAnchor,
612+ pitchTextWithMap,
613+ rotateTextWithMap,
614+ bearing = state.getBearing ()
615+ ](const SymbolInstance& symbol) noexcept ->bool {
608616 auto it = locationCache.find (symbol.crossTileID );
609617 if (it != locationCache.end ()) return it->second ;
610618
@@ -623,7 +631,7 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
623631 symbol.textBoxScale ,
624632 rotateTextWithMap,
625633 pitchTextWithMap,
626- state. getBearing () );
634+ bearing );
627635 }
628636 intersects = collisionBoxIntersectsTileEdges (textCollisionBox, offset);
629637 }
@@ -637,46 +645,47 @@ void Placement::placeSymbolBucket(const BucketPlacementData& params, std::set<ui
637645 return intersects;
638646 };
639647
640- std::stable_sort (symbolInstances.begin (),
641- symbolInstances.end (),
642- [&symbolIntersectsTileEdges](const SymbolInstance& a, const SymbolInstance& b) {
643- assert (!a.textCollisionFeature .alongLine );
644- assert (!b.textCollisionFeature .alongLine );
645- auto intersectsA = symbolIntersectsTileEdges (a);
646- auto intersectsB = symbolIntersectsTileEdges (b);
647- if (intersectsA) {
648- if (!intersectsB) return true ;
649- // Both symbols are inrecepting the tile borders, we need a universal cross-tile rule
650- // to define which of them shall be placed first - use anchor `y` point.
651- return a.anchor .point .y < b.anchor .point .y ;
652- }
653- return false ;
654- });
648+ std::stable_sort (
649+ symbolInstances.begin (),
650+ symbolInstances.end (),
651+ [&symbolIntersectsTileEdges](const SymbolInstance& a, const SymbolInstance& b) noexcept {
652+ assert (!a.textCollisionFeature .alongLine );
653+ assert (!b.textCollisionFeature .alongLine );
654+ auto intersectsA = symbolIntersectsTileEdges (a);
655+ auto intersectsB = symbolIntersectsTileEdges (b);
656+ if (intersectsA) {
657+ if (!intersectsB) return true ;
658+ // Both symbols are inrecepting the tile borders, we need a universal cross-tile rule
659+ // to define which of them shall be placed first - use anchor `y` point.
660+ return a.anchor .point .y < b.anchor .point .y ;
661+ }
662+ return false ;
663+ });
655664
656665 for (const SymbolInstance& symbol : symbolInstances) {
657666 placeSymbol (symbol);
658667 }
659-
660668 } else {
661- auto sortedSymbols = bucket.getSymbols (params.sortKeyRange );
669+ SymbolInstanceReferences sortedSymbols = bucket.getSymbols (params.sortKeyRange );
662670 auto * previousPlacement = getPrevPlacement ();
663671 if (previousPlacement && isTiltedView ()) {
664- std::stable_sort (sortedSymbols.begin (),
665- sortedSymbols.end (),
666- [&previousPlacement](const SymbolInstance& a, const SymbolInstance& b) {
667- auto * aPlacement = previousPlacement->getSymbolPlacement (a);
668- auto * bPlacement = previousPlacement->getSymbolPlacement (b);
669- if (!aPlacement) {
670- // a < b, if 'a' is new and if 'b' was previously hidden.
671- return bPlacement && !bPlacement->placed ();
672- }
673- if (!bPlacement) {
674- // a < b, if 'b' is new and 'a' was previously shown.
675- return aPlacement && aPlacement->placed ();
676- }
677- // a < b, if 'a' was shown and 'b' was hidden.
678- return aPlacement->placed () && !bPlacement->placed ();
679- });
672+ std::stable_sort (
673+ sortedSymbols.begin (),
674+ sortedSymbols.end (),
675+ [previousPlacement](const SymbolInstance& a, const SymbolInstance& b) noexcept {
676+ auto * aPlacement = previousPlacement->getSymbolPlacement (a);
677+ auto * bPlacement = previousPlacement->getSymbolPlacement (b);
678+ if (!aPlacement) {
679+ // a < b, if 'a' is new and if 'b' was previously hidden.
680+ return bPlacement && !bPlacement->placed ();
681+ }
682+ if (!bPlacement) {
683+ // a < b, if 'b' is new and 'a' was previously shown.
684+ return aPlacement && aPlacement->placed ();
685+ }
686+ // a < b, if 'a' was shown and 'b' was hidden.
687+ return aPlacement->placed () && !bPlacement->placed ();
688+ });
680689 }
681690 for (const SymbolInstance& symbol : sortedSymbols) {
682691 placeSymbol (symbol);
@@ -1226,8 +1235,7 @@ float Placement::zoomAdjustment(const float zoom) const {
12261235const JointPlacement* Placement::getSymbolPlacement (const SymbolInstance& symbol) const {
12271236 assert (symbol.crossTileID != 0 );
12281237 auto found = placements.find (symbol.crossTileID );
1229- if (found == placements.end ()) return nullptr ;
1230- return &found->second ;
1238+ return (found == placements.end ()) ? &found->second : nullptr ;
12311239}
12321240
12331241Duration Placement::getUpdatePeriod (const float zoom) const {
0 commit comments