diff options
author | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
---|---|---|
committer | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
commit | 9e8dc9a9e3e86adb9987ae69766cc42c7d9efece (patch) | |
tree | f5f0abd4d342c89ad0405d01969f9d6caecc1c90 /include/mbgl/style/conversion/data_driven_property_value.hpp | |
parent | 16fb0672e64a72b7400c321d55858b73cd5d8c3f (diff) | |
parent | f28d75dccd9bf4a7615df87faccc5cf5eff8df89 (diff) | |
download | qtlocation-mapboxgl-9e8dc9a9e3e86adb9987ae69766cc42c7d9efece.tar.gz |
Merge remote-tracking branch 'origin/master' into feature/custom-vector-source
Diffstat (limited to 'include/mbgl/style/conversion/data_driven_property_value.hpp')
-rw-r--r-- | include/mbgl/style/conversion/data_driven_property_value.hpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/include/mbgl/style/conversion/data_driven_property_value.hpp b/include/mbgl/style/conversion/data_driven_property_value.hpp new file mode 100644 index 0000000000..83f44fdb27 --- /dev/null +++ b/include/mbgl/style/conversion/data_driven_property_value.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include <mbgl/style/data_driven_property_value.hpp> +#include <mbgl/style/conversion.hpp> +#include <mbgl/style/conversion/constant.hpp> +#include <mbgl/style/conversion/function.hpp> + +namespace mbgl { +namespace style { +namespace conversion { + +template <class T> +struct Converter<DataDrivenPropertyValue<T>> { + template <class V> + Result<DataDrivenPropertyValue<T>> operator()(const V& value) const { + if (isUndefined(value)) { + return {}; + } else if (!isObject(value)) { + Result<T> constant = convert<T>(value); + if (!constant) { + return constant.error(); + } + return DataDrivenPropertyValue<T>(*constant); + } else if (!objectMember(value, "property")) { + Result<CameraFunction<T>> function = convert<CameraFunction<T>>(value); + if (!function) { + return function.error(); + } + return DataDrivenPropertyValue<T>(*function); + } else { + Result<CompositeFunction<T>> composite = convert<CompositeFunction<T>>(value); + if (composite) { + return DataDrivenPropertyValue<T>(*composite); + } + Result<SourceFunction<T>> source = convert<SourceFunction<T>>(value); + if (!source) { + return source.error(); + } + return DataDrivenPropertyValue<T>(*source); + } + } +}; + +} // namespace conversion +} // namespace style +} // namespace mbgl |