Fix result value from parseProperty when T = std::array<float, 2>

This commit is contained in:
Bruno de Oliveira Abinader
2015-06-22 22:45:42 +03:00
parent 43d69b6a65
commit 7bfae2a1a5
3 changed files with 27 additions and 2 deletions

View File

@@ -286,7 +286,7 @@ std::tuple<bool, std::array<float, 2>> StyleParser::parseProperty(JSVal value, c
float first = value[rapidjson::SizeType(0)].GetDouble();
float second = value[rapidjson::SizeType(1)].GetDouble();
return std::tuple<bool, std::array<float, 2>> { false, {{ first, second }} };
return std::tuple<bool, std::array<float, 2>> { true, {{ first, second }} };
} else {
Log::Warning(Event::ParseStyle, "value must be array of two numbers");
return std::tuple<bool, std::array<float, 2>> { false, {{ 0.0f, 0.0f }} };
@@ -367,7 +367,7 @@ std::tuple<bool, std::vector<std::pair<float, T>>> StyleParser::parseStops(JSVal
template <typename T>
std::tuple<bool, Function<T>> StyleParser::parseFunction(JSVal value, const char *property_name) {
if (!value.IsObject()) {
return std::tuple<bool, Function<T>> { true, ConstantFunction<T>(std::get<1>(parseProperty<T>(value, property_name))) };
return parseProperty<T>(value, property_name);
}
if (!value.HasMember("stops")) {

View File

@@ -0,0 +1,7 @@
{
"default": {
"log": [
[1, "WARNING", "ParseStyle", "value must be array of two numbers"]
]
}
}

View File

@@ -0,0 +1,18 @@
{
"version": 6,
"sources": {
"mapbox": {
"type": "vector",
"url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5",
"maxzoom": 14
}
},
"layers": [{
"id": "line_translate_example",
"type": "line",
"source": "mapbox",
"paint": {
"line-translate": null
}
}]
}