diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-10-28 22:33:06 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-10-31 15:33:50 +0200 |
commit | c43d01cba40b7f47bcc9712d1b99eddb4134c870 (patch) | |
tree | 416a81ea30e43a3980d2afdd3fb4b94e76dc874c /src/mbgl/style/layers/symbol_layer.cpp | |
parent | 56808731b699d7750726cd88dd06516c63d7f2f0 (diff) | |
download | qtlocation-mapboxgl-upstream/mikhail_introduce_layer_factory.tar.gz |
Introduce the style::Layer factory classesupstream/mikhail_introduce_layer_factory
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/symbol_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/symbol_layer.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mbgl/style/layers/symbol_layer.cpp b/src/mbgl/style/layers/symbol_layer.cpp index d7d024d0e0..d453ddb58d 100644 --- a/src/mbgl/style/layers/symbol_layer.cpp +++ b/src/mbgl/style/layers/symbol_layer.cpp @@ -1978,5 +1978,24 @@ Mutable<Layer::Impl> SymbolLayer::mutableBaseImpl() const { return staticMutableCast<Layer::Impl>(mutableImpl()); } +SymbolLayerFactory::~SymbolLayerFactory() = default; + +const char* SymbolLayerFactory::type() const { + return "symbol"; +} + +std::unique_ptr<style::Layer> SymbolLayerFactory::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 SymbolLayer(id, *source)); + if (!initSourceLayerAndFilter(layer.get(), value)) { + return nullptr; + } + return layer; +} + } // namespace style } // namespace mbgl |