summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/glfw_view.cpp2
-rw-r--r--include/llmr/map/map.hpp1
-rw-r--r--include/llmr/platform/platform.hpp17
-rw-r--r--include/llmr/style/style.hpp1
-rw-r--r--include/llmr/style/style_bucket.hpp1
-rw-r--r--include/llmr/style/types.hpp13
m---------ios/mapbox-gl-cocoa0
-rw-r--r--src/map/map.cpp4
-rw-r--r--src/map/tile_parser.cpp14
-rw-r--r--src/map/transform.cpp18
-rw-r--r--src/style/style.cpp4
-rw-r--r--src/style/style_parser.cpp1
-rw-r--r--test/headless.cpp2
13 files changed, 66 insertions, 12 deletions
diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp
index bcfa5f1bc1..d4f8969143 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 0f359b1a50..6ffb0b8041 100644
--- a/include/llmr/map/map.hpp
+++ b/include/llmr/map/map.hpp
@@ -55,6 +55,7 @@ public:
void setAppliedClasses(const std::vector<std::string> &classes);
void toggleClass(const std::string &name);
const std::vector<std::string> &getAppliedClasses() const;
+ void setAppliedClasses(std::vector<std::string> &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 220acd3971..138843fee3 100644
--- a/include/llmr/platform/platform.hpp
+++ b/include/llmr/platform/platform.hpp
@@ -24,6 +24,19 @@ struct Response {
std::function<void(Response *)> 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> request_http(const std::string &url,
// Cancels an HTTP request.
void cancel_request_http(const std::shared_ptr<Request> &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 c92e95a7ff..b6056986f8 100644
--- a/include/llmr/style/style.hpp
+++ b/include/llmr/style/style.hpp
@@ -39,6 +39,7 @@ public:
void setAppliedClasses(const std::vector<std::string> &classes);
const std::vector<std::string> &getAppliedClasses() const;
+ void setAppliedClasses(std::vector<std::string> &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 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/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa
-Subproject 359b6b6b03703be2e80e9597ec13d96512dc78a
+Subproject 8269f98e8bbfe8522c9440e989eb7436995f1af
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 5aa69b2875..b04f88a546 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -397,6 +397,10 @@ const std::vector<std::string> &Map::getAppliedClasses() const {
return style->getAppliedClasses();
}
+void Map::setAppliedClasses(std::vector<std::string> &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 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/map/transform.cpp b/src/map/transform.cpp
index c7bbbfdf7d..72449956d0 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<util::ease_transition<double>>(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 6092280afd..77d69299eb 100644
--- a/src/style/style.cpp
+++ b/src/style/style.cpp
@@ -63,8 +63,8 @@ const std::vector<std::string> &Style::getAppliedClasses() const {
return appliedClasses;
}
-void Style::setAppliedClasses(const std::vector<std::string> &classes) {
- appliedClasses = classes;
+void Style::setAppliedClasses(std::vector<std::string> &class_names) {
+ appliedClasses.swap(class_names);
updateClasses();
}
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")) {
diff --git a/test/headless.cpp b/test/headless.cpp
index 8c1dc3a260..34a3f1db77 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
}