summaryrefslogtreecommitdiff
path: root/src/mbgl/text/collision_feature.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/text/collision_feature.hpp')
-rw-r--r--src/mbgl/text/collision_feature.hpp98
1 files changed, 55 insertions, 43 deletions
diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp
index 12c14fe0c1..1436e0815b 100644
--- a/src/mbgl/text/collision_feature.hpp
+++ b/src/mbgl/text/collision_feature.hpp
@@ -8,57 +8,69 @@
#include <vector>
namespace mbgl {
- class CollisionBox {
- public:
- explicit CollisionBox(Point<float> _anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale) :
- anchor(std::move(_anchor)), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale) {}
- // the box is centered around the anchor point
- Point<float> anchor;
+class CollisionBox {
+public:
+ CollisionBox(Point<float> _anchor, float _x1, float _y1, float _x2, float _y2, float _maxScale) :
+ anchor(std::move(_anchor)), x1(_x1), y1(_y1), x2(_x2), y2(_y2), maxScale(_maxScale) {}
- // distances to the edges from the anchor
- float x1;
- float y1;
- float x2;
- float y2;
+ // the box is centered around the anchor point
+ Point<float> anchor;
- // the box is only valid for scales < maxScale.
- // The box does not block other boxes at scales >= maxScale;
- float maxScale;
+ // distances to the edges from the anchor
+ float x1;
+ float y1;
+ float x2;
+ float y2;
- // the scale at which the label can first be shown
- float placementScale = 0.0f;
- };
+ // the box is only valid for scales < maxScale.
+ // The box does not block other boxes at scales >= maxScale;
+ float maxScale;
- class CollisionFeature {
- public:
- // for text
- explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor,
- const Shaping &shapedText,
- const float boxScale, const float padding, const style::SymbolPlacementType placement, const IndexedSubfeature& indexedFeature_)
- : CollisionFeature(line, anchor,
- shapedText.top, shapedText.bottom, shapedText.left, shapedText.right,
- boxScale, padding, placement, indexedFeature_, false) {}
+ // the scale at which the label can first be shown
+ float placementScale = 0.0f;
+};
- // for icons
- explicit CollisionFeature(const GeometryCoordinates &line, const Anchor &anchor,
- const PositionedIcon &shapedIcon,
- const float boxScale, const float padding, const style::SymbolPlacementType placement, const IndexedSubfeature& indexedFeature_)
- : CollisionFeature(line, anchor,
- shapedIcon.top, shapedIcon.bottom, shapedIcon.left, shapedIcon.right,
- boxScale, padding, placement, indexedFeature_, true) {}
+class CollisionFeature {
+public:
+ // for text
+ CollisionFeature(const GeometryCoordinates& line,
+ const Anchor& anchor,
+ const Shaping& shapedText,
+ const float boxScale,
+ const float padding,
+ const style::SymbolPlacementType placement,
+ const IndexedSubfeature& indexedFeature_)
+ : CollisionFeature(line, anchor, shapedText.top, shapedText.bottom, shapedText.left, shapedText.right, boxScale, padding, placement, indexedFeature_, false) {}
- explicit 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 style::SymbolPlacementType placement,
- IndexedSubfeature, const bool straight);
+ // for icons
+ CollisionFeature(const GeometryCoordinates& line,
+ const Anchor& anchor,
+ const PositionedIcon& shapedIcon,
+ const float boxScale,
+ const float padding,
+ const style::SymbolPlacementType placement,
+ const IndexedSubfeature& indexedFeature_)
+ : CollisionFeature(line, anchor, shapedIcon.top, shapedIcon.bottom, shapedIcon.left, shapedIcon.right, boxScale, padding, placement, indexedFeature_, true) {}
+ 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 style::SymbolPlacementType placement,
+ IndexedSubfeature,
+ const bool straight);
- std::vector<CollisionBox> boxes;
- IndexedSubfeature indexedFeature;
+ std::vector<CollisionBox> boxes;
+ IndexedSubfeature indexedFeature;
+
+private:
+ void bboxifyLabel(const GeometryCoordinates& line, GeometryCoordinate& anchorPoint,
+ const int segment, const float length, const float height);
+};
- private:
- void bboxifyLabel(const GeometryCoordinates &line, GeometryCoordinate &anchorPoint,
- const int segment, const float length, const float height);
- };
} // namespace mbgl