summaryrefslogtreecommitdiff
path: root/src/mbgl/style/paint_property.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-06-22 16:28:21 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-06-24 09:39:51 -0700
commit16c435b1517b15a5ea8654987979ef58800b838b (patch)
tree8f81c4e202e1337d0966a06f27842d45a113fded /src/mbgl/style/paint_property.hpp
parentc4e4cc5081965d03132eea754c27ece3c95961cb (diff)
downloadqtlocation-mapboxgl-16c435b1517b15a5ea8654987979ef58800b838b.tar.gz
[core, node] Implement bindings for addLayer
Diffstat (limited to 'src/mbgl/style/paint_property.hpp')
-rw-r--r--src/mbgl/style/paint_property.hpp46
1 files changed, 13 insertions, 33 deletions
diff --git a/src/mbgl/style/paint_property.hpp b/src/mbgl/style/paint_property.hpp
index 7bb2e68b80..b982fe76e2 100644
--- a/src/mbgl/style/paint_property.hpp
+++ b/src/mbgl/style/paint_property.hpp
@@ -8,7 +8,6 @@
#include <mbgl/style/calculation_parameters.hpp>
#include <mbgl/util/constants.hpp>
#include <mbgl/util/interpolate.hpp>
-#include <mbgl/util/std.hpp>
#include <mbgl/util/rapidjson.hpp>
#include <map>
@@ -28,47 +27,28 @@ public:
}
PaintProperty(const PaintProperty& other)
- : values(other.values),
+ : defaultValue(other.defaultValue),
+ values(other.values),
transitions(other.transitions) {
}
+ PaintProperty& operator=(const PaintProperty& other) {
+ defaultValue = other.defaultValue;
+ values = other.values;
+ transitions = other.transitions;
+ return *this;
+ }
+
const PropertyValue<T>& get() const {
return values.at(ClassID::Default);
}
- void set(const PropertyValue<T>& value_) {
- values[ClassID::Default] = value_;
+ void set(const PropertyValue<T>& value_, const optional<std::string>& klass) {
+ values[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = value_;
}
- void parse(const char* name, const JSValue& layer) {
- mbgl::util::erase_if(values, [] (const auto& p) { return p.first != ClassID::Fallback; });
-
- std::string transitionName = { name };
- transitionName += "-transition";
-
- for (auto it = layer.MemberBegin(); it != layer.MemberEnd(); ++it) {
- const std::string paintName { it->name.GetString(), it->name.GetStringLength() };
- if (paintName.compare(0, 5, "paint") != 0)
- continue;
-
- bool isClass = paintName.compare(0, 6, "paint.") == 0;
- if (isClass && paintName.length() <= 6)
- continue;
-
- ClassID classID = isClass ? ClassDictionary::Get().lookup(paintName.substr(6)) : ClassID::Default;
-
- if (it->value.HasMember(name)) {
- if (auto v = parseProperty<T>(name, it->value[name])) {
- values.emplace(classID, v);
- }
- }
-
- if (it->value.HasMember(transitionName.c_str())) {
- if (auto v = parseTransitionOptions(name, it->value[transitionName.c_str()])) {
- transitions.emplace(classID, *v);
- }
- }
- }
+ void setTransition(const TransitionOptions& transition, const optional<std::string>& klass) {
+ transitions[klass ? ClassDictionary::Get().lookup(*klass) : ClassID::Default] = transition;
}
void cascade(const CascadeParameters& params) {