diff --git a/GeoLib/IO/NetCDFRasterReader.cpp b/GeoLib/IO/NetCDFRasterReader.cpp index b5d4800ce67..ab5f28b27d1 100644 --- a/GeoLib/IO/NetCDFRasterReader.cpp +++ b/GeoLib/IO/NetCDFRasterReader.cpp @@ -152,10 +152,11 @@ std::vector readDataFromNetCDF( return raster_data; } -GeoLib::Raster readNetCDF(std::filesystem::path const& filepath, - std::string_view const var_name, - std::size_t const dimension_number, - GeoLib::MinMaxPoints const& min_max_points) +std::unique_ptr readNetCDF( + std::filesystem::path const& filepath, + std::string_view const var_name, + std::size_t const dimension_number, + GeoLib::MinMaxPoints const& min_max_points) { netCDF::NcFile dataset(filepath.string(), netCDF::NcFile::read); if (dataset.isNull()) @@ -168,7 +169,8 @@ GeoLib::Raster readNetCDF(std::filesystem::path const& filepath, std::vector raster_data = readDataFromNetCDF( variables, var_name, dimension_number, min_max_points, header); - return GeoLib::Raster{header, raster_data.begin(), raster_data.end()}; + return std::make_unique(header, raster_data.begin(), + raster_data.end()); } #endif @@ -190,14 +192,14 @@ GeoLib::NamedRaster readRasterFromFile( return GeoLib::NamedRaster{filename.replace_extension().string() + "_" + var_name + "_" + std::to_string(dimension_number), - raster}; + std::move(raster)}; #else OGS_FATAL("OGS was not build with NetCDF support. Can not read {}", (path / filename).string()); #endif } - auto* raster = - FileIO::AsciiRasterInterface::readRaster((path / filename).string()); + auto raster = std::unique_ptr( + FileIO::AsciiRasterInterface::readRaster((path / filename).string())); if (raster == nullptr) { OGS_FATAL("Could not read raster from file '{}'.", @@ -206,7 +208,7 @@ GeoLib::NamedRaster readRasterFromFile( return GeoLib::NamedRaster{filename.replace_extension().string() + "_" + var_name + "_" + std::to_string(dimension_number), - *raster}; + std::move(raster)}; } } // anonymous namespace diff --git a/GeoLib/Raster.h b/GeoLib/Raster.h index c2b24c7b060..6234c0395ff 100644 --- a/GeoLib/Raster.h +++ b/GeoLib/Raster.h @@ -154,7 +154,7 @@ class Raster final struct NamedRaster { std::string raster_name; - GeoLib::Raster raster; + std::unique_ptr raster; }; } // namespace GeoLib diff --git a/ParameterLib/RasterParameter.h b/ParameterLib/RasterParameter.h index e864560b095..436fddfb41e 100644 --- a/ParameterLib/RasterParameter.h +++ b/ParameterLib/RasterParameter.h @@ -35,7 +35,7 @@ struct RasterParameter final : public Parameter { OGS_FATAL("RasterParameter::operator(): couldn't get coordinates."); } - auto const value = _named_raster.raster.getValueAtPoint(*coordinates); + auto const value = _named_raster.raster->getValueAtPoint(*coordinates); return {value}; }