summaryrefslogtreecommitdiff
path: root/src/mbgl/style/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/parser.cpp')
-rw-r--r--src/mbgl/style/parser.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp
index fc3ccf410b..a83897dbf5 100644
--- a/src/mbgl/style/parser.cpp
+++ b/src/mbgl/style/parser.cpp
@@ -2,11 +2,13 @@
#include <mbgl/style/layer_impl.hpp>
#include <mbgl/style/rapidjson_conversion.hpp>
#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/conversion/coordinate.hpp>
#include <mbgl/style/conversion/source.hpp>
#include <mbgl/style/conversion/layer.hpp>
#include <mbgl/style/conversion/light.hpp>
#include <mbgl/util/logging.hpp>
+#include <mbgl/util/string.hpp>
#include <mapbox/geojsonvt.hpp>
@@ -55,10 +57,12 @@ StyleParseResult Parser::parse(const std::string& json) {
if (document.HasMember("center")) {
const JSValue& value = document["center"];
- if (value.IsArray() && value.Size() >= 2) {
- // Style spec uses lon/lat order
- latLng = LatLng(value[1].IsNumber() ? value[1].GetDouble() : 0,
- value[0].IsNumber() ? value[0].GetDouble() : 0);
+ conversion::Error error;
+ auto convertedLatLng = conversion::convert<LatLng>(value, error);
+ if (convertedLatLng) {
+ latLng = *convertedLatLng;
+ } else {
+ Log::Warning(Event::ParseStyle, "center coordinate must be a longitude, latitude pair");
}
}
@@ -83,6 +87,10 @@ StyleParseResult Parser::parse(const std::string& json) {
}
}
+ if (document.HasMember("transition")) {
+ parseTransition(document["transition"]);
+ }
+
if (document.HasMember("light")) {
parseLight(document["light"]);
}
@@ -112,6 +120,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);
@@ -236,7 +255,7 @@ void Parser::parseLayer(const std::string& id, const JSValue& value, std::unique
return;
}
- layer = reference->baseImpl->cloneRef(id);
+ layer = reference->cloneRef(id);
conversion::setPaintProperties(*layer, value);
} else {
conversion::Error error;