[core] Enable property functions for text-{field,transform} (#7944)

This commit is contained in:
Anand Thakker
2017-02-17 16:16:25 -05:00
committed by John Firebaugh
parent d4c569a018
commit 062b18374d
23 changed files with 474 additions and 175 deletions

View File

@@ -1,4 +1,6 @@
#include <mbgl/style/function/identity_stops.hpp>
#include <mbgl/style/types.hpp>
#include <mbgl/util/enum.hpp>
#include <mbgl/util/color.hpp>
#include <array>
@@ -11,6 +13,15 @@ optional<float> IdentityStops<float>::evaluate(const Value& value) const {
return numericValue<float>(value);
}
template <>
optional<std::string> IdentityStops<std::string>::evaluate(const Value& value) const {
if (!value.is<std::string>()) {
return {};
}
return value.get<std::string>();
}
template <>
optional<Color> IdentityStops<Color>::evaluate(const Value& value) const {
if (!value.is<std::string>()) {
@@ -20,6 +31,15 @@ optional<Color> IdentityStops<Color>::evaluate(const Value& value) const {
return Color::parse(value.get<std::string>());
}
template <>
optional<TextTransformType> IdentityStops<TextTransformType>::evaluate(const Value& value) const {
if (!value.is<std::string>()) {
return {};
}
return Enum<TextTransformType>::toEnum(value.get<std::string>());
}
template <>
optional<std::array<float, 2>> IdentityStops<std::array<float, 2>>::evaluate(const Value& value) const {
if (!value.is<std::vector<Value>>()) {