diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp index bcfa5f1bc..d4f896914 100644 --- a/common/glfw_view.cpp +++ b/common/glfw_view.cpp @@ -281,7 +281,7 @@ void show_color_debug_image(std::string name, const char *data, size_t logical_w } #endif -void notify_map_change() { +void notify_map_change(MapChange change) { // no-op } diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 0f359b1a5..6ffb0b804 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -55,6 +55,7 @@ public: void setAppliedClasses(const std::vector &classes); void toggleClass(const std::string &name); const std::vector &getAppliedClasses() const; + void setAppliedClasses(std::vector &class_names); void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); void setStyleJSON(std::string newStyleJSON); std::string getStyleJSON() const; diff --git a/include/llmr/platform/platform.hpp b/include/llmr/platform/platform.hpp index 220acd397..138843fee 100644 --- a/include/llmr/platform/platform.hpp +++ b/include/llmr/platform/platform.hpp @@ -24,6 +24,19 @@ struct Response { std::function callback; }; +enum MapChange : uint8_t { + MapChangeRegionWillChange = 0, + MapChangeRegionWillChangeAnimated = 1, + MapChangeRegionDidChange = 2, + MapChangeRegionDidChangeAnimated = 3, + MapChangeWillStartLoadingMap = 4, + MapChangeDidFinishLoadingMap = 5, + MapChangeDidFailLoadingMap = 6, + MapChangeWillStartRenderingMap = 7, + MapChangeDidFinishRenderingMap = 8, + MapChangeDidFinishRenderingMapFullyRendered = 9 +}; + // Makes an HTTP request of a URL, preferrably on a background thread, and calls a function with the // results in the original thread (which runs the libuv loop). // If the loop pointer is NULL, the callback function will be called on an arbitrary thread. @@ -35,8 +48,8 @@ std::shared_ptr request_http(const std::string &url, // Cancels an HTTP request. void cancel_request_http(const std::shared_ptr &req); -// Notifies a watcher of map x/y/scale/rotation changes. -void notify_map_change(); +// Notifies a watcher of map changes. +void notify_map_change(MapChange key); // Shows an alpha image with the specified dimensions in a named window. void show_debug_image(std::string name, const char *data, size_t width, size_t height); diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index c92e95a7f..b6056986f 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -39,6 +39,7 @@ public: void setAppliedClasses(const std::vector &classes); const std::vector &getAppliedClasses() const; + void setAppliedClasses(std::vector &class_names); void toggleClass(const std::string &name); // Updates the styling information to reflect the current array diff --git a/include/llmr/style/style_bucket.hpp b/include/llmr/style/style_bucket.hpp index 1e3cb2db0..b963caba8 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 95365947f..fd862c00d 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/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index 359b6b6b0..8269f98e8 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit 359b6b6b03703be2e80e9597ec13d96512dc78a0 +Subproject commit 8269f98e8bbfe8522c9440e989eb7436995f1af4 diff --git a/src/map/map.cpp b/src/map/map.cpp index 5aa69b287..b04f88a54 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -397,6 +397,10 @@ const std::vector &Map::getAppliedClasses() const { return style->getAppliedClasses(); } +void Map::setAppliedClasses(std::vector &class_names) { + style->setAppliedClasses(class_names); +} + void Map::setDefaultTransitionDuration(uint64_t duration_milliseconds) { style->setDefaultTransitionDuration(duration_milliseconds); } diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 02f1a50f5..c420f8111 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -19,6 +19,8 @@ #include #include +#include + #ifdef __linux__ #include namespace regex_impl = boost; @@ -208,8 +210,16 @@ std::unique_ptr 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::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/map/transform.cpp b/src/map/transform.cpp index c7bbbfdf7..72449956d 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -28,6 +28,8 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio, if (final.width != w || final.height != h || final.pixelRatio != ratio || final.framebuffer[0] != fb_w || final.framebuffer[1] != fb_h) { + platform::notify_map_change(platform::MapChangeRegionWillChange); + current.width = final.width = w; current.height = final.height = h; current.pixelRatio = final.pixelRatio = ratio; @@ -35,7 +37,9 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio, current.framebuffer[1] = final.framebuffer[1] = fb_h; if (!canRotate() && current.angle) _setAngle(0); constrain(current.scale, current.y); - platform::notify_map_change(); + + platform::notify_map_change(platform::MapChangeRegionDidChange); + return true; } else { return false; @@ -76,7 +80,9 @@ void Transform::_moveBy(const double dx, const double dy, const timestamp durati std::make_shared>(current.y, final.y, current.y, start, duration)); } - platform::notify_map_change(); + platform::notify_map_change(duration ? + platform::MapChangeRegionDidChangeAnimated : + platform::MapChangeRegionDidChange); } void Transform::setLonLat(const double lon, const double lat, const timestamp duration) { @@ -294,7 +300,9 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl Bc = s / 360; Cc = s / (2 * M_PI); - platform::notify_map_change(); + platform::notify_map_change(duration ? + platform::MapChangeRegionDidChangeAnimated : + platform::MapChangeRegionDidChange); } #pragma mark - Constraints @@ -388,7 +396,9 @@ void Transform::_setAngle(double new_angle, const timestamp duration) { current.angle, final.angle, current.angle, start, duration)); } - platform::notify_map_change(); + platform::notify_map_change(duration ? + platform::MapChangeRegionDidChangeAnimated : + platform::MapChangeRegionDidChange); } double Transform::getAngle() const { diff --git a/src/style/style.cpp b/src/style/style.cpp index 6092280af..77d69299e 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -63,8 +63,8 @@ const std::vector &Style::getAppliedClasses() const { return appliedClasses; } -void Style::setAppliedClasses(const std::vector &classes) { - appliedClasses = classes; +void Style::setAppliedClasses(std::vector &class_names) { + appliedClasses.swap(class_names); updateClasses(); } diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 645f3aa0f..e33db355e 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 &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")) { diff --git a/test/headless.cpp b/test/headless.cpp index 8c1dc3a26..34a3f1db7 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -15,7 +15,7 @@ namespace llmr { namespace platform { -void notify_map_change() { +void notify_map_change(MapChange change) { // no-op }