feat: add production-like particle field feed
This commit is contained in:
@@ -207,6 +207,30 @@ std::optional<std::unique_ptr<Source>> convertImageSource(const std::string& id,
|
||||
std::optional<std::unique_ptr<Source>> convertRasterArraySource(const std::string& id,
|
||||
const Convertible& value,
|
||||
Error& error) {
|
||||
if (const auto localFieldsValue = objectMember(value, "production-fields")) {
|
||||
if (!isArray(*localFieldsValue) || arrayLength(*localFieldsValue) < 2) {
|
||||
error.message = "raster-array production-fields must contain at least two entries";
|
||||
return std::nullopt;
|
||||
}
|
||||
std::vector<RasterArrayLocalFieldDescriptor> localFields;
|
||||
for (size_t index = 0; index < arrayLength(*localFieldsValue); ++index) {
|
||||
const auto entry = arrayMember(*localFieldsValue, index);
|
||||
const auto metadata = objectMember(entry, "metadata");
|
||||
const auto field = objectMember(entry, "field");
|
||||
if (!metadata || !field) {
|
||||
error.message = "raster-array production field requires metadata and field";
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto metadataURL = toString(*metadata);
|
||||
const auto fieldURL = toString(*field);
|
||||
if (!metadataURL || !fieldURL) {
|
||||
error.message = "raster-array production field inputs must be strings";
|
||||
return std::nullopt;
|
||||
}
|
||||
localFields.push_back({*metadataURL, *fieldURL});
|
||||
}
|
||||
return {std::make_unique<RasterArraySource>(id, std::move(localFields))};
|
||||
}
|
||||
const auto fixture = objectMember(value, "fixture");
|
||||
const auto metadata = objectMember(value, "metadata");
|
||||
const auto field = objectMember(value, "field");
|
||||
|
||||
Reference in New Issue
Block a user