blob: c7f63b86992b5b089258b788a323e317a18dd793 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <mbgl/layermanager/layer_factory.hpp>
#include <mbgl/style/conversion/constant.hpp>
#include <mbgl/style/conversion/filter.hpp>
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/style/layer.hpp>
namespace mbgl {
optional<std::string> LayerFactory::getSource(const style::conversion::Convertible& value) const noexcept {
auto sourceValue = objectMember(value, "source");
if (!sourceValue) {
return nullopt;
}
optional<std::string> source = toString(*sourceValue);
if (!source) {
return nullopt;
}
return source;
}
bool LayerFactory::initSourceLayerAndFilter(style::Layer* layer, const style::conversion::Convertible& value) const noexcept {
auto sourceLayerValue = objectMember(value, "source-layer");
if (sourceLayerValue) {
optional<std::string> sourceLayer = toString(*sourceLayerValue);
if (!sourceLayer) {
return false;
}
layer->setSourceLayer(*sourceLayer);
}
auto filterValue = objectMember(value, "filter");
if (filterValue) {
style::conversion::Error error;
optional<style::Filter> filter = style::conversion::convert<style::Filter>(*filterValue, error);
if (!filter) {
return false;
}
layer->setFilter(*filter);
}
return true;
}
} // namespace mbgl
|