WSL/SLF GitLab Repository

Commit e4c44300 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

New constructors and setters for the grids, to fill them with a constant value

parent 2dde63a7
......@@ -57,6 +57,13 @@ Grid2DObject::Grid2DObject(const unsigned int& i_ncols, const unsigned int& i_nr
set(i_ncols, i_nrows, i_cellsize, i_llcorner, i_grid2D);
}
Grid2DObject::Grid2DObject(const unsigned int& i_ncols, const unsigned int& i_nrows,
const double& i_cellsize, const Coords& i_llcorner, const double& init) : grid2D(i_ncols, i_nrows, init)
{
//set metadata, grid2D already successfully created
setValues(i_ncols, i_nrows, i_cellsize, i_llcorner);
}
Grid2DObject::Grid2DObject(const Grid2DObject& i_grid2Dobj, const unsigned int& i_nx, const unsigned int& i_ny,
const unsigned int& i_ncols, const unsigned int& i_nrows)
: grid2D(i_grid2Dobj.grid2D, i_nx,i_ny, i_ncols,i_nrows)
......@@ -191,8 +198,15 @@ bool Grid2DObject::WGS84_to_grid(Coords& point) const {
void Grid2DObject::set(const unsigned int& i_ncols, const unsigned int& i_nrows,
const double& i_cellsize, const Coords& i_llcorner)
{
setValues(i_ncols, i_nrows, i_cellsize, i_llcorner);
grid2D.resize(ncols, nrows, IOUtils::nodata);
setValues(i_ncols, i_nrows, i_cellsize, i_llcorner);
}
void Grid2DObject::set(const unsigned int& i_ncols, const unsigned int& i_nrows,
const double& i_cellsize, const Coords& i_llcorner, const double& init)
{
grid2D.resize(ncols, nrows, init);
setValues(i_ncols, i_nrows, i_cellsize, i_llcorner);
}
void Grid2DObject::set(const unsigned int& i_ncols, const unsigned int& i_nrows,
......
......@@ -75,6 +75,9 @@ class Grid2DObject {
Grid2DObject(const unsigned int& ncols, const unsigned int& nrows,
const double& cellsize, const Coords& i_llcorner);
Grid2DObject(const unsigned int& ncols, const unsigned int& nrows,
const double& cellsize, const Coords& i_llcorner, const double& init);
Grid2DObject(const unsigned int& ncols, const unsigned int& nrows,
const double& cellsize, const Coords& i_llcorner, const Array2D<double>& grid2D_in);
......@@ -132,6 +135,9 @@ class Grid2DObject {
void set(const unsigned int& ncols, const unsigned int& nrows,
const double& cellsize, const Coords& i_llcorner, const Array2D<double>& grid2D_in); //TODO: const CArray would be better...
void set(const unsigned int& ncols, const unsigned int& nrows,
const double& cellsize, const Coords& i_llcorner, const double& init);
void size(unsigned int& o_ncols, unsigned int& o_nrows) const;
unsigned int getNx() const;
unsigned int getNy() const;
......
......@@ -68,6 +68,13 @@ Grid3DObject::Grid3DObject(const unsigned int& i_ncols, const unsigned int& i_nr
z_is_absolute = true;
}
Grid3DObject::Grid3DObject(const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepths,
const double& i_cellsize, const Coords& i_llcorner, const double& init) : grid3D(i_ncols, i_nrows, i_ndepths, init)
{
setValues(i_ncols, i_nrows, i_ndepths, i_cellsize, i_llcorner);
z_is_absolute = true;
}
Grid3DObject::Grid3DObject(const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepths,
const double& i_cellsize, const Coords& i_llcorner, const Array3D<double>& i_grid3D) : grid3D()
{
......@@ -209,8 +216,15 @@ bool Grid3DObject::WGS84_to_grid(Coords point) const
void Grid3DObject::set(const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepths,
const double& i_cellsize, const Coords& i_llcorner)
{
setValues(i_ncols, i_nrows, i_ndepths, i_cellsize, i_llcorner);
grid3D.resize(ncols, nrows, ndepths, IOUtils::nodata);
setValues(i_ncols, i_nrows, i_ndepths, i_cellsize, i_llcorner);
}
void Grid3DObject::set(const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepths,
const double& i_cellsize, const Coords& i_llcorner, const double& init)
{
grid3D.resize(ncols, nrows, ndepths, init);
setValues(i_ncols, i_nrows, i_ndepths, i_cellsize, i_llcorner);
}
void Grid3DObject::set(const unsigned int& i_ncols, const unsigned int& i_nrows, const unsigned int& i_ndepths,
......
......@@ -73,14 +73,17 @@ class Grid3DObject{
* a subspace of the space spanned by the i_grid3Dobj
*/
Grid3DObject(const Grid3DObject& i_grid3Dobj,
const unsigned int& i_nx, const unsigned int& i_ny, const unsigned int& i_nz,
const unsigned int& i_nwidths, const unsigned int& i_nheights, const unsigned int& i_ndepths);
const unsigned int& i_nx, const unsigned int& i_ny, const unsigned int& i_nz,
const unsigned int& i_nwidths, const unsigned int& i_nheights, const unsigned int& i_ndepths);
Grid3DObject(const unsigned int& ncols, const unsigned int& nrows, const unsigned int& ndepths,
const double& cellsize, const Coords& i_llcorner);
const double& cellsize, const Coords& i_llcorner);
Grid3DObject(const unsigned int& ncols, const unsigned int& nrows, const unsigned int& ndepths,
const double& cellsize, const Coords& i_llcorner, const Array3D<double>& grid3D);
const double& cellsize, const Coords& i_llcorner, const double& init);
Grid3DObject(const unsigned int& ncols, const unsigned int& nrows, const unsigned int& ndepths,
const double& cellsize, const Coords& i_llcorner, const Array3D<double>& grid3D);
/**
* @brief Set all variables in one go.
......@@ -91,7 +94,7 @@ class Grid3DObject{
* @param i_llcorner lower left corner coordinates
*/
void set(const unsigned int& ncols, const unsigned int& nrows, const unsigned int& depths,
const double& cellsize, const Coords& i_llcorner);
const double& cellsize, const Coords& i_llcorner);
/**
* @brief Set all variables in one go. Notably the member grid3D of type Array3D<double>
* will be destroyed and recreated to size ncols x nrows.
......@@ -104,7 +107,10 @@ class Grid3DObject{
* @param grid3D_in (Array\<double\>&) grid to be copied by value
*/
void set(const unsigned int& ncols, const unsigned int& nrows, const unsigned int& ndepths,
const double& cellsize, const Coords& i_llcorner, const Array3D<double>& grid3D_in);
const double& cellsize, const Coords& i_llcorner, const Array3D<double>& grid3D_in);
void set(const unsigned int& ncols, const unsigned int& nrows, const unsigned int& ndepths,
const double& cellsize, const Coords& i_llcorner, const double& init);
void size(unsigned int& o_ncols, unsigned int& o_nrows, unsigned int& o_ndepths) const;
unsigned int getNx() const;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment