summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-06-12 15:21:15 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-15 07:43:51 -0700
commit5a8729182652a5cb4d78644a5b9b9a2a2ff343b6 (patch)
tree32a946fe3e728a4436d720058bd98c364f7760ac /src/mbgl/style
parentae5b0391b62b537ba6813df54221283685edd6f2 (diff)
downloadqtlocation-mapboxgl-5a8729182652a5cb4d78644a5b9b9a2a2ff343b6.tar.gz
[core] Obey "transition" property from style and its default value
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/parser.cpp15
-rw-r--r--src/mbgl/style/parser.hpp2
-rw-r--r--src/mbgl/style/style.cpp1
3 files changed, 18 insertions, 0 deletions
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp
index 725feb3fc2..467b44632c 100644
--- a/src/mbgl/style/parser.cpp
+++ b/src/mbgl/style/parser.cpp
@@ -86,6 +86,10 @@ StyleParseResult Parser::parse(const std::string& json) {
}
}
+ if (document.HasMember("transition")) {
+ parseTransition(document["transition"]);
+ }
+
if (document.HasMember("light")) {
parseLight(document["light"]);
}
@@ -115,6 +119,17 @@ StyleParseResult Parser::parse(const std::string& json) {
return nullptr;
}
+void Parser::parseTransition(const JSValue& value) {
+ conversion::Error error;
+ optional<TransitionOptions> converted = conversion::convert<TransitionOptions>(value, error);
+ if (!converted) {
+ Log::Warning(Event::ParseStyle, error.message);
+ return;
+ }
+
+ transition = std::move(*converted);
+}
+
void Parser::parseLight(const JSValue& value) {
conversion::Error error;
optional<Light> converted = conversion::convert<Light>(value, error);
diff --git a/src/mbgl/style/parser.hpp b/src/mbgl/style/parser.hpp
index 32b8a7a8bc..401b5ff513 100644
--- a/src/mbgl/style/parser.hpp
+++ b/src/mbgl/style/parser.hpp
@@ -32,6 +32,7 @@ public:
std::vector<std::unique_ptr<Source>> sources;
std::vector<std::unique_ptr<Layer>> layers;
+ TransitionOptions transition;
Light light;
std::string name;
@@ -44,6 +45,7 @@ public:
std::vector<FontStack> fontStacks() const;
private:
+ void parseTransition(const JSValue&);
void parseLight(const JSValue&);
void parseSources(const JSValue&);
void parseLayers(const JSValue&);
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 27ca58e85d..94e003df51 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -57,6 +57,7 @@ void Style::setJSON(const std::string& json) {
images.clear();
transitionOptions = {};
+ transitionOptions.duration = util::DEFAULT_TRANSITION_DURATION;
Parser parser;
auto error = parser.parse(json);