blob: 95dc7d1edd6be1863b9b06038a97cd6c4392980e (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#include <mbgl/style/conversion/json.hpp>
#include <mbgl/style/conversion/tileset.hpp>
#include <mbgl/style/layer.hpp>
#include <mbgl/style/source_observer.hpp>
#include <mbgl/style/sources/raster_dem_source.hpp>
#include <mbgl/style/sources/raster_dem_source_impl.hpp>
#include <mbgl/tile/tile.hpp>
#include <mbgl/util/enum.hpp>
#include <utility>
namespace mbgl {
using TilesetDEMEncoding = Tileset::DEMEncoding;
MBGL_DEFINE_ENUM(TilesetDEMEncoding,
{{TilesetDEMEncoding::Mapbox, "mapbox"}, {TilesetDEMEncoding::Terrarium, "terrarium"}});
namespace style {
RasterDEMSource::RasterDEMSource(std::string id, variant<std::string, Tileset> urlOrTileset_, uint16_t tileSize)
: RasterSource(makeMutable<Impl>(std::move(id), tileSize), std::move(urlOrTileset_)) {}
bool RasterDEMSource::supportsLayerType(const mbgl::style::LayerTypeInfo* info) const {
return mbgl::underlying_type(TileKind::RasterDEM) == mbgl::underlying_type(info->tileKind);
}
Value RasterDEMSource::serialize() const {
auto value = RasterSource::serialize();
if (auto* tileset = getTileset()) {
value.getObject()->insert({"encoding", conversion::makeValue(tileset->encoding)});
}
return value;
}
const RasterDEMSource::Impl& RasterDEMSource::impl() const {
return static_cast<const Impl&>(*baseImpl);
}
Value RasterDEMSource::getPropertyInternal(const std::string& name) const {
if (name == "encoding") {
if (auto* tileset = getTileset()) {
return conversion::makeValue(tileset->encoding);
}
}
return NullValue();
}
Value RasterDEMSource::getPropertyDefaultValueInternal(const std::string& name) const {
if (name == "encoding") {
return conversion::makeValue(TilesetDEMEncoding::Mapbox);
}
return NullValue();
}
Mutable<Source::Impl> RasterDEMSource::createMutable() const noexcept {
return staticMutableCast<Source::Impl>(makeMutable<Impl>(impl()));
}
Mutable<Source::Impl> RasterDEMSource::createMutable(Tileset tileset) const noexcept {
return staticMutableCast<Source::Impl>(makeMutable<Impl>(impl(), std::move(tileset)));
}
} // namespace style
} // namespace mbgl
|