WSL/SLF GitLab Repository

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

Putting the code into shape for major changes in the spatial interpolations as...

Putting the code into shape for major changes in the spatial interpolations as well as pushing the minor version nunmber up
parent c98489ae
......@@ -4,7 +4,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/")
# Version of library
SET(VERSION_MAJOR 2 CACHE INTERNAL "")
SET(VERSION_MINOR 3 CACHE INTERNAL "")
SET(VERSION_PATCH 0 CACHE INTERNAL "")
SET(VERSION_PATCH 1 CACHE INTERNAL "")
SET(POPCC popcc)
SET(LIBPREFIX "lib") #make sure ALL plugins are libXXX for ALL plateforms
......
......@@ -123,16 +123,15 @@ size_t InterpolationAlgorithm::getData(const MeteoData::Parameters& i_param,
{
vector<StationData> tmp_vecMeta;
return getData(i_param, o_vecData, tmp_vecMeta);
}
size_t InterpolationAlgorithm::getData(const MeteoData::Parameters& i_param,
std::vector<double>& o_vecData, std::vector<StationData>& o_vecMeta) const
{
if (o_vecData.empty())
if (!o_vecData.empty())
o_vecData.clear();
if (o_vecMeta.empty())
if (!o_vecMeta.empty())
o_vecMeta.clear();
for (size_t ii=0; ii<vecMeteo.size(); ii++){
......@@ -183,7 +182,7 @@ void StandardPressureAlgorithm::initialize(const MeteoData::Parameters& in_param
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double StandardPressureAlgorithm::getQualityRating()
double StandardPressureAlgorithm::getQualityRating() const
{
if (param != MeteoData::P)
return 0.0;
......@@ -196,7 +195,6 @@ double StandardPressureAlgorithm::getQualityRating()
void StandardPressureAlgorithm::calculate(Grid2DObject& grid)
{
//run algorithm
Interpol2D::stdPressureGrid2DFill(dem, grid);
}
......@@ -206,7 +204,7 @@ void ConstAlgorithm::initialize(const MeteoData::Parameters& in_param) {
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double ConstAlgorithm::getQualityRating()
double ConstAlgorithm::getQualityRating() const
{
if (nrOfMeasurments == 0){
return 0.0;
......@@ -225,7 +223,6 @@ void ConstAlgorithm::calculate(Grid2DObject& grid)
if (nrOfMeasurments == 0)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
//run algorithm
Interpol2D::constantGrid2DFill(Interpol1D::arithmeticMean(vecData), dem, grid);
}
......@@ -235,7 +232,7 @@ void ConstLapseRateAlgorithm::initialize(const MeteoData::Parameters& in_param)
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double ConstLapseRateAlgorithm::getQualityRating()
double ConstLapseRateAlgorithm::getQualityRating() const
{
if (nrOfMeasurments == 0){
return 0.0;
......@@ -259,8 +256,6 @@ void ConstLapseRateAlgorithm::calculate(Grid2DObject& grid)
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
LapseRateProjectPtr funcptr = &Interpol2D::LinProject;
if ((vecAltitudes.empty()) || (nrOfMeasurments == 0))
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
......@@ -269,6 +264,7 @@ void ConstLapseRateAlgorithm::calculate(Grid2DObject& grid)
//Set regression coefficients
std::vector<double> vecCoefficients(4, 0.0);
LapseRateProjectPtr funcptr = &Interpol2D::LinProject;
//Get the optional arguments for the algorithm: lapse rate, lapse rate usage
if (vecArgs.empty()) {
......@@ -295,7 +291,6 @@ void ConstLapseRateAlgorithm::calculate(Grid2DObject& grid)
throw InvalidArgumentException("Wrong number of arguments supplied for the CST_LAPSE algorithm", AT);
}
//run algorithm
info << "r^2=" << Optim::pow2( vecCoefficients[3] );
Interpol2D::constantLapseGrid2DFill(avgData, avgAltitudes, dem, vecCoefficients, funcptr, grid);
}
......@@ -306,7 +301,7 @@ void IDWAlgorithm::initialize(const MeteoData::Parameters& in_param) {
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double IDWAlgorithm::getQualityRating()
double IDWAlgorithm::getQualityRating() const
{
if (nrOfMeasurments == 0){
return 0.0;
......@@ -324,7 +319,6 @@ void IDWAlgorithm::calculate(Grid2DObject& grid)
if (nrOfMeasurments == 0)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
//run algorithm
Interpol2D::IDW(vecData, vecMeta, dem, grid);
}
......@@ -334,7 +328,7 @@ void IDWLapseAlgorithm::initialize(const MeteoData::Parameters& in_param) {
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double IDWLapseAlgorithm::getQualityRating()
double IDWLapseAlgorithm::getQualityRating() const
{
if (nrOfMeasurments == 0)
return 0.0;
......@@ -344,16 +338,16 @@ double IDWLapseAlgorithm::getQualityRating()
void IDWLapseAlgorithm::calculate(Grid2DObject& grid)
{ const double thresh_r_fixed_rate = 0.6;
vector<double> vecAltitudes;
if (nrOfMeasurments == 0)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
LapseRateProjectPtr funcptr = &Interpol2D::LinProject;
//Set regression coefficients
std::vector<double> vecCoefficients(4, 0.0);
LapseRateProjectPtr funcptr = &Interpol2D::LinProject;
//Get the optional arguments for the algorithm: lapse rate, lapse rate usage
if (vecArgs.empty()) { //force compute lapse rate
......@@ -392,7 +386,7 @@ void LocalIDWLapseAlgorithm::initialize(const MeteoData::Parameters& in_param) {
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double LocalIDWLapseAlgorithm::getQualityRating()
double LocalIDWLapseAlgorithm::getQualityRating() const
{
if (nrOfMeasurments == 0)
return 0.0;
......@@ -417,7 +411,6 @@ void LocalIDWLapseAlgorithm::calculate(Grid2DObject& grid)
throw InvalidArgumentException("Wrong number of arguments supplied for the IDW_LAPSE algorithm", AT);
}
//run algorithm
double r2=0.;
Interpol2D::LocalLapseIDW(vecData, vecMeta, dem, nrOfNeighbors, grid, r2);
info << "r^2=" << Optim::pow2( r2 );
......@@ -438,7 +431,7 @@ void RHAlgorithm::initialize(const MeteoData::Parameters& in_param) {
}
}
double RHAlgorithm::getQualityRating()
double RHAlgorithm::getQualityRating() const
{
//This algorithm is only valid for RH
if (param != MeteoData::RH)
......@@ -505,7 +498,7 @@ void ILWRAlgorithm::initialize(const MeteoData::Parameters& in_param) {
}
}
double ILWRAlgorithm::getQualityRating()
double ILWRAlgorithm::getQualityRating() const
{
//This algorithm is only valid for RH
if (param != MeteoData::ILWR)
......@@ -519,7 +512,7 @@ double ILWRAlgorithm::getQualityRating()
void ILWRAlgorithm::calculate(Grid2DObject& grid)
{
//This algorithm is only valid for RH
//This algorithm is only valid for ILWR
if (param != MeteoData::ILWR)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
if (vecDataEA.empty()) //No matching data
......@@ -527,13 +520,13 @@ void ILWRAlgorithm::calculate(Grid2DObject& grid)
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
LapseRateProjectPtr funcptr = &Interpol2D::LinProject;
Grid2DObject ta;
mi.interpolate(date, dem, MeteoData::TA, ta); //get TA interpolation from call back to Meteo2DInterpolator
//Krieging on Td
std::vector<double> vecCoefficients(4, 0.0);
LapseRateProjectPtr funcptr = &Interpol2D::LinProject;
//Get the optional arguments for the algorithm: lapse rate, lapse rate usage
if (vecArgs.empty()) {
......@@ -587,7 +580,7 @@ void SimpleWindInterpolationAlgorithm::initialize(const MeteoData::Parameters& i
}
}
double SimpleWindInterpolationAlgorithm::getQualityRating()
double SimpleWindInterpolationAlgorithm::getQualityRating() const
{
//This algorithm is only valid for VW
if (param != MeteoData::VW)
......@@ -616,7 +609,6 @@ void SimpleWindInterpolationAlgorithm::calculate(Grid2DObject& grid)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
if( vecDataDW.empty())
......@@ -638,7 +630,7 @@ void USERInterpolation::initialize(const MeteoData::Parameters& in_param) {
param = in_param;
}
std::string USERInterpolation::getGridFileName()
std::string USERInterpolation::getGridFileName() const
{
//HACK: use read2DGrid(grid, MeteoGrid::Parameters, Date) instead?
const std::string ext=std::string(".asc");
......@@ -658,7 +650,7 @@ std::string USERInterpolation::getGridFileName()
return gridname;
}
double USERInterpolation::getQualityRating()
double USERInterpolation::getQualityRating() const
{
const std::string filename = getGridFileName();
......@@ -679,8 +671,7 @@ void USERInterpolation::calculate(Grid2DObject& grid)
nrOfMeasurments = 0;
iomanager.read2DGrid(grid, filename);
//make sure the grid is georeferenced the same as the dem
if(grid.isSameGeolocalization(dem)==false) {
if(!grid.isSameGeolocalization(dem)) {
throw InvalidArgumentException("[E] trying to load a grid(" + filename + ") that has not the same georeferencing as the DEM!", AT);
}
}
......@@ -691,7 +682,7 @@ void SnowHNWInterpolation::initialize(const MeteoData::Parameters& in_param) {
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double SnowHNWInterpolation::getQualityRating()
double SnowHNWInterpolation::getQualityRating() const
{
if (nrOfMeasurments == 0)
return 0.0;
......@@ -739,7 +730,7 @@ void OrdinaryKrigingAlgorithm::initialize(const MeteoData::Parameters& in_param)
nrOfMeasurments = getData(param, vecData, vecMeta);
}
double OrdinaryKrigingAlgorithm::getQualityRating()
double OrdinaryKrigingAlgorithm::getQualityRating() const
{
if(nrOfMeasurments>=20) return 0.9;
return 0.1;
......
......@@ -141,10 +141,15 @@ class InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom);
virtual ~InterpolationAlgorithm() {}
virtual void initialize(const MeteoData::Parameters& in_param) = 0;
virtual double getQualityRating() = 0;
virtual double getQualityRating() const = 0;
virtual void calculate(Grid2DObject& grid) = 0;
std::string getInfo() const;
protected:
size_t getData(const MeteoData::Parameters& i_param, std::vector<double>& o_vecData) const;
size_t getData(const MeteoData::Parameters& i_param,
std::vector<double>& o_vecData, std::vector<StationData>& o_vecMeta) const;
size_t getStationAltitudes(const std::vector<StationData>& i_vecMeta, std::vector<double>& o_vecData) const;
Meteo2DInterpolator& mi;
const Date& date;
const DEMObject& dem;
......@@ -159,11 +164,6 @@ class InterpolationAlgorithm {
std::vector<StationData> vecMeta; ///<store the station data for the given parameter
std::stringstream info; ///<to store some extra information about the interoplation process
size_t nrOfMeasurments; ///<the available number of measurements
size_t getData(const MeteoData::Parameters& i_param, std::vector<double>& o_vecData) const;
size_t getData(const MeteoData::Parameters& i_param,
std::vector<double>& o_vecData, std::vector<StationData>& o_vecMeta) const;
size_t getStationAltitudes(const std::vector<StationData>& i_vecMeta, std::vector<double>& o_vecData) const;
};
class AlgorithmFactory {
......@@ -192,7 +192,7 @@ class ConstAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -210,7 +210,7 @@ class StandardPressureAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -235,7 +235,7 @@ class ConstLapseRateAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -255,7 +255,7 @@ class IDWAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -282,7 +282,7 @@ class IDWLapseAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -304,7 +304,7 @@ class LocalIDWLapseAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -327,7 +327,7 @@ class RHAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom), vecDataTA(), vecDataRH() {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
private:
std::vector<double> vecDataTA, vecDataRH; ///<vectors of extracted TA and RH
......@@ -351,7 +351,7 @@ class ILWRAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom), vecDataEA() {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
private:
std::vector<double> vecDataEA; ///<vectors of extracted emissivities
......@@ -375,7 +375,7 @@ class SimpleWindInterpolationAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom), vecDataVW(), vecDataDW() {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
private:
std::vector<double> vecDataVW, vecDataDW; ///<vectors of extracted VW and DW
......@@ -405,10 +405,10 @@ class USERInterpolation : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
private:
std::string getGridFileName();
std::string getGridFileName() const;
};
/**
......@@ -441,7 +441,7 @@ class SnowHNWInterpolation : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom) {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
};
......@@ -477,7 +477,7 @@ class OrdinaryKrigingAlgorithm : public InterpolationAlgorithm {
const std::string& i_algo, IOManager& iom)
: InterpolationAlgorithm(i_mi, i_date, i_dem, i_vecArgs, i_algo, iom), variogram() {}
virtual void initialize(const MeteoData::Parameters& in_param);
virtual double getQualityRating();
virtual double getQualityRating() const;
virtual void calculate(Grid2DObject& grid);
private:
double computeVariogram();
......
......@@ -22,12 +22,14 @@ using namespace std;
namespace mio {
Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg, IOManager& i_iom) : cfg(i_cfg), iomanager(&i_iom), mapAlgorithms()
Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg, IOManager& i_iom)
: cfg(i_cfg), iomanager(&i_iom), mapAlgorithms()
{
setAlgorithms();
}
Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg) : cfg(i_cfg), iomanager(NULL), mapAlgorithms()
Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg)
: cfg(i_cfg), iomanager(NULL), mapAlgorithms()
{
setAlgorithms();
}
......@@ -44,9 +46,9 @@ Meteo2DInterpolator& Meteo2DInterpolator::operator=(const Meteo2DInterpolator& s
return *this;
}
void Meteo2DInterpolator::setAlgorithms() {
/*
* By reading the Config object build up a list of user configured algorithms
void Meteo2DInterpolator::setAlgorithms()
{
/* By reading the Config object build up a list of user configured algorithms
* for each MeteoData::Parameters parameter (i.e. each member variable of MeteoData like ta, p, hnw, ...)
* Concept of this constructor: loop over all MeteoData::Parameters and then look
* for configuration of interpolation algorithms within the Config object.
......@@ -94,6 +96,10 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
{
if(iomanager==NULL)
throw IOException("No IOManager reference has been set!", AT);
//check that the output grid is using the same projection as the dem
if(!result.llcorner.isSameProj(dem.llcorner)) {
throw IOException("The output grid is not using the same geographic projection as the DEM", AT);
}
//Show algorithms to be used for this parameter
const map<string, vector<string> >::const_iterator it = mapAlgorithms.find(MeteoData::getParameterName(meteoparam));
......@@ -112,7 +118,7 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
//Get the quality rating and compare to previously computed quality ratings
algorithm->initialize(meteoparam);
const double rating = algorithm->getQualityRating();
if ((rating != 0.0) && (rating > maxQualityRating)){
if ((rating != 0.0) && (rating > maxQualityRating)) {
//we use ">" so that in case of equality, the first choice will be kept
bestalgorithm = algorithm; //remember this algorithm: ownership belongs to bestalgorithm
maxQualityRating = rating;
......@@ -131,11 +137,6 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
MeteoData::getParameterName(meteoparam), AT);
}
//check that the output grid is using the same projection as the dem
if(!result.llcorner.isSameProj(dem.llcorner)) {
throw IOException("The output grid is not using the same geographic projection as the DEM", AT);
}
//Run soft min/max filter for RH, HNW and HS
if (meteoparam == MeteoData::RH){
Meteo2DInterpolator::checkMinMax(0.0, 1.0, result);
......@@ -150,13 +151,11 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
size_t Meteo2DInterpolator::getAlgorithmsForParameter(const std::string& parname, std::vector<std::string>& vecAlgorithms)
{
/*
* This function retrieves the user defined interpolation algorithms for
* parameter 'parname' by querying the Config object
*/
std::vector<std::string> vecKeys;
// This function retrieves the user defined interpolation algorithms for
// parameter 'parname' by querying the Config object
vecAlgorithms.clear();
std::vector<std::string> vecKeys;
cfg.findKeys(vecKeys, parname+"::algorithms", "Interpolations2D");
if (vecKeys.size() > 1)
......
......@@ -30,8 +30,8 @@ namespace mio {
const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const unsigned int ncols = (unsigned int)round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)round( i_grid.nrows*factor );
const unsigned int ncols = (unsigned int)Optim::round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)Optim::round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
Bilinear(o_grid, i_grid); //GridObjects always keep nodata
......@@ -41,8 +41,8 @@ const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject
const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const unsigned int ncols = (unsigned int)round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)round( i_grid.nrows*factor );
const unsigned int ncols = (unsigned int)Optim::round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)Optim::round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
cubicBSpline(o_grid, i_grid); //GridObjects always keep nodata
......@@ -52,8 +52,8 @@ const Grid2DObject ResamplingAlgorithms2D::cubicBSplineResampling(const Grid2DOb
const Grid2DObject ResamplingAlgorithms2D::NearestNeighbour(const Grid2DObject &i_grid, const double &factor)
{
const double cellsize = i_grid.cellsize/factor;
const unsigned int ncols = (unsigned int)round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)round( i_grid.nrows*factor );
const unsigned int ncols = (unsigned int)Optim::round( i_grid.ncols*factor );
const unsigned int nrows = (unsigned int)Optim::round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
NearestNeighbour(o_grid, i_grid); //GridObjects always keep nodata
......@@ -71,11 +71,11 @@ void ResamplingAlgorithms2D::NearestNeighbour(Grid2DObject &o_grid, const Grid2D
const double scale_y = (double)o_grid.nrows / (double)org_nrows;
for (unsigned int jj=0; jj<o_grid.nrows; jj++) {
unsigned int org_jj = (unsigned int) round( (double)jj/scale_y );
unsigned int org_jj = (unsigned int) Optim::round( (double)jj/scale_y );
if(org_jj>=org_nrows) org_jj=org_nrows-1;
for (unsigned int ii=0; ii<o_grid.ncols; ii++) {
unsigned int org_ii = (unsigned int) round( (double)ii/scale_x );
unsigned int org_ii = (unsigned int) Optim::round( (double)ii/scale_x );
if(org_ii>=org_ncols) org_ii=org_ncols-1;
o_grid(ii,jj) = i_grid(org_ii, org_jj);
}
......
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