[core] Merge style::Layer::set{Layout,Paint}Property
This commit is contained in:
@@ -110,9 +110,7 @@ public:
|
||||
void setMaxZoom(float);
|
||||
|
||||
// Dynamic properties
|
||||
virtual optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) = 0;
|
||||
virtual optional<conversion::Error> setPaintProperty(const std::string& name,
|
||||
const conversion::Convertible& value) = 0;
|
||||
virtual optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) = 0;
|
||||
optional<conversion::Error> setVisibility(const conversion::Convertible& value);
|
||||
|
||||
virtual StyleProperty getProperty(const std::string&) const = 0;
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
~BackgroundLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
~CircleLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -69,8 +69,7 @@ public:
|
||||
~CustomLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
StyleProperty getProperty(const std::string&) const final;
|
||||
// Private implementation
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
~FillExtrusionLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
~FillLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ public:
|
||||
~HeatmapLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
~HillshadeLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -37,8 +37,7 @@ public:
|
||||
~<%- camelize(type) %>Layer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ public:
|
||||
~LineLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ public:
|
||||
~RasterLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ public:
|
||||
~SymbolLayer() final;
|
||||
|
||||
// Dynamic properties
|
||||
optional<conversion::Error> setLayoutProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setPaintProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
optional<conversion::Error> setProperty(const std::string& name, const conversion::Convertible& value) final;
|
||||
|
||||
StyleProperty getProperty(const std::string& name) const final;
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@ optional<Error> setPaintProperties(Layer& layer, const Convertible& value) {
|
||||
if (!isObject(*paintValue)) {
|
||||
return { { "paint must be an object" } };
|
||||
}
|
||||
return eachMember(*paintValue, [&] (const std::string& k, const Convertible& v) {
|
||||
return layer.setPaintProperty(k, v);
|
||||
});
|
||||
return eachMember(*paintValue, [&](const std::string& k, const Convertible& v) { return layer.setProperty(k, v); });
|
||||
}
|
||||
|
||||
optional<std::unique_ptr<Layer>> Converter<std::unique_ptr<Layer>>::operator()(const Convertible& value, Error& error) const {
|
||||
@@ -83,9 +81,8 @@ optional<std::unique_ptr<Layer>> Converter<std::unique_ptr<Layer>>::operator()(c
|
||||
error.message = "layout must be an object";
|
||||
return nullopt;
|
||||
}
|
||||
optional<Error> error_ = eachMember(*layoutValue, [&] (const std::string& k, const Convertible& v) {
|
||||
return layer->setLayoutProperty(k, v);
|
||||
});
|
||||
optional<Error> error_ = eachMember(
|
||||
*layoutValue, [&](const std::string& k, const Convertible& v) { return layer->setProperty(k, v); });
|
||||
if (error_) {
|
||||
error = *error_;
|
||||
return nullopt;
|
||||
|
||||
@@ -169,56 +169,47 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"background-color-transition", toUint8(Property::BackgroundColorTransition)},
|
||||
{"background-opacity-transition", toUint8(Property::BackgroundOpacityTransition)},
|
||||
{"background-pattern-transition", toUint8(Property::BackgroundPatternTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::BackgroundPatternTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> BackgroundLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> BackgroundLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::BackgroundColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setBackgroundColor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::BackgroundOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setBackgroundOpacity(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::BackgroundPattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<expression::Image>> typedValue =
|
||||
convert<PropertyValue<expression::Image>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setBackgroundPattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -267,14 +258,6 @@ StyleProperty BackgroundLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> BackgroundLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -417,123 +417,107 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"circle-stroke-width-transition", toUint8(Property::CircleStrokeWidthTransition)},
|
||||
{"circle-translate-transition", toUint8(Property::CircleTranslateTransition)},
|
||||
{"circle-translate-anchor-transition", toUint8(Property::CircleTranslateAnchorTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::CircleTranslateAnchorTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> CircleLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> CircleLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::CircleBlur || property == Property::CircleOpacity || property == Property::CircleRadius || property == Property::CircleStrokeOpacity || property == Property::CircleStrokeWidth) {
|
||||
if (property == Property::CircleBlur || property == Property::CircleOpacity || property == Property::CircleRadius ||
|
||||
property == Property::CircleStrokeOpacity || property == Property::CircleStrokeWidth) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleBlur) {
|
||||
setCircleBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleOpacity) {
|
||||
setCircleOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleRadius) {
|
||||
setCircleRadius(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleStrokeOpacity) {
|
||||
setCircleStrokeOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleStrokeWidth) {
|
||||
setCircleStrokeWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::CircleColor || property == Property::CircleStrokeColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleColor) {
|
||||
setCircleColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleStrokeColor) {
|
||||
setCircleStrokeColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::CirclePitchAlignment) {
|
||||
Error error;
|
||||
optional<PropertyValue<AlignmentType>> typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCirclePitchAlignment(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::CirclePitchScale) {
|
||||
Error error;
|
||||
optional<PropertyValue<CirclePitchScaleType>> typedValue =
|
||||
convert<PropertyValue<CirclePitchScaleType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<CirclePitchScaleType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCirclePitchScale(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::CircleTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCircleTranslate(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::CircleTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue =
|
||||
convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCircleTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -654,14 +638,6 @@ StyleProperty CircleLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> CircleLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> CircleLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -39,11 +39,7 @@ std::unique_ptr<Layer> CustomLayer::cloneRef(const std::string&) const {
|
||||
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> CustomLayer::setPaintProperty(const std::string&, const Convertible&) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
optional<Error> CustomLayer::setLayoutProperty(const std::string&, const Convertible&) {
|
||||
optional<Error> CustomLayer::setProperty(const std::string&, const Convertible&) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -324,113 +324,94 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"fill-extrusion-translate-transition", toUint8(Property::FillExtrusionTranslateTransition)},
|
||||
{"fill-extrusion-translate-anchor-transition", toUint8(Property::FillExtrusionTranslateAnchorTransition)},
|
||||
{"fill-extrusion-vertical-gradient-transition", toUint8(Property::FillExtrusionVerticalGradientTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::FillExtrusionVerticalGradientTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> FillExtrusionLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::FillExtrusionBase || property == Property::FillExtrusionHeight) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::FillExtrusionBase) {
|
||||
setFillExtrusionBase(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::FillExtrusionHeight) {
|
||||
setFillExtrusionHeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionColor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionOpacity(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionPattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<expression::Image>> typedValue =
|
||||
convert<PropertyValue<expression::Image>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionPattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionTranslate(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue =
|
||||
convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionVerticalGradient) {
|
||||
Error error;
|
||||
optional<PropertyValue<bool>> typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionVerticalGradient(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -524,14 +505,6 @@ StyleProperty FillExtrusionLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> FillExtrusionLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> FillExtrusionLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -293,101 +293,84 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"fill-pattern-transition", toUint8(Property::FillPatternTransition)},
|
||||
{"fill-translate-transition", toUint8(Property::FillTranslateTransition)},
|
||||
{"fill-translate-anchor-transition", toUint8(Property::FillTranslateAnchorTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::FillTranslateAnchorTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> FillLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> FillLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::FillAntialias) {
|
||||
Error error;
|
||||
optional<PropertyValue<bool>> typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillAntialias(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillColor || property == Property::FillOutlineColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::FillColor) {
|
||||
setFillColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::FillOutlineColor) {
|
||||
setFillOutlineColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillOpacity(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillPattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<expression::Image>> typedValue =
|
||||
convert<PropertyValue<expression::Image>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillPattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillTranslate(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::FillTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue =
|
||||
convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -472,14 +455,6 @@ StyleProperty FillLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> FillLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -233,69 +233,61 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"heatmap-opacity-transition", toUint8(Property::HeatmapOpacityTransition)},
|
||||
{"heatmap-radius-transition", toUint8(Property::HeatmapRadiusTransition)},
|
||||
{"heatmap-weight-transition", toUint8(Property::HeatmapWeightTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::HeatmapWeightTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> HeatmapLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> HeatmapLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::HeatmapColor) {
|
||||
Error error;
|
||||
optional<ColorRampPropertyValue> typedValue = convert<ColorRampPropertyValue>(value, error, false, false);
|
||||
const auto& typedValue = convert<ColorRampPropertyValue>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setHeatmapColor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapIntensity || property == Property::HeatmapOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HeatmapIntensity) {
|
||||
setHeatmapIntensity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HeatmapOpacity) {
|
||||
setHeatmapOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapRadius || property == Property::HeatmapWeight) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HeatmapRadius) {
|
||||
setHeatmapRadius(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HeatmapWeight) {
|
||||
setHeatmapWeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -362,14 +354,6 @@ StyleProperty HeatmapLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> HeatmapLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -262,75 +262,67 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"hillshade-illumination-anchor-transition", toUint8(Property::HillshadeIlluminationAnchorTransition)},
|
||||
{"hillshade-illumination-direction-transition", toUint8(Property::HillshadeIlluminationDirectionTransition)},
|
||||
{"hillshade-shadow-color-transition", toUint8(Property::HillshadeShadowColorTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::HillshadeShadowColorTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> HillshadeLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> HillshadeLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::HillshadeAccentColor || property == Property::HillshadeHighlightColor || property == Property::HillshadeShadowColor) {
|
||||
if (property == Property::HillshadeAccentColor || property == Property::HillshadeHighlightColor ||
|
||||
property == Property::HillshadeShadowColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HillshadeAccentColor) {
|
||||
setHillshadeAccentColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HillshadeHighlightColor) {
|
||||
setHillshadeHighlightColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HillshadeShadowColor) {
|
||||
setHillshadeShadowColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeExaggeration || property == Property::HillshadeIlluminationDirection) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HillshadeExaggeration) {
|
||||
setHillshadeExaggeration(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HillshadeIlluminationDirection) {
|
||||
setHillshadeIlluminationDirection(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeIlluminationAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<HillshadeIlluminationAnchorType>> typedValue =
|
||||
convert<PropertyValue<HillshadeIlluminationAnchorType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<HillshadeIlluminationAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setHillshadeIlluminationAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -406,14 +398,6 @@ StyleProperty HillshadeLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> HillshadeLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> HillshadeLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
const type = locals.type;
|
||||
const layoutProperties = locals.layoutProperties;
|
||||
const paintProperties = locals.paintProperties;
|
||||
const allProperties = paintProperties.concat(layoutProperties);
|
||||
-%>
|
||||
// This file is generated. Edit scripts/generate-style-code.js, then run `make style-code`.
|
||||
|
||||
@@ -80,8 +81,9 @@ layerCapabilities['raster'] = defaults.require('Source').set('TileKind',
|
||||
|
||||
// Splits lines that are over 120 characters at the firts occurance of '='.
|
||||
const split120Line = line => {
|
||||
if (line.length > 120) {
|
||||
return line.replace('=', '=\n ');
|
||||
const ident = ' ';
|
||||
if (line.length + ident.length > 120) {
|
||||
return line.replace('=', `=\n${ident}`);
|
||||
}
|
||||
return line;
|
||||
};
|
||||
@@ -224,50 +226,55 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
<%- paintProperties.map(p => `{"${p.name}-transition", toUint8(Property::${camelize(p.name)}Transition)}`).join(',\n ') %>,
|
||||
<%- layoutProperties.map(p => `{"${p.name}", toUint8(Property::${camelize(p.name)})}`).join(',\n ') %>});
|
||||
<% } -%>
|
||||
|
||||
<% const lastPaintProperty = paintProperties[paintProperties.length - 1]; -%>
|
||||
<%-`constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::${camelize(lastPaintProperty.name)}Transition);` %>
|
||||
} // namespace
|
||||
|
||||
optional<Error> <%- camelize(type) %>Layer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> <%- camelize(type) %>Layer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
<%
|
||||
const paintConversions = {};
|
||||
for (const property of paintProperties) {
|
||||
const dataDriven = property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven';
|
||||
const convertTokens = property.name === 'icon-image' || property.name === 'text-field';
|
||||
const conversion = `optional<${propertyValueType(property)}> typedValue = convert<${propertyValueType(property)}>(value, error, ${dataDriven}, ${convertTokens})`;
|
||||
paintConversions[conversion] = paintConversions[conversion] || [];
|
||||
paintConversions[conversion].push(property);
|
||||
}
|
||||
-%>
|
||||
<% for (const key in paintConversions) {
|
||||
const properties = paintConversions[key];
|
||||
%>
|
||||
if (<%- properties.map(p => `property == Property::${camelize(p.name)}`).join(' || ') %>) {
|
||||
<%
|
||||
const conversions = {};
|
||||
for (const property of allProperties) {
|
||||
const dataDriven = property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven';
|
||||
const convertTokens = property.name === 'icon-image' || property.name === 'text-field';
|
||||
const conversion = `const auto& typedValue = convert<${propertyValueType(property)}>(value, error, ${dataDriven}, ${convertTokens})`;
|
||||
conversions[conversion] = conversions[conversion] || [];
|
||||
conversions[conversion].push(property);
|
||||
}
|
||||
const reduceConditions = (total, e) => {
|
||||
const splitter = ' || ';
|
||||
const ident = ' ';
|
||||
let totalLength = total.length + e.length + ident.length + splitter.length + 3 /* ||*/;
|
||||
const lastCR = total.lastIndexOf('\n');
|
||||
const length = (lastCR == -1) ? totalLength : (totalLength - (ident.length + lastCR));
|
||||
return total + (length <= 120 ? splitter : ` ||\n${ident}`) + e;
|
||||
}
|
||||
-%>
|
||||
<% for (const key in conversions) {
|
||||
const properties = conversions[key];
|
||||
-%>
|
||||
if (<%- properties.map(p => `property == Property::${camelize(p.name)}`).reduce(reduceConditions) %>) {
|
||||
Error error;
|
||||
<%- split120Line(key) %>;
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
<% if (properties.length == 1) { %>
|
||||
<% if (properties.length == 1) { %>
|
||||
set<%- camelize(properties[0].name) %>(*typedValue);
|
||||
return nullopt;
|
||||
<% } else for (const property of properties) { %>
|
||||
<% } else for (const property of properties) { %>
|
||||
if (property == Property::<%- camelize(property.name) %>) {
|
||||
set<%- camelize(property.name) %>(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
<% } %>
|
||||
<% } -%>
|
||||
}
|
||||
<% } %>
|
||||
|
||||
<% } %>
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
@@ -305,52 +312,6 @@ StyleProperty <%- camelize(type) %>Layer::getProperty(const std::string& name) c
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> <%- camelize(type) %>Layer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
<% if (layoutProperties.length) { -%>
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second <= lastPaintPropertyIndex) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
<%
|
||||
const layoutConversions = {};
|
||||
for (const property of layoutProperties) {
|
||||
const dataDriven = property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven';
|
||||
const convertTokens = property.name === 'icon-image' || property.name === 'text-field';
|
||||
const conversion = `optional<${propertyValueType(property)}> typedValue = convert<${propertyValueType(property)}>(value, error, ${dataDriven}, ${convertTokens})`;
|
||||
layoutConversions[conversion] = layoutConversions[conversion] || [];
|
||||
layoutConversions[conversion].push(property);
|
||||
}
|
||||
-%>
|
||||
<% for (const key in layoutConversions) {
|
||||
const properties = layoutConversions[key];
|
||||
%>
|
||||
if (<%- properties.map(p => `property == Property::${camelize(p.name)}`).join(' || ') %>) {
|
||||
Error error;
|
||||
<%- split120Line(key) %>;
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
<% if (properties.length == 1) { %>
|
||||
set<%- camelize(properties[0].name) %>(*typedValue);
|
||||
return nullopt;
|
||||
<% } else for (const property of properties) { %>
|
||||
if (property == Property::<%- camelize(property.name) %>) {
|
||||
set<%- camelize(property.name) %>(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
<% } %>
|
||||
<% } /* if (layoutProperties.length) */ %>
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> <%- camelize(type) %>Layer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -491,129 +491,147 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"line-join", toUint8(Property::LineJoin)},
|
||||
{"line-miter-limit", toUint8(Property::LineMiterLimit)},
|
||||
{"line-round-limit", toUint8(Property::LineRoundLimit)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::LineWidthTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> LineLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> LineLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::LineBlur || property == Property::LineGapWidth || property == Property::LineOffset || property == Property::LineOpacity || property == Property::LineWidth) {
|
||||
if (property == Property::LineBlur || property == Property::LineGapWidth || property == Property::LineOffset ||
|
||||
property == Property::LineOpacity || property == Property::LineWidth) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::LineBlur) {
|
||||
setLineBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::LineGapWidth) {
|
||||
setLineGapWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::LineOffset) {
|
||||
setLineOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::LineOpacity) {
|
||||
setLineOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::LineWidth) {
|
||||
setLineWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineColor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineDasharray) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::vector<float>>> typedValue =
|
||||
convert<PropertyValue<std::vector<float>>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<std::vector<float>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineDasharray(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineGradient) {
|
||||
Error error;
|
||||
optional<ColorRampPropertyValue> typedValue = convert<ColorRampPropertyValue>(value, error, false, false);
|
||||
const auto& typedValue = convert<ColorRampPropertyValue>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineGradient(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LinePattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<expression::Image>> typedValue =
|
||||
convert<PropertyValue<expression::Image>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLinePattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineTranslate(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue =
|
||||
convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineCap) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<LineCapType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineCap(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::LineJoin) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<LineJoinType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineJoin(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::LineMiterLimit || property == Property::LineRoundLimit) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::LineMiterLimit) {
|
||||
setLineMiterLimit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineRoundLimit) {
|
||||
setLineRoundLimit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -742,65 +760,6 @@ StyleProperty LineLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> LineLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second <= lastPaintPropertyIndex) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::LineCap) {
|
||||
Error error;
|
||||
optional<PropertyValue<LineCapType>> typedValue = convert<PropertyValue<LineCapType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineCap(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineJoin) {
|
||||
Error error;
|
||||
optional<PropertyValue<LineJoinType>> typedValue = convert<PropertyValue<LineJoinType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineJoin(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::LineMiterLimit || property == Property::LineRoundLimit) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::LineMiterLimit) {
|
||||
setLineMiterLimit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineRoundLimit) {
|
||||
setLineRoundLimit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -324,76 +324,72 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"raster-opacity-transition", toUint8(Property::RasterOpacityTransition)},
|
||||
{"raster-resampling-transition", toUint8(Property::RasterResamplingTransition)},
|
||||
{"raster-saturation-transition", toUint8(Property::RasterSaturationTransition)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::RasterSaturationTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> RasterLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> RasterLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::RasterBrightnessMax || property == Property::RasterBrightnessMin || property == Property::RasterContrast || property == Property::RasterFadeDuration || property == Property::RasterHueRotate || property == Property::RasterOpacity || property == Property::RasterSaturation) {
|
||||
if (property == Property::RasterBrightnessMax || property == Property::RasterBrightnessMin ||
|
||||
property == Property::RasterContrast || property == Property::RasterFadeDuration ||
|
||||
property == Property::RasterHueRotate || property == Property::RasterOpacity ||
|
||||
property == Property::RasterSaturation) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterBrightnessMax) {
|
||||
setRasterBrightnessMax(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterBrightnessMin) {
|
||||
setRasterBrightnessMin(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterContrast) {
|
||||
setRasterContrast(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterFadeDuration) {
|
||||
setRasterFadeDuration(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterHueRotate) {
|
||||
setRasterHueRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterOpacity) {
|
||||
setRasterOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterSaturation) {
|
||||
setRasterSaturation(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::RasterResampling) {
|
||||
Error error;
|
||||
optional<PropertyValue<RasterResamplingType>> typedValue =
|
||||
convert<PropertyValue<RasterResamplingType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<RasterResamplingType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setRasterResampling(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -487,14 +483,6 @@ StyleProperty RasterLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> RasterLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> RasterLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
@@ -1249,127 +1249,424 @@ MAPBOX_ETERNAL_CONSTEXPR const auto layerProperties = mapbox::eternal::hash_map<
|
||||
{"text-transform", toUint8(Property::TextTransform)},
|
||||
{"text-variable-anchor", toUint8(Property::TextVariableAnchor)},
|
||||
{"text-writing-mode", toUint8(Property::TextWritingMode)}});
|
||||
|
||||
constexpr uint8_t lastPaintPropertyIndex = toUint8(Property::TextTranslateAnchorTransition);
|
||||
} // namespace
|
||||
|
||||
optional<Error> SymbolLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
optional<Error> SymbolLayer::setProperty(const std::string& name, const Convertible& value) {
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second > lastPaintPropertyIndex) {
|
||||
if (it == layerProperties.end()) {
|
||||
if (name == "visibility") return setVisibility(value);
|
||||
return Error{"layer doesn't support this property"};
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::IconColor || property == Property::IconHaloColor || property == Property::TextColor || property == Property::TextHaloColor) {
|
||||
if (property == Property::IconColor || property == Property::IconHaloColor || property == Property::TextColor ||
|
||||
property == Property::TextHaloColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconColor) {
|
||||
setIconColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconHaloColor) {
|
||||
setIconHaloColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextColor) {
|
||||
setTextColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextHaloColor) {
|
||||
setTextHaloColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconHaloBlur || property == Property::IconHaloWidth || property == Property::IconOpacity || property == Property::TextHaloBlur || property == Property::TextHaloWidth || property == Property::TextOpacity) {
|
||||
if (property == Property::IconHaloBlur || property == Property::IconHaloWidth ||
|
||||
property == Property::IconOpacity || property == Property::TextHaloBlur ||
|
||||
property == Property::TextHaloWidth || property == Property::TextOpacity || property == Property::IconRotate ||
|
||||
property == Property::IconSize || property == Property::SymbolSortKey ||
|
||||
property == Property::TextLetterSpacing || property == Property::TextMaxWidth ||
|
||||
property == Property::TextRadialOffset || property == Property::TextRotate || property == Property::TextSize) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconHaloBlur) {
|
||||
setIconHaloBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconHaloWidth) {
|
||||
setIconHaloWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconOpacity) {
|
||||
setIconOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextHaloBlur) {
|
||||
setTextHaloBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextHaloWidth) {
|
||||
setTextHaloWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextOpacity) {
|
||||
setTextOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconRotate) {
|
||||
setIconRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconSize) {
|
||||
setIconSize(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::SymbolSortKey) {
|
||||
setSymbolSortKey(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextLetterSpacing) {
|
||||
setTextLetterSpacing(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextMaxWidth) {
|
||||
setTextMaxWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextRadialOffset) {
|
||||
setTextRadialOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextRotate) {
|
||||
setTextRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextSize) {
|
||||
setTextSize(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
if (property == Property::IconTranslate || property == Property::TextTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconTranslate) {
|
||||
setIconTranslate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextTranslate) {
|
||||
setTextTranslate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconTranslateAnchor || property == Property::TextTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue =
|
||||
convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
const auto& typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::IconTranslateAnchor) {
|
||||
setIconTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::TextTranslateAnchor) {
|
||||
setTextTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconAllowOverlap || property == Property::IconIgnorePlacement ||
|
||||
property == Property::IconKeepUpright || property == Property::IconOptional ||
|
||||
property == Property::SymbolAvoidEdges || property == Property::TextAllowOverlap ||
|
||||
property == Property::TextIgnorePlacement || property == Property::TextKeepUpright ||
|
||||
property == Property::TextOptional) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconAllowOverlap) {
|
||||
setIconAllowOverlap(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconIgnorePlacement) {
|
||||
setIconIgnorePlacement(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconKeepUpright) {
|
||||
setIconKeepUpright(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconOptional) {
|
||||
setIconOptional(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::SymbolAvoidEdges) {
|
||||
setSymbolAvoidEdges(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextAllowOverlap) {
|
||||
setTextAllowOverlap(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextIgnorePlacement) {
|
||||
setTextIgnorePlacement(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextKeepUpright) {
|
||||
setTextKeepUpright(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextOptional) {
|
||||
setTextOptional(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
if (property == Property::IconAnchor || property == Property::TextAnchor) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<SymbolAnchorType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconAnchor) {
|
||||
setIconAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextAnchor) {
|
||||
setTextAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
if (property == Property::IconImage) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<expression::Image>>(value, error, true, true);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setIconImage(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::IconOffset || property == Property::TextOffset) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconOffset) {
|
||||
setIconOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextOffset) {
|
||||
setTextOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
if (property == Property::IconPadding || property == Property::SymbolSpacing ||
|
||||
property == Property::TextLineHeight || property == Property::TextMaxAngle ||
|
||||
property == Property::TextPadding) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconPadding) {
|
||||
setIconPadding(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::SymbolSpacing) {
|
||||
setSymbolSpacing(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextLineHeight) {
|
||||
setTextLineHeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextMaxAngle) {
|
||||
setTextMaxAngle(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextPadding) {
|
||||
setTextPadding(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
if (property == Property::IconPitchAlignment || property == Property::IconRotationAlignment ||
|
||||
property == Property::TextPitchAlignment || property == Property::TextRotationAlignment) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconPitchAlignment) {
|
||||
setIconPitchAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconRotationAlignment) {
|
||||
setIconRotationAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextPitchAlignment) {
|
||||
setTextPitchAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextRotationAlignment) {
|
||||
setTextRotationAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
}
|
||||
if (property == Property::IconTextFit) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<IconTextFitType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setIconTextFit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::IconTextFitPadding) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<std::array<float, 4>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setIconTextFitPadding(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::SymbolPlacement) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<SymbolPlacementType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setSymbolPlacement(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::SymbolZOrder) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<SymbolZOrderType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setSymbolZOrder(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::TextField) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<expression::Formatted>>(value, error, true, true);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextField(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::TextFont) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<std::vector<std::string>>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextFont(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::TextJustify) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<TextJustifyType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextJustify(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::TextTransform) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<TextTransformType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextTransform(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::TextVariableAnchor) {
|
||||
Error error;
|
||||
const auto& typedValue =
|
||||
convert<PropertyValue<std::vector<TextVariableAnchorType>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextVariableAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (property == Property::TextWritingMode) {
|
||||
Error error;
|
||||
const auto& typedValue = convert<PropertyValue<std::vector<TextWritingModeType>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextWritingMode(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
@@ -1599,370 +1896,6 @@ StyleProperty SymbolLayer::getProperty(const std::string& name) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
optional<Error> SymbolLayer::setLayoutProperty(const std::string& name, const Convertible& value) {
|
||||
if (name == "visibility") {
|
||||
return Layer::setVisibility(value);
|
||||
}
|
||||
const auto it = layerProperties.find(name.c_str());
|
||||
if (it == layerProperties.end() || it->second <= lastPaintPropertyIndex) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
auto property = static_cast<Property>(it->second);
|
||||
|
||||
|
||||
if (property == Property::IconAllowOverlap || property == Property::IconIgnorePlacement || property == Property::IconKeepUpright || property == Property::IconOptional || property == Property::SymbolAvoidEdges || property == Property::TextAllowOverlap || property == Property::TextIgnorePlacement || property == Property::TextKeepUpright || property == Property::TextOptional) {
|
||||
Error error;
|
||||
optional<PropertyValue<bool>> typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconAllowOverlap) {
|
||||
setIconAllowOverlap(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconIgnorePlacement) {
|
||||
setIconIgnorePlacement(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconKeepUpright) {
|
||||
setIconKeepUpright(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconOptional) {
|
||||
setIconOptional(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::SymbolAvoidEdges) {
|
||||
setSymbolAvoidEdges(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextAllowOverlap) {
|
||||
setTextAllowOverlap(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextIgnorePlacement) {
|
||||
setTextIgnorePlacement(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextKeepUpright) {
|
||||
setTextKeepUpright(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextOptional) {
|
||||
setTextOptional(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconAnchor || property == Property::TextAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<SymbolAnchorType>> typedValue =
|
||||
convert<PropertyValue<SymbolAnchorType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconAnchor) {
|
||||
setIconAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextAnchor) {
|
||||
setTextAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconImage) {
|
||||
Error error;
|
||||
optional<PropertyValue<expression::Image>> typedValue =
|
||||
convert<PropertyValue<expression::Image>>(value, error, true, true);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setIconImage(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconOffset || property == Property::TextOffset) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 2>>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconOffset) {
|
||||
setIconOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextOffset) {
|
||||
setTextOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconPadding || property == Property::SymbolSpacing || property == Property::TextLineHeight || property == Property::TextMaxAngle || property == Property::TextPadding) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconPadding) {
|
||||
setIconPadding(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::SymbolSpacing) {
|
||||
setSymbolSpacing(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextLineHeight) {
|
||||
setTextLineHeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextMaxAngle) {
|
||||
setTextMaxAngle(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextPadding) {
|
||||
setTextPadding(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconPitchAlignment || property == Property::IconRotationAlignment || property == Property::TextPitchAlignment || property == Property::TextRotationAlignment) {
|
||||
Error error;
|
||||
optional<PropertyValue<AlignmentType>> typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconPitchAlignment) {
|
||||
setIconPitchAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconRotationAlignment) {
|
||||
setIconRotationAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextPitchAlignment) {
|
||||
setTextPitchAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextRotationAlignment) {
|
||||
setTextRotationAlignment(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconRotate || property == Property::IconSize || property == Property::SymbolSortKey || property == Property::TextLetterSpacing || property == Property::TextMaxWidth || property == Property::TextRadialOffset || property == Property::TextRotate || property == Property::TextSize) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::IconRotate) {
|
||||
setIconRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::IconSize) {
|
||||
setIconSize(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::SymbolSortKey) {
|
||||
setSymbolSortKey(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextLetterSpacing) {
|
||||
setTextLetterSpacing(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextMaxWidth) {
|
||||
setTextMaxWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextRadialOffset) {
|
||||
setTextRadialOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextRotate) {
|
||||
setTextRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::TextSize) {
|
||||
setTextSize(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconTextFit) {
|
||||
Error error;
|
||||
optional<PropertyValue<IconTextFitType>> typedValue =
|
||||
convert<PropertyValue<IconTextFitType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setIconTextFit(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::IconTextFitPadding) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 4>>> typedValue =
|
||||
convert<PropertyValue<std::array<float, 4>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setIconTextFitPadding(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::SymbolPlacement) {
|
||||
Error error;
|
||||
optional<PropertyValue<SymbolPlacementType>> typedValue =
|
||||
convert<PropertyValue<SymbolPlacementType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setSymbolPlacement(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::SymbolZOrder) {
|
||||
Error error;
|
||||
optional<PropertyValue<SymbolZOrderType>> typedValue =
|
||||
convert<PropertyValue<SymbolZOrderType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setSymbolZOrder(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::TextField) {
|
||||
Error error;
|
||||
optional<PropertyValue<expression::Formatted>> typedValue =
|
||||
convert<PropertyValue<expression::Formatted>>(value, error, true, true);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextField(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::TextFont) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::vector<std::string>>> typedValue =
|
||||
convert<PropertyValue<std::vector<std::string>>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextFont(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::TextJustify) {
|
||||
Error error;
|
||||
optional<PropertyValue<TextJustifyType>> typedValue = convert<PropertyValue<TextJustifyType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextJustify(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::TextTransform) {
|
||||
Error error;
|
||||
optional<PropertyValue<TextTransformType>> typedValue =
|
||||
convert<PropertyValue<TextTransformType>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextTransform(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::TextVariableAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::vector<TextVariableAnchorType>>> typedValue =
|
||||
convert<PropertyValue<std::vector<TextVariableAnchorType>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextVariableAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::TextWritingMode) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::vector<TextWritingModeType>>> typedValue =
|
||||
convert<PropertyValue<std::vector<TextWritingModeType>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setTextWritingMode(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user