summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/hillshade_layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/layers/hillshade_layer.cpp')
-rw-r--r--src/mbgl/style/layers/hillshade_layer.cpp237
1 files changed, 152 insertions, 85 deletions
diff --git a/src/mbgl/style/layers/hillshade_layer.cpp b/src/mbgl/style/layers/hillshade_layer.cpp
index 2d8c837baa..9ccdd1567b 100644
--- a/src/mbgl/style/layers/hillshade_layer.cpp
+++ b/src/mbgl/style/layers/hillshade_layer.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 {
@@ -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") {
- Error error;
- optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
- if (!transition) {
- return error;
- }
-
- setHillshadeIlluminationAnchorTransition(*transition);
- return nullopt;
+
}
- if (name == "hillshade-exaggeration") {
+ if (property == Property::HillshadeShadowColor || property == Property::HillshadeHighlightColor || property == Property::HillshadeAccentColor) {
Error error;
- optional<PropertyValue<float>> typedValue = convert<PropertyValue<float>>(value, error, false, false);
+ optional<PropertyValue<Color>> typedValue = convert<PropertyValue<Color>>(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::HillshadeShadowColor) {
+ setHillshadeShadowColor(*typedValue);
+ return nullopt;
}
-
- setHillshadeExaggerationTransition(*transition);
- return nullopt;
+
+ if (property == Property::HillshadeHighlightColor) {
+ setHillshadeHighlightColor(*typedValue);
+ return nullopt;
+ }
+
+ if (property == Property::HillshadeAccentColor) {
+ setHillshadeAccentColor(*typedValue);
+ 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);
+ Error error;
+ optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
+ if (!transition) {
+ return error;
+ }
+
+ if (property == Property::HillshadeIlluminationDirectionTransition) {
+ setHillshadeIlluminationDirectionTransition(*transition);
return nullopt;
}
- if (name == "hillshade-shadow-color-transition") {
- Error error;
- optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
- if (!transition) {
- return error;
- }
-
- setHillshadeShadowColorTransition(*transition);
+
+ if (property == Property::HillshadeIlluminationAnchorTransition) {
+ setHillshadeIlluminationAnchorTransition(*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);
+ if (property == Property::HillshadeExaggerationTransition) {
+ setHillshadeExaggerationTransition(*transition);
return nullopt;
}
- if (name == "hillshade-highlight-color-transition") {
- Error error;
- optional<TransitionOptions> transition = convert<TransitionOptions>(value, error);
- if (!transition) {
- return error;
- }
-
- setHillshadeHighlightColorTransition(*transition);
+
+ if (property == Property::HillshadeShadowColorTransition) {
+ setHillshadeShadowColorTransition(*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);
+ if (property == Property::HillshadeHighlightColorTransition) {
+ setHillshadeHighlightColorTransition(*transition);
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" };
}