summaryrefslogtreecommitdiff
path: root/include
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 /include
parentc4e4cc5081965d03132eea754c27ece3c95961cb (diff)
downloadqtlocation-mapboxgl-16c435b1517b15a5ea8654987979ef58800b838b.tar.gz
[core, node] Implement bindings for addLayer
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/style/conversion.hpp5
-rw-r--r--include/mbgl/style/conversion/layer.hpp208
-rw-r--r--include/mbgl/style/conversion/make_property_setters.hpp133
-rw-r--r--include/mbgl/style/conversion/make_property_setters.hpp.ejs45
-rw-r--r--include/mbgl/style/conversion/property_setter.hpp55
-rw-r--r--include/mbgl/style/conversion/property_value.hpp4
-rw-r--r--include/mbgl/style/layers/background_layer.hpp6
-rw-r--r--include/mbgl/style/layers/circle_layer.hpp12
-rw-r--r--include/mbgl/style/layers/fill_layer.hpp14
-rw-r--r--include/mbgl/style/layers/layer.hpp.ejs2
-rw-r--r--include/mbgl/style/layers/line_layer.hpp20
-rw-r--r--include/mbgl/style/layers/raster_layer.hpp14
-rw-r--r--include/mbgl/style/layers/symbol_layer.hpp28
13 files changed, 497 insertions, 49 deletions
diff --git a/include/mbgl/style/conversion.hpp b/include/mbgl/style/conversion.hpp
index eff7e293a3..2cb3ced376 100644
--- a/include/mbgl/style/conversion.hpp
+++ b/include/mbgl/style/conversion.hpp
@@ -28,6 +28,8 @@ namespace conversion {
The implementation of `convert` requires that the following are legal expressions for a value `v`
of type `const V&`:
+ * `isUndefined(v)` -- returns a boolean indication whether `v` is undefined or a JSON null
+
* `isArray(v)` -- returns a boolean indicating whether `v` represents a JSON array
* `arrayLength(v)` -- called only if `isArray(v)`; returns a size_t length
* `arrayMember(v)` -- called only if `isArray(v)`; returns `V` or `V&`
@@ -36,6 +38,9 @@ namespace conversion {
* `objectMember(v, name)` -- called only if `isObject(v)`; `name` is `const char *`; return value:
* is true when evaluated in a boolean context iff the named member exists
* is convertable to a `V` or `V&` when dereferenced
+ * `eachMember(v, [] (const std::string&, const V&) -> optional<Error> {...})` -- called
+ only if `isObject(v)`; calls the provided lambda once for each key and value of the object;
+ short-circuits if any call returns an `Error`
* `toBool(v)` -- returns `optional<bool>`, absence indicating `v` is not a JSON boolean
* `toNumber(v)` -- returns `optional<float>`, absence indicating `v` is not a JSON number
diff --git a/include/mbgl/style/conversion/layer.hpp b/include/mbgl/style/conversion/layer.hpp
new file mode 100644
index 0000000000..0539dcf9ad
--- /dev/null
+++ b/include/mbgl/style/conversion/layer.hpp
@@ -0,0 +1,208 @@
+#pragma once
+
+#include <mbgl/style/layer.hpp>
+#include <mbgl/style/layers/background_layer.hpp>
+#include <mbgl/style/layers/circle_layer.hpp>
+#include <mbgl/style/layers/fill_layer.hpp>
+#include <mbgl/style/layers/line_layer.hpp>
+#include <mbgl/style/layers/raster_layer.hpp>
+#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/conversion/constant.hpp>
+#include <mbgl/style/conversion/filter.hpp>
+#include <mbgl/style/conversion/make_property_setters.hpp>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+template <class V>
+optional<Error> setLayoutProperty(Layer& layer, const std::string& name, const V& value) {
+ static const auto setters = makeLayoutPropertySetters<V>();
+ auto it = setters.find(name);
+ if (it == setters.end()) {
+ return Error { "property not found" };
+ }
+ return it->second(layer, value);
+}
+
+template <class V>
+optional<Error> setPaintProperty(Layer& layer, const std::string& name, const V& value, const optional<std::string>& klass) {
+ static const auto setters = makePaintPropertySetters<V>();
+ auto it = setters.find(name);
+ if (it == setters.end()) {
+ return Error { "property not found" };
+ }
+ return it->second(layer, value, klass);
+}
+
+template <class V>
+optional<Error> setPaintProperties(Layer& layer, const V& value) {
+ return eachMember(value, [&] (const std::string& paintName, const V& paintValue) -> optional<Error> {
+ if (paintName.compare(0, 5, "paint") != 0) {
+ return {};
+ }
+
+ optional<std::string> klass;
+ if (paintName.compare(0, 6, "paint.") == 0) {
+ klass = paintName.substr(6);
+ }
+
+ return eachMember(paintValue, [&] (const std::string& k, const V& v) {
+ return setPaintProperty(layer, k, v, klass);
+ });
+ });
+}
+
+template <>
+struct Converter<std::unique_ptr<Layer>> {
+public:
+ template <class V>
+ Result<std::unique_ptr<Layer>> operator()(const V& value) const {
+ if (!isObject(value)) {
+ return Error { "layer must be an object" };
+ }
+
+ auto idValue = objectMember(value, "id");
+ if (!idValue) {
+ return Error { "layer must have an id" };
+ }
+
+ optional<std::string> id = toString(*idValue);
+ if (!id) {
+ return Error { "layer id must be a string" };
+ }
+
+ auto typeValue = objectMember(value, "type");
+ if (!typeValue) {
+ return Error { "layer must have a type" };
+ }
+
+ optional<std::string> type = toString(*typeValue);
+ if (!type) {
+ return Error { "layer type must be a string" };
+ }
+
+ Result<std::unique_ptr<Layer>> converted;
+
+ if (*type == "fill") {
+ converted = convertVectorLayer<FillLayer>(*id, value);
+ } else if (*type == "line") {
+ converted = convertVectorLayer<LineLayer>(*id, value);
+ } else if (*type == "circle") {
+ converted = convertVectorLayer<CircleLayer>(*id, value);
+ } else if (*type == "symbol") {
+ converted = convertVectorLayer<SymbolLayer>(*id, value);
+ } else if (*type == "raster") {
+ converted = convertRasterLayer(*id, value);
+ } else if (*type == "background") {
+ converted = convertBackgroundLayer(*id, value);
+ } else {
+ return Error { "invalid layer type" };
+ }
+
+ if (!converted) {
+ return converted;
+ }
+
+ std::unique_ptr<Layer> layer = std::move(*converted);
+
+ auto minzoomValue = objectMember(value, "minzoom");
+ if (minzoomValue) {
+ optional<float> minzoom = toNumber(*minzoomValue);
+ if (!minzoom) {
+ return Error { "minzoom must be numeric" };
+ }
+ layer->setMinZoom(*minzoom);
+ }
+
+ auto maxzoomValue = objectMember(value, "maxzoom");
+ if (maxzoomValue) {
+ optional<float> maxzoom = toNumber(*maxzoomValue);
+ if (!maxzoom) {
+ return Error { "maxzoom must be numeric" };
+ }
+ layer->setMaxZoom(*maxzoom);
+ }
+
+ auto layoutValue = objectMember(value, "layout");
+ if (layoutValue) {
+ if (!isObject(*layoutValue)) {
+ return Error { "layout must be an object" };
+ }
+ optional<Error> error = eachMember(*layoutValue, [&] (const std::string& k, const V& v) {
+ return setLayoutProperty(*layer, k, v);
+ });
+ if (error) {
+ return *error;
+ }
+ }
+
+ optional<Error> error = setPaintProperties(*layer, value);
+ if (error) {
+ return *error;
+ }
+
+ return std::move(layer);
+ }
+
+private:
+ template <class LayerType, class V>
+ Result<std::unique_ptr<Layer>> convertVectorLayer(const std::string& id, const V& value) const {
+ auto sourceValue = objectMember(value, "source");
+ if (!sourceValue) {
+ return Error { "layer must have a source" };
+ }
+
+ optional<std::string> source = toString(*sourceValue);
+ if (!source) {
+ return Error { "layer source must be a string" };
+ }
+
+ std::unique_ptr<LayerType> layer = std::make_unique<LayerType>(id, *source);
+
+ auto sourceLayerValue = objectMember(value, "source-layer");
+ if (sourceLayerValue) {
+ optional<std::string> sourceLayer = toString(*sourceLayerValue);
+ if (!sourceLayer) {
+ return Error { "layer source-layer must be a string" };
+ }
+ layer->setSourceLayer(*sourceLayer);
+ }
+
+ auto filterValue = objectMember(value, "filter");
+ if (filterValue) {
+ Result<Filter> filter = convert<Filter>(*filterValue);
+ if (!filter) {
+ return filter.error();
+ }
+ layer->setFilter(*filter);
+ }
+
+ return std::move(layer);
+ }
+
+ template <class V>
+ Result<std::unique_ptr<Layer>> convertRasterLayer(const std::string& id, const V& value) const {
+ auto sourceValue = objectMember(value, "source");
+ if (!sourceValue) {
+ return Error { "layer must have a source" };
+ }
+
+ optional<std::string> source = toString(*sourceValue);
+ if (!source) {
+ return Error { "layer source must be a string" };
+ }
+
+ return std::make_unique<RasterLayer>(id, *source);
+ }
+
+ template <class V>
+ Result<std::unique_ptr<Layer>> convertBackgroundLayer(const std::string& id, const V&) const {
+ return std::make_unique<BackgroundLayer>(id);
+ }
+};
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl
diff --git a/include/mbgl/style/conversion/make_property_setters.hpp b/include/mbgl/style/conversion/make_property_setters.hpp
new file mode 100644
index 0000000000..4c0089deaf
--- /dev/null
+++ b/include/mbgl/style/conversion/make_property_setters.hpp
@@ -0,0 +1,133 @@
+// This file is generated. Edit make_property_setters.hpp.ejs, then run `make style-code`.
+
+#include <mbgl/style/conversion/property_setter.hpp>
+
+#include <mbgl/style/layers/fill_layer.hpp>
+#include <mbgl/style/layers/line_layer.hpp>
+#include <mbgl/style/layers/symbol_layer.hpp>
+#include <mbgl/style/layers/circle_layer.hpp>
+#include <mbgl/style/layers/raster_layer.hpp>
+#include <mbgl/style/layers/background_layer.hpp>
+
+#include <unordered_map>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+template <class V>
+auto makeLayoutPropertySetters() {
+ std::unordered_map<std::string, LayoutPropertySetter<V>> result;
+
+ result["visibility"] = &setVisibility<V>;
+
+
+ result["line-cap"] = makePropertySetter<V>(&LineLayer::setLineCap);
+ result["line-join"] = makePropertySetter<V>(&LineLayer::setLineJoin);
+ result["line-miter-limit"] = makePropertySetter<V>(&LineLayer::setLineMiterLimit);
+ result["line-round-limit"] = makePropertySetter<V>(&LineLayer::setLineRoundLimit);
+
+ result["symbol-placement"] = makePropertySetter<V>(&SymbolLayer::setSymbolPlacement);
+ result["symbol-spacing"] = makePropertySetter<V>(&SymbolLayer::setSymbolSpacing);
+ result["symbol-avoid-edges"] = makePropertySetter<V>(&SymbolLayer::setSymbolAvoidEdges);
+ result["icon-allow-overlap"] = makePropertySetter<V>(&SymbolLayer::setIconAllowOverlap);
+ result["icon-ignore-placement"] = makePropertySetter<V>(&SymbolLayer::setIconIgnorePlacement);
+ result["icon-optional"] = makePropertySetter<V>(&SymbolLayer::setIconOptional);
+ result["icon-rotation-alignment"] = makePropertySetter<V>(&SymbolLayer::setIconRotationAlignment);
+ result["icon-size"] = makePropertySetter<V>(&SymbolLayer::setIconSize);
+ result["icon-text-fit"] = makePropertySetter<V>(&SymbolLayer::setIconTextFit);
+ result["icon-text-fit-padding"] = makePropertySetter<V>(&SymbolLayer::setIconTextFitPadding);
+ result["icon-image"] = makePropertySetter<V>(&SymbolLayer::setIconImage);
+ result["icon-rotate"] = makePropertySetter<V>(&SymbolLayer::setIconRotate);
+ result["icon-padding"] = makePropertySetter<V>(&SymbolLayer::setIconPadding);
+ result["icon-keep-upright"] = makePropertySetter<V>(&SymbolLayer::setIconKeepUpright);
+ result["icon-offset"] = makePropertySetter<V>(&SymbolLayer::setIconOffset);
+ result["text-pitch-alignment"] = makePropertySetter<V>(&SymbolLayer::setTextPitchAlignment);
+ result["text-rotation-alignment"] = makePropertySetter<V>(&SymbolLayer::setTextRotationAlignment);
+ result["text-field"] = makePropertySetter<V>(&SymbolLayer::setTextField);
+ result["text-font"] = makePropertySetter<V>(&SymbolLayer::setTextFont);
+ result["text-size"] = makePropertySetter<V>(&SymbolLayer::setTextSize);
+ result["text-max-width"] = makePropertySetter<V>(&SymbolLayer::setTextMaxWidth);
+ result["text-line-height"] = makePropertySetter<V>(&SymbolLayer::setTextLineHeight);
+ result["text-letter-spacing"] = makePropertySetter<V>(&SymbolLayer::setTextLetterSpacing);
+ result["text-justify"] = makePropertySetter<V>(&SymbolLayer::setTextJustify);
+ result["text-anchor"] = makePropertySetter<V>(&SymbolLayer::setTextAnchor);
+ result["text-max-angle"] = makePropertySetter<V>(&SymbolLayer::setTextMaxAngle);
+ result["text-rotate"] = makePropertySetter<V>(&SymbolLayer::setTextRotate);
+ result["text-padding"] = makePropertySetter<V>(&SymbolLayer::setTextPadding);
+ result["text-keep-upright"] = makePropertySetter<V>(&SymbolLayer::setTextKeepUpright);
+ result["text-transform"] = makePropertySetter<V>(&SymbolLayer::setTextTransform);
+ result["text-offset"] = makePropertySetter<V>(&SymbolLayer::setTextOffset);
+ result["text-allow-overlap"] = makePropertySetter<V>(&SymbolLayer::setTextAllowOverlap);
+ result["text-ignore-placement"] = makePropertySetter<V>(&SymbolLayer::setTextIgnorePlacement);
+ result["text-optional"] = makePropertySetter<V>(&SymbolLayer::setTextOptional);
+
+
+
+
+ return result;
+}
+
+template <class V>
+auto makePaintPropertySetters() {
+ std::unordered_map<std::string, PaintPropertySetter<V>> result;
+
+ result["fill-antialias"] = makePropertySetter<V>(&FillLayer::setFillAntialias);
+ result["fill-opacity"] = makePropertySetter<V>(&FillLayer::setFillOpacity);
+ result["fill-color"] = makePropertySetter<V>(&FillLayer::setFillColor);
+ result["fill-outline-color"] = makePropertySetter<V>(&FillLayer::setFillOutlineColor);
+ result["fill-translate"] = makePropertySetter<V>(&FillLayer::setFillTranslate);
+ result["fill-translate-anchor"] = makePropertySetter<V>(&FillLayer::setFillTranslateAnchor);
+ result["fill-pattern"] = makePropertySetter<V>(&FillLayer::setFillPattern);
+
+ result["line-opacity"] = makePropertySetter<V>(&LineLayer::setLineOpacity);
+ result["line-color"] = makePropertySetter<V>(&LineLayer::setLineColor);
+ result["line-translate"] = makePropertySetter<V>(&LineLayer::setLineTranslate);
+ result["line-translate-anchor"] = makePropertySetter<V>(&LineLayer::setLineTranslateAnchor);
+ result["line-width"] = makePropertySetter<V>(&LineLayer::setLineWidth);
+ result["line-gap-width"] = makePropertySetter<V>(&LineLayer::setLineGapWidth);
+ result["line-offset"] = makePropertySetter<V>(&LineLayer::setLineOffset);
+ result["line-blur"] = makePropertySetter<V>(&LineLayer::setLineBlur);
+ result["line-dasharray"] = makePropertySetter<V>(&LineLayer::setLineDasharray);
+ result["line-pattern"] = makePropertySetter<V>(&LineLayer::setLinePattern);
+
+ result["icon-opacity"] = makePropertySetter<V>(&SymbolLayer::setIconOpacity);
+ result["icon-color"] = makePropertySetter<V>(&SymbolLayer::setIconColor);
+ result["icon-halo-color"] = makePropertySetter<V>(&SymbolLayer::setIconHaloColor);
+ result["icon-halo-width"] = makePropertySetter<V>(&SymbolLayer::setIconHaloWidth);
+ result["icon-halo-blur"] = makePropertySetter<V>(&SymbolLayer::setIconHaloBlur);
+ result["icon-translate"] = makePropertySetter<V>(&SymbolLayer::setIconTranslate);
+ result["icon-translate-anchor"] = makePropertySetter<V>(&SymbolLayer::setIconTranslateAnchor);
+ result["text-opacity"] = makePropertySetter<V>(&SymbolLayer::setTextOpacity);
+ result["text-color"] = makePropertySetter<V>(&SymbolLayer::setTextColor);
+ result["text-halo-color"] = makePropertySetter<V>(&SymbolLayer::setTextHaloColor);
+ result["text-halo-width"] = makePropertySetter<V>(&SymbolLayer::setTextHaloWidth);
+ result["text-halo-blur"] = makePropertySetter<V>(&SymbolLayer::setTextHaloBlur);
+ result["text-translate"] = makePropertySetter<V>(&SymbolLayer::setTextTranslate);
+ result["text-translate-anchor"] = makePropertySetter<V>(&SymbolLayer::setTextTranslateAnchor);
+
+ result["circle-radius"] = makePropertySetter<V>(&CircleLayer::setCircleRadius);
+ result["circle-color"] = makePropertySetter<V>(&CircleLayer::setCircleColor);
+ result["circle-blur"] = makePropertySetter<V>(&CircleLayer::setCircleBlur);
+ result["circle-opacity"] = makePropertySetter<V>(&CircleLayer::setCircleOpacity);
+ result["circle-translate"] = makePropertySetter<V>(&CircleLayer::setCircleTranslate);
+ result["circle-translate-anchor"] = makePropertySetter<V>(&CircleLayer::setCircleTranslateAnchor);
+
+ result["raster-opacity"] = makePropertySetter<V>(&RasterLayer::setRasterOpacity);
+ result["raster-hue-rotate"] = makePropertySetter<V>(&RasterLayer::setRasterHueRotate);
+ result["raster-brightness-min"] = makePropertySetter<V>(&RasterLayer::setRasterBrightnessMin);
+ result["raster-brightness-max"] = makePropertySetter<V>(&RasterLayer::setRasterBrightnessMax);
+ result["raster-saturation"] = makePropertySetter<V>(&RasterLayer::setRasterSaturation);
+ result["raster-contrast"] = makePropertySetter<V>(&RasterLayer::setRasterContrast);
+ result["raster-fade-duration"] = makePropertySetter<V>(&RasterLayer::setRasterFadeDuration);
+
+ result["background-color"] = makePropertySetter<V>(&BackgroundLayer::setBackgroundColor);
+ result["background-pattern"] = makePropertySetter<V>(&BackgroundLayer::setBackgroundPattern);
+ result["background-opacity"] = makePropertySetter<V>(&BackgroundLayer::setBackgroundOpacity);
+
+ return result;
+}
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl
diff --git a/include/mbgl/style/conversion/make_property_setters.hpp.ejs b/include/mbgl/style/conversion/make_property_setters.hpp.ejs
new file mode 100644
index 0000000000..493c68ea31
--- /dev/null
+++ b/include/mbgl/style/conversion/make_property_setters.hpp.ejs
@@ -0,0 +1,45 @@
+// This file is generated. Edit make_property_setters.hpp.ejs, then run `make style-code`.
+
+#include <mbgl/style/conversion/property_setter.hpp>
+
+<% for (const layer of locals.layers) { -%>
+#include <mbgl/style/layers/<%- layer.type %>_layer.hpp>
+<% } -%>
+
+#include <unordered_map>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+template <class V>
+auto makeLayoutPropertySetters() {
+ std::unordered_map<std::string, LayoutPropertySetter<V>> result;
+
+ result["visibility"] = &setVisibility<V>;
+
+<% for (const layer of locals.layers) { -%>
+<% for (const property of layer.layoutProperties) { -%>
+ result["<%- property.name %>"] = makePropertySetter<V>(&<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>);
+<% } -%>
+
+<% } -%>
+ return result;
+}
+
+template <class V>
+auto makePaintPropertySetters() {
+ std::unordered_map<std::string, PaintPropertySetter<V>> result;
+
+<% for (const layer of locals.layers) { -%>
+<% for (const property of layer.paintProperties) { -%>
+ result["<%- property.name %>"] = makePropertySetter<V>(&<%- camelize(layer.type) %>Layer::set<%- camelize(property.name) %>);
+<% } -%>
+
+<% } -%>
+ return result;
+}
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl
diff --git a/include/mbgl/style/conversion/property_setter.hpp b/include/mbgl/style/conversion/property_setter.hpp
new file mode 100644
index 0000000000..38dd934252
--- /dev/null
+++ b/include/mbgl/style/conversion/property_setter.hpp
@@ -0,0 +1,55 @@
+#include <mbgl/style/layer.hpp>
+#include <mbgl/style/conversion.hpp>
+#include <mbgl/style/conversion/constant.hpp>
+#include <mbgl/style/conversion/property_value.hpp>
+
+#include <functional>
+#include <string>
+
+namespace mbgl {
+namespace style {
+namespace conversion {
+
+template <class V>
+using LayoutPropertySetter = std::function<optional<Error> (Layer&, const V&)>;
+
+template <class V>
+using PaintPropertySetter = std::function<optional<Error> (Layer&, const V&, const optional<std::string>&)>;
+
+template <class V, class L, class T, class...Args>
+auto makePropertySetter(void (L::*setter)(PropertyValue<T>, const Args&...args)) {
+ return [setter] (Layer& layer, const V& value, const Args&...args) -> optional<Error> {
+ L* typedLayer = layer.as<L>();
+ if (!typedLayer) {
+ return Error { "layer doesn't support this property" };
+ }
+
+ Result<PropertyValue<T>> typedValue = convert<PropertyValue<T>>(value);
+ if (!typedValue) {
+ return typedValue.error();
+ }
+
+ (typedLayer->*setter)(*typedValue, args...);
+ return {};
+ };
+}
+
+template <class V>
+optional<Error> setVisibility(Layer& layer, const V& value) {
+ if (isUndefined(value)) {
+ layer.setVisibility(VisibilityType::Visible);
+ return {};
+ }
+
+ Result<VisibilityType> visibility = convert<VisibilityType>(value);
+ if (!visibility) {
+ return visibility.error();
+ }
+
+ layer.setVisibility(*visibility);
+ return {};
+}
+
+} // namespace conversion
+} // namespace style
+} // namespace mbgl
diff --git a/include/mbgl/style/conversion/property_value.hpp b/include/mbgl/style/conversion/property_value.hpp
index 840643abbe..de95b56155 100644
--- a/include/mbgl/style/conversion/property_value.hpp
+++ b/include/mbgl/style/conversion/property_value.hpp
@@ -13,7 +13,9 @@ template <class T>
struct Converter<PropertyValue<T>> {
template <class V>
Result<PropertyValue<T>> operator()(const V& value) const {
- if (isObject(value)) {
+ if (isUndefined(value)) {
+ return {};
+ } else if (isObject(value)) {
Result<Function<T>> function = convert<Function<T>>(value);
if (!function) {
return function.error();
diff --git a/include/mbgl/style/layers/background_layer.hpp b/include/mbgl/style/layers/background_layer.hpp
index 2eb84ee499..ac97ec2e6d 100644
--- a/include/mbgl/style/layers/background_layer.hpp
+++ b/include/mbgl/style/layers/background_layer.hpp
@@ -19,13 +19,13 @@ public:
// Paint properties
PropertyValue<Color> getBackgroundColor() const;
- void setBackgroundColor(PropertyValue<Color>);
+ void setBackgroundColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<std::string> getBackgroundPattern() const;
- void setBackgroundPattern(PropertyValue<std::string>);
+ void setBackgroundPattern(PropertyValue<std::string>, const optional<std::string>& klass = {});
PropertyValue<float> getBackgroundOpacity() const;
- void setBackgroundOpacity(PropertyValue<float>);
+ void setBackgroundOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
// Private implementation
diff --git a/include/mbgl/style/layers/circle_layer.hpp b/include/mbgl/style/layers/circle_layer.hpp
index 9c2b458d4b..c8d99ab30e 100644
--- a/include/mbgl/style/layers/circle_layer.hpp
+++ b/include/mbgl/style/layers/circle_layer.hpp
@@ -27,22 +27,22 @@ public:
// Paint properties
PropertyValue<float> getCircleRadius() const;
- void setCircleRadius(PropertyValue<float>);
+ void setCircleRadius(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<Color> getCircleColor() const;
- void setCircleColor(PropertyValue<Color>);
+ void setCircleColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<float> getCircleBlur() const;
- void setCircleBlur(PropertyValue<float>);
+ void setCircleBlur(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getCircleOpacity() const;
- void setCircleOpacity(PropertyValue<float>);
+ void setCircleOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<std::array<float, 2>> getCircleTranslate() const;
- void setCircleTranslate(PropertyValue<std::array<float, 2>>);
+ void setCircleTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {});
PropertyValue<TranslateAnchorType> getCircleTranslateAnchor() const;
- void setCircleTranslateAnchor(PropertyValue<TranslateAnchorType>);
+ void setCircleTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});
// Private implementation
diff --git a/include/mbgl/style/layers/fill_layer.hpp b/include/mbgl/style/layers/fill_layer.hpp
index 90538dd3ea..e70d67f538 100644
--- a/include/mbgl/style/layers/fill_layer.hpp
+++ b/include/mbgl/style/layers/fill_layer.hpp
@@ -27,25 +27,25 @@ public:
// Paint properties
PropertyValue<bool> getFillAntialias() const;
- void setFillAntialias(PropertyValue<bool>);
+ void setFillAntialias(PropertyValue<bool>, const optional<std::string>& klass = {});
PropertyValue<float> getFillOpacity() const;
- void setFillOpacity(PropertyValue<float>);
+ void setFillOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<Color> getFillColor() const;
- void setFillColor(PropertyValue<Color>);
+ void setFillColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<Color> getFillOutlineColor() const;
- void setFillOutlineColor(PropertyValue<Color>);
+ void setFillOutlineColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<std::array<float, 2>> getFillTranslate() const;
- void setFillTranslate(PropertyValue<std::array<float, 2>>);
+ void setFillTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {});
PropertyValue<TranslateAnchorType> getFillTranslateAnchor() const;
- void setFillTranslateAnchor(PropertyValue<TranslateAnchorType>);
+ void setFillTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});
PropertyValue<std::string> getFillPattern() const;
- void setFillPattern(PropertyValue<std::string>);
+ void setFillPattern(PropertyValue<std::string>, const optional<std::string>& klass = {});
// Private implementation
diff --git a/include/mbgl/style/layers/layer.hpp.ejs b/include/mbgl/style/layers/layer.hpp.ejs
index 60365be906..aaae30287c 100644
--- a/include/mbgl/style/layers/layer.hpp.ejs
+++ b/include/mbgl/style/layers/layer.hpp.ejs
@@ -54,7 +54,7 @@ public:
<% for (const property of paintProperties) { -%>
PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() const;
- void set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>>);
+ void set<%- camelize(property.name) %>(PropertyValue<<%- propertyType(property) %>>, const optional<std::string>& klass = {});
<% } -%>
// Private implementation
diff --git a/include/mbgl/style/layers/line_layer.hpp b/include/mbgl/style/layers/line_layer.hpp
index 4ffeee114a..abcb425b96 100644
--- a/include/mbgl/style/layers/line_layer.hpp
+++ b/include/mbgl/style/layers/line_layer.hpp
@@ -43,34 +43,34 @@ public:
// Paint properties
PropertyValue<float> getLineOpacity() const;
- void setLineOpacity(PropertyValue<float>);
+ void setLineOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<Color> getLineColor() const;
- void setLineColor(PropertyValue<Color>);
+ void setLineColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<std::array<float, 2>> getLineTranslate() const;
- void setLineTranslate(PropertyValue<std::array<float, 2>>);
+ void setLineTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {});
PropertyValue<TranslateAnchorType> getLineTranslateAnchor() const;
- void setLineTranslateAnchor(PropertyValue<TranslateAnchorType>);
+ void setLineTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});
PropertyValue<float> getLineWidth() const;
- void setLineWidth(PropertyValue<float>);
+ void setLineWidth(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getLineGapWidth() const;
- void setLineGapWidth(PropertyValue<float>);
+ void setLineGapWidth(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getLineOffset() const;
- void setLineOffset(PropertyValue<float>);
+ void setLineOffset(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getLineBlur() const;
- void setLineBlur(PropertyValue<float>);
+ void setLineBlur(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<std::vector<float>> getLineDasharray() const;
- void setLineDasharray(PropertyValue<std::vector<float>>);
+ void setLineDasharray(PropertyValue<std::vector<float>>, const optional<std::string>& klass = {});
PropertyValue<std::string> getLinePattern() const;
- void setLinePattern(PropertyValue<std::string>);
+ void setLinePattern(PropertyValue<std::string>, const optional<std::string>& klass = {});
// Private implementation
diff --git a/include/mbgl/style/layers/raster_layer.hpp b/include/mbgl/style/layers/raster_layer.hpp
index 372434e46d..dea0c26bf3 100644
--- a/include/mbgl/style/layers/raster_layer.hpp
+++ b/include/mbgl/style/layers/raster_layer.hpp
@@ -22,25 +22,25 @@ public:
// Paint properties
PropertyValue<float> getRasterOpacity() const;
- void setRasterOpacity(PropertyValue<float>);
+ void setRasterOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getRasterHueRotate() const;
- void setRasterHueRotate(PropertyValue<float>);
+ void setRasterHueRotate(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getRasterBrightnessMin() const;
- void setRasterBrightnessMin(PropertyValue<float>);
+ void setRasterBrightnessMin(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getRasterBrightnessMax() const;
- void setRasterBrightnessMax(PropertyValue<float>);
+ void setRasterBrightnessMax(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getRasterSaturation() const;
- void setRasterSaturation(PropertyValue<float>);
+ void setRasterSaturation(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getRasterContrast() const;
- void setRasterContrast(PropertyValue<float>);
+ void setRasterContrast(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getRasterFadeDuration() const;
- void setRasterFadeDuration(PropertyValue<float>);
+ void setRasterFadeDuration(PropertyValue<float>, const optional<std::string>& klass = {});
// Private implementation
diff --git a/include/mbgl/style/layers/symbol_layer.hpp b/include/mbgl/style/layers/symbol_layer.hpp
index b21c8deaf7..77b63d9b91 100644
--- a/include/mbgl/style/layers/symbol_layer.hpp
+++ b/include/mbgl/style/layers/symbol_layer.hpp
@@ -133,46 +133,46 @@ public:
// Paint properties
PropertyValue<float> getIconOpacity() const;
- void setIconOpacity(PropertyValue<float>);
+ void setIconOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<Color> getIconColor() const;
- void setIconColor(PropertyValue<Color>);
+ void setIconColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<Color> getIconHaloColor() const;
- void setIconHaloColor(PropertyValue<Color>);
+ void setIconHaloColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<float> getIconHaloWidth() const;
- void setIconHaloWidth(PropertyValue<float>);
+ void setIconHaloWidth(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getIconHaloBlur() const;
- void setIconHaloBlur(PropertyValue<float>);
+ void setIconHaloBlur(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<std::array<float, 2>> getIconTranslate() const;
- void setIconTranslate(PropertyValue<std::array<float, 2>>);
+ void setIconTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {});
PropertyValue<TranslateAnchorType> getIconTranslateAnchor() const;
- void setIconTranslateAnchor(PropertyValue<TranslateAnchorType>);
+ void setIconTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});
PropertyValue<float> getTextOpacity() const;
- void setTextOpacity(PropertyValue<float>);
+ void setTextOpacity(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<Color> getTextColor() const;
- void setTextColor(PropertyValue<Color>);
+ void setTextColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<Color> getTextHaloColor() const;
- void setTextHaloColor(PropertyValue<Color>);
+ void setTextHaloColor(PropertyValue<Color>, const optional<std::string>& klass = {});
PropertyValue<float> getTextHaloWidth() const;
- void setTextHaloWidth(PropertyValue<float>);
+ void setTextHaloWidth(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<float> getTextHaloBlur() const;
- void setTextHaloBlur(PropertyValue<float>);
+ void setTextHaloBlur(PropertyValue<float>, const optional<std::string>& klass = {});
PropertyValue<std::array<float, 2>> getTextTranslate() const;
- void setTextTranslate(PropertyValue<std::array<float, 2>>);
+ void setTextTranslate(PropertyValue<std::array<float, 2>>, const optional<std::string>& klass = {});
PropertyValue<TranslateAnchorType> getTextTranslateAnchor() const;
- void setTextTranslateAnchor(PropertyValue<TranslateAnchorType>);
+ void setTextTranslateAnchor(PropertyValue<TranslateAnchorType>, const optional<std::string>& klass = {});
// Private implementation