summaryrefslogtreecommitdiff
path: root/src/mbgl/style/parser.cpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-08-15 16:16:45 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-08-19 17:34:10 +0200
commitcb33c861b4cfa82d7afcb5b9ec85d7797679a7d8 (patch)
tree8ad68018af87fd9e41e58a19f5d0286698f203e7 /src/mbgl/style/parser.cpp
parentdfd40b27a54115cdf769abdda3ec4d3a1329758c (diff)
downloadqtlocation-mapboxgl-cb33c861b4cfa82d7afcb5b9ec85d7797679a7d8.tar.gz
[core] parse more Style JSON properties
We're now parsing "name", "center", "zoom", "bearing", and "pitch" from the stylesheet.
Diffstat (limited to 'src/mbgl/style/parser.cpp')
-rw-r--r--src/mbgl/style/parser.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp
index 2746b8af92..bc05b5484a 100644
--- a/src/mbgl/style/parser.cpp
+++ b/src/mbgl/style/parser.cpp
@@ -42,6 +42,43 @@ void Parser::parse(const std::string& json) {
}
}
+ if (document.HasMember("name")) {
+ const JSValue& value = document["name"];
+ if (value.IsString()) {
+ name = { value.GetString(), value.GetStringLength() };
+ }
+ }
+
+ if (document.HasMember("center")) {
+ const JSValue& value = document["center"];
+ if (value.IsArray() && value.Size() >= 2) {
+ // Style spec uses lon/lat order
+ latLng.longitude = value[0].IsNumber() ? value[0].GetDouble() : 0;
+ latLng.latitude = value[1].IsNumber() ? value[1].GetDouble() : 0;
+ }
+ }
+
+ if (document.HasMember("zoom")) {
+ const JSValue& value = document["zoom"];
+ if (value.IsNumber()) {
+ zoom = value.GetDouble();
+ }
+ }
+
+ if (document.HasMember("bearing")) {
+ const JSValue& value = document["bearing"];
+ if (value.IsNumber()) {
+ bearing = value.GetDouble();
+ }
+ }
+
+ if (document.HasMember("pitch")) {
+ const JSValue& value = document["pitch"];
+ if (value.IsNumber()) {
+ pitch = value.GetDouble();
+ }
+ }
+
if (document.HasMember("sources")) {
parseSources(document["sources"]);
}