blob: 14e020594a5e9409dc9a319365fef8273b5356fa (
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
|
#include <mbgl/sourcemanager/source_manager.hpp>
#include <mbgl/style/conversion/coordinate.hpp>
#include <mbgl/style/conversion/source.hpp>
#include <mbgl/style/conversion/tileset.hpp>
#include <mbgl/style/conversion_impl.hpp>
#include <mbgl/util/geo.hpp>
namespace mbgl {
namespace style {
namespace conversion {
optional<std::unique_ptr<Source>> Converter<std::unique_ptr<Source>>::operator()(const Convertible& value,
Error& error,
const std::string& id) const {
if (!isObject(value)) {
error.message = "source must be an object";
return nullopt;
}
auto typeValue = objectMember(value, "type");
if (!typeValue) {
error.message = "source must have a type";
return nullopt;
}
optional<std::string> type = toString(*typeValue);
if (!type) {
error.message = "source type must be a string";
return nullopt;
}
const std::string& tname = type.value();
auto source = SourceManager::get()->createSource(tname, id, value, error);
if (!source) return nullopt;
return source;
}
} // namespace conversion
} // namespace style
} // namespace mbgl
|