summaryrefslogtreecommitdiff
path: root/src/mbgl/layermanager/hillshade_layer_factory.cpp
blob: c2981e17edfe3a3d238533ef8deea63dd4716f07 (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
#include <mbgl/layermanager/hillshade_layer_factory.hpp>

#include <mbgl/renderer/layers/render_hillshade_layer.hpp>
#include <mbgl/style/layers/hillshade_layer.hpp>
#include <mbgl/style/layers/hillshade_layer_impl.hpp>

namespace mbgl {

const style::LayerTypeInfo* HillshadeLayerFactory::getTypeInfo() const noexcept {
    return style::HillshadeLayer::Impl::staticTypeInfo();
}

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

    std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::HillshadeLayer(id, *source));
    return layer;
}

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

} // namespace mbgl