diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/geometry/feature_index.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/text/collision_feature.cpp | 16 | ||||
-rw-r--r-- | src/mbgl/text/collision_feature.hpp | 19 | ||||
-rw-r--r-- | src/mbgl/text/collision_tile.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/text/collision_tile.hpp | 2 |
5 files changed, 20 insertions, 23 deletions
diff --git a/src/mbgl/geometry/feature_index.hpp b/src/mbgl/geometry/feature_index.hpp index 5d78df2138..a3cb16ee76 100644 --- a/src/mbgl/geometry/feature_index.hpp +++ b/src/mbgl/geometry/feature_index.hpp @@ -17,6 +17,7 @@ enum class TranslateAnchorType : bool; class IndexedSubfeature { public: + IndexedSubfeature() = delete; std::size_t index; std::string sourceLayerName; std::string bucketName; diff --git a/src/mbgl/text/collision_feature.cpp b/src/mbgl/text/collision_feature.cpp index 8f0f099670..57a9da0440 100644 --- a/src/mbgl/text/collision_feature.cpp +++ b/src/mbgl/text/collision_feature.cpp @@ -5,8 +5,9 @@ namespace mbgl { CollisionFeature::CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const float top, const float bottom, const float left, const float right, - const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature, - const bool straight) { + const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_, + const bool straight) + : indexedFeature(indexedFeature_) { if (top == 0 && bottom == 0 && left == 0 && right == 0) return; @@ -29,19 +30,18 @@ CollisionFeature::CollisionFeature(const GeometryCoordinates &line, const Anchor // used for icon labels that are aligned with the line, but don't curve along it const GeometryCoordinate vector = convertPoint<int16_t>(util::unit(convertPoint<double>(line[anchor.segment + 1] - line[anchor.segment])) * length); const GeometryCoordinates newLine({ anchorPoint - vector, anchorPoint + vector }); - bboxifyLabel(newLine, anchorPoint, 0, length, height, indexedFeature); + bboxifyLabel(newLine, anchorPoint, 0, length, height); } else { // used for text labels that curve along a line - bboxifyLabel(line, anchorPoint, anchor.segment, length, height, indexedFeature); + bboxifyLabel(line, anchorPoint, anchor.segment, length, height); } } else { - boxes.emplace_back(anchor.point, x1, y1, x2, y2, std::numeric_limits<float>::infinity(), indexedFeature); + boxes.emplace_back(anchor.point, x1, y1, x2, y2, std::numeric_limits<float>::infinity()); } } void CollisionFeature::bboxifyLabel(const GeometryCoordinates &line, - GeometryCoordinate &anchorPoint, const int segment, const float labelLength, const float boxSize, - const IndexedSubfeature& indexedFeature) { + GeometryCoordinate &anchorPoint, const int segment, const float labelLength, const float boxSize) { const float step = boxSize / 2; const unsigned int nBoxes = std::floor(labelLength / step); @@ -97,7 +97,7 @@ void CollisionFeature::bboxifyLabel(const GeometryCoordinates &line, const float distanceToInnerEdge = std::max(std::fabs(boxDistanceToAnchor - firstBoxOffset) - step / 2, 0.0f); const float maxScale = labelLength / 2 / distanceToInnerEdge; - boxes.emplace_back(boxAnchor, -boxSize / 2, -boxSize / 2, boxSize / 2, boxSize / 2, maxScale, indexedFeature); + boxes.emplace_back(boxAnchor, -boxSize / 2, -boxSize / 2, boxSize / 2, boxSize / 2, maxScale); } } diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp index 0fe248a3de..840b37b943 100644 --- a/src/mbgl/text/collision_feature.hpp +++ b/src/mbgl/text/collision_feature.hpp @@ -11,9 +11,8 @@ namespace mbgl { class CollisionBox { public: - explicit CollisionBox(const Point<float> &_anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale, - const IndexedSubfeature& indexedFeature_ = { 0, "", "", 0 }) : - anchor(_anchor), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale), indexedFeature(indexedFeature_) {} + explicit CollisionBox(const Point<float> &_anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale) : + anchor(_anchor), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale) {} // the box is centered around the anchor point Point<float> anchor; @@ -30,8 +29,6 @@ namespace mbgl { // the scale at which the label can first be shown float placementScale = 0.0f; - - IndexedSubfeature indexedFeature; }; class CollisionFeature { @@ -39,18 +36,18 @@ namespace mbgl { // for text inline explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const Shaping &shapedText, - const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature) + const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_) : CollisionFeature(line, anchor, shapedText.top, shapedText.bottom, shapedText.left, shapedText.right, - boxScale, padding, alongLine, indexedFeature, false) {} + boxScale, padding, alongLine, indexedFeature_, false) {} // for icons inline explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const PositionedIcon &shapedIcon, - const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature) + const float boxScale, const float padding, const bool alongLine, const IndexedSubfeature& indexedFeature_) : CollisionFeature(line, anchor, shapedIcon.top, shapedIcon.bottom, shapedIcon.left, shapedIcon.right, - boxScale, padding, alongLine, indexedFeature, true) {} + boxScale, padding, alongLine, indexedFeature_, true) {} explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor, const float top, const float bottom, const float left, const float right, @@ -59,11 +56,11 @@ namespace mbgl { std::vector<CollisionBox> boxes; + IndexedSubfeature indexedFeature; private: void bboxifyLabel(const GeometryCoordinates &line, GeometryCoordinate &anchorPoint, - const int segment, const float length, const float height, - const IndexedSubfeature&); + const int segment, const float length, const float height); }; } // namespace mbgl diff --git a/src/mbgl/text/collision_tile.cpp b/src/mbgl/text/collision_tile.cpp index fe62d978fa..e0bc35c1fb 100644 --- a/src/mbgl/text/collision_tile.cpp +++ b/src/mbgl/text/collision_tile.cpp @@ -129,7 +129,7 @@ void CollisionTile::insertFeature(CollisionFeature& feature, const float minPlac if (minPlacementScale < maxScale) { std::vector<CollisionTreeBox> treeBoxes; for (auto& box : feature.boxes) { - treeBoxes.emplace_back(getTreeBox(util::matrixMultiply(rotationMatrix, box.anchor), box), box); + treeBoxes.emplace_back(getTreeBox(util::matrixMultiply(rotationMatrix, box.anchor), box), box, feature.indexedFeature); } if (ignorePlacement) { ignoredTree.insert(treeBoxes.begin(), treeBoxes.end()); @@ -168,8 +168,7 @@ std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const float m for (auto& blockingTreeBox : blockingBoxes) { const auto& blocking = std::get<1>(blockingTreeBox); - - auto& indexedFeature = blocking.indexedFeature; + const auto& indexedFeature = std::get<2>(blockingTreeBox); auto& seenFeatures = sourceLayerFeatures[indexedFeature.sourceLayerName]; if (seenFeatures.find(indexedFeature.index) == seenFeatures.end()) { diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp index fe25a6ee5d..61d5af3134 100644 --- a/src/mbgl/text/collision_tile.hpp +++ b/src/mbgl/text/collision_tile.hpp @@ -30,7 +30,7 @@ namespace bgm = bg::model; namespace bgi = bg::index; typedef bgm::point<float, 2, bg::cs::cartesian> CollisionPoint; typedef bgm::box<CollisionPoint> Box; -typedef std::pair<Box, CollisionBox> CollisionTreeBox; +typedef std::tuple<Box, CollisionBox, IndexedSubfeature> CollisionTreeBox; typedef bgi::rtree<CollisionTreeBox, bgi::linear<16, 4>> Tree; class IndexedSubfeature; |