summaryrefslogtreecommitdiff
path: root/src/mbgl/style/conversion/source.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style/conversion/source.cpp')
-rw-r--r--src/mbgl/style/conversion/source.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/mbgl/style/conversion/source.cpp b/src/mbgl/style/conversion/source.cpp
index c10d0babcf..670f50c041 100644
--- a/src/mbgl/style/conversion/source.cpp
+++ b/src/mbgl/style/conversion/source.cpp
@@ -5,6 +5,7 @@
#include <mbgl/style/conversion/tileset.hpp>
#include <mbgl/style/sources/geojson_source.hpp>
#include <mbgl/style/sources/raster_source.hpp>
+#include <mbgl/style/sources/raster_dem_source.hpp>
#include <mbgl/style/sources/vector_source.hpp>
#include <mbgl/style/sources/image_source.hpp>
#include <mbgl/util/geo.hpp>
@@ -55,6 +56,28 @@ static optional<std::unique_ptr<Source>> convertRasterSource(const std::string&
return { std::make_unique<RasterSource>(id, std::move(*urlOrTileset), tileSize) };
}
+static optional<std::unique_ptr<Source>> convertRasterDEMSource(const std::string& id,
+ const Convertible& value,
+ Error& error) {
+ optional<variant<std::string, Tileset>> urlOrTileset = convertURLOrTileset(value, error);
+ if (!urlOrTileset) {
+ return {};
+ }
+
+ uint16_t tileSize = util::tileSize;
+ auto tileSizeValue = objectMember(value, "tileSize");
+ if (tileSizeValue) {
+ optional<float> size = toNumber(*tileSizeValue);
+ if (!size || *size < 0 || *size > std::numeric_limits<uint16_t>::max()) {
+ error = { "invalid tileSize" };
+ return {};
+ }
+ tileSize = *size;
+ }
+
+ return { std::make_unique<RasterDEMSource>(id, std::move(*urlOrTileset), tileSize) };
+}
+
static optional<std::unique_ptr<Source>> convertVectorSource(const std::string& id,
const Convertible& value,
Error& error) {
@@ -155,9 +178,11 @@ optional<std::unique_ptr<Source>> Converter<std::unique_ptr<Source>>::operator()
error = { "source type must be a string" };
return {};
}
-
+ const std::string tname = *type;
if (*type == "raster") {
return convertRasterSource(id, value, error);
+ } else if (*type == "raster-dem") {
+ return convertRasterDEMSource(id, value, error);
} else if (*type == "vector") {
return convertVectorSource(id, value, error);
} else if (*type == "geojson") {