[core] Optimize generated set{Paint,Layout}Property code
This commit is contained in:
@@ -707,6 +707,7 @@ set(MBGL_CORE_FILES
|
||||
src/mbgl/util/dtoa.cpp
|
||||
src/mbgl/util/dtoa.hpp
|
||||
src/mbgl/util/event.cpp
|
||||
src/mbgl/util/fnv_hash.hpp
|
||||
src/mbgl/util/font_stack.cpp
|
||||
src/mbgl/util/geo.cpp
|
||||
src/mbgl/util/geojson_impl.cpp
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -158,70 +159,115 @@ TransitionOptions BackgroundLayer::getBackgroundOpacityTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> BackgroundLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
BackgroundColor,
|
||||
BackgroundPattern,
|
||||
BackgroundOpacity,
|
||||
BackgroundColorTransition,
|
||||
BackgroundPatternTransition,
|
||||
BackgroundOpacityTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("background-color"):
|
||||
if (name == "background-color") {
|
||||
property = Property::BackgroundColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("background-color-transition"):
|
||||
if (name == "background-color-transition") {
|
||||
property = Property::BackgroundColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("background-pattern"):
|
||||
if (name == "background-pattern") {
|
||||
property = Property::BackgroundPattern;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("background-pattern-transition"):
|
||||
if (name == "background-pattern-transition") {
|
||||
property = Property::BackgroundPatternTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("background-opacity"):
|
||||
if (name == "background-opacity") {
|
||||
property = Property::BackgroundOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("background-opacity-transition"):
|
||||
if (name == "background-opacity-transition") {
|
||||
property = Property::BackgroundOpacityTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "background-color") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::BackgroundColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setBackgroundColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "background-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setBackgroundColorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "background-pattern") {
|
||||
if (property == Property::BackgroundPattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::string>> typedValue = convert<PropertyValue<std::string>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setBackgroundPattern(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "background-pattern-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setBackgroundPatternTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "background-opacity") {
|
||||
if (property == Property::BackgroundOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setBackgroundOpacity(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "background-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::BackgroundColorTransition) {
|
||||
setBackgroundColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::BackgroundPatternTransition) {
|
||||
setBackgroundPatternTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::BackgroundOpacityTransition) {
|
||||
setBackgroundOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -242,7 +288,21 @@ optional<Error> BackgroundLayer::setLayoutProperty(const std::string& name, cons
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -402,238 +403,316 @@ TransitionOptions CircleLayer::getCircleStrokeOpacityTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> CircleLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
CircleRadius,
|
||||
CircleColor,
|
||||
CircleBlur,
|
||||
CircleOpacity,
|
||||
CircleTranslate,
|
||||
CircleTranslateAnchor,
|
||||
CirclePitchScale,
|
||||
CirclePitchAlignment,
|
||||
CircleStrokeWidth,
|
||||
CircleStrokeColor,
|
||||
CircleStrokeOpacity,
|
||||
CircleRadiusTransition,
|
||||
CircleColorTransition,
|
||||
CircleBlurTransition,
|
||||
CircleOpacityTransition,
|
||||
CircleTranslateTransition,
|
||||
CircleTranslateAnchorTransition,
|
||||
CirclePitchScaleTransition,
|
||||
CirclePitchAlignmentTransition,
|
||||
CircleStrokeWidthTransition,
|
||||
CircleStrokeColorTransition,
|
||||
CircleStrokeOpacityTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("circle-radius"):
|
||||
if (name == "circle-radius") {
|
||||
property = Property::CircleRadius;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-radius-transition"):
|
||||
if (name == "circle-radius-transition") {
|
||||
property = Property::CircleRadiusTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-color"):
|
||||
if (name == "circle-color") {
|
||||
property = Property::CircleColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-color-transition"):
|
||||
if (name == "circle-color-transition") {
|
||||
property = Property::CircleColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-blur"):
|
||||
if (name == "circle-blur") {
|
||||
property = Property::CircleBlur;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-blur-transition"):
|
||||
if (name == "circle-blur-transition") {
|
||||
property = Property::CircleBlurTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-opacity"):
|
||||
if (name == "circle-opacity") {
|
||||
property = Property::CircleOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-opacity-transition"):
|
||||
if (name == "circle-opacity-transition") {
|
||||
property = Property::CircleOpacityTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-translate"):
|
||||
if (name == "circle-translate") {
|
||||
property = Property::CircleTranslate;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-translate-transition"):
|
||||
if (name == "circle-translate-transition") {
|
||||
property = Property::CircleTranslateTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-translate-anchor"):
|
||||
if (name == "circle-translate-anchor") {
|
||||
property = Property::CircleTranslateAnchor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-translate-anchor-transition"):
|
||||
if (name == "circle-translate-anchor-transition") {
|
||||
property = Property::CircleTranslateAnchorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-pitch-scale"):
|
||||
if (name == "circle-pitch-scale") {
|
||||
property = Property::CirclePitchScale;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-pitch-scale-transition"):
|
||||
if (name == "circle-pitch-scale-transition") {
|
||||
property = Property::CirclePitchScaleTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-pitch-alignment"):
|
||||
if (name == "circle-pitch-alignment") {
|
||||
property = Property::CirclePitchAlignment;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-pitch-alignment-transition"):
|
||||
if (name == "circle-pitch-alignment-transition") {
|
||||
property = Property::CirclePitchAlignmentTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-stroke-width"):
|
||||
if (name == "circle-stroke-width") {
|
||||
property = Property::CircleStrokeWidth;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-stroke-width-transition"):
|
||||
if (name == "circle-stroke-width-transition") {
|
||||
property = Property::CircleStrokeWidthTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-stroke-color"):
|
||||
if (name == "circle-stroke-color") {
|
||||
property = Property::CircleStrokeColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-stroke-color-transition"):
|
||||
if (name == "circle-stroke-color-transition") {
|
||||
property = Property::CircleStrokeColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-stroke-opacity"):
|
||||
if (name == "circle-stroke-opacity") {
|
||||
property = Property::CircleStrokeOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("circle-stroke-opacity-transition"):
|
||||
if (name == "circle-stroke-opacity-transition") {
|
||||
property = Property::CircleStrokeOpacityTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "circle-radius") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::CircleRadius || property == Property::CircleBlur || property == Property::CircleOpacity || property == Property::CircleStrokeWidth || property == Property::CircleStrokeOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleRadius(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-radius-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::CircleRadius) {
|
||||
setCircleRadius(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setCircleRadiusTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::CircleBlur) {
|
||||
setCircleBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleOpacity) {
|
||||
setCircleOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleStrokeWidth) {
|
||||
setCircleStrokeWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleStrokeOpacity) {
|
||||
setCircleStrokeOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "circle-color") {
|
||||
if (property == Property::CircleColor || property == Property::CircleStrokeColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::CircleColor) {
|
||||
setCircleColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setCircleColorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::CircleStrokeColor) {
|
||||
setCircleStrokeColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "circle-blur") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-blur-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleBlurTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "circle-opacity") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "circle-translate") {
|
||||
if (property == Property::CircleTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCircleTranslate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-translate-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "circle-translate-anchor") {
|
||||
if (property == Property::CircleTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCircleTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-translate-anchor-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "circle-pitch-scale") {
|
||||
if (property == Property::CirclePitchScale) {
|
||||
Error error;
|
||||
optional<PropertyValue<CirclePitchScaleType>> typedValue = convert<PropertyValue<CirclePitchScaleType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCirclePitchScale(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-pitch-scale-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCirclePitchScaleTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "circle-pitch-alignment") {
|
||||
if (property == Property::CirclePitchAlignment) {
|
||||
Error error;
|
||||
optional<PropertyValue<AlignmentType>> typedValue = convert<PropertyValue<AlignmentType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setCirclePitchAlignment(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "circle-pitch-alignment-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::CircleRadiusTransition) {
|
||||
setCircleRadiusTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleColorTransition) {
|
||||
setCircleColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleBlurTransition) {
|
||||
setCircleBlurTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleOpacityTransition) {
|
||||
setCircleOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleTranslateTransition) {
|
||||
setCircleTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CircleTranslateAnchorTransition) {
|
||||
setCircleTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CirclePitchScaleTransition) {
|
||||
setCirclePitchScaleTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::CirclePitchAlignmentTransition) {
|
||||
setCirclePitchAlignmentTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "circle-stroke-width") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleStrokeWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-stroke-width-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::CircleStrokeWidthTransition) {
|
||||
setCircleStrokeWidthTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "circle-stroke-color") {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleStrokeColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-stroke-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::CircleStrokeColorTransition) {
|
||||
setCircleStrokeColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "circle-stroke-opacity") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setCircleStrokeOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "circle-stroke-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::CircleStrokeOpacityTransition) {
|
||||
setCircleStrokeOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -654,7 +733,21 @@ optional<Error> CircleLayer::setLayoutProperty(const std::string& name, const Co
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -294,154 +295,226 @@ TransitionOptions FillExtrusionLayer::getFillExtrusionBaseTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> FillExtrusionLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
FillExtrusionOpacity,
|
||||
FillExtrusionColor,
|
||||
FillExtrusionTranslate,
|
||||
FillExtrusionTranslateAnchor,
|
||||
FillExtrusionPattern,
|
||||
FillExtrusionHeight,
|
||||
FillExtrusionBase,
|
||||
FillExtrusionOpacityTransition,
|
||||
FillExtrusionColorTransition,
|
||||
FillExtrusionTranslateTransition,
|
||||
FillExtrusionTranslateAnchorTransition,
|
||||
FillExtrusionPatternTransition,
|
||||
FillExtrusionHeightTransition,
|
||||
FillExtrusionBaseTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("fill-extrusion-opacity"):
|
||||
if (name == "fill-extrusion-opacity") {
|
||||
property = Property::FillExtrusionOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-opacity-transition"):
|
||||
if (name == "fill-extrusion-opacity-transition") {
|
||||
property = Property::FillExtrusionOpacityTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-color"):
|
||||
if (name == "fill-extrusion-color") {
|
||||
property = Property::FillExtrusionColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-color-transition"):
|
||||
if (name == "fill-extrusion-color-transition") {
|
||||
property = Property::FillExtrusionColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-translate"):
|
||||
if (name == "fill-extrusion-translate") {
|
||||
property = Property::FillExtrusionTranslate;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-translate-transition"):
|
||||
if (name == "fill-extrusion-translate-transition") {
|
||||
property = Property::FillExtrusionTranslateTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-translate-anchor"):
|
||||
if (name == "fill-extrusion-translate-anchor") {
|
||||
property = Property::FillExtrusionTranslateAnchor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-translate-anchor-transition"):
|
||||
if (name == "fill-extrusion-translate-anchor-transition") {
|
||||
property = Property::FillExtrusionTranslateAnchorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-pattern"):
|
||||
if (name == "fill-extrusion-pattern") {
|
||||
property = Property::FillExtrusionPattern;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-pattern-transition"):
|
||||
if (name == "fill-extrusion-pattern-transition") {
|
||||
property = Property::FillExtrusionPatternTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-height"):
|
||||
if (name == "fill-extrusion-height") {
|
||||
property = Property::FillExtrusionHeight;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-height-transition"):
|
||||
if (name == "fill-extrusion-height-transition") {
|
||||
property = Property::FillExtrusionHeightTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-base"):
|
||||
if (name == "fill-extrusion-base") {
|
||||
property = Property::FillExtrusionBase;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-extrusion-base-transition"):
|
||||
if (name == "fill-extrusion-base-transition") {
|
||||
property = Property::FillExtrusionBaseTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "fill-extrusion-opacity") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::FillExtrusionOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-extrusion-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillExtrusionOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-extrusion-color") {
|
||||
if (property == Property::FillExtrusionColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-extrusion-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillExtrusionColorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-extrusion-translate") {
|
||||
if (property == Property::FillExtrusionTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionTranslate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-extrusion-translate-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillExtrusionTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-extrusion-translate-anchor") {
|
||||
if (property == Property::FillExtrusionTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-extrusion-translate-anchor-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillExtrusionTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-extrusion-pattern") {
|
||||
if (property == Property::FillExtrusionPattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::string>> typedValue = convert<PropertyValue<std::string>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillExtrusionPattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "fill-extrusion-pattern-transition") {
|
||||
|
||||
if (property == Property::FillExtrusionHeight || property == Property::FillExtrusionBase) {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionHeight) {
|
||||
setFillExtrusionHeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionBase) {
|
||||
setFillExtrusionBase(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionOpacityTransition) {
|
||||
setFillExtrusionOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionColorTransition) {
|
||||
setFillExtrusionColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionTranslateTransition) {
|
||||
setFillExtrusionTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionTranslateAnchorTransition) {
|
||||
setFillExtrusionTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionPatternTransition) {
|
||||
setFillExtrusionPatternTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "fill-extrusion-height") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillExtrusionHeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-extrusion-height-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionHeightTransition) {
|
||||
setFillExtrusionHeightTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "fill-extrusion-base") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillExtrusionBase(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-extrusion-base-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::FillExtrusionBaseTransition) {
|
||||
setFillExtrusionBaseTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -462,7 +535,21 @@ optional<Error> FillExtrusionLayer::setLayoutProperty(const std::string& name, c
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -294,154 +295,226 @@ TransitionOptions FillLayer::getFillPatternTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> FillLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
FillAntialias,
|
||||
FillOpacity,
|
||||
FillColor,
|
||||
FillOutlineColor,
|
||||
FillTranslate,
|
||||
FillTranslateAnchor,
|
||||
FillPattern,
|
||||
FillAntialiasTransition,
|
||||
FillOpacityTransition,
|
||||
FillColorTransition,
|
||||
FillOutlineColorTransition,
|
||||
FillTranslateTransition,
|
||||
FillTranslateAnchorTransition,
|
||||
FillPatternTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("fill-antialias"):
|
||||
if (name == "fill-antialias") {
|
||||
property = Property::FillAntialias;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-antialias-transition"):
|
||||
if (name == "fill-antialias-transition") {
|
||||
property = Property::FillAntialiasTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-opacity"):
|
||||
if (name == "fill-opacity") {
|
||||
property = Property::FillOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-opacity-transition"):
|
||||
if (name == "fill-opacity-transition") {
|
||||
property = Property::FillOpacityTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-color"):
|
||||
if (name == "fill-color") {
|
||||
property = Property::FillColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-color-transition"):
|
||||
if (name == "fill-color-transition") {
|
||||
property = Property::FillColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-outline-color"):
|
||||
if (name == "fill-outline-color") {
|
||||
property = Property::FillOutlineColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-outline-color-transition"):
|
||||
if (name == "fill-outline-color-transition") {
|
||||
property = Property::FillOutlineColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-translate"):
|
||||
if (name == "fill-translate") {
|
||||
property = Property::FillTranslate;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-translate-transition"):
|
||||
if (name == "fill-translate-transition") {
|
||||
property = Property::FillTranslateTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-translate-anchor"):
|
||||
if (name == "fill-translate-anchor") {
|
||||
property = Property::FillTranslateAnchor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-translate-anchor-transition"):
|
||||
if (name == "fill-translate-anchor-transition") {
|
||||
property = Property::FillTranslateAnchorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-pattern"):
|
||||
if (name == "fill-pattern") {
|
||||
property = Property::FillPattern;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("fill-pattern-transition"):
|
||||
if (name == "fill-pattern-transition") {
|
||||
property = Property::FillPatternTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "fill-antialias") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::FillAntialias) {
|
||||
Error error;
|
||||
optional<PropertyValue<bool>> typedValue = convert<PropertyValue<bool>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillAntialias(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-antialias-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillAntialiasTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-opacity") {
|
||||
if (property == Property::FillOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-color") {
|
||||
if (property == Property::FillColor || property == Property::FillOutlineColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::FillColor) {
|
||||
setFillColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setFillColorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::FillOutlineColor) {
|
||||
setFillOutlineColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-outline-color") {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillOutlineColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-outline-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillOutlineColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "fill-translate") {
|
||||
if (property == Property::FillTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillTranslate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-translate-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-translate-anchor") {
|
||||
if (property == Property::FillTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "fill-translate-anchor-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setFillTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "fill-pattern") {
|
||||
if (property == Property::FillPattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::string>> typedValue = convert<PropertyValue<std::string>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setFillPattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "fill-pattern-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::FillAntialiasTransition) {
|
||||
setFillAntialiasTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillOpacityTransition) {
|
||||
setFillOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillColorTransition) {
|
||||
setFillColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillOutlineColorTransition) {
|
||||
setFillOutlineColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillTranslateTransition) {
|
||||
setFillTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillTranslateAnchorTransition) {
|
||||
setFillTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::FillPatternTransition) {
|
||||
setFillPatternTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -462,7 +535,21 @@ optional<Error> FillLayer::setLayoutProperty(const std::string& name, const Conv
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -242,112 +243,163 @@ TransitionOptions HeatmapLayer::getHeatmapOpacityTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> HeatmapLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
HeatmapRadius,
|
||||
HeatmapWeight,
|
||||
HeatmapIntensity,
|
||||
HeatmapColor,
|
||||
HeatmapOpacity,
|
||||
HeatmapRadiusTransition,
|
||||
HeatmapWeightTransition,
|
||||
HeatmapIntensityTransition,
|
||||
HeatmapColorTransition,
|
||||
HeatmapOpacityTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("heatmap-radius"):
|
||||
if (name == "heatmap-radius") {
|
||||
property = Property::HeatmapRadius;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-radius-transition"):
|
||||
if (name == "heatmap-radius-transition") {
|
||||
property = Property::HeatmapRadiusTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-weight"):
|
||||
if (name == "heatmap-weight") {
|
||||
property = Property::HeatmapWeight;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-weight-transition"):
|
||||
if (name == "heatmap-weight-transition") {
|
||||
property = Property::HeatmapWeightTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-intensity"):
|
||||
if (name == "heatmap-intensity") {
|
||||
property = Property::HeatmapIntensity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-intensity-transition"):
|
||||
if (name == "heatmap-intensity-transition") {
|
||||
property = Property::HeatmapIntensityTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-color"):
|
||||
if (name == "heatmap-color") {
|
||||
property = Property::HeatmapColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-color-transition"):
|
||||
if (name == "heatmap-color-transition") {
|
||||
property = Property::HeatmapColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-opacity"):
|
||||
if (name == "heatmap-opacity") {
|
||||
property = Property::HeatmapOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("heatmap-opacity-transition"):
|
||||
if (name == "heatmap-opacity-transition") {
|
||||
property = Property::HeatmapOpacityTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "heatmap-radius") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HeatmapRadius || property == Property::HeatmapWeight) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHeatmapRadius(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "heatmap-radius-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::HeatmapRadius) {
|
||||
setHeatmapRadius(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setHeatmapRadiusTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::HeatmapWeight) {
|
||||
setHeatmapWeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "heatmap-weight") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHeatmapWeight(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "heatmap-weight-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHeatmapWeightTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "heatmap-intensity") {
|
||||
if (property == Property::HeatmapIntensity || property == Property::HeatmapOpacity) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHeatmapIntensity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "heatmap-intensity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::HeatmapIntensity) {
|
||||
setHeatmapIntensity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setHeatmapIntensityTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::HeatmapOpacity) {
|
||||
setHeatmapOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "heatmap-color") {
|
||||
if (property == Property::HeatmapColor) {
|
||||
Error error;
|
||||
optional<ColorRampPropertyValue> typedValue = convert<ColorRampPropertyValue>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setHeatmapColor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "heatmap-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapRadiusTransition) {
|
||||
setHeatmapRadiusTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapWeightTransition) {
|
||||
setHeatmapWeightTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapIntensityTransition) {
|
||||
setHeatmapIntensityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapColorTransition) {
|
||||
setHeatmapColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "heatmap-opacity") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHeatmapOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "heatmap-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HeatmapOpacityTransition) {
|
||||
setHeatmapOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -368,7 +420,21 @@ optional<Error> HeatmapLayer::setLayoutProperty(const std::string& name, const C
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ struct HeatmapIntensity : PaintProperty<float> {
|
||||
static float defaultValue() { return 1; }
|
||||
};
|
||||
|
||||
using HeatmapColor = ColorRampProperty;
|
||||
struct HeatmapColor : ColorRampProperty {
|
||||
};
|
||||
|
||||
struct HeatmapOpacity : PaintProperty<float> {
|
||||
static float defaultValue() { return 1; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -245,133 +246,185 @@ TransitionOptions HillshadeLayer::getHillshadeAccentColorTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> HillshadeLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
HillshadeIlluminationDirection,
|
||||
HillshadeIlluminationAnchor,
|
||||
HillshadeExaggeration,
|
||||
HillshadeShadowColor,
|
||||
HillshadeHighlightColor,
|
||||
HillshadeAccentColor,
|
||||
HillshadeIlluminationDirectionTransition,
|
||||
HillshadeIlluminationAnchorTransition,
|
||||
HillshadeExaggerationTransition,
|
||||
HillshadeShadowColorTransition,
|
||||
HillshadeHighlightColorTransition,
|
||||
HillshadeAccentColorTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("hillshade-illumination-direction"):
|
||||
if (name == "hillshade-illumination-direction") {
|
||||
property = Property::HillshadeIlluminationDirection;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-illumination-direction-transition"):
|
||||
if (name == "hillshade-illumination-direction-transition") {
|
||||
property = Property::HillshadeIlluminationDirectionTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-illumination-anchor"):
|
||||
if (name == "hillshade-illumination-anchor") {
|
||||
property = Property::HillshadeIlluminationAnchor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-illumination-anchor-transition"):
|
||||
if (name == "hillshade-illumination-anchor-transition") {
|
||||
property = Property::HillshadeIlluminationAnchorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-exaggeration"):
|
||||
if (name == "hillshade-exaggeration") {
|
||||
property = Property::HillshadeExaggeration;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-exaggeration-transition"):
|
||||
if (name == "hillshade-exaggeration-transition") {
|
||||
property = Property::HillshadeExaggerationTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-shadow-color"):
|
||||
if (name == "hillshade-shadow-color") {
|
||||
property = Property::HillshadeShadowColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-shadow-color-transition"):
|
||||
if (name == "hillshade-shadow-color-transition") {
|
||||
property = Property::HillshadeShadowColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-highlight-color"):
|
||||
if (name == "hillshade-highlight-color") {
|
||||
property = Property::HillshadeHighlightColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-highlight-color-transition"):
|
||||
if (name == "hillshade-highlight-color-transition") {
|
||||
property = Property::HillshadeHighlightColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-accent-color"):
|
||||
if (name == "hillshade-accent-color") {
|
||||
property = Property::HillshadeAccentColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("hillshade-accent-color-transition"):
|
||||
if (name == "hillshade-accent-color-transition") {
|
||||
property = Property::HillshadeAccentColorTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "hillshade-illumination-direction") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::HillshadeIlluminationDirection || property == Property::HillshadeExaggeration) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHillshadeIlluminationDirection(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "hillshade-illumination-direction-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::HillshadeIlluminationDirection) {
|
||||
setHillshadeIlluminationDirection(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setHillshadeIlluminationDirectionTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::HillshadeExaggeration) {
|
||||
setHillshadeExaggeration(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "hillshade-illumination-anchor") {
|
||||
if (property == Property::HillshadeIlluminationAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<HillshadeIlluminationAnchorType>> typedValue = convert<PropertyValue<HillshadeIlluminationAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setHillshadeIlluminationAnchor(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "hillshade-illumination-anchor-transition") {
|
||||
|
||||
if (property == Property::HillshadeShadowColor || property == Property::HillshadeHighlightColor || property == Property::HillshadeAccentColor) {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeShadowColor) {
|
||||
setHillshadeShadowColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeHighlightColor) {
|
||||
setHillshadeHighlightColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeAccentColor) {
|
||||
setHillshadeAccentColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeIlluminationDirectionTransition) {
|
||||
setHillshadeIlluminationDirectionTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeIlluminationAnchorTransition) {
|
||||
setHillshadeIlluminationAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "hillshade-exaggeration") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHillshadeExaggeration(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "hillshade-exaggeration-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeExaggerationTransition) {
|
||||
setHillshadeExaggerationTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "hillshade-shadow-color") {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHillshadeShadowColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "hillshade-shadow-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeShadowColorTransition) {
|
||||
setHillshadeShadowColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "hillshade-highlight-color") {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHillshadeHighlightColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "hillshade-highlight-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeHighlightColorTransition) {
|
||||
setHillshadeHighlightColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "hillshade-accent-color") {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setHillshadeAccentColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "hillshade-accent-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::HillshadeAccentColorTransition) {
|
||||
setHillshadeAccentColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -392,7 +445,21 @@ optional<Error> HillshadeLayer::setLayoutProperty(const std::string& name, const
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -178,28 +179,78 @@ TransitionOptions <%- camelize(type) %>Layer::get<%- camelize(property.name) %>T
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> <%- camelize(type) %>Layer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
<% for (const property of paintProperties) { %>
|
||||
if (name == "<%- property.name %>") {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
<% for (const property of paintProperties) { -%>
|
||||
<%- camelize(property.name) %>,
|
||||
<% } -%>
|
||||
<% for (const property of paintProperties) { -%>
|
||||
<%- camelize(property.name) %>Transition,
|
||||
<% } -%>
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
<% for (const property of paintProperties) { -%>
|
||||
case util::hashFNV1a("<%- property.name %>"):
|
||||
if (name == "<%- property.name %>") {
|
||||
property = Property::<%- camelize(property.name) %>;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("<%- property.name %>-transition"):
|
||||
if (name == "<%- property.name %>-transition") {
|
||||
property = Property::<%- camelize(property.name) %>Transition;
|
||||
}
|
||||
break;
|
||||
<% } %>
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
<%
|
||||
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(' || ') %>) {
|
||||
Error error;
|
||||
optional<<%- propertyValueType(property) %>> typedValue = convert<<%- propertyValueType(property) %>>(value, error, <%- property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven' %>, <%- property.name === 'icon-image' || property.name === 'text-field' %>);
|
||||
<%- key %>;
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
set<%- camelize(property.name) %>(*typedValue);
|
||||
<% if (properties.length == 1) { %>
|
||||
set<%- camelize(properties[0].name) %>(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "<%- property.name %>-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
<% } 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) {
|
||||
return error;
|
||||
}
|
||||
<% for (const property of paintProperties) { %>
|
||||
if (property == Property::<%- camelize(property.name) %>Transition) {
|
||||
set<%- camelize(property.name) %>Transition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
<% } -%>
|
||||
<% } %>
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
@@ -221,18 +272,58 @@ optional<Error> <%- camelize(type) %>Layer::setLayoutProperty(const std::string&
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
<% for (const property of layoutProperties) { -%>
|
||||
<%- camelize(property.name) %>,
|
||||
<% } -%>
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
<% for (const property of layoutProperties) { %>
|
||||
if (name == "<%- property.name %>") {
|
||||
case util::hashFNV1a("<%- property.name %>"):
|
||||
if (name == "<%- property.name %>") {
|
||||
property = Property::<%- camelize(property.name) %>;
|
||||
}
|
||||
break;
|
||||
<% } %>
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
<%
|
||||
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;
|
||||
optional<<%- propertyValueType(property) %>> typedValue = convert<<%- propertyValueType(property) %>>(value, error, <%- property['property-type'] === 'data-driven' || property['property-type'] === 'cross-faded-data-driven' %>, <%- property.name === 'icon-image' || property.name === 'text-field' %>);
|
||||
<%- key %>;
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
set<%- camelize(property.name) %>(*typedValue);
|
||||
<% 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;
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
<% } -%>
|
||||
<% } %>
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ struct <%- camelize(property.name) %> : <%- layoutPropertyType(property, type) %
|
||||
<% } -%>
|
||||
<% for (const property of paintProperties) { -%>
|
||||
<% if (property['property-type'] === 'color-ramp') { -%>
|
||||
using <%- camelize(property.name) %> = ColorRampProperty;
|
||||
struct <%- camelize(property.name) %> : ColorRampProperty {
|
||||
};
|
||||
<% } else { -%>
|
||||
struct <%- camelize(property.name) %> : <%- paintPropertyType(property, type) %> {
|
||||
static <%- evaluatedType(property) %> defaultValue() { return <%- defaultValue(property) %>; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -440,217 +441,292 @@ TransitionOptions LineLayer::getLinePatternTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> LineLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
LineOpacity,
|
||||
LineColor,
|
||||
LineTranslate,
|
||||
LineTranslateAnchor,
|
||||
LineWidth,
|
||||
LineGapWidth,
|
||||
LineOffset,
|
||||
LineBlur,
|
||||
LineDasharray,
|
||||
LinePattern,
|
||||
LineOpacityTransition,
|
||||
LineColorTransition,
|
||||
LineTranslateTransition,
|
||||
LineTranslateAnchorTransition,
|
||||
LineWidthTransition,
|
||||
LineGapWidthTransition,
|
||||
LineOffsetTransition,
|
||||
LineBlurTransition,
|
||||
LineDasharrayTransition,
|
||||
LinePatternTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("line-opacity"):
|
||||
if (name == "line-opacity") {
|
||||
property = Property::LineOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-opacity-transition"):
|
||||
if (name == "line-opacity-transition") {
|
||||
property = Property::LineOpacityTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-color"):
|
||||
if (name == "line-color") {
|
||||
property = Property::LineColor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-color-transition"):
|
||||
if (name == "line-color-transition") {
|
||||
property = Property::LineColorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-translate"):
|
||||
if (name == "line-translate") {
|
||||
property = Property::LineTranslate;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-translate-transition"):
|
||||
if (name == "line-translate-transition") {
|
||||
property = Property::LineTranslateTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-translate-anchor"):
|
||||
if (name == "line-translate-anchor") {
|
||||
property = Property::LineTranslateAnchor;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-translate-anchor-transition"):
|
||||
if (name == "line-translate-anchor-transition") {
|
||||
property = Property::LineTranslateAnchorTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-width"):
|
||||
if (name == "line-width") {
|
||||
property = Property::LineWidth;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-width-transition"):
|
||||
if (name == "line-width-transition") {
|
||||
property = Property::LineWidthTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-gap-width"):
|
||||
if (name == "line-gap-width") {
|
||||
property = Property::LineGapWidth;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-gap-width-transition"):
|
||||
if (name == "line-gap-width-transition") {
|
||||
property = Property::LineGapWidthTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-offset"):
|
||||
if (name == "line-offset") {
|
||||
property = Property::LineOffset;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-offset-transition"):
|
||||
if (name == "line-offset-transition") {
|
||||
property = Property::LineOffsetTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-blur"):
|
||||
if (name == "line-blur") {
|
||||
property = Property::LineBlur;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-blur-transition"):
|
||||
if (name == "line-blur-transition") {
|
||||
property = Property::LineBlurTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-dasharray"):
|
||||
if (name == "line-dasharray") {
|
||||
property = Property::LineDasharray;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-dasharray-transition"):
|
||||
if (name == "line-dasharray-transition") {
|
||||
property = Property::LineDasharrayTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-pattern"):
|
||||
if (name == "line-pattern") {
|
||||
property = Property::LinePattern;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("line-pattern-transition"):
|
||||
if (name == "line-pattern-transition") {
|
||||
property = Property::LinePatternTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "line-opacity") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::LineOpacity || property == Property::LineWidth || property == Property::LineGapWidth || property == Property::LineOffset || property == Property::LineBlur) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::LineOpacity) {
|
||||
setLineOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setLineOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::LineWidth) {
|
||||
setLineWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineGapWidth) {
|
||||
setLineGapWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineOffset) {
|
||||
setLineOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineBlur) {
|
||||
setLineBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "line-color") {
|
||||
if (property == Property::LineColor) {
|
||||
Error error;
|
||||
optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineColor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-color-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineColorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "line-translate") {
|
||||
if (property == Property::LineTranslate) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::array<float, 2>>> typedValue = convert<PropertyValue<std::array<float, 2>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineTranslate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-translate-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "line-translate-anchor") {
|
||||
if (property == Property::LineTranslateAnchor) {
|
||||
Error error;
|
||||
optional<PropertyValue<TranslateAnchorType>> typedValue = convert<PropertyValue<TranslateAnchorType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineTranslateAnchor(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-translate-anchor-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "line-width") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-width-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineWidthTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "line-gap-width") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineGapWidth(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-gap-width-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineGapWidthTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "line-offset") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineOffset(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-offset-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineOffsetTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "line-blur") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, true, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineBlur(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-blur-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineBlurTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "line-dasharray") {
|
||||
if (property == Property::LineDasharray) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::vector<float>>> typedValue = convert<PropertyValue<std::vector<float>>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLineDasharray(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "line-dasharray-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineDasharrayTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
|
||||
if (name == "line-pattern") {
|
||||
if (property == Property::LinePattern) {
|
||||
Error error;
|
||||
optional<PropertyValue<std::string>> typedValue = convert<PropertyValue<std::string>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setLinePattern(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "line-pattern-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::LineOpacityTransition) {
|
||||
setLineOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineColorTransition) {
|
||||
setLineColorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineTranslateTransition) {
|
||||
setLineTranslateTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineTranslateAnchorTransition) {
|
||||
setLineTranslateAnchorTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineWidthTransition) {
|
||||
setLineWidthTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineGapWidthTransition) {
|
||||
setLineGapWidthTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineOffsetTransition) {
|
||||
setLineOffsetTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineBlurTransition) {
|
||||
setLineBlurTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LineDasharrayTransition) {
|
||||
setLineDasharrayTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::LinePatternTransition) {
|
||||
setLinePatternTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -671,51 +747,92 @@ optional<Error> LineLayer::setLayoutProperty(const std::string& name, const Conv
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
LineCap,
|
||||
LineJoin,
|
||||
LineMiterLimit,
|
||||
LineRoundLimit,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
if (name == "line-cap") {
|
||||
case util::hashFNV1a("line-cap"):
|
||||
if (name == "line-cap") {
|
||||
property = Property::LineCap;
|
||||
}
|
||||
break;
|
||||
|
||||
case util::hashFNV1a("line-join"):
|
||||
if (name == "line-join") {
|
||||
property = Property::LineJoin;
|
||||
}
|
||||
break;
|
||||
|
||||
case util::hashFNV1a("line-miter-limit"):
|
||||
if (name == "line-miter-limit") {
|
||||
property = Property::LineMiterLimit;
|
||||
}
|
||||
break;
|
||||
|
||||
case util::hashFNV1a("line-round-limit"):
|
||||
if (name == "line-round-limit") {
|
||||
property = Property::LineRoundLimit;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
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 (name == "line-join") {
|
||||
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 (name == "line-miter-limit") {
|
||||
if (property == Property::LineMiterLimit || property == Property::LineRoundLimit) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setLineMiterLimit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "line-round-limit") {
|
||||
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;
|
||||
}
|
||||
|
||||
setLineRoundLimit(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::LineRoundLimit) {
|
||||
setLineRoundLimit(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <mbgl/style/conversion/property_value.hpp>
|
||||
#include <mbgl/style/conversion/transition_options.hpp>
|
||||
#include <mbgl/style/conversion/json.hpp>
|
||||
#include <mbgl/util/fnv_hash.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
@@ -299,175 +300,220 @@ TransitionOptions RasterLayer::getRasterFadeDurationTransition() const {
|
||||
using namespace conversion;
|
||||
|
||||
optional<Error> RasterLayer::setPaintProperty(const std::string& name, const Convertible& value) {
|
||||
enum class Property {
|
||||
Unknown,
|
||||
RasterOpacity,
|
||||
RasterHueRotate,
|
||||
RasterBrightnessMin,
|
||||
RasterBrightnessMax,
|
||||
RasterSaturation,
|
||||
RasterContrast,
|
||||
RasterResampling,
|
||||
RasterFadeDuration,
|
||||
RasterOpacityTransition,
|
||||
RasterHueRotateTransition,
|
||||
RasterBrightnessMinTransition,
|
||||
RasterBrightnessMaxTransition,
|
||||
RasterSaturationTransition,
|
||||
RasterContrastTransition,
|
||||
RasterResamplingTransition,
|
||||
RasterFadeDurationTransition,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
case util::hashFNV1a("raster-opacity"):
|
||||
if (name == "raster-opacity") {
|
||||
property = Property::RasterOpacity;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-opacity-transition"):
|
||||
if (name == "raster-opacity-transition") {
|
||||
property = Property::RasterOpacityTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-hue-rotate"):
|
||||
if (name == "raster-hue-rotate") {
|
||||
property = Property::RasterHueRotate;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-hue-rotate-transition"):
|
||||
if (name == "raster-hue-rotate-transition") {
|
||||
property = Property::RasterHueRotateTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-brightness-min"):
|
||||
if (name == "raster-brightness-min") {
|
||||
property = Property::RasterBrightnessMin;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-brightness-min-transition"):
|
||||
if (name == "raster-brightness-min-transition") {
|
||||
property = Property::RasterBrightnessMinTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-brightness-max"):
|
||||
if (name == "raster-brightness-max") {
|
||||
property = Property::RasterBrightnessMax;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-brightness-max-transition"):
|
||||
if (name == "raster-brightness-max-transition") {
|
||||
property = Property::RasterBrightnessMaxTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-saturation"):
|
||||
if (name == "raster-saturation") {
|
||||
property = Property::RasterSaturation;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-saturation-transition"):
|
||||
if (name == "raster-saturation-transition") {
|
||||
property = Property::RasterSaturationTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-contrast"):
|
||||
if (name == "raster-contrast") {
|
||||
property = Property::RasterContrast;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-contrast-transition"):
|
||||
if (name == "raster-contrast-transition") {
|
||||
property = Property::RasterContrastTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-resampling"):
|
||||
if (name == "raster-resampling") {
|
||||
property = Property::RasterResampling;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-resampling-transition"):
|
||||
if (name == "raster-resampling-transition") {
|
||||
property = Property::RasterResamplingTransition;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-fade-duration"):
|
||||
if (name == "raster-fade-duration") {
|
||||
property = Property::RasterFadeDuration;
|
||||
}
|
||||
break;
|
||||
case util::hashFNV1a("raster-fade-duration-transition"):
|
||||
if (name == "raster-fade-duration-transition") {
|
||||
property = Property::RasterFadeDurationTransition;
|
||||
}
|
||||
break;
|
||||
|
||||
if (name == "raster-opacity") {
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
if (property == Property::RasterOpacity || property == Property::RasterHueRotate || property == Property::RasterBrightnessMin || property == Property::RasterBrightnessMax || property == Property::RasterSaturation || property == Property::RasterContrast || property == Property::RasterFadeDuration) {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-opacity-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
|
||||
if (property == Property::RasterOpacity) {
|
||||
setRasterOpacity(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
setRasterOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
|
||||
if (property == Property::RasterHueRotate) {
|
||||
setRasterHueRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterBrightnessMin) {
|
||||
setRasterBrightnessMin(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterBrightnessMax) {
|
||||
setRasterBrightnessMax(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterSaturation) {
|
||||
setRasterSaturation(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterContrast) {
|
||||
setRasterContrast(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterFadeDuration) {
|
||||
setRasterFadeDuration(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (name == "raster-hue-rotate") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterHueRotate(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-hue-rotate-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterHueRotateTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "raster-brightness-min") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterBrightnessMin(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-brightness-min-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterBrightnessMinTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "raster-brightness-max") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterBrightnessMax(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-brightness-max-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterBrightnessMaxTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "raster-saturation") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterSaturation(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-saturation-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterSaturationTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "raster-contrast") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterContrast(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-contrast-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterContrastTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "raster-resampling") {
|
||||
if (property == Property::RasterResampling) {
|
||||
Error error;
|
||||
optional<PropertyValue<RasterResamplingType>> typedValue = convert<PropertyValue<RasterResamplingType>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
setRasterResampling(*typedValue);
|
||||
return nullopt;
|
||||
|
||||
}
|
||||
if (name == "raster-resampling-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::RasterOpacityTransition) {
|
||||
setRasterOpacityTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterHueRotateTransition) {
|
||||
setRasterHueRotateTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterBrightnessMinTransition) {
|
||||
setRasterBrightnessMinTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterBrightnessMaxTransition) {
|
||||
setRasterBrightnessMaxTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterSaturationTransition) {
|
||||
setRasterSaturationTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterContrastTransition) {
|
||||
setRasterContrastTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (property == Property::RasterResamplingTransition) {
|
||||
setRasterResamplingTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
if (name == "raster-fade-duration") {
|
||||
Error error;
|
||||
optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
|
||||
if (!typedValue) {
|
||||
return error;
|
||||
}
|
||||
|
||||
setRasterFadeDuration(*typedValue);
|
||||
return nullopt;
|
||||
}
|
||||
if (name == "raster-fade-duration-transition") {
|
||||
Error error;
|
||||
optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
|
||||
if (!transition) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (property == Property::RasterFadeDurationTransition) {
|
||||
setRasterFadeDurationTransition(*transition);
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
@@ -488,7 +534,21 @@ optional<Error> RasterLayer::setLayoutProperty(const std::string& name, const Co
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
enum class Property {
|
||||
Unknown,
|
||||
};
|
||||
|
||||
Property property = Property::Unknown;
|
||||
switch (util::hashFNV1a(name.c_str())) {
|
||||
|
||||
}
|
||||
|
||||
if (property == Property::Unknown) {
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Error { "layer doesn't support this property" };
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
11
src/mbgl/util/fnv_hash.hpp
Normal file
11
src/mbgl/util/fnv_hash.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
inline constexpr uint64_t hashFNV1a(const char * str, uint64_t value = 0xcbf29ce484222325) {
|
||||
return str[0] ? hashFNV1a(str + 1, (value ^ uint64_t(str[0])) * 0x100000001b3) : value;
|
||||
}
|
||||
|
||||
} // end namespace util
|
||||
} // end namespace mbgl
|
||||
Reference in New Issue
Block a user