summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llmr/style/style_bucket.hpp1
-rw-r--r--include/llmr/style/types.hpp13
-rw-r--r--src/map/tile_parser.cpp14
-rw-r--r--src/style/style_parser.cpp1
4 files changed, 27 insertions, 2 deletions
diff --git a/include/llmr/style/style_bucket.hpp b/include/llmr/style/style_bucket.hpp
index 1e3cb2db0a..b963caba80 100644
--- a/include/llmr/style/style_bucket.hpp
+++ b/include/llmr/style/style_bucket.hpp
@@ -40,6 +40,7 @@ class StyleBucketText {
public:
std::string field;
TextPathType path = TextPathType::Default;
+ TextTransformType transform = TextTransformType::Default;
std::string font;
float max_size = 16.0f;
float max_width = 15.0f * 24;
diff --git a/include/llmr/style/types.hpp b/include/llmr/style/types.hpp
index 95365947f4..fd862c00d4 100644
--- a/include/llmr/style/types.hpp
+++ b/include/llmr/style/types.hpp
@@ -52,6 +52,13 @@ enum class TextPathType : uint8_t {
Default = Horizontal
};
+enum class TextTransformType : uint8_t {
+ None,
+ Uppercase,
+ Lowercase,
+ Default = None
+};
+
enum class TranslateAnchorType : uint8_t {
Map,
Viewport,
@@ -98,6 +105,12 @@ inline TextPathType parseTextPathType(const std::string &path) {
return TextPathType::Default;
}
+inline TextTransformType parseTextTransformType(const std::string& transform) {
+ if (transform == "uppercase") return TextTransformType::Uppercase;
+ if (transform == "lowercase") return TextTransformType::Lowercase;
+ return TextTransformType::Default;
+};
+
inline TranslateAnchorType parseTranslateAnchorType(const std::string &anchor) {
if (anchor == "map") return TranslateAnchorType::Map;
if (anchor == "viewport") return TranslateAnchorType::Viewport;
diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp
index 02f1a50f5d..c420f81111 100644
--- a/src/map/tile_parser.cpp
+++ b/src/map/tile_parser.cpp
@@ -19,6 +19,8 @@
#include <llmr/util/std.hpp>
#include <llmr/util/utf.hpp>
+#include <locale>
+
#ifdef __linux__
#include <boost/regex.hpp>
namespace regex_impl = boost;
@@ -208,8 +210,16 @@ std::unique_ptr<Bucket> TileParser::createTextBucket(const VectorTileLayer& laye
return nullptr;
VectorTileFeature feature{feature_pbf, layer};
- const std::u32string string = ucs4conv.convert(
- util::replaceTokens(properties.field, feature.properties));
+ std::string u8string = util::replaceTokens(properties.field, feature.properties);
+
+ auto& convert = std::use_facet<std::ctype<char>>(std::locale());
+ if (properties.transform == TextTransformType::Uppercase) {
+ convert.toupper(&u8string[0], &u8string[0] + u8string.size());
+ } else if (properties.transform == TextTransformType::Lowercase) {
+ convert.tolower(&u8string[0], &u8string[0] + u8string.size());
+ }
+
+ std::u32string string = ucs4conv.convert(u8string);
// Loop through all characters of this text and collect unique codepoints.
for (char32_t chr : string) {
diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp
index 645f3aa0f3..e33db355e8 100644
--- a/src/style/style_parser.cpp
+++ b/src/style/style_parser.cpp
@@ -890,6 +890,7 @@ void StyleParser::parseRender(JSVal value, std::shared_ptr<StyleLayer> &layer) {
parseRenderProperty(value, render.field, "text-field");
parseRenderProperty(value, render.path, "text-path", parseTextPathType);
+ parseRenderProperty(value, render.transform, "text-transform", parseTextTransformType);
parseRenderProperty(value, render.font, "text-font");
parseRenderProperty(value, render.max_size, "text-max-size");
if (parseRenderProperty(value, render.max_width, "text-max-width")) {