From f3294200c6c866e5ab031ad8346c59a76aa37249 Mon Sep 17 00:00:00 2001 From: Molly Lloyd Date: Tue, 23 Jan 2018 10:49:23 -0800 Subject: [core] add raster-dem source type and hillshade layer type (#10642) --- src/mbgl/style/conversion/layer.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/mbgl/style/conversion/layer.cpp') diff --git a/src/mbgl/style/conversion/layer.cpp b/src/mbgl/style/conversion/layer.cpp index 0ca582f8dc..8f624e3324 100644 --- a/src/mbgl/style/conversion/layer.cpp +++ b/src/mbgl/style/conversion/layer.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,23 @@ static optional> convertRasterLayer(const std::string& id return { std::make_unique(id, *source) }; } +static optional> convertHillshadeLayer(const std::string& id, const Convertible& value, Error& error) { + auto sourceValue = objectMember(value, "source"); + if (!sourceValue) { + error = { "layer must have a source" }; + return {}; + } + + optional source = toString(*sourceValue); + if (!source) { + error = { "layer source must be a string" }; + return {}; + } + + return { std::make_unique(id, *source) }; +} + + static optional> convertBackgroundLayer(const std::string& id, const Convertible&, Error&) { return { std::make_unique(id) }; } @@ -144,6 +162,8 @@ optional> Converter>::operator()(c converted = convertVectorLayer(*id, value, error); } else if (*type == "raster") { converted = convertRasterLayer(*id, value, error); + } else if (*type == "hillshade") { + converted = convertHillshadeLayer(*id, value, error); } else if (*type == "background") { converted = convertBackgroundLayer(*id, value, error); } else { -- cgit v1.2.1