summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/fill_layer.cpp
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-10-28 22:33:06 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-10-31 18:05:01 +0200
commitcfcb53128b41941a9cdacfec18d618b0866a96bc (patch)
tree27ee48ad45fca144d21f71673137c470bbb19459 /src/mbgl/style/layers/fill_layer.cpp
parent278aa3370374154ad6fac7790d2da1546e8493f3 (diff)
downloadqtlocation-mapboxgl-cfcb53128b41941a9cdacfec18d618b0866a96bc.tar.gz
Introduce the style::Layer factory classes
This patch introduces the initial implementation of - A `LayerFactory` abstract class that creates `style::Layer` instances of a certain layer type (line, hillshade, round, ..) - A singleton `LayerManager` class, which is responsible for initializing the `LayerFactory` instances and forwarding the `create()` calls to the corresponding factory.
Diffstat (limited to 'src/mbgl/style/layers/fill_layer.cpp')
-rw-r--r--src/mbgl/style/layers/fill_layer.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mbgl/style/layers/fill_layer.cpp b/src/mbgl/style/layers/fill_layer.cpp
index b244df6eea..9314d5026a 100644
--- a/src/mbgl/style/layers/fill_layer.cpp
+++ b/src/mbgl/style/layers/fill_layer.cpp
@@ -489,5 +489,24 @@ Mutable<Layer::Impl> FillLayer::mutableBaseImpl() const {
return staticMutableCast<Layer::Impl>(mutableImpl());
}
+FillLayerFactory::~FillLayerFactory() = default;
+
+const char* FillLayerFactory::type() const {
+ return "fill";
+}
+
+std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) {
+ optional<std::string> source = getSource(value);
+ if (!source) {
+ return nullptr;
+ }
+
+ std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new FillLayer(id, *source));
+ if (!initSourceLayerAndFilter(layer.get(), value)) {
+ return nullptr;
+ }
+ return layer;
+}
+
} // namespace style
} // namespace mbgl