summaryrefslogtreecommitdiff
path: root/src/mbgl/layermanager/symbol_layer_factory.cpp
blob: 5f3de27bb5a0f83ba3dc3bcd93a841bdbd37456c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <mbgl/layermanager/symbol_layer_factory.hpp>

#include <mbgl/layout/symbol_layout.hpp>
#include <mbgl/renderer/layers/render_symbol_layer.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/style/layers/symbol_layer_impl.hpp>

namespace mbgl {

const style::LayerTypeInfo* SymbolLayerFactory::getTypeInfo() const noexcept {
    return style::SymbolLayer::Impl::staticTypeInfo();
}

std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept {
    optional<std::string> source = getSource(value);
    if (!source) {
        return nullptr;
    }
    return std::unique_ptr<style::Layer>(new style::SymbolLayer(id, *source));
}

std::unique_ptr<Layout> SymbolLayerFactory::createLayout(const LayoutParameters& parameters,
                                                         std::unique_ptr<GeometryTileLayer> tileLayer,
                                                         const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
    return std::make_unique<SymbolLayout>(parameters.bucketParameters, group, std::move(tileLayer), parameters);
}

std::unique_ptr<RenderLayer> SymbolLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept {
    assert(impl->getTypeInfo() == getTypeInfo());
    return std::make_unique<RenderSymbolLayer>(staticImmutableCast<style::SymbolLayer::Impl>(impl));
}

} // namespace mbgl