diff options
Diffstat (limited to 'src/mbgl/style/layers/heatmap_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/heatmap_layer.cpp | 94 |
1 files changed, 20 insertions, 74 deletions
diff --git a/src/mbgl/style/layers/heatmap_layer.cpp b/src/mbgl/style/layers/heatmap_layer.cpp index 29c5fc5e4e..d548ee9b74 100644 --- a/src/mbgl/style/layers/heatmap_layer.cpp +++ b/src/mbgl/style/layers/heatmap_layer.cpp @@ -9,7 +9,8 @@ #include <mbgl/style/conversion/transition_options.hpp> #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion_impl.hpp> -#include <mbgl/util/fnv_hash.hpp> + +#include <mapbox/eternal.hpp> namespace mbgl { namespace style { @@ -201,8 +202,7 @@ TransitionOptions HeatmapLayer::getHeatmapOpacityTransition() const { using namespace conversion; optional<Error> HeatmapLayer::setPaintProperty(const std::string& name, const Convertible& value) { - enum class Property { - Unknown, + enum class Property : uint8_t { HeatmapRadius, HeatmapWeight, HeatmapIntensity, @@ -215,65 +215,26 @@ optional<Error> HeatmapLayer::setPaintProperty(const std::string& name, const Co 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 (property == Property::Unknown) { + MAPBOX_ETERNAL_CONSTEXPR const auto properties = mapbox::eternal::hash_map<mapbox::eternal::string, uint8_t>({ + { "heatmap-radius", static_cast<uint8_t>(Property::HeatmapRadius) }, + { "heatmap-weight", static_cast<uint8_t>(Property::HeatmapWeight) }, + { "heatmap-intensity", static_cast<uint8_t>(Property::HeatmapIntensity) }, + { "heatmap-color", static_cast<uint8_t>(Property::HeatmapColor) }, + { "heatmap-opacity", static_cast<uint8_t>(Property::HeatmapOpacity) }, + { "heatmap-radius-transition", static_cast<uint8_t>(Property::HeatmapRadiusTransition) }, + { "heatmap-weight-transition", static_cast<uint8_t>(Property::HeatmapWeightTransition) }, + { "heatmap-intensity-transition", static_cast<uint8_t>(Property::HeatmapIntensityTransition) }, + { "heatmap-color-transition", static_cast<uint8_t>(Property::HeatmapColorTransition) }, + { "heatmap-opacity-transition", static_cast<uint8_t>(Property::HeatmapOpacityTransition) } + }); + + const auto it = properties.find(name.c_str()); + if (it == properties.end()) { return Error { "layer doesn't support this property" }; } + Property property = static_cast<Property>(it->second); + if (property == Property::HeatmapRadius || property == Property::HeatmapWeight) { Error error; @@ -366,21 +327,6 @@ optional<Error> HeatmapLayer::setLayoutProperty(const std::string& name, const C return Layer::setVisibility(value); } - 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" }; } |