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.
This commit is contained in:
@@ -374,5 +374,24 @@ Mutable<Layer::Impl> HeatmapLayer::mutableBaseImpl() const {
|
||||
return staticMutableCast<Layer::Impl>(mutableImpl());
|
||||
}
|
||||
|
||||
HeatmapLayerFactory::~HeatmapLayerFactory() = default;
|
||||
|
||||
const char* HeatmapLayerFactory::type() const {
|
||||
return "heatmap";
|
||||
}
|
||||
|
||||
std::unique_ptr<style::Layer> HeatmapLayerFactory::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 HeatmapLayer(id, *source));
|
||||
if (!initSourceLayerAndFilter(layer.get(), value)) {
|
||||
return nullptr;
|
||||
}
|
||||
return layer;
|
||||
}
|
||||
|
||||
} // namespace style
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user