diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-09 17:51:26 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2019-08-12 17:14:32 +0300 |
commit | 5a752061fe9d84588d4bd70a37d1c3a861eaa206 (patch) | |
tree | d53c56dad0d2c6b216dfd1d98f0c2d3acd9b7c49 /src/mbgl/style/conversion | |
parent | bc09cdbf76ffa50ccdd8dc8df7997fdd3a0eb0d6 (diff) | |
download | qtlocation-mapboxgl-upstream/mikhail_two_component_text_radial_offset.tar.gz |
[core] Enable two-component text radial offsetupstream/mikhail_two_component_text_radial_offset
Diffstat (limited to 'src/mbgl/style/conversion')
-rw-r--r-- | src/mbgl/style/conversion/constant.cpp | 18 | ||||
-rw-r--r-- | src/mbgl/style/conversion/function.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/style/conversion/property_value.cpp | 1 |
3 files changed, 23 insertions, 0 deletions
diff --git a/src/mbgl/style/conversion/constant.cpp b/src/mbgl/style/conversion/constant.cpp index 0fcaab433b..0ed5fad425 100644 --- a/src/mbgl/style/conversion/constant.cpp +++ b/src/mbgl/style/conversion/constant.cpp @@ -168,6 +168,24 @@ optional<std::vector<std::string>> Converter<std::vector<std::string>>::operator return result; } +optional<RadialOffsetType> Converter<RadialOffsetType>::operator()(const Convertible& value, Error& error) const { + Converter<std::vector<float>> arrayConverter; + if (auto val = arrayConverter(value, error)) { + RadialOffsetType result = std::move(*val); + return result; + } + + Converter<float> numberConverter; + if (auto val = numberConverter(value, error)) { + RadialOffsetType result(2, *val); + return result; + } + + error.message = "value must be an array of numbers or a number"; + + return nullopt; +} + } // namespace conversion } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/conversion/function.cpp b/src/mbgl/style/conversion/function.cpp index 086bc4e277..ade5a5dc5e 100644 --- a/src/mbgl/style/conversion/function.cpp +++ b/src/mbgl/style/conversion/function.cpp @@ -153,6 +153,10 @@ template optional<PropertyExpression<TranslateAnchorType>> template optional<PropertyExpression<Formatted>> convertFunctionToExpression<Formatted>(const Convertible&, Error&, bool); +template optional<PropertyExpression<RadialOffsetType>> + convertFunctionToExpression<RadialOffsetType>(const Convertible&, Error&, bool); + + // Ad-hoc Converters for double and int64_t. We should replace float with double wholesale, // and promote the int64_t Converter to general use (and it should check that the input is // an integer). diff --git a/src/mbgl/style/conversion/property_value.cpp b/src/mbgl/style/conversion/property_value.cpp index 6e1d747324..91e61ec5cb 100644 --- a/src/mbgl/style/conversion/property_value.cpp +++ b/src/mbgl/style/conversion/property_value.cpp @@ -80,6 +80,7 @@ template optional<PropertyValue<TextJustifyType>> Converter<PropertyValue<TextJu template optional<PropertyValue<TextTransformType>> Converter<PropertyValue<TextTransformType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; template optional<PropertyValue<TranslateAnchorType>> Converter<PropertyValue<TranslateAnchorType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; template optional<PropertyValue<mbgl::style::expression::Formatted>> Converter<PropertyValue<mbgl::style::expression::Formatted>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; +template optional<PropertyValue<RadialOffsetType>> Converter<PropertyValue<RadialOffsetType>>::operator()(conversion::Convertible const&, conversion::Error&, bool, bool) const; } // namespace conversion } // namespace style |