WSL/SLF GitLab Repository

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

The grids.isEmpty() method has been renamed as empty() in order to follow the...

The grids.isEmpty() method has been renamed as empty() in order to follow the STL convention. The ARC grids written with Alpine3D naming were still not properly named, they should now be directly recognized by the Alpine3D grid viewer.
parent 250bcc88
......@@ -422,7 +422,7 @@ bool IOManager::getMeteoData(const Date& date, const DEMObject& dem, const Meteo
skip_virtual_stations = true;
interpolator.interpolate(date, dem, meteoparam, result, info_string);
skip_virtual_stations = false;
return (!result.isEmpty());
return (!result.empty());
}
void IOManager::interpolate(const Date& date, const DEMObject& dem, const MeteoData::Parameters& meteoparam,
......
......@@ -68,7 +68,7 @@ template<class T> class Array1D {
void resize(const size_t& asize);
void resize(const size_t& asize, const T& init);
void clear();
bool isEmpty() const;
bool empty() const;
void insertAt(const int& index, T e);
void removeAt(const size_t& index);
......@@ -232,7 +232,7 @@ template<class T> void Array1D<T>::clear() {
nx = 0;
}
template<class T> bool Array1D<T>::isEmpty() const {
template<class T> bool Array1D<T>::empty() const {
return (nx==0);
}
......
......@@ -148,7 +148,7 @@ template<class T> class Array2D {
size_t getNy() const;
void clear();
bool isEmpty() const;
bool empty() const;
/**
* @brief returns the minimum value contained in the grid
......@@ -397,7 +397,7 @@ template<class T> void Array2D<T>::clear() {
nx=ny=0;
}
template<class T> bool Array2D<T>::isEmpty() const {
template<class T> bool Array2D<T>::empty() const {
return (nx==0 && ny==0);
}
......
......@@ -181,7 +181,7 @@ template<class T> class Array3D {
size_t getNy() const;
size_t getNz() const;
void clear();
bool isEmpty() const;
bool empty() const;
/**
* @brief returns the minimum value contained in the grid
......@@ -465,7 +465,7 @@ template<class T> void Array3D<T>::clear() {
nx = ny = nz = nxny = 0;
}
template<class T> bool Array3D<T>::isEmpty() const {
template<class T> bool Array3D<T>::empty() const {
return (nx==0 && ny==0 && nz==0);
}
......
......@@ -126,7 +126,7 @@ template<class T> class Array4D {
size_t getNy() const;
size_t getNz() const;
void clear();
bool isEmpty() const;
bool empty() const;
/**
* @brief returns the minimum value contained in the grid
......@@ -398,7 +398,7 @@ template<class T> void Array4D<T>::clear() {
nw = nx = ny = nz = nwnx = nwnxny = 0;
}
template<class T> bool Array4D<T>::isEmpty() const {
template<class T> bool Array4D<T>::empty() const {
return (nw==0 && nx==0 && ny==0 && nz==0);
}
......
......@@ -391,7 +391,7 @@ void DEMObject::sanitize() {
*/
Grid2DObject DEMObject::getHillshade(const double& elev, const double& azimuth) const
{
if(slope.isEmpty() || azi.isEmpty())
if(slope.empty() || azi.empty())
throw InvalidArgumentException("Hillshade computation requires slope and azimuth!", AT);
const double zenith_rad = (90.-elev)*Cst::to_rad;
......@@ -491,31 +491,18 @@ double DEMObject::terrainDistance(Coords point1, const Coords& point2) {
}
/**
* @brief Returns a list of grid points that are on the straight line between two coordinates
* @param point1 first point (ie: origin)
* @param point2 second point (ie: destination)
* @brief Returns a list of grid points that are on the straight line between two coordinates.
* This implements Bresenham's algorithm (see https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm)
* @param ix1 origin's abscissa
* @param iy1 origin's ordinate
* @param ix2 destination's abscissa
* @param iy2 destination's ordinate
* @param vec_points vector of points that are in between
*
*/
void DEMObject::getPointsBetween(Coords point1, Coords point2, std::vector<GRID_POINT_2D>& vec_points) {
if(point1.isSameProj(point2)==false) {
point1.copyProj(point2);
}
if(point1.getEasting() > point2.getEasting()) {
//we want xcoord1<xcoord2, so we swap the two points
const Coords tmp = point1;
point1 = point2;
point2 = tmp;
}
//extension of the line segment (pts1, pts2) along the X axis
const int ix1 = (int)floor( (point1.getEasting() - llcorner.getEasting())/cellsize );
const int iy1 = (int)floor( (point1.getNorthing() - llcorner.getNorthing())/cellsize );
const int ix2 = (int)floor( (point2.getEasting() - llcorner.getEasting())/cellsize );
const int iy2 = (int)floor( (point2.getNorthing() - llcorner.getNorthing())/cellsize );
void DEMObject::getPointsBetween(const int& ix1, const int& iy1, const int& ix2, const int& iy2, std::vector<GRID_POINT_2D>& vec_points)
{
vec_points.clear();
if(ix1==ix2) {
//special case of vertical alignement
for(int iy=min(iy1,iy2); iy<=max(iy1,iy2); iy++) {
......@@ -559,6 +546,35 @@ void DEMObject::getPointsBetween(Coords point1, Coords point2, std::vector<GRID_
}
}
/**
* @brief Returns a list of grid points that are on the straight line between two coordinates
* @param point1 first point (ie: origin)
* @param point2 second point (ie: destination)
* @param vec_points vector of points that are in between
*
*/
void DEMObject::getPointsBetween(Coords point1, Coords point2, std::vector<GRID_POINT_2D>& vec_points) {
if(point1.isSameProj(point2)==false) {
point1.copyProj(point2);
}
if(point1.getEasting() > point2.getEasting()) {
//we want xcoord1<xcoord2, so we swap the two points
const Coords tmp = point1;
point1 = point2;
point2 = tmp;
}
//extension of the line segment (pts1, pts2) along the X axis
const int ix1 = (int)floor( (point1.getEasting() - llcorner.getEasting())/cellsize );
const int iy1 = (int)floor( (point1.getNorthing() - llcorner.getNorthing())/cellsize );
const int ix2 = (int)floor( (point2.getEasting() - llcorner.getEasting())/cellsize );
const int iy2 = (int)floor( (point2.getNorthing() - llcorner.getNorthing())/cellsize );
getPointsBetween(ix1, iy1, ix2, iy2, vec_points);
}
/**
* @brief Returns a list of grid points that are on the straight line between two coordinates
* @param point the origin point
......
......@@ -97,6 +97,7 @@ class DEMObject : public Grid2DObject {
double horizontalDistance(const double& xcoord1, const double& ycoord1, const double& xcoord2, const double& ycoord2);
double horizontalDistance(Coords point1, const Coords& point2);
double terrainDistance(Coords point1, const Coords& point2);
void getPointsBetween(const int& ix1, const int& iy1, const int& ix2, const int& iy2, std::vector<GRID_POINT_2D>& vec_points);
void getPointsBetween(Coords point1, Coords point2, std::vector<GRID_POINT_2D>& vec_points);
void getPointsBetween(const Coords& point, const double& bearing, std::vector<GRID_POINT_2D>& vec_points);
double getHorizon(const Coords& point, const double& bearing);
......
......@@ -345,7 +345,7 @@ void Grid2DObject::clear() {
grid2D.clear();
}
bool Grid2DObject::isEmpty() const {
bool Grid2DObject::empty() const {
return (grid2D.getNx()==0 && grid2D.getNy()==0);
}
......
......@@ -139,7 +139,7 @@ class Grid2DObject {
* @brief Check if a grid does not contain any data (but it can contain geolocalization)
* @return true if the grid is 0x0
*/
bool isEmpty() const;
bool empty() const;
/**
* @brief check if the current Grid2DObject has the same geolocalization attributes
......
......@@ -371,7 +371,7 @@ void Grid3DObject::clear() {
grid3D.clear();
}
bool Grid3DObject::isEmpty() const {
bool Grid3DObject::empty() const {
return (grid3D.getNx()==0 && grid3D.getNy()==0 && grid3D.getNz()==0);
}
......
......@@ -117,7 +117,7 @@ class Grid3DObject{
* @brief Check if a grid does not contain any data (but it can contain geolocalization)
* @return true if the grid is 0x0
*/
bool isEmpty() const;
bool empty() const;
/**
* @brief Compute the positional parameters that are not already known
......
......@@ -354,7 +354,7 @@ void Interpol2D::ListonWind(const DEMObject& i_dem, Grid2DObject& VW, Grid2DObje
}
//make sure dem has the curvature that we need
const bool recomputeDEM = i_dem.curvature.isEmpty();
const bool recomputeDEM = i_dem.curvature.empty();
DEMObject *intern_dem = NULL;
if(recomputeDEM) {
std::cerr << "[W] WIND_CURV spatial interpolations algorithm selected but no dem curvature available! Computing it...\n";
......
......@@ -259,10 +259,16 @@ void ARCIO::read2DGrid(Grid2DObject& grid_out, const std::string& filename) {
void ARCIO::read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date)
{
if(a3d_view_in) {
if (a3d_view_in) {
// the A3D grid viewer looks for the following extensions:
//sdp, tss, swr, lwr, swe, alb, wet
string ext;
if(parameter==MeteoGrids::HS)
if (parameter==MeteoGrids::HS)
ext="sdp";
else if (parameter==MeteoGrids::ISWR)
ext="swr";
else if (parameter==MeteoGrids::ILWR)
ext="lwr";
else {
ext = MeteoGrids::getParameterName(parameter);
IOUtils::toLower(ext);
......
......@@ -213,7 +213,7 @@ void ARPSIO::read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& pa
grid_out.set(dem.cellsize, dem.llcorner, dem.azi);
}
if(grid_out.isEmpty()) {
if(grid_out.empty()) {
ostringstream ss;
ss << "No suitable data found for parameter " << MeteoGrids::getParameterName(parameter) << " ";
ss << "at time step " << date.toString(Date::ISO) << " in file \"" << name << "\"";
......
......@@ -631,7 +631,7 @@ void GRIBIO::read2DGrid(const std::string& filename, Grid2DObject& grid_out, con
grid_out = VW;
}
if(grid_out.isEmpty()) {
if(grid_out.empty()) {
ostringstream ss;
ss << "No suitable data found for parameter " << MeteoGrids::getParameterName(parameter) << " ";
ss << "at time step " << date.toString(Date::ISO) << " in file \"" << filename << "\"";
......
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