diff options
author | Anand Thakker <anandthakker@users.noreply.github.com> | 2017-02-17 16:16:25 -0500 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-02-17 13:16:25 -0800 |
commit | 062b18374d580f3522f577c4dccbfcd15e260e80 (patch) | |
tree | 357406a6090d755b33b46534e44b9f47fb040360 /src/mbgl/layout | |
parent | d4c569a0187d98bca6b71671fa5daf6ee09747da (diff) | |
download | qtlocation-mapboxgl-062b18374d580f3522f577c4dccbfcd15e260e80.tar.gz |
[core] Enable property functions for text-{field,transform} (#7944)
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 4ff9bd9452..867b82e285 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -72,8 +72,14 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, layout.get<IconSize>() = leader.layout.evaluate<IconSize>(PropertyEvaluationParameters(zoom + 1)); layout.get<TextSize>() = leader.layout.evaluate<TextSize>(PropertyEvaluationParameters(zoom + 1)); + + const bool hasTextField = layout.get<TextField>().match( + [&] (const std::string& s) { return !s.empty(); }, + [&] (const auto&) { return true; } + ); + + const bool hasText = !layout.get<TextFont>().empty() && hasTextField; - const bool hasText = !layout.get<TextField>().empty() && !layout.get<TextFont>().empty(); const bool hasIcon = !layout.get<IconImage>().empty(); if (!hasText && !hasIcon) { @@ -110,13 +116,18 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters, return util::toString(value->get<double>()); return "null"; }; - + if (hasText) { - std::string u8string = util::replaceTokens(layout.get<TextField>(), getValue); + std::string u8string = layout.evaluate<TextField>(zoom, *feature); + if (layout.get<TextField>().isConstant()) { + u8string = util::replaceTokens(u8string, getValue); + } + + auto textTransform = layout.evaluate<TextTransform>(zoom, *feature); - if (layout.get<TextTransform>() == TextTransformType::Uppercase) { + if (textTransform == TextTransformType::Uppercase) { u8string = platform::uppercase(u8string); - } else if (layout.get<TextTransform>() == TextTransformType::Lowercase) { + } else if (textTransform == TextTransformType::Lowercase) { u8string = platform::lowercase(u8string); } @@ -154,7 +165,12 @@ bool SymbolLayout::hasSymbolInstances() const { } bool SymbolLayout::canPrepare(GlyphAtlas& glyphAtlas) { - if (!layout.get<TextField>().empty() && !layout.get<TextFont>().empty() && !glyphAtlas.hasGlyphRanges(layout.get<TextFont>(), ranges)) { + const bool hasTextField = layout.get<TextField>().match( + [&] (const std::string& s) { return !s.empty(); }, + [&] (const auto&) { return true; } + ); + + if (hasTextField && !layout.get<TextFont>().empty() && !glyphAtlas.hasGlyphRanges(layout.get<TextFont>(), ranges)) { return false; } |