OGS
RasterParameter.cpp
Go to the documentation of this file.
1
11#include "RasterParameter.h"
12
13#include "BaseLib/ConfigTree.h"
14#include "BaseLib/Error.h"
15#include "BaseLib/Logging.h"
16
17namespace ParameterLib
18{
19std::unique_ptr<ParameterBase> createRasterParameter(
20 std::string const& name, BaseLib::ConfigTree const& config,
21 std::vector<GeoLib::NamedRaster> const& named_rasters)
22{
24 config.checkConfigParameter("type", "Raster");
25
26 auto const& named_raster = BaseLib::getIfOrError(
27 named_rasters,
28 [&name](auto const& named_raster)
29 { return name == named_raster.raster_name; },
30 "Could not find raster '" + name);
31
32 DBUG("Using the raster '{}' for the raster parameter.", name);
33
34 return std::make_unique<RasterParameter>(name, named_raster);
35}
36
37} // namespace ParameterLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
void checkConfigParameter(std::string const &param, std::string_view const value) const
OGS_NO_DANGLING Container::value_type const & getIfOrError(Container const &container, Predicate &&predicate, std::string const &error_message)
Definition Algorithm.h:159
std::unique_ptr< ParameterBase > createRasterParameter(std::string const &name, BaseLib::ConfigTree const &config, std::vector< GeoLib::NamedRaster > const &named_rasters)