summaryrefslogtreecommitdiff
path: root/src/mbgl/text/collision_feature.hpp
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-04-11 20:31:18 +0300
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-04-14 12:33:13 -0700
commit98e2e59e5e963dbc5451a19233d942b429a74855 (patch)
tree2eb68e34823d07a7402e0c633e4c3e9510b76b4c /src/mbgl/text/collision_feature.hpp
parent2f4d162debd7e4accfc0b20360058304dce40801 (diff)
downloadqtlocation-mapboxgl-98e2e59e5e963dbc5451a19233d942b429a74855.tar.gz
[core] Safeguard PositionedIcon usage via optional
Diffstat (limited to 'src/mbgl/text/collision_feature.hpp')
-rw-r--r--src/mbgl/text/collision_feature.hpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/mbgl/text/collision_feature.hpp b/src/mbgl/text/collision_feature.hpp
index 1436e0815b..006a47eb74 100644
--- a/src/mbgl/text/collision_feature.hpp
+++ b/src/mbgl/text/collision_feature.hpp
@@ -33,6 +33,11 @@ public:
class CollisionFeature {
public:
+ enum class AlignmentType : bool {
+ Straight = 0,
+ Curved
+ };
+
// for text
CollisionFeature(const GeometryCoordinates& line,
const Anchor& anchor,
@@ -41,29 +46,34 @@ public:
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) {}
+ : CollisionFeature(line, anchor, shapedText.top, shapedText.bottom, shapedText.left, shapedText.right, boxScale, padding, placement, indexedFeature_, AlignmentType::Curved) {}
// for icons
CollisionFeature(const GeometryCoordinates& line,
const Anchor& anchor,
- const PositionedIcon& shapedIcon,
+ optional<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(line, anchor,
+ (shapedIcon ? shapedIcon->top() : 0),
+ (shapedIcon ? shapedIcon->bottom() : 0),
+ (shapedIcon ? shapedIcon->left() : 0),
+ (shapedIcon ? shapedIcon->right() : 0),
+ boxScale, padding, placement, indexedFeature_, AlignmentType::Straight) {}
CollisionFeature(const GeometryCoordinates& line,
- const Anchor& anchor,
+ const Anchor&,
const float top,
const float bottom,
const float left,
const float right,
const float boxScale,
const float padding,
- const style::SymbolPlacementType placement,
+ const style::SymbolPlacementType,
IndexedSubfeature,
- const bool straight);
+ const AlignmentType);
std::vector<CollisionBox> boxes;
IndexedSubfeature indexedFeature;