WSL/SLF GitLab Repository

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

The cubic B-spline image resampling algorithm has been implemented in...

The cubic B-spline image resampling algorithm has been implemented in ResamplingAlgorithms2D. Various Weffc++ warnings have been fixed in PNGIO, ImisIO and GRIBIO, leading to the suppression of unused variables.
parent 9e30ad0d
......@@ -16,6 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/IOUtils.h>
#include <meteoio/MathOptim.h>
#include <meteoio/ResamplingAlgorithms2D.h>
#include <cmath>
......@@ -33,7 +34,18 @@ const Grid2DObject ResamplingAlgorithms2D::BilinearResampling(const Grid2DObject
const unsigned int nrows = (unsigned int)round( i_grid.nrows*factor );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
Bilinear_nodata(o_grid, i_grid); //GridObjects always keep nodata
Bilinear(o_grid, i_grid); //GridObjects always keep nodata
return o_grid;
}
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 );
Grid2DObject o_grid(ncols, nrows, cellsize, i_grid.llcorner);
cubicBSpline(o_grid, i_grid); //GridObjects always keep nodata
return o_grid;
}
......@@ -70,7 +82,54 @@ void ResamplingAlgorithms2D::NearestNeighbour(Grid2DObject &o_grid, const Grid2D
}
}
void ResamplingAlgorithms2D::Bilinear_raw(Grid2DObject &o_grid, const Grid2DObject &i_grid)
double ResamplingAlgorithms2D::bilinear_pixel(const Grid2DObject &i_grid, const unsigned int &org_ii, const unsigned int &org_jj, const unsigned int &org_ncols, const unsigned int &org_nrows, const double &x, const double &y)
{
if(org_jj>=(org_nrows-1) || org_ii>=(org_ncols-1)) return i_grid(org_ii, org_jj);
const double f_0_0 = i_grid(org_ii, org_jj);
const double f_1_0 = i_grid(org_ii+1, org_jj);
const double f_0_1 = i_grid(org_ii, org_jj+1);
const double f_1_1 = i_grid(org_ii+1, org_jj+1);
double avg_value = 0.;
unsigned int avg_count = 0;
if(f_0_0!=IOUtils::nodata) {
avg_value += f_0_0;
avg_count++;
}
if(f_1_0!=IOUtils::nodata) {
avg_value += f_1_0;
avg_count++;
}
if(f_0_1!=IOUtils::nodata) {
avg_value += f_0_1;
avg_count++;
}
if(f_1_1!=IOUtils::nodata) {
avg_value += f_1_1;
avg_count++;
}
if(avg_count==4) return f_0_0 * (1.-x)*(1.-y) + f_1_0 * x*(1.-y) + f_0_1 * (1.-x)*y + f_1_1 *x*y;
//special cases: less than two neighbours or three neighbours
if(avg_count<=2) return IOUtils::nodata;
double value = 0.;
const double avg = avg_value/(double)avg_count;
if(f_0_0!=IOUtils::nodata) value += f_0_0 * (1.-x)*(1.-y);
else value += avg * (1.-x)*(1.-y);
if(f_1_0!=IOUtils::nodata) value += f_1_0 * x*(1.-y);
else value += avg * x*(1.-y);
if(f_0_1!=IOUtils::nodata) value += f_0_1 * (1.-x)*y;
else value += avg * (1.-x)*y;
if(f_1_1!=IOUtils::nodata) value += f_1_1 *x*y;
else value += avg *x*y;
return value;
}
void ResamplingAlgorithms2D::Bilinear(Grid2DObject &o_grid, const Grid2DObject &i_grid)
{
const unsigned int org_ncols = i_grid.ncols;
const unsigned int org_nrows = i_grid.nrows;
......@@ -79,31 +138,31 @@ void ResamplingAlgorithms2D::Bilinear_raw(Grid2DObject &o_grid, const Grid2DObje
for (unsigned int jj=0; jj<o_grid.nrows; jj++) {
const double org_y = (double)jj/scale_y;
const unsigned int org_jj = (unsigned int) floor(org_y);
const unsigned int org_jj = static_cast<unsigned int>( org_y );
const double y = org_y - (double)org_jj; //normalized y, between 0 and 1
for (unsigned int ii=0; ii<o_grid.ncols; ii++) {
const double org_x = (double)ii/scale_x;
const unsigned int org_ii = (unsigned int) floor(org_x);
const unsigned int org_ii = static_cast<unsigned int>( org_x );
const double x = org_x - (double)org_ii; //normalized x, between 0 and 1
if(org_jj>=(org_nrows-1) || org_ii>=(org_ncols-1)) {
o_grid(ii,jj) = i_grid(org_ii, org_jj);
continue;
}
const double f_0_0 = i_grid(org_ii, org_jj);
const double f_1_0 = i_grid(org_ii+1, org_jj);
const double f_0_1 = i_grid(org_ii, org_jj+1);
const double f_1_1 = i_grid(org_ii+1, org_jj+1);
o_grid(ii,jj) = f_0_0 * (1.-x)*(1.-y) + f_1_0 * x*(1.-y) + f_0_1 * (1.-x)*y + f_1_1 *x*y;
o_grid(ii,jj) = bilinear_pixel(i_grid, org_ii, org_jj, org_ncols, org_nrows, x, y);
}
}
}
void ResamplingAlgorithms2D::Bilinear_nodata(Grid2DObject &o_grid, const Grid2DObject &i_grid)
{
double ResamplingAlgorithms2D::BSpline_weight(const double &x) {
double R = 0.;
if((x+2.)>0.) R += Optim::pow3(x+2.);
if((x+1.)>0.) R += -4.*Optim::pow3(x+1.);
if((x)>0.) R += 6.*Optim::pow3(x);
if((x-1.)>0.) R += -4.*Optim::pow3(x-1.);
return 1./6.*R;
}
void ResamplingAlgorithms2D::cubicBSpline(Grid2DObject &o_grid, const Grid2DObject &i_grid)
{//see http://paulbourke.net/texture_colour/imageprocess/
const unsigned int org_ncols = i_grid.ncols;
const unsigned int org_nrows = i_grid.nrows;
const double scale_x = (double)o_grid.ncols / (double)org_ncols;
......@@ -112,69 +171,40 @@ void ResamplingAlgorithms2D::Bilinear_nodata(Grid2DObject &o_grid, const Grid2DO
for (unsigned int jj=0; jj<o_grid.nrows; jj++) {
const double org_y = (double)jj/scale_y;
const unsigned int org_jj = static_cast<unsigned int>( org_y );
const double y = org_y - (double)org_jj; //normalized y, between 0 and 1
const double dy = org_y - (double)org_jj; //normalized y, between 0 and 1
for (unsigned int ii=0; ii<o_grid.ncols; ii++) {
const double org_x = (double)ii/scale_x;
const unsigned int org_ii = static_cast<unsigned int>( org_x );
const double x = org_x - (double)org_ii; //normalized x, between 0 and 1
const double dx = org_x - (double)org_ii; //normalized x, between 0 and 1
if(org_jj>=(org_nrows-1) || org_ii>=(org_ncols-1)) {
o_grid(ii,jj) = i_grid(org_ii, org_jj);
continue;
}
const double f_0_0 = i_grid(org_ii, org_jj);
const double f_1_0 = i_grid(org_ii+1, org_jj);
const double f_0_1 = i_grid(org_ii, org_jj+1);
const double f_1_1 = i_grid(org_ii+1, org_jj+1);
double avg_value = 0.;
double F = 0., max=-std::numeric_limits<double>::max(), min=std::numeric_limits<double>::max();
unsigned int avg_count = 0;
if(f_0_0!=IOUtils::nodata) {
avg_value += f_0_0;
avg_count++;
}
if(f_1_0!=IOUtils::nodata) {
avg_value += f_1_0;
avg_count++;
}
if(f_0_1!=IOUtils::nodata) {
avg_value += f_0_1;
avg_count++;
}
if(f_1_1!=IOUtils::nodata) {
avg_value += f_1_1;
avg_count++;
for(int n=-1; n<=2; n++) {
for(int m=-1; m<=2; m++) {
if(((signed)org_ii+m)<0 || ((signed)org_ii+m)>=(signed)org_ncols || ((signed)org_jj+n)<0 || ((signed)org_jj+n)>=(signed)org_nrows) continue;
const double pixel = i_grid(org_ii+m, org_jj+n);
if(pixel!=IOUtils::nodata) {
F += pixel * BSpline_weight(m-dx) * BSpline_weight(dy-n);
avg_count++;
if(pixel>max) max=pixel;
if(pixel<min) min=pixel;
}
}
}
if(avg_count==4) {
o_grid(ii,jj) = f_0_0 * (1.-x)*(1.-y) + f_1_0 * x*(1.-y) + f_0_1 * (1.-x)*y + f_1_1 *x*y;
continue;
}
//special cases: less than two neighbours or three neighbours
if(avg_count<=2) {
o_grid(ii,jj) = IOUtils::nodata;
continue;
}
if(avg_count==16) { //normal bicubic
o_grid(ii,jj) = F*(16/avg_count);
if(o_grid(ii,jj)>max) o_grid(ii,jj)=max; //try to limit overshoot
else if(o_grid(ii,jj)<min) o_grid(ii,jj)=min; //try to limit overshoot
} else if(avg_count==0) o_grid(ii,jj) = IOUtils::nodata; //nodata-> nodata
else //not enought data points -> bilinear for this pixel
o_grid(ii,jj) = bilinear_pixel(i_grid, org_ii, org_jj, org_ncols, org_nrows, dx, dy);
double value = 0.;
const double avg = avg_value/(double)avg_count;
if(f_0_0!=IOUtils::nodata) value += f_0_0 * (1.-x)*(1.-y);
else value += avg * (1.-x)*(1.-y);
if(f_1_0!=IOUtils::nodata) value += f_1_0 * x*(1.-y);
else value += avg * x*(1.-y);
if(f_0_1!=IOUtils::nodata) value += f_0_1 * (1.-x)*y;
else value += avg * (1.-x)*y;
if(f_1_1!=IOUtils::nodata) value += f_1_1 *x*y;
else value += avg *x*y;
o_grid(ii,jj) = value;
}
}
}
}
} //namespace
......@@ -37,11 +37,15 @@ class ResamplingAlgorithms2D {
//Available algorithms
static const Grid2DObject NearestNeighbour(const Grid2DObject &i_grid, const double &factor);
static const Grid2DObject BilinearResampling(const Grid2DObject &i_grid, const double &factor);
static const Grid2DObject cubicBSplineResampling(const Grid2DObject &i_grid, const double &factor);
private:
static void Bilinear_raw(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static void Bilinear_nodata(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static void cubicBSpline(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static void Bilinear(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static void NearestNeighbour(Grid2DObject &o_grid, const Grid2DObject &i_grid);
static double bilinear_pixel(const Grid2DObject &i_grid, const unsigned int &org_ii, const unsigned int &org_jj, const unsigned int &org_ncols, const unsigned int &org_nrows, const double &x, const double &y);
static double BSpline_weight(const double &x);
};
} //end namespace
......
......@@ -86,28 +86,56 @@ const double GRIBIO::plugin_nodata = -999.; //plugin specific nodata value. It c
const double GRIBIO::tz_in = 0.; //GRIB time zone, always UTC
const std::string GRIBIO::default_ext=".grb"; //filename extension
GRIBIO::GRIBIO(const std::string& configfile) : cfg(configfile)
GRIBIO::GRIBIO(const std::string& configfile)
: cfg(configfile), grid2dpath_in(), meteopath_in(), vecPts(), cache_meteo_files(),
meteo_ext(default_ext), grid2d_ext(default_ext), grid2d_prefix(), idx_filename(), coordin(), coordinparam(),
VW(), DW(), wind_date(), llcorner(), fp(NULL), idx(NULL),
latitudeOfNorthernPole(IOUtils::nodata), longitudeOfNorthernPole(IOUtils::nodata), bearing_offset(IOUtils::nodata),
cellsize_x(IOUtils::nodata), cellsize_y(IOUtils::nodata),
indexed(false), meteo_initialized(false), update_dem(false)
{
setOptions();
indexed = false;
idx=NULL;
fp = NULL;
meteo_initialized = false;
latitudeOfNorthernPole = longitudeOfNorthernPole = IOUtils::nodata;
bearing_offset = IOUtils::nodata;
cellsize_x = cellsize_y = IOUtils::nodata;
}
GRIBIO::GRIBIO(const Config& cfgreader) : cfg(cfgreader)
GRIBIO::GRIBIO(const Config& cfgreader)
: cfg(cfgreader), grid2dpath_in(), meteopath_in(), vecPts(), cache_meteo_files(),
meteo_ext(default_ext), grid2d_ext(default_ext), grid2d_prefix(), idx_filename(), coordin(), coordinparam(),
VW(), DW(), wind_date(), llcorner(), fp(NULL), idx(NULL),
latitudeOfNorthernPole(IOUtils::nodata), longitudeOfNorthernPole(IOUtils::nodata), bearing_offset(IOUtils::nodata),
cellsize_x(IOUtils::nodata), cellsize_y(IOUtils::nodata),
indexed(false), meteo_initialized(false), update_dem(false)
{
setOptions();
indexed = false;
idx=NULL;
fp = NULL;
meteo_initialized = false;
latitudeOfNorthernPole = longitudeOfNorthernPole = IOUtils::nodata;
bearing_offset = IOUtils::nodata;
cellsize_x = cellsize_y = IOUtils::nodata;
}
GRIBIO& GRIBIO::operator=(const GRIBIO& source) {
if(this != &source) {
fp = NULL;
idx = NULL;
grid2dpath_in = source.grid2dpath_in;
meteopath_in = source.meteopath_in;
vecPts = source.vecPts;
cache_meteo_files = source.cache_meteo_files;
meteo_ext = source.meteo_ext;
grid2d_ext = source.grid2d_ext;
grid2d_prefix = source.grid2d_prefix;
idx_filename = source.idx_filename;
coordin = source.coordin;
coordinparam = source.coordinparam;
VW = source.VW;
DW = source.DW;
wind_date = source.wind_date;
llcorner = source.llcorner;
latitudeOfNorthernPole = source.latitudeOfNorthernPole;
longitudeOfNorthernPole = source.longitudeOfNorthernPole;
bearing_offset = source.bearing_offset;
cellsize_x = source.cellsize_x;
cellsize_y = source.cellsize_y;
indexed = source.indexed;
meteo_initialized = source.meteo_initialized;
update_dem = source.update_dem;
}
return *this;
}
GRIBIO::~GRIBIO() throw()
......@@ -119,7 +147,6 @@ void GRIBIO::setOptions()
{
std::string coordout, coordoutparam;
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
update_dem = false;
string tmp="";
cfg.getValue("GRID2D", "Input", tmp, Config::nothrow);
......@@ -129,16 +156,14 @@ void GRIBIO::setOptions()
}
cfg.getValue("GRID2DPREFIX", "Input", grid2d_prefix, Config::nothrow);
meteo_ext = default_ext;
cfg.getValue("METEOEXT", "Input", meteo_ext, Config::nothrow);
if(meteo_ext=="none") meteo_ext="";
grid2d_ext = default_ext;
cfg.getValue("GRID2DEXT", "Input", grid2d_ext, Config::nothrow);
if(grid2d_ext=="none") grid2d_ext="";
}
void GRIBIO::readStations()
void GRIBIO::readStations(std::vector<Coords> &vecPoints)
{
cfg.getValue("METEOPATH", "Input", meteopath_in);
size_t current_stationnr = 1;
......@@ -151,14 +176,14 @@ void GRIBIO::readStations()
IOUtils::stripComments(current_station);
if (current_station != "") {
addStation(current_station);
std::cerr << "\tRead virtual station " << vecPts.back().printLatLon() << "\n";
addStation(current_station, vecPoints);
std::cerr << "\tRead virtual station " << vecPoints.back().printLatLon() << "\n";
}
current_stationnr++;
} while (current_station != "");
}
void GRIBIO::addStation(const std::string& coord_spec)
void GRIBIO::addStation(const std::string& coord_spec, std::vector<Coords> &vecPoints)
{
std::istringstream iss(coord_spec);
double coord1=IOUtils::nodata, coord2=IOUtils::nodata;
......@@ -172,13 +197,13 @@ void GRIBIO::addStation(const std::string& coord_spec)
Coords point;
point.setEPSG(epsg);
point.setXY(coord1, coord2, IOUtils::nodata);
vecPts.push_back(point);
vecPoints.push_back(point);
return;
}
if(coord1!=IOUtils::nodata && coord2!=IOUtils::nodata) {
Coords point(coordin, coordinparam);
point.setLatLon(coord1, coord2, IOUtils::nodata);
vecPts.push_back(point);
vecPoints.push_back(point);
return;
}
......@@ -743,7 +768,7 @@ void GRIBIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
const size_t&)
{
if(!meteo_initialized) {
readStations();
readStations(vecPts);
scanMeteoPath();
meteo_initialized=true;
}
......@@ -803,9 +828,9 @@ void GRIBIO::readMeteoData(const Date& dateStart, const Date& dateEnd,
free(lats); free(lons);
}
bool GRIBIO::removeDuplicatePoints(std::vector<Coords>& vecPts, double *lats, double *lons)
bool GRIBIO::removeDuplicatePoints(std::vector<Coords>& vecPoints, double *lats, double *lons)
{ //remove potential duplicates. Returns true if some have been removed
const unsigned int npoints = vecPts.size();
const unsigned int npoints = vecPoints.size();
std::vector<size_t> deletions;
deletions.reserve(npoints);
for(unsigned int ii=0; ii<npoints; ii++) {
......@@ -821,15 +846,15 @@ bool GRIBIO::removeDuplicatePoints(std::vector<Coords>& vecPts, double *lats, do
//we need to erase from the end in order to keep the index unchanged...
for(unsigned int ii=deletions.size(); ii>0; ii--) {
const unsigned int index=deletions[ii-1];
vecPts.erase(vecPts.begin()+index);
vecPoints.erase(vecPoints.begin()+index);
}
if(deletions.size()>0) return true;
return false;
}
bool GRIBIO::readMeteoMeta(std::vector<Coords>& vecPts, std::vector<StationData> &stations, double *lats, double *lons)
{//return true if the metadata have been read, false if it needs to be re-read (ie: some points were leading to duplicates -> vecPts has been changed)
bool GRIBIO::readMeteoMeta(std::vector<Coords>& vecPoints, std::vector<StationData> &stations, double *lats, double *lons)
{//return true if the metadata have been read, false if it needs to be re-read (ie: some points were leading to duplicates -> vecPoints has been changed)
stations.clear();
GRIB_CHECK(grib_index_select_double(idx,"marsParam",8.2),0); //This is the DEM
......@@ -842,7 +867,7 @@ bool GRIBIO::readMeteoMeta(std::vector<Coords>& vecPts, std::vector<StationData>
throw IOException("Can not find DEM grid in GRIB file!", AT);
}
const long npoints = vecPts.size();
const long npoints = vecPoints.size();
double latitudeOfSouthernPole, longitudeOfSouthernPole;
GRIB_CHECK(grib_get_double(h,"latitudeOfSouthernPoleInDegrees",&latitudeOfSouthernPole),0);
GRIB_CHECK(grib_get_double(h,"longitudeOfSouthernPoleInDegrees",&longitudeOfSouthernPole),0);
......@@ -854,7 +879,7 @@ bool GRIBIO::readMeteoMeta(std::vector<Coords>& vecPts, std::vector<StationData>
//build GRIB local coordinates for the points
for(unsigned int ii=0; ii<(unsigned)npoints; ii++) {
Coords::trueLatLonToRotated(latitudeOfNorthernPole, longitudeOfNorthernPole, vecPts[ii].getLat(), vecPts[ii].getLon(), lats[ii], lons[ii]);
Coords::trueLatLonToRotated(latitudeOfNorthernPole, longitudeOfNorthernPole, vecPoints[ii].getLat(), vecPoints[ii].getLon(), lats[ii], lons[ii]);
}
//retrieve nearest points
......@@ -870,7 +895,7 @@ bool GRIBIO::readMeteoMeta(std::vector<Coords>& vecPts, std::vector<StationData>
}
//remove potential duplicates
if(removeDuplicatePoints(vecPts, outlats, outlons)==true) {
if(removeDuplicatePoints(vecPoints, outlats, outlons)==true) {
free(outlats); free(outlons); free(values); free(distances); free(indexes);
grib_handle_delete(h);
return false;
......
......@@ -41,6 +41,8 @@ class GRIBIO : public IOInterface {
GRIBIO(const Config& cfgreader);
~GRIBIO() throw();
GRIBIO& operator=(const GRIBIO&); ///<Assignement operator, required because of pointer member
virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
virtual void readDEM(DEMObject& dem_out);
......@@ -69,16 +71,16 @@ class GRIBIO : public IOInterface {
void read2DGrid(const std::string& filename, Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
void readWind(const std::string& filename, const Date& date);
void indexFile(const std::string& filename);
void addStation(const std::string& coord_spec);
void readStations();
void addStation(const std::string& coord_spec, std::vector<Coords> &vecPoints);
void readStations(std::vector<Coords> &vecPoints);
void listKeys(grib_handle** h, const std::string& filename);
void scanMeteoPath();
/*void rotatedToTrueLatLon(const double& lat_rot, const double& lon_rot, double &lat_true, double &lon_true) const;
void trueLatLonToRotated(const double& lat_true, const double& lon_true, double &lat_rot, double &lon_rot) const;*/
void cleanup() throw();
bool removeDuplicatePoints(std::vector<Coords>& vecPts, double *lats, double *lons);
bool readMeteoMeta(std::vector<Coords>& vecPts, std::vector<StationData> &stations, double *lats, double *lons);
bool removeDuplicatePoints(std::vector<Coords>& vecPoints, double *lats, double *lons);
bool readMeteoMeta(std::vector<Coords>& vecPoints, std::vector<StationData> &stations, double *lats, double *lons);
bool readMeteoValues(const double& marsParam, const long& levelType, const long& i_level, const Date& i_date, const long& npoints, double *lats, double *lons, double *values);
void fillMeteo(double *values, const MeteoData::Parameters& param, const long& npoints, std::vector<MeteoData> &Meteo);
void readMeteoStep(std::vector<StationData> &stations, double *lats, double *lons, const Date i_date, std::vector<MeteoData> &Meteo);
......@@ -87,27 +89,27 @@ class GRIBIO : public IOInterface {
std::string grid2dpath_in;
std::string meteopath_in;
std::vector<Coords> vecPts; //points to use for virtual stations if METEO=GRIB
FILE *fp; //since passing fp always fail...
std::vector< std::pair<Date,std::string> > cache_meteo_files; //cache of meteo files in METEOPATH
std::string meteo_ext; //file extension
std::string grid2d_ext; //file extension
std::string grid2d_prefix; //filename prefix, like "laf"
bool indexed; //flag to know if the file has already been indexed
grib_index *idx; //because it needs to be kept between calls
std::string idx_filename; //matching file name for the index
std::vector< std::pair<Date,std::string> > cache_meteo_files; //cache of meteo files in METEOPATH
bool meteo_initialized; //set to true after we scanned METEOPATH, filed the cache, read the virtual stations from io.ini
double latitudeOfNorthernPole, longitudeOfNorthernPole; //for rotated coordinates
double bearing_offset; //to correct vectors coming from rotated lat/lon, we will add an offset to the bearing
std::string coordin, coordinparam; //projection parameters
Grid2DObject VW, DW; //for caching wind fields, since they require quite some calculations
Date wind_date;
Coords llcorner;
FILE *fp; //since passing fp always fail...
grib_index *idx; //because it needs to be kept between calls
double latitudeOfNorthernPole, longitudeOfNorthernPole; //for rotated coordinates
double bearing_offset; //to correct vectors coming from rotated lat/lon, we will add an offset to the bearing
double cellsize_x, cellsize_y;
static const unsigned int MAX_VAL_LEN; //max value string lengthin GRIB
static const std::string default_ext;
static const double plugin_nodata; //plugin specific nodata value, e.g. -999
static const double tz_in; //GRIB time zone
static const std::string default_ext;
std::string coordin, coordinparam; //projection parameters
bool indexed; //flag to know if the file has already been indexed
bool meteo_initialized; //set to true after we scanned METEOPATH, filed the cache, read the virtual stations from io.ini
bool update_dem;
};
......
......@@ -175,21 +175,22 @@ void ImisIO::getDBParameters()
cfg.getValue("DBUSER", "Input", oracleUserName_in);
cfg.getValue("DBPASS", "Input", oraclePassword_in);
useAnetz = false;
cfg.getValue("USEANETZ", "Input", useAnetz, Config::nothrow);
use_imis_hnw = false;
cfg.getValue("USE_IMIS_HNW", "Input", use_imis_hnw, Config::nothrow);
use_hnw_snowpack = false;
cfg.getValue("USE_SNOWPACK_HNW", "Input", use_hnw_snowpack, Config::nothrow);
}
ImisIO::ImisIO(const std::string& configfile) : cfg(configfile)
ImisIO::ImisIO(const std::string& configfile)
: cfg(configfile), coordin(), coordinparam(), coordout(), coordoutparam(), vecStationMetaData(), mapDriftStation(),
oracleUserName_in(), oraclePassword_in(), oracleDBName_in(), useAnetz(false), use_imis_hnw(false), use_hnw_snowpack(false)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
getDBParameters();
}
ImisIO::ImisIO(const Config& cfgreader) : cfg(cfgreader)
ImisIO::ImisIO(const Config& cfgreader)
: cfg(cfgreader), coordin(), coordinparam(), coordout(), coordoutparam(), vecStationMetaData(), mapDriftStation(),
oracleUserName_in(), oraclePassword_in(), oracleDBName_in(), useAnetz(false), use_imis_hnw(false), use_hnw_snowpack(false)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
getDBParameters();
......@@ -937,10 +938,10 @@ size_t ImisIO::getSensorDepths(const std::string& stat_abk, const std::string& s
* @param return number of columns retrieved
*/
size_t ImisIO::getStationMetaData(const std::string& stat_abk, const std::string& stao_nr,
const std::string& sqlQuery, std::vector<std::string>& vecStationMetaData,
const std::string& sqlQuery, std::vector<std::string>& vecMetaData,
oracle::occi::Connection*& conn)
{
vecStationMetaData.clear();
vecMetaData.clear();
try {
Statement *stmt = conn->createStatement(sqlQuery);
......@@ -954,7 +955,7 @@ size_t ImisIO::getStationMetaData(const std::string& stat_abk, const std::string
while (rs->next() == true) {
for (size_t ii=1; ii<=cols.size(); ii++) {
vecStationMetaData.push_back(rs->getString(ii));
vecMetaData.push_back(rs->getString(ii));
}
}
......
......@@ -37,30 +37,25 @@ namespace mio {
class AnetzData{
public:
AnetzData(): nrOfAnetzStations(0), nrOfCoefficients(0) {
anetzstations.push_back("");
anetzstations.push_back("");
anetzstations.push_back("");
coeffs.push_back(IOUtils::nodata);
coeffs.push_back(IOUtils::nodata);
coeffs.push_back(IOUtils::nodata);
AnetzData()
: nrOfAnetzStations(3), nrOfCoefficients(3), coeffs(3, IOUtils::nodata), anetzstations(3, "")
{
}
AnetzData(const size_t& nr_anetz,
const std::string& i_anetz1, const std::string& i_anetz2, const std::string& i_anetz3,
const size_t& nr_coeffs,
const double& coeff1, const double& coeff2, const double& coeff3)
: nrOfAnetzStations(nr_anetz), nrOfCoefficients(nr_coeffs)
: nrOfAnetzStations(nr_anetz), nrOfCoefficients(nr_coeffs), coeffs(3), anetzstations(3)
{
anetzstations.push_back(i_anetz1);
anetzstations.push_back(i_anetz2);
anetzstations.push_back(i_anetz3);
coeffs.