feat: establish formal raster particle source chain
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <mbgl/style/sources/raster_dem_source.hpp>
|
||||
#include <mbgl/style/sources/vector_source.hpp>
|
||||
#include <mbgl/style/sources/image_source.hpp>
|
||||
#include <mbgl/style/sources/raster_array_source.hpp>
|
||||
#include <mbgl/util/geo.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
@@ -202,6 +203,26 @@ std::optional<std::unique_ptr<Source>> convertImageSource(const std::string& id,
|
||||
|
||||
return {std::move(result)};
|
||||
}
|
||||
|
||||
std::optional<std::unique_ptr<Source>> convertRasterArraySource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
const auto fixture = objectMember(value, "fixture");
|
||||
const auto metadata = objectMember(value, "metadata");
|
||||
const auto field = objectMember(value, "field");
|
||||
if (!fixture || !metadata || !field) {
|
||||
error.message = "raster-array source requires fixture, metadata, and field";
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto fixtureID = toString(*fixture);
|
||||
const auto metadataURL = toString(*metadata);
|
||||
const auto fieldURL = toString(*field);
|
||||
if (!fixtureID || !metadataURL || !fieldURL) {
|
||||
error.message = "raster-array fixture inputs must be strings";
|
||||
return std::nullopt;
|
||||
}
|
||||
return {std::make_unique<RasterArraySource>(id, *fixtureID, *metadataURL, *fieldURL)};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::optional<std::unique_ptr<Source>> Converter<std::unique_ptr<Source>>::operator()(const Convertible& value,
|
||||
@@ -234,6 +255,8 @@ std::optional<std::unique_ptr<Source>> Converter<std::unique_ptr<Source>>::opera
|
||||
return convertGeoJSONSource(id, value, error);
|
||||
} else if (tname == "image") {
|
||||
return convertImageSource(id, value, error);
|
||||
} else if (tname == "raster-array") {
|
||||
return convertRasterArraySource(id, value, error);
|
||||
} else {
|
||||
error.message = "invalid source type";
|
||||
return std::nullopt;
|
||||
|
||||
Reference in New Issue
Block a user