[core] parse more Style JSON properties

We're now parsing "name", "center", "zoom", "bearing", and "pitch" from the stylesheet.
This commit is contained in:
Konstantin Käfer
2016-08-15 16:16:45 +02:00
parent dfd40b27a5
commit cb33c861b4
7 changed files with 147 additions and 0 deletions

View File

@@ -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"]);
}