diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-03 15:07:33 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2014-11-04 12:26:27 -0800 |
commit | 0790b574b43322a0ea85e6ec6488b16dc74e11ce (patch) | |
tree | d1aae5f458f0f559f957048935d775de94debcb1 /src | |
parent | 9a3b740fcc76d9f245ec330093b2e1231656697f (diff) | |
download | qtlocation-mapboxgl-0790b574b43322a0ea85e6ec6488b16dc74e11ce.tar.gz |
Single text positioning property
https://github.com/mapbox/mapbox-gl-style-spec/issues/197
Diffstat (limited to 'src')
-rw-r--r-- | src/renderer/symbol_bucket.cpp | 26 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 3 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/renderer/symbol_bucket.cpp b/src/renderer/symbol_bucket.cpp index 37ff4a0a6b..e80f1505bf 100644 --- a/src/renderer/symbol_bucket.cpp +++ b/src/renderer/symbol_bucket.cpp @@ -103,16 +103,24 @@ void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpress const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore, sprite); float horizontalAlign = 0.5; - if (properties.text.horizontal_align == TextHorizontalAlignType::Right) - horizontalAlign = 1; - else if (properties.text.horizontal_align == TextHorizontalAlignType::Left) - horizontalAlign = 0; - float verticalAlign = 0.5; - if (properties.text.vertical_align == TextVerticalAlignType::Bottom) - verticalAlign = 1; - else if (properties.text.vertical_align == TextVerticalAlignType::Top) - verticalAlign = 0; + + switch (properties.text.anchor) { + case TextAnchorType::Center: + break; + case TextAnchorType::Right: + horizontalAlign = 1; + break; + case TextAnchorType::Left: + horizontalAlign = 0; + break; + case TextAnchorType::Bottom: + verticalAlign = 1; + break; + case TextAnchorType::Top: + verticalAlign = 0; + break; + } float justify = 0.5; if (properties.text.justify == TextJustifyType::Right) justify = 1; diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index b32c36f17a..fa51e48cee 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -801,8 +801,7 @@ void StyleParser::parseLayout(JSVal value, util::ptr<StyleLayer> &layer) { render.text.letter_spacing *= 24; // em } parseRenderProperty<TextJustifyTypeClass>(value, render.text.justify, "text-justify"); - parseRenderProperty<TextHorizontalAlignTypeClass>(value, render.text.horizontal_align, "text-horizontal-align"); - parseRenderProperty<TextVerticalAlignTypeClass>(value, render.text.vertical_align, "text-vertical-align"); + parseRenderProperty<TextAnchorTypeClass>(value, render.text.anchor, "text-anchor"); parseRenderProperty(value, render.text.max_angle, "text-max-angle"); parseRenderProperty(value, render.text.rotate, "text-rotate"); parseRenderProperty(value, render.text.slant, "text-slant"); |