From 051e1c32ae4f553085adfc7b66e005ef70f62349 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 4 Nov 2014 10:53:35 -0800 Subject: [PATCH] Support compound text-anchor values --- include/mbgl/style/types.hpp | 10 +++++++++- src/renderer/symbol_bucket.cpp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/mbgl/style/types.hpp b/include/mbgl/style/types.hpp index 36cb39181..2f7ca7683 100644 --- a/include/mbgl/style/types.hpp +++ b/include/mbgl/style/types.hpp @@ -157,7 +157,11 @@ enum class TextAnchorType : uint8_t { Left, Right, Top, - Bottom + Bottom, + TopLeft, + TopRight, + BottomLeft, + BottomRight }; MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, { @@ -166,6 +170,10 @@ MBGL_DEFINE_ENUM_CLASS(TextAnchorTypeClass, TextAnchorType, { { TextAnchorType::Right, "right" }, { TextAnchorType::Top, "top" }, { TextAnchorType::Bottom, "bottom" }, + { TextAnchorType::TopLeft, "top-left" }, + { TextAnchorType::TopRight, "top-right" }, + { TextAnchorType::BottomLeft, "bottom-left" }, + { TextAnchorType::BottomRight, "bottom-right" } }); // ------------------------------------------------------------------------------------------------- diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index e80f1505b..a00544962 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -106,18 +106,35 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress float verticalAlign = 0.5; switch (properties.text.anchor) { + case TextAnchorType::Top: + case TextAnchorType::Bottom: case TextAnchorType::Center: break; case TextAnchorType::Right: + case TextAnchorType::TopRight: + case TextAnchorType::BottomRight: horizontalAlign = 1; break; case TextAnchorType::Left: + case TextAnchorType::TopLeft: + case TextAnchorType::BottomLeft: horizontalAlign = 0; break; + } + + switch (properties.text.anchor) { + case TextAnchorType::Left: + case TextAnchorType::Right: + case TextAnchorType::Center: + break; case TextAnchorType::Bottom: + case TextAnchorType::BottomLeft: + case TextAnchorType::BottomRight: verticalAlign = 1; break; case TextAnchorType::Top: + case TextAnchorType::TopLeft: + case TextAnchorType::TopRight: verticalAlign = 0; break; }