summaryrefslogtreecommitdiff
path: root/src
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
parentc4e4cc5081965d03132eea754c27ece3c95961cb (diff)
downloadqtlocation-mapboxgl-16c435b1517b15a5ea8654987979ef58800b838b.tar.gz
[core, node] Implement bindings for addLayer
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/layer_impl.hpp5
-rw-r--r--src/mbgl/style/layers/background_layer.cpp20
-rw-r--r--src/mbgl/style/layers/background_layer_impl.cpp4
-rw-r--r--src/mbgl/style/layers/background_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/background_layer_properties.cpp6
-rw-r--r--src/mbgl/style/layers/background_layer_properties.hpp2
-rw-r--r--src/mbgl/style/layers/circle_layer.cpp32
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.cpp4
-rw-r--r--src/mbgl/style/layers/circle_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/circle_layer_properties.cpp9
-rw-r--r--src/mbgl/style/layers/circle_layer_properties.hpp2
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.cpp5
-rw-r--r--src/mbgl/style/layers/custom_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp36
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.cpp4
-rw-r--r--src/mbgl/style/layers/fill_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/fill_layer_properties.cpp10
-rw-r--r--src/mbgl/style/layers/fill_layer_properties.hpp2
-rw-r--r--src/mbgl/style/layers/layer.cpp.ejs12
-rw-r--r--src/mbgl/style/layers/layer_properties.cpp.ejs12
-rw-r--r--src/mbgl/style/layers/layer_properties.hpp.ejs3
-rw-r--r--src/mbgl/style/layers/line_layer.cpp48
-rw-r--r--src/mbgl/style/layers/line_layer_impl.cpp8
-rw-r--r--src/mbgl/style/layers/line_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/line_layer_properties.cpp20
-rw-r--r--src/mbgl/style/layers/line_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layers/raster_layer.cpp36
-rw-r--r--src/mbgl/style/layers/raster_layer_impl.cpp4
-rw-r--r--src/mbgl/style/layers/raster_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/raster_layer_properties.cpp10
-rw-r--r--src/mbgl/style/layers/raster_layer_properties.hpp2
-rw-r--r--src/mbgl/style/layers/symbol_layer.cpp64
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.cpp8
-rw-r--r--src/mbgl/style/layers/symbol_layer_impl.hpp4
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.cpp54
-rw-r--r--src/mbgl/style/layers/symbol_layer_properties.hpp3
-rw-r--r--src/mbgl/style/layout_property.hpp7
-rw-r--r--src/mbgl/style/paint_property.hpp46
-rw-r--r--src/mbgl/style/parser.cpp118
-rw-r--r--src/mbgl/style/parser.hpp1
-rw-r--r--src/mbgl/style/rapidjson_conversion.hpp16
-rw-r--r--src/mbgl/style/style.cpp2
42 files changed, 204 insertions, 442 deletions
diff --git a/src/mbgl/style/layer_impl.hpp b/src/mbgl/style/layer_impl.hpp
index 33ad2e32ac..d2bf866e8e 100644
--- a/src/mbgl/style/layer_impl.hpp
+++ b/src/mbgl/style/layer_impl.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/filter.hpp>
#include <mbgl/renderer/render_pass.hpp>
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/util/rapidjson.hpp>
#include <mbgl/tile/geometry_tile_data.hpp>
#include <memory>
@@ -46,8 +45,8 @@ public:
// Create an identical copy of this layer.
virtual std::unique_ptr<Layer> clone() const = 0;
- virtual void parseLayout(const JSValue& value) = 0;
- virtual void parsePaints(const JSValue& value) = 0;
+ // Create a layer, copying all properties except id, ref, and paint properties from this layer.
+ virtual std::unique_ptr<Layer> cloneRef(const std::string& id) const = 0;
// If the layer has a ref, the ref. Otherwise, the id.
const std::string& bucketName() const;
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp
index aeb4067503..42cd76d01f 100644
--- a/src/mbgl/style/layers/background_layer.cpp
+++ b/src/mbgl/style/layers/background_layer.cpp
@@ -23,6 +23,14 @@ std::unique_ptr<Layer> BackgroundLayer::Impl::clone() const {
return std::make_unique<BackgroundLayer>(*this);
}
+std::unique_ptr<Layer> BackgroundLayer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<BackgroundLayer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = BackgroundPaintProperties();
+ return std::move(result);
+}
+
// Layout properties
@@ -33,24 +41,24 @@ PropertyValue<Color> BackgroundLayer::getBackgroundColor() const {
return impl->paint.backgroundColor.get();
}
-void BackgroundLayer::setBackgroundColor(PropertyValue<Color> value) {
- impl->paint.backgroundColor.set(value);
+void BackgroundLayer::setBackgroundColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.backgroundColor.set(value, klass);
}
PropertyValue<std::string> BackgroundLayer::getBackgroundPattern() const {
return impl->paint.backgroundPattern.get();
}
-void BackgroundLayer::setBackgroundPattern(PropertyValue<std::string> value) {
- impl->paint.backgroundPattern.set(value);
+void BackgroundLayer::setBackgroundPattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
+ impl->paint.backgroundPattern.set(value, klass);
}
PropertyValue<float> BackgroundLayer::getBackgroundOpacity() const {
return impl->paint.backgroundOpacity.get();
}
-void BackgroundLayer::setBackgroundOpacity(PropertyValue<float> value) {
- impl->paint.backgroundOpacity.set(value);
+void BackgroundLayer::setBackgroundOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.backgroundOpacity.set(value, klass);
}
} // namespace style
diff --git a/src/mbgl/style/layers/background_layer_impl.cpp b/src/mbgl/style/layers/background_layer_impl.cpp
index 0c09c5d158..ea389b828e 100644
--- a/src/mbgl/style/layers/background_layer_impl.cpp
+++ b/src/mbgl/style/layers/background_layer_impl.cpp
@@ -4,10 +4,6 @@
namespace mbgl {
namespace style {
-void BackgroundLayer::Impl::parsePaints(const JSValue& layer) {
- paint.parse(layer);
-}
-
void BackgroundLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
diff --git a/src/mbgl/style/layers/background_layer_impl.hpp b/src/mbgl/style/layers/background_layer_impl.hpp
index 19e2a062a4..abbb740f42 100644
--- a/src/mbgl/style/layers/background_layer_impl.hpp
+++ b/src/mbgl/style/layers/background_layer_impl.hpp
@@ -10,9 +10,7 @@ namespace style {
class BackgroundLayer::Impl : public Layer::Impl {
public:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) override {};
- void parsePaints(const JSValue&) override;
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
bool recalculate(const CalculationParameters&) override;
diff --git a/src/mbgl/style/layers/background_layer_properties.cpp b/src/mbgl/style/layers/background_layer_properties.cpp
index a20cedf12c..558093a255 100644
--- a/src/mbgl/style/layers/background_layer_properties.cpp
+++ b/src/mbgl/style/layers/background_layer_properties.cpp
@@ -5,12 +5,6 @@
namespace mbgl {
namespace style {
-void BackgroundPaintProperties::parse(const JSValue& value) {
- backgroundColor.parse("background-color", value);
- backgroundPattern.parse("background-pattern", value);
- backgroundOpacity.parse("background-opacity", value);
-}
-
void BackgroundPaintProperties::cascade(const CascadeParameters& parameters) {
backgroundColor.cascade(parameters);
backgroundPattern.cascade(parameters);
diff --git a/src/mbgl/style/layers/background_layer_properties.hpp b/src/mbgl/style/layers/background_layer_properties.hpp
index 88a2ef1478..6c5a7c57ca 100644
--- a/src/mbgl/style/layers/background_layer_properties.hpp
+++ b/src/mbgl/style/layers/background_layer_properties.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -15,7 +14,6 @@ class CalculationParameters;
class BackgroundPaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp
index 8066d7fd3c..a47d723548 100644
--- a/src/mbgl/style/layers/circle_layer.cpp
+++ b/src/mbgl/style/layers/circle_layer.cpp
@@ -24,6 +24,14 @@ std::unique_ptr<Layer> CircleLayer::Impl::clone() const {
return std::make_unique<CircleLayer>(*this);
}
+std::unique_ptr<Layer> CircleLayer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<CircleLayer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = CirclePaintProperties();
+ return std::move(result);
+}
+
// Source
const std::string& CircleLayer::getSourceID() const {
@@ -57,48 +65,48 @@ PropertyValue<float> CircleLayer::getCircleRadius() const {
return impl->paint.circleRadius.get();
}
-void CircleLayer::setCircleRadius(PropertyValue<float> value) {
- impl->paint.circleRadius.set(value);
+void CircleLayer::setCircleRadius(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.circleRadius.set(value, klass);
}
PropertyValue<Color> CircleLayer::getCircleColor() const {
return impl->paint.circleColor.get();
}
-void CircleLayer::setCircleColor(PropertyValue<Color> value) {
- impl->paint.circleColor.set(value);
+void CircleLayer::setCircleColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.circleColor.set(value, klass);
}
PropertyValue<float> CircleLayer::getCircleBlur() const {
return impl->paint.circleBlur.get();
}
-void CircleLayer::setCircleBlur(PropertyValue<float> value) {
- impl->paint.circleBlur.set(value);
+void CircleLayer::setCircleBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.circleBlur.set(value, klass);
}
PropertyValue<float> CircleLayer::getCircleOpacity() const {
return impl->paint.circleOpacity.get();
}
-void CircleLayer::setCircleOpacity(PropertyValue<float> value) {
- impl->paint.circleOpacity.set(value);
+void CircleLayer::setCircleOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.circleOpacity.set(value, klass);
}
PropertyValue<std::array<float, 2>> CircleLayer::getCircleTranslate() const {
return impl->paint.circleTranslate.get();
}
-void CircleLayer::setCircleTranslate(PropertyValue<std::array<float, 2>> value) {
- impl->paint.circleTranslate.set(value);
+void CircleLayer::setCircleTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ impl->paint.circleTranslate.set(value, klass);
}
PropertyValue<TranslateAnchorType> CircleLayer::getCircleTranslateAnchor() const {
return impl->paint.circleTranslateAnchor.get();
}
-void CircleLayer::setCircleTranslateAnchor(PropertyValue<TranslateAnchorType> value) {
- impl->paint.circleTranslateAnchor.set(value);
+void CircleLayer::setCircleTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ impl->paint.circleTranslateAnchor.set(value, klass);
}
} // namespace style
diff --git a/src/mbgl/style/layers/circle_layer_impl.cpp b/src/mbgl/style/layers/circle_layer_impl.cpp
index d64759e743..e08d9df146 100644
--- a/src/mbgl/style/layers/circle_layer_impl.cpp
+++ b/src/mbgl/style/layers/circle_layer_impl.cpp
@@ -8,10 +8,6 @@
namespace mbgl {
namespace style {
-void CircleLayer::Impl::parsePaints(const JSValue& layer) {
- paint.parse(layer);
-}
-
void CircleLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
diff --git a/src/mbgl/style/layers/circle_layer_impl.hpp b/src/mbgl/style/layers/circle_layer_impl.hpp
index 463f3ca18d..555691b6b4 100644
--- a/src/mbgl/style/layers/circle_layer_impl.hpp
+++ b/src/mbgl/style/layers/circle_layer_impl.hpp
@@ -10,9 +10,7 @@ namespace style {
class CircleLayer::Impl : public Layer::Impl {
public:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) override {};
- void parsePaints(const JSValue&) override;
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
bool recalculate(const CalculationParameters&) override;
diff --git a/src/mbgl/style/layers/circle_layer_properties.cpp b/src/mbgl/style/layers/circle_layer_properties.cpp
index b21df1e2d0..045c73ba63 100644
--- a/src/mbgl/style/layers/circle_layer_properties.cpp
+++ b/src/mbgl/style/layers/circle_layer_properties.cpp
@@ -5,15 +5,6 @@
namespace mbgl {
namespace style {
-void CirclePaintProperties::parse(const JSValue& value) {
- circleRadius.parse("circle-radius", value);
- circleColor.parse("circle-color", value);
- circleBlur.parse("circle-blur", value);
- circleOpacity.parse("circle-opacity", value);
- circleTranslate.parse("circle-translate", value);
- circleTranslateAnchor.parse("circle-translate-anchor", value);
-}
-
void CirclePaintProperties::cascade(const CascadeParameters& parameters) {
circleRadius.cascade(parameters);
circleColor.cascade(parameters);
diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp
index 87091e7b59..40d37dc392 100644
--- a/src/mbgl/style/layers/circle_layer_properties.hpp
+++ b/src/mbgl/style/layers/circle_layer_properties.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -15,7 +14,6 @@ class CalculationParameters;
class CirclePaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layers/custom_layer_impl.cpp b/src/mbgl/style/layers/custom_layer_impl.cpp
index 214d4ce663..a0686e353c 100644
--- a/src/mbgl/style/layers/custom_layer_impl.cpp
+++ b/src/mbgl/style/layers/custom_layer_impl.cpp
@@ -33,6 +33,11 @@ std::unique_ptr<Layer> CustomLayer::Impl::clone() const {
return std::make_unique<CustomLayer>(*this);
}
+std::unique_ptr<Layer> CustomLayer::Impl::cloneRef(const std::string&) const {
+ assert(false);
+ return std::make_unique<CustomLayer>(*this);
+}
+
void CustomLayer::Impl::initialize() {
assert(initializeFn);
initializeFn(context);
diff --git a/src/mbgl/style/layers/custom_layer_impl.hpp b/src/mbgl/style/layers/custom_layer_impl.hpp
index 00e576b6a3..ffa892ddf8 100644
--- a/src/mbgl/style/layers/custom_layer_impl.hpp
+++ b/src/mbgl/style/layers/custom_layer_impl.hpp
@@ -25,9 +25,7 @@ public:
private:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) final {}
- void parsePaints(const JSValue&) final {}
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) final {}
bool recalculate(const CalculationParameters&) final;
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index 7d7d1a9e27..44894aff33 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -24,6 +24,14 @@ std::unique_ptr<Layer> FillLayer::Impl::clone() const {
return std::make_unique<FillLayer>(*this);
}
+std::unique_ptr<Layer> FillLayer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<FillLayer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = FillPaintProperties();
+ return std::move(result);
+}
+
// Source
const std::string& FillLayer::getSourceID() const {
@@ -57,56 +65,56 @@ PropertyValue<bool> FillLayer::getFillAntialias() const {
return impl->paint.fillAntialias.get();
}
-void FillLayer::setFillAntialias(PropertyValue<bool> value) {
- impl->paint.fillAntialias.set(value);
+void FillLayer::setFillAntialias(PropertyValue<bool> value, const optional<std::string>& klass) {
+ impl->paint.fillAntialias.set(value, klass);
}
PropertyValue<float> FillLayer::getFillOpacity() const {
return impl->paint.fillOpacity.get();
}
-void FillLayer::setFillOpacity(PropertyValue<float> value) {
- impl->paint.fillOpacity.set(value);
+void FillLayer::setFillOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.fillOpacity.set(value, klass);
}
PropertyValue<Color> FillLayer::getFillColor() const {
return impl->paint.fillColor.get();
}
-void FillLayer::setFillColor(PropertyValue<Color> value) {
- impl->paint.fillColor.set(value);
+void FillLayer::setFillColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.fillColor.set(value, klass);
}
PropertyValue<Color> FillLayer::getFillOutlineColor() const {
return impl->paint.fillOutlineColor.get();
}
-void FillLayer::setFillOutlineColor(PropertyValue<Color> value) {
- impl->paint.fillOutlineColor.set(value);
+void FillLayer::setFillOutlineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.fillOutlineColor.set(value, klass);
}
PropertyValue<std::array<float, 2>> FillLayer::getFillTranslate() const {
return impl->paint.fillTranslate.get();
}
-void FillLayer::setFillTranslate(PropertyValue<std::array<float, 2>> value) {
- impl->paint.fillTranslate.set(value);
+void FillLayer::setFillTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ impl->paint.fillTranslate.set(value, klass);
}
PropertyValue<TranslateAnchorType> FillLayer::getFillTranslateAnchor() const {
return impl->paint.fillTranslateAnchor.get();
}
-void FillLayer::setFillTranslateAnchor(PropertyValue<TranslateAnchorType> value) {
- impl->paint.fillTranslateAnchor.set(value);
+void FillLayer::setFillTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ impl->paint.fillTranslateAnchor.set(value, klass);
}
PropertyValue<std::string> FillLayer::getFillPattern() const {
return impl->paint.fillPattern.get();
}
-void FillLayer::setFillPattern(PropertyValue<std::string> value) {
- impl->paint.fillPattern.set(value);
+void FillLayer::setFillPattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
+ impl->paint.fillPattern.set(value, klass);
}
} // namespace style
diff --git a/src/mbgl/style/layers/fill_layer_impl.cpp b/src/mbgl/style/layers/fill_layer_impl.cpp
index 3d847127c9..2992312514 100644
--- a/src/mbgl/style/layers/fill_layer_impl.cpp
+++ b/src/mbgl/style/layers/fill_layer_impl.cpp
@@ -8,10 +8,6 @@
namespace mbgl {
namespace style {
-void FillLayer::Impl::parsePaints(const JSValue& layer) {
- paint.parse(layer);
-}
-
void FillLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
diff --git a/src/mbgl/style/layers/fill_layer_impl.hpp b/src/mbgl/style/layers/fill_layer_impl.hpp
index a37dd76ace..fc6578ecd1 100644
--- a/src/mbgl/style/layers/fill_layer_impl.hpp
+++ b/src/mbgl/style/layers/fill_layer_impl.hpp
@@ -10,9 +10,7 @@ namespace style {
class FillLayer::Impl : public Layer::Impl {
public:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) override {};
- void parsePaints(const JSValue&) override;
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
bool recalculate(const CalculationParameters&) override;
diff --git a/src/mbgl/style/layers/fill_layer_properties.cpp b/src/mbgl/style/layers/fill_layer_properties.cpp
index a4714689f9..9a55cbc145 100644
--- a/src/mbgl/style/layers/fill_layer_properties.cpp
+++ b/src/mbgl/style/layers/fill_layer_properties.cpp
@@ -5,16 +5,6 @@
namespace mbgl {
namespace style {
-void FillPaintProperties::parse(const JSValue& value) {
- fillAntialias.parse("fill-antialias", value);
- fillOpacity.parse("fill-opacity", value);
- fillColor.parse("fill-color", value);
- fillOutlineColor.parse("fill-outline-color", value);
- fillTranslate.parse("fill-translate", value);
- fillTranslateAnchor.parse("fill-translate-anchor", value);
- fillPattern.parse("fill-pattern", value);
-}
-
void FillPaintProperties::cascade(const CascadeParameters& parameters) {
fillAntialias.cascade(parameters);
fillOpacity.cascade(parameters);
diff --git a/src/mbgl/style/layers/fill_layer_properties.hpp b/src/mbgl/style/layers/fill_layer_properties.hpp
index fb60b90258..82981a9b64 100644
--- a/src/mbgl/style/layers/fill_layer_properties.hpp
+++ b/src/mbgl/style/layers/fill_layer_properties.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -15,7 +14,6 @@ class CalculationParameters;
class FillPaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layers/layer.cpp.ejs b/src/mbgl/style/layers/layer.cpp.ejs
index 4f78d6b55e..017691c8ec 100644
--- a/src/mbgl/style/layers/layer.cpp.ejs
+++ b/src/mbgl/style/layers/layer.cpp.ejs
@@ -37,6 +37,14 @@ std::unique_ptr<Layer> <%- camelize(type) %>Layer::Impl::clone() const {
return std::make_unique<<%- camelize(type) %>Layer>(*this);
}
+std::unique_ptr<Layer> <%- camelize(type) %>Layer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<<%- camelize(type) %>Layer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = <%- camelize(type) %>PaintProperties();
+ return std::move(result);
+}
+
<% if (type !== 'background') { -%>
// Source
@@ -83,8 +91,8 @@ PropertyValue<<%- propertyType(property) %>> <%- camelize(type) %>Layer::get<%-
return impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.get();
}
-void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value) {
- impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.set(value);
+void <%- camelize(type) %>Layer::set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>> value, const optional<std::string>& klass) {
+ impl->paint.<%- camelizeWithLeadingLowercase(property.name) %>.set(value, klass);
}
<% } -%>
diff --git a/src/mbgl/style/layers/layer_properties.cpp.ejs b/src/mbgl/style/layers/layer_properties.cpp.ejs
index 8fef8d29c4..b781a4a9d9 100644
--- a/src/mbgl/style/layers/layer_properties.cpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.cpp.ejs
@@ -11,12 +11,6 @@ namespace mbgl {
namespace style {
<% if (layoutProperties.length) { -%>
-void <%- camelize(type) %>LayoutProperties::parse(const JSValue& value) {
-<% for (const property of layoutProperties) { -%>
- <%- camelizeWithLeadingLowercase(property.name) %>.parse(<%- JSON.stringify(property.name) %>, value);
-<% } -%>
-}
-
void <%- camelize(type) %>LayoutProperties::recalculate(const CalculationParameters& parameters) {
<% for (const property of layoutProperties) { -%>
<%- camelizeWithLeadingLowercase(property.name) %>.calculate(parameters);
@@ -24,12 +18,6 @@ void <%- camelize(type) %>LayoutProperties::recalculate(const CalculationParamet
}
<% } -%>
-void <%- camelize(type) %>PaintProperties::parse(const JSValue& value) {
-<% for (const property of paintProperties) { -%>
- <%- camelizeWithLeadingLowercase(property.name) %>.parse(<%- JSON.stringify(property.name) %>, value);
-<% } -%>
-}
-
void <%- camelize(type) %>PaintProperties::cascade(const CascadeParameters& parameters) {
<% for (const property of paintProperties) { -%>
<%- camelizeWithLeadingLowercase(property.name) %>.cascade(parameters);
diff --git a/src/mbgl/style/layers/layer_properties.hpp.ejs b/src/mbgl/style/layers/layer_properties.hpp.ejs
index 60f40efa8e..a485621ac6 100644
--- a/src/mbgl/style/layers/layer_properties.hpp.ejs
+++ b/src/mbgl/style/layers/layer_properties.hpp.ejs
@@ -10,7 +10,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -21,7 +20,6 @@ class CalculationParameters;
<% if (layoutProperties.length) { -%>
class <%- camelize(type) %>LayoutProperties {
public:
- void parse(const JSValue&);
void recalculate(const CalculationParameters&);
<% for (const property of layoutProperties) { -%>
@@ -32,7 +30,6 @@ public:
<% } -%>
class <%- camelize(type) %>PaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp
index e720d1fcfb..3ad72cda16 100644
--- a/src/mbgl/style/layers/line_layer.cpp
+++ b/src/mbgl/style/layers/line_layer.cpp
@@ -24,6 +24,14 @@ std::unique_ptr<Layer> LineLayer::Impl::clone() const {
return std::make_unique<LineLayer>(*this);
}
+std::unique_ptr<Layer> LineLayer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<LineLayer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = LinePaintProperties();
+ return std::move(result);
+}
+
// Source
const std::string& LineLayer::getSourceID() const {
@@ -85,80 +93,80 @@ PropertyValue<float> LineLayer::getLineOpacity() const {
return impl->paint.lineOpacity.get();
}
-void LineLayer::setLineOpacity(PropertyValue<float> value) {
- impl->paint.lineOpacity.set(value);
+void LineLayer::setLineOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.lineOpacity.set(value, klass);
}
PropertyValue<Color> LineLayer::getLineColor() const {
return impl->paint.lineColor.get();
}
-void LineLayer::setLineColor(PropertyValue<Color> value) {
- impl->paint.lineColor.set(value);
+void LineLayer::setLineColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.lineColor.set(value, klass);
}
PropertyValue<std::array<float, 2>> LineLayer::getLineTranslate() const {
return impl->paint.lineTranslate.get();
}
-void LineLayer::setLineTranslate(PropertyValue<std::array<float, 2>> value) {
- impl->paint.lineTranslate.set(value);
+void LineLayer::setLineTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ impl->paint.lineTranslate.set(value, klass);
}
PropertyValue<TranslateAnchorType> LineLayer::getLineTranslateAnchor() const {
return impl->paint.lineTranslateAnchor.get();
}
-void LineLayer::setLineTranslateAnchor(PropertyValue<TranslateAnchorType> value) {
- impl->paint.lineTranslateAnchor.set(value);
+void LineLayer::setLineTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ impl->paint.lineTranslateAnchor.set(value, klass);
}
PropertyValue<float> LineLayer::getLineWidth() const {
return impl->paint.lineWidth.get();
}
-void LineLayer::setLineWidth(PropertyValue<float> value) {
- impl->paint.lineWidth.set(value);
+void LineLayer::setLineWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.lineWidth.set(value, klass);
}
PropertyValue<float> LineLayer::getLineGapWidth() const {
return impl->paint.lineGapWidth.get();
}
-void LineLayer::setLineGapWidth(PropertyValue<float> value) {
- impl->paint.lineGapWidth.set(value);
+void LineLayer::setLineGapWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.lineGapWidth.set(value, klass);
}
PropertyValue<float> LineLayer::getLineOffset() const {
return impl->paint.lineOffset.get();
}
-void LineLayer::setLineOffset(PropertyValue<float> value) {
- impl->paint.lineOffset.set(value);
+void LineLayer::setLineOffset(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.lineOffset.set(value, klass);
}
PropertyValue<float> LineLayer::getLineBlur() const {
return impl->paint.lineBlur.get();
}
-void LineLayer::setLineBlur(PropertyValue<float> value) {
- impl->paint.lineBlur.set(value);
+void LineLayer::setLineBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.lineBlur.set(value, klass);
}
PropertyValue<std::vector<float>> LineLayer::getLineDasharray() const {
return impl->paint.lineDasharray.get();
}
-void LineLayer::setLineDasharray(PropertyValue<std::vector<float>> value) {
- impl->paint.lineDasharray.set(value);
+void LineLayer::setLineDasharray(PropertyValue<std::vector<float>> value, const optional<std::string>& klass) {
+ impl->paint.lineDasharray.set(value, klass);
}
PropertyValue<std::string> LineLayer::getLinePattern() const {
return impl->paint.linePattern.get();
}
-void LineLayer::setLinePattern(PropertyValue<std::string> value) {
- impl->paint.linePattern.set(value);
+void LineLayer::setLinePattern(PropertyValue<std::string> value, const optional<std::string>& klass) {
+ impl->paint.linePattern.set(value, klass);
}
} // namespace style
diff --git a/src/mbgl/style/layers/line_layer_impl.cpp b/src/mbgl/style/layers/line_layer_impl.cpp
index 589b129ee6..3cdd90b7fd 100644
--- a/src/mbgl/style/layers/line_layer_impl.cpp
+++ b/src/mbgl/style/layers/line_layer_impl.cpp
@@ -8,14 +8,6 @@
namespace mbgl {
namespace style {
-void LineLayer::Impl::parseLayout(const JSValue& value) {
- layout.parse(value);
-}
-
-void LineLayer::Impl::parsePaints(const JSValue& layer) {
- paint.parse(layer);
-}
-
void LineLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
diff --git a/src/mbgl/style/layers/line_layer_impl.hpp b/src/mbgl/style/layers/line_layer_impl.hpp
index 3356dc2ceb..e130bc01bc 100644
--- a/src/mbgl/style/layers/line_layer_impl.hpp
+++ b/src/mbgl/style/layers/line_layer_impl.hpp
@@ -10,9 +10,7 @@ namespace style {
class LineLayer::Impl : public Layer::Impl {
public:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) override;
- void parsePaints(const JSValue&) override;
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
bool recalculate(const CalculationParameters&) override;
diff --git a/src/mbgl/style/layers/line_layer_properties.cpp b/src/mbgl/style/layers/line_layer_properties.cpp
index 7c74f6de04..2d6092745e 100644
--- a/src/mbgl/style/layers/line_layer_properties.cpp
+++ b/src/mbgl/style/layers/line_layer_properties.cpp
@@ -5,13 +5,6 @@
namespace mbgl {
namespace style {
-void LineLayoutProperties::parse(const JSValue& value) {
- lineCap.parse("line-cap", value);
- lineJoin.parse("line-join", value);
- lineMiterLimit.parse("line-miter-limit", value);
- lineRoundLimit.parse("line-round-limit", value);
-}
-
void LineLayoutProperties::recalculate(const CalculationParameters& parameters) {
lineCap.calculate(parameters);
lineJoin.calculate(parameters);
@@ -19,19 +12,6 @@ void LineLayoutProperties::recalculate(const CalculationParameters& parameters)
lineRoundLimit.calculate(parameters);
}
-void LinePaintProperties::parse(const JSValue& value) {
- lineOpacity.parse("line-opacity", value);
- lineColor.parse("line-color", value);
- lineTranslate.parse("line-translate", value);
- lineTranslateAnchor.parse("line-translate-anchor", value);
- lineWidth.parse("line-width", value);
- lineGapWidth.parse("line-gap-width", value);
- lineOffset.parse("line-offset", value);
- lineBlur.parse("line-blur", value);
- lineDasharray.parse("line-dasharray", value);
- linePattern.parse("line-pattern", value);
-}
-
void LinePaintProperties::cascade(const CascadeParameters& parameters) {
lineOpacity.cascade(parameters);
lineColor.cascade(parameters);
diff --git a/src/mbgl/style/layers/line_layer_properties.hpp b/src/mbgl/style/layers/line_layer_properties.hpp
index 0bc08f1988..e7dbddf442 100644
--- a/src/mbgl/style/layers/line_layer_properties.hpp
+++ b/src/mbgl/style/layers/line_layer_properties.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -15,7 +14,6 @@ class CalculationParameters;
class LineLayoutProperties {
public:
- void parse(const JSValue&);
void recalculate(const CalculationParameters&);
LayoutProperty<LineCapType> lineCap { LineCapType::Butt };
@@ -26,7 +24,6 @@ public:
class LinePaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layers/raster_layer.cpp b/src/mbgl/style/layers/raster_layer.cpp
index cdba19ac4e..d4e121babe 100644
--- a/src/mbgl/style/layers/raster_layer.cpp
+++ b/src/mbgl/style/layers/raster_layer.cpp
@@ -24,6 +24,14 @@ std::unique_ptr<Layer> RasterLayer::Impl::clone() const {
return std::make_unique<RasterLayer>(*this);
}
+std::unique_ptr<Layer> RasterLayer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<RasterLayer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = RasterPaintProperties();
+ return std::move(result);
+}
+
// Source
const std::string& RasterLayer::getSourceID() const {
@@ -40,56 +48,56 @@ PropertyValue<float> RasterLayer::getRasterOpacity() const {
return impl->paint.rasterOpacity.get();
}
-void RasterLayer::setRasterOpacity(PropertyValue<float> value) {
- impl->paint.rasterOpacity.set(value);
+void RasterLayer::setRasterOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterOpacity.set(value, klass);
}
PropertyValue<float> RasterLayer::getRasterHueRotate() const {
return impl->paint.rasterHueRotate.get();
}
-void RasterLayer::setRasterHueRotate(PropertyValue<float> value) {
- impl->paint.rasterHueRotate.set(value);
+void RasterLayer::setRasterHueRotate(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterHueRotate.set(value, klass);
}
PropertyValue<float> RasterLayer::getRasterBrightnessMin() const {
return impl->paint.rasterBrightnessMin.get();
}
-void RasterLayer::setRasterBrightnessMin(PropertyValue<float> value) {
- impl->paint.rasterBrightnessMin.set(value);
+void RasterLayer::setRasterBrightnessMin(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterBrightnessMin.set(value, klass);
}
PropertyValue<float> RasterLayer::getRasterBrightnessMax() const {
return impl->paint.rasterBrightnessMax.get();
}
-void RasterLayer::setRasterBrightnessMax(PropertyValue<float> value) {
- impl->paint.rasterBrightnessMax.set(value);
+void RasterLayer::setRasterBrightnessMax(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterBrightnessMax.set(value, klass);
}
PropertyValue<float> RasterLayer::getRasterSaturation() const {
return impl->paint.rasterSaturation.get();
}
-void RasterLayer::setRasterSaturation(PropertyValue<float> value) {
- impl->paint.rasterSaturation.set(value);
+void RasterLayer::setRasterSaturation(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterSaturation.set(value, klass);
}
PropertyValue<float> RasterLayer::getRasterContrast() const {
return impl->paint.rasterContrast.get();
}
-void RasterLayer::setRasterContrast(PropertyValue<float> value) {
- impl->paint.rasterContrast.set(value);
+void RasterLayer::setRasterContrast(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterContrast.set(value, klass);
}
PropertyValue<float> RasterLayer::getRasterFadeDuration() const {
return impl->paint.rasterFadeDuration.get();
}
-void RasterLayer::setRasterFadeDuration(PropertyValue<float> value) {
- impl->paint.rasterFadeDuration.set(value);
+void RasterLayer::setRasterFadeDuration(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.rasterFadeDuration.set(value, klass);
}
} // namespace style
diff --git a/src/mbgl/style/layers/raster_layer_impl.cpp b/src/mbgl/style/layers/raster_layer_impl.cpp
index 4854ec041d..879bfa4559 100644
--- a/src/mbgl/style/layers/raster_layer_impl.cpp
+++ b/src/mbgl/style/layers/raster_layer_impl.cpp
@@ -4,10 +4,6 @@
namespace mbgl {
namespace style {
-void RasterLayer::Impl::parsePaints(const JSValue& layer) {
- paint.parse(layer);
-}
-
void RasterLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
diff --git a/src/mbgl/style/layers/raster_layer_impl.hpp b/src/mbgl/style/layers/raster_layer_impl.hpp
index 6812b469a6..a5b396e2ed 100644
--- a/src/mbgl/style/layers/raster_layer_impl.hpp
+++ b/src/mbgl/style/layers/raster_layer_impl.hpp
@@ -10,9 +10,7 @@ namespace style {
class RasterLayer::Impl : public Layer::Impl {
public:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) override {};
- void parsePaints(const JSValue&) override;
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
bool recalculate(const CalculationParameters&) override;
diff --git a/src/mbgl/style/layers/raster_layer_properties.cpp b/src/mbgl/style/layers/raster_layer_properties.cpp
index 0e6afc5e9c..68d9d1d35d 100644
--- a/src/mbgl/style/layers/raster_layer_properties.cpp
+++ b/src/mbgl/style/layers/raster_layer_properties.cpp
@@ -5,16 +5,6 @@
namespace mbgl {
namespace style {
-void RasterPaintProperties::parse(const JSValue& value) {
- rasterOpacity.parse("raster-opacity", value);
- rasterHueRotate.parse("raster-hue-rotate", value);
- rasterBrightnessMin.parse("raster-brightness-min", value);
- rasterBrightnessMax.parse("raster-brightness-max", value);
- rasterSaturation.parse("raster-saturation", value);
- rasterContrast.parse("raster-contrast", value);
- rasterFadeDuration.parse("raster-fade-duration", value);
-}
-
void RasterPaintProperties::cascade(const CascadeParameters& parameters) {
rasterOpacity.cascade(parameters);
rasterHueRotate.cascade(parameters);
diff --git a/src/mbgl/style/layers/raster_layer_properties.hpp b/src/mbgl/style/layers/raster_layer_properties.hpp
index 1581ca6687..ddfb833e12 100644
--- a/src/mbgl/style/layers/raster_layer_properties.hpp
+++ b/src/mbgl/style/layers/raster_layer_properties.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -15,7 +14,6 @@ class CalculationParameters;
class RasterPaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp
index 905caa0310..c26123f0ec 100644
--- a/src/mbgl/style/layers/symbol_layer.cpp
+++ b/src/mbgl/style/layers/symbol_layer.cpp
@@ -24,6 +24,14 @@ std::unique_ptr<Layer> SymbolLayer::Impl::clone() const {
return std::make_unique<SymbolLayer>(*this);
}
+std::unique_ptr<Layer> SymbolLayer::Impl::cloneRef(const std::string& id_) const {
+ auto result = std::make_unique<SymbolLayer>(*this);
+ result->impl->id = id_;
+ result->impl->ref = this->id;
+ result->impl->paint = SymbolPaintProperties();
+ return std::move(result);
+}
+
// Source
const std::string& SymbolLayer::getSourceID() const {
@@ -295,112 +303,112 @@ PropertyValue<float> SymbolLayer::getIconOpacity() const {
return impl->paint.iconOpacity.get();
}
-void SymbolLayer::setIconOpacity(PropertyValue<float> value) {
- impl->paint.iconOpacity.set(value);
+void SymbolLayer::setIconOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.iconOpacity.set(value, klass);
}
PropertyValue<Color> SymbolLayer::getIconColor() const {
return impl->paint.iconColor.get();
}
-void SymbolLayer::setIconColor(PropertyValue<Color> value) {
- impl->paint.iconColor.set(value);
+void SymbolLayer::setIconColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.iconColor.set(value, klass);
}
PropertyValue<Color> SymbolLayer::getIconHaloColor() const {
return impl->paint.iconHaloColor.get();
}
-void SymbolLayer::setIconHaloColor(PropertyValue<Color> value) {
- impl->paint.iconHaloColor.set(value);
+void SymbolLayer::setIconHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.iconHaloColor.set(value, klass);
}
PropertyValue<float> SymbolLayer::getIconHaloWidth() const {
return impl->paint.iconHaloWidth.get();
}
-void SymbolLayer::setIconHaloWidth(PropertyValue<float> value) {
- impl->paint.iconHaloWidth.set(value);
+void SymbolLayer::setIconHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.iconHaloWidth.set(value, klass);
}
PropertyValue<float> SymbolLayer::getIconHaloBlur() const {
return impl->paint.iconHaloBlur.get();
}
-void SymbolLayer::setIconHaloBlur(PropertyValue<float> value) {
- impl->paint.iconHaloBlur.set(value);
+void SymbolLayer::setIconHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.iconHaloBlur.set(value, klass);
}
PropertyValue<std::array<float, 2>> SymbolLayer::getIconTranslate() const {
return impl->paint.iconTranslate.get();
}
-void SymbolLayer::setIconTranslate(PropertyValue<std::array<float, 2>> value) {
- impl->paint.iconTranslate.set(value);
+void SymbolLayer::setIconTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ impl->paint.iconTranslate.set(value, klass);
}
PropertyValue<TranslateAnchorType> SymbolLayer::getIconTranslateAnchor() const {
return impl->paint.iconTranslateAnchor.get();
}
-void SymbolLayer::setIconTranslateAnchor(PropertyValue<TranslateAnchorType> value) {
- impl->paint.iconTranslateAnchor.set(value);
+void SymbolLayer::setIconTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ impl->paint.iconTranslateAnchor.set(value, klass);
}
PropertyValue<float> SymbolLayer::getTextOpacity() const {
return impl->paint.textOpacity.get();
}
-void SymbolLayer::setTextOpacity(PropertyValue<float> value) {
- impl->paint.textOpacity.set(value);
+void SymbolLayer::setTextOpacity(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.textOpacity.set(value, klass);
}
PropertyValue<Color> SymbolLayer::getTextColor() const {
return impl->paint.textColor.get();
}
-void SymbolLayer::setTextColor(PropertyValue<Color> value) {
- impl->paint.textColor.set(value);
+void SymbolLayer::setTextColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.textColor.set(value, klass);
}
PropertyValue<Color> SymbolLayer::getTextHaloColor() const {
return impl->paint.textHaloColor.get();
}
-void SymbolLayer::setTextHaloColor(PropertyValue<Color> value) {
- impl->paint.textHaloColor.set(value);
+void SymbolLayer::setTextHaloColor(PropertyValue<Color> value, const optional<std::string>& klass) {
+ impl->paint.textHaloColor.set(value, klass);
}
PropertyValue<float> SymbolLayer::getTextHaloWidth() const {
return impl->paint.textHaloWidth.get();
}
-void SymbolLayer::setTextHaloWidth(PropertyValue<float> value) {
- impl->paint.textHaloWidth.set(value);
+void SymbolLayer::setTextHaloWidth(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.textHaloWidth.set(value, klass);
}
PropertyValue<float> SymbolLayer::getTextHaloBlur() const {
return impl->paint.textHaloBlur.get();
}
-void SymbolLayer::setTextHaloBlur(PropertyValue<float> value) {
- impl->paint.textHaloBlur.set(value);
+void SymbolLayer::setTextHaloBlur(PropertyValue<float> value, const optional<std::string>& klass) {
+ impl->paint.textHaloBlur.set(value, klass);
}
PropertyValue<std::array<float, 2>> SymbolLayer::getTextTranslate() const {
return impl->paint.textTranslate.get();
}
-void SymbolLayer::setTextTranslate(PropertyValue<std::array<float, 2>> value) {
- impl->paint.textTranslate.set(value);
+void SymbolLayer::setTextTranslate(PropertyValue<std::array<float, 2>> value, const optional<std::string>& klass) {
+ impl->paint.textTranslate.set(value, klass);
}
PropertyValue<TranslateAnchorType> SymbolLayer::getTextTranslateAnchor() const {
return impl->paint.textTranslateAnchor.get();
}
-void SymbolLayer::setTextTranslateAnchor(PropertyValue<TranslateAnchorType> value) {
- impl->paint.textTranslateAnchor.set(value);
+void SymbolLayer::setTextTranslateAnchor(PropertyValue<TranslateAnchorType> value, const optional<std::string>& klass) {
+ impl->paint.textTranslateAnchor.set(value, klass);
}
} // namespace style
diff --git a/src/mbgl/style/layers/symbol_layer_impl.cpp b/src/mbgl/style/layers/symbol_layer_impl.cpp
index eeceb52078..0243b1dfa5 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.cpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.cpp
@@ -5,14 +5,6 @@
namespace mbgl {
namespace style {
-void SymbolLayer::Impl::parseLayout(const JSValue& value) {
- layout.parse(value);
-}
-
-void SymbolLayer::Impl::parsePaints(const JSValue& layer) {
- paint.parse(layer);
-}
-
void SymbolLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
diff --git a/src/mbgl/style/layers/symbol_layer_impl.hpp b/src/mbgl/style/layers/symbol_layer_impl.hpp
index 9727cc6480..7765d6790e 100644
--- a/src/mbgl/style/layers/symbol_layer_impl.hpp
+++ b/src/mbgl/style/layers/symbol_layer_impl.hpp
@@ -13,9 +13,7 @@ namespace style {
class SymbolLayer::Impl : public Layer::Impl {
public:
std::unique_ptr<Layer> clone() const override;
-
- void parseLayout(const JSValue&) override;
- void parsePaints(const JSValue&) override;
+ std::unique_ptr<Layer> cloneRef(const std::string& id) const override;
void cascade(const CascadeParameters&) override;
bool recalculate(const CalculationParameters&) override;
diff --git a/src/mbgl/style/layers/symbol_layer_properties.cpp b/src/mbgl/style/layers/symbol_layer_properties.cpp
index d77d10700c..59a73d3d59 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.cpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.cpp
@@ -5,43 +5,6 @@
namespace mbgl {
namespace style {
-void SymbolLayoutProperties::parse(const JSValue& value) {
- symbolPlacement.parse("symbol-placement", value);
- symbolSpacing.parse("symbol-spacing", value);
- symbolAvoidEdges.parse("symbol-avoid-edges", value);
- iconAllowOverlap.parse("icon-allow-overlap", value);
- iconIgnorePlacement.parse("icon-ignore-placement", value);
- iconOptional.parse("icon-optional", value);
- iconRotationAlignment.parse("icon-rotation-alignment", value);
- iconSize.parse("icon-size", value);
- iconTextFit.parse("icon-text-fit", value);
- iconTextFitPadding.parse("icon-text-fit-padding", value);
- iconImage.parse("icon-image", value);
- iconRotate.parse("icon-rotate", value);
- iconPadding.parse("icon-padding", value);
- iconKeepUpright.parse("icon-keep-upright", value);
- iconOffset.parse("icon-offset", value);
- textPitchAlignment.parse("text-pitch-alignment", value);
- textRotationAlignment.parse("text-rotation-alignment", value);
- textField.parse("text-field", value);
- textFont.parse("text-font", value);
- textSize.parse("text-size", value);
- textMaxWidth.parse("text-max-width", value);
- textLineHeight.parse("text-line-height", value);
- textLetterSpacing.parse("text-letter-spacing", value);
- textJustify.parse("text-justify", value);
- textAnchor.parse("text-anchor", value);
- textMaxAngle.parse("text-max-angle", value);
- textRotate.parse("text-rotate", value);
- textPadding.parse("text-padding", value);
- textKeepUpright.parse("text-keep-upright", value);
- textTransform.parse("text-transform", value);
- textOffset.parse("text-offset", value);
- textAllowOverlap.parse("text-allow-overlap", value);
- textIgnorePlacement.parse("text-ignore-placement", value);
- textOptional.parse("text-optional", value);
-}
-
void SymbolLayoutProperties::recalculate(const CalculationParameters& parameters) {
symbolPlacement.calculate(parameters);
symbolSpacing.calculate(parameters);
@@ -79,23 +42,6 @@ void SymbolLayoutProperties::recalculate(const CalculationParameters& parameters
textOptional.calculate(parameters);
}
-void SymbolPaintProperties::parse(const JSValue& value) {
- iconOpacity.parse("icon-opacity", value);
- iconColor.parse("icon-color", value);
- iconHaloColor.parse("icon-halo-color", value);
- iconHaloWidth.parse("icon-halo-width", value);
- iconHaloBlur.parse("icon-halo-blur", value);
- iconTranslate.parse("icon-translate", value);
- iconTranslateAnchor.parse("icon-translate-anchor", value);
- textOpacity.parse("text-opacity", value);
- textColor.parse("text-color", value);
- textHaloColor.parse("text-halo-color", value);
- textHaloWidth.parse("text-halo-width", value);
- textHaloBlur.parse("text-halo-blur", value);
- textTranslate.parse("text-translate", value);
- textTranslateAnchor.parse("text-translate-anchor", value);
-}
-
void SymbolPaintProperties::cascade(const CascadeParameters& parameters) {
iconOpacity.cascade(parameters);
iconColor.cascade(parameters);
diff --git a/src/mbgl/style/layers/symbol_layer_properties.hpp b/src/mbgl/style/layers/symbol_layer_properties.hpp
index 378562d605..a269969cb8 100644
--- a/src/mbgl/style/layers/symbol_layer_properties.hpp
+++ b/src/mbgl/style/layers/symbol_layer_properties.hpp
@@ -5,7 +5,6 @@
#include <mbgl/style/types.hpp>
#include <mbgl/style/layout_property.hpp>
#include <mbgl/style/paint_property.hpp>
-#include <mbgl/util/rapidjson.hpp>
namespace mbgl {
namespace style {
@@ -15,7 +14,6 @@ class CalculationParameters;
class SymbolLayoutProperties {
public:
- void parse(const JSValue&);
void recalculate(const CalculationParameters&);
LayoutProperty<SymbolPlacementType> symbolPlacement { SymbolPlacementType::Point };
@@ -56,7 +54,6 @@ public:
class SymbolPaintProperties {
public:
- void parse(const JSValue&);
void cascade(const CascadeParameters&);
bool recalculate(const CalculationParameters&);
diff --git a/src/mbgl/style/layout_property.hpp b/src/mbgl/style/layout_property.hpp
index f5045b47fc..db1a1ebf28 100644
--- a/src/mbgl/style/layout_property.hpp
+++ b/src/mbgl/style/layout_property.hpp
@@ -3,7 +3,6 @@
#include <mbgl/style/property_value.hpp>
#include <mbgl/style/property_parsing.hpp>
#include <mbgl/style/property_evaluator.hpp>
-#include <mbgl/util/rapidjson.hpp>
#include <utility>
@@ -25,12 +24,6 @@ public:
currentValue = value_;
}
- void parse(const char * name, const JSValue& layout) {
- if (layout.HasMember(name)) {
- currentValue = parseProperty<T>(name, layout[name]);
- }
- }
-
void calculate(const CalculationParameters& parameters) {
if (currentValue) {
PropertyEvaluator<T> evaluator(parameters, defaultValue);
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) {
diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp
index a0f4dd24c9..ac263dbc57 100644
--- a/src/mbgl/style/parser.cpp
+++ b/src/mbgl/style/parser.cpp
@@ -11,7 +11,7 @@
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/rapidjson_conversion.hpp>
#include <mbgl/style/conversion.hpp>
-#include <mbgl/style/conversion/filter.hpp>
+#include <mbgl/style/conversion/layer.hpp>
#include <mbgl/platform/log.hpp>
@@ -219,120 +219,16 @@ void Parser::parseLayer(const std::string& id, const JSValue& value, std::unique
return;
}
- layer = reference->baseImpl->copy(id, ref, reference->baseImpl->source);
- layer->baseImpl->parsePaints(value);
+ layer = reference->baseImpl->cloneRef(id);
+ conversion::setPaintProperties(*layer, value);
} else {
- // Otherwise, parse the source/source-layer/filter/render keys to form the bucket.
- if (!value.HasMember("type")) {
- Log::Warning(Event::ParseStyle, "layer '%s' is missing a type", id.c_str());
+ conversion::Result<std::unique_ptr<Layer>> converted = conversion::convert<std::unique_ptr<Layer>>(value);
+ if (!converted) {
+ Log::Warning(Event::ParseStyle, converted.error().message);
return;
}
-
- const JSValue& typeVal = value["type"];
- if (!typeVal.IsString()) {
- Log::Warning(Event::ParseStyle, "layer '%s' has an invalid type", id.c_str());
- return;
- }
-
- std::string type { typeVal.GetString(), typeVal.GetStringLength() };
- std::string source;
-
- if (value.HasMember("source")) {
- const JSValue& value_source = value["source"];
- if (value_source.IsString()) {
- source = { value_source.GetString(), value_source.GetStringLength() };
- auto source_it = sourcesMap.find(source);
- if (source_it == sourcesMap.end()) {
- Log::Warning(Event::ParseStyle, "can't find source '%s' required for layer '%s'", source.c_str(), id.c_str());
- }
- } else {
- Log::Warning(Event::ParseStyle, "source of layer '%s' must be a string", id.c_str());
- }
- }
-
- if (type == "fill") {
- layer = std::make_unique<FillLayer>(id, source);
- } else if (type == "line") {
- layer = std::make_unique<LineLayer>(id, source);
- } else if (type == "circle") {
- layer = std::make_unique<CircleLayer>(id, source);
- } else if (type == "symbol") {
- layer = std::make_unique<SymbolLayer>(id, source);
- } else if (type == "raster") {
- layer = std::make_unique<RasterLayer>(id, source);
- } else if (type == "background") {
- layer = std::make_unique<BackgroundLayer>(id);
- } else {
- Log::Warning(Event::ParseStyle, "unknown type '%s' for layer '%s'", type.c_str(), id.c_str());
- return;
- }
-
- Layer::Impl* impl = layer->baseImpl.get();
-
- if (value.HasMember("source-layer")) {
- const JSValue& value_source_layer = value["source-layer"];
- if (value_source_layer.IsString()) {
- impl->sourceLayer = { value_source_layer.GetString(), value_source_layer.GetStringLength() };
- } else {
- Log::Warning(Event::ParseStyle, "source-layer of layer '%s' must be a string", impl->id.c_str());
- }
- }
-
- if (value.HasMember("filter")) {
- conversion::Result<Filter> filter = conversion::convert<Filter>(value["filter"]);
- if (filter) {
- impl->filter = *filter;
- } else {
- Log::Warning(Event::ParseStyle, filter.error().message);
- }
- }
-
- if (value.HasMember("minzoom")) {
- const JSValue& min_zoom = value["minzoom"];
- if (min_zoom.IsNumber()) {
- impl->minZoom = min_zoom.GetDouble();
- } else {
- Log::Warning(Event::ParseStyle, "minzoom of layer %s must be numeric", impl->id.c_str());
- }
- }
-
- if (value.HasMember("maxzoom")) {
- const JSValue& max_zoom = value["maxzoom"];
- if (max_zoom.IsNumber()) {
- impl->maxZoom = max_zoom.GetDouble();
- } else {
- Log::Warning(Event::ParseStyle, "maxzoom of layer %s must be numeric", impl->id.c_str());
- }
- }
-
- if (value.HasMember("layout")) {
- parseVisibility(*layer, value["layout"]);
- impl->parseLayout(value["layout"]);
- }
-
- impl->parsePaints(value);
- }
-}
-
-void Parser::parseVisibility(Layer& layer, const JSValue& value) {
- Layer::Impl& impl = *layer.baseImpl;
-
- if (!value.HasMember("visibility")) {
- return;
- }
-
- if (!value["visibility"].IsString()) {
- Log::Warning(Event::ParseStyle, "value of 'visibility' must be a string");
- return;
+ layer = std::move(*converted);
}
-
- const auto enumValue = Enum<VisibilityType>::toEnum({ value["visibility"].GetString(), value["visibility"].GetStringLength() });
- if (!enumValue) {
- Log::Warning(Event::ParseStyle, "value of 'visibility' must be a valid enumeration value");
- return;
- }
-
- impl.visibility = *enumValue;
}
std::vector<FontStack> Parser::fontStacks() const {
diff --git a/src/mbgl/style/parser.hpp b/src/mbgl/style/parser.hpp
index 30da0dd2b0..faf80cee93 100644
--- a/src/mbgl/style/parser.hpp
+++ b/src/mbgl/style/parser.hpp
@@ -34,7 +34,6 @@ private:
void parseSources(const JSValue&);
void parseLayers(const JSValue&);
void parseLayer(const std::string& id, const JSValue&, std::unique_ptr<Layer>&);
- void parseVisibility(Layer&, const JSValue& value);
std::unordered_map<std::string, const Source*> sourcesMap;
std::unordered_map<std::string, std::pair<const JSValue&, std::unique_ptr<Layer>>> layersMap;
diff --git a/src/mbgl/style/rapidjson_conversion.hpp b/src/mbgl/style/rapidjson_conversion.hpp
index 1d9f88efa3..ecf044fb64 100644
--- a/src/mbgl/style/rapidjson_conversion.hpp
+++ b/src/mbgl/style/rapidjson_conversion.hpp
@@ -2,11 +2,16 @@
#include <mbgl/util/rapidjson.hpp>
#include <mbgl/util/feature.hpp>
+#include <mbgl/style/conversion.hpp>
namespace mbgl {
namespace style {
namespace conversion {
+inline bool isUndefined(const JSValue& value) {
+ return value.IsNull();
+}
+
inline bool isArray(const JSValue& value) {
return value.IsArray();
}
@@ -30,6 +35,17 @@ inline const JSValue* objectMember(const JSValue& value, const char * name) {
return &value[name];
}
+template <class Fn>
+optional<Error> eachMember(const JSValue& value, Fn&& fn) {
+ for (auto it = value.MemberBegin(); it != value.MemberEnd(); ++it) {
+ optional<Error> result = fn({it->name.GetString(), it->name.GetStringLength()}, it->value);
+ if (result) {
+ return result;
+ }
+ }
+ return {};
+}
+
inline optional<bool> toBool(const JSValue& value) {
if (!value.IsBool()) {
return {};
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index cb48790c9f..9073894cc2 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -141,6 +141,8 @@ Layer* Style::getLayer(const std::string& id) const {
}
void Style::addLayer(std::unique_ptr<Layer> layer, optional<std::string> before) {
+ // TODO: verify source
+
if (SymbolLayer* symbolLayer = layer->as<SymbolLayer>()) {
if (!symbolLayer->impl->spriteAtlas) {
symbolLayer->impl->spriteAtlas = spriteAtlas.get();