WSL/SLF GitLab Repository

Commit 8cad297f authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Fixing a small bug/warning in libsmet and properly initializing the members in...

Fixing a small bug/warning in libsmet and properly initializing the members in some plugins (through initialization lists, as usual).
parent 51a8e652
......@@ -653,7 +653,7 @@ void SMETWriter::set_precision(const std::vector<int>& vec_precision)
}
SMETReader::SMETReader(const std::string& in_fname) :
data_start_fpointer(NULL), vec_offset(), vec_multiplier(), vec_fieldnames(),
data_start_fpointer(), vec_offset(), vec_multiplier(), vec_fieldnames(),
header(), map_timestamp_streampos(), map_julian_streampos(),
filename(in_fname), timestamp_start("-4714-11-24T00:00"),
timestamp_end("9999-12-31T00:00"), nodata_value(-999.),
......
......@@ -59,29 +59,27 @@ namespace mio {
const double A3DIO::plugin_nodata = -9999.0; //plugin specific nodata value
const unsigned int A3DIO::buffer_reserve = 23*24*2; //kind of average size of a buffer for optimizing vectors
A3DIO::A3DIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
A3DIO::A3DIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
in_tz(0.), out_tz(0.), fin(), coordin(), coordinparam(), coordout(), coordoutparam()
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
IOUtils::getTimeZoneParameters(cfg, in_tz, out_tz);
}
A3DIO::A3DIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
A3DIO::A3DIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
in_tz(0.), out_tz(0.), fin(), coordin(), coordinparam(), coordout(), coordoutparam()
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
IOUtils::getTimeZoneParameters(cfg, in_tz, out_tz);
}
//Copy constructor
A3DIO::A3DIO(const A3DIO& aio) : IOInterface(NULL), cfg(aio.cfg)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
IOUtils::getTimeZoneParameters(cfg, in_tz, out_tz);
}
A3DIO::A3DIO(const Config& in_cfg) : IOInterface(NULL), cfg(in_cfg)
A3DIO::A3DIO(const Config& in_cfg)
: IOInterface(NULL), cfg(in_cfg),
in_tz(0.), out_tz(0.), fin(), coordin(), coordinparam(), coordout(), coordoutparam()
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
......
......@@ -36,7 +36,6 @@ class A3DIO : public IOInterface {
A3DIO(void (*delObj)(void*), const Config& i_cfg);
A3DIO(const std::string& configfile);
A3DIO(const A3DIO&);
A3DIO(const Config&);
~A3DIO() throw();
......@@ -89,8 +88,8 @@ class A3DIO : public IOInterface {
const std::string& filename, const std::string& label);
void write2DMeteo(const std::vector< std::vector<MeteoData> >& data);
double in_tz, out_tz; //timezones
const Config& cfg;
double in_tz, out_tz; //timezones
std::ifstream fin; //Input file streams
std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
};
......
......@@ -99,7 +99,11 @@ namespace mio {
* - DAPATH: path+prefix of file containing data assimilation grids (named with ISO 8601 basic date and .sca extension, example ./input/dagrids/sdp_200812011530.sca)
*/
ARCIO::ARCIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
ARCIO::ARCIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
fin(), fout(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), grid2dpath_out(), grid2d_ext_in(), grid2d_ext_out(),
a3d_view_in(false), a3d_view_out(false)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
a3d_view_in = false;
......@@ -109,7 +113,11 @@ ARCIO::ARCIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj),
getGridPaths();
}
ARCIO::ARCIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
ARCIO::ARCIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
fin(), fout(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), grid2dpath_out(), grid2d_ext_in(), grid2d_ext_out(),
a3d_view_in(false), a3d_view_out(false)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
a3d_view_in = false;
......@@ -119,7 +127,11 @@ ARCIO::ARCIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
getGridPaths();
}
ARCIO::ARCIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
ARCIO::ARCIO(const Config& cfgreader)
: IOInterface(NULL), cfg(cfgreader),
fin(), fout(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), grid2dpath_out(), grid2d_ext_in(), grid2d_ext_out(),
a3d_view_in(false), a3d_view_out(false)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
a3d_view_in = false;
......
......@@ -48,33 +48,33 @@ namespace mio {
const double ARPSIO::plugin_nodata = -999.; //plugin specific nodata value
const std::string ARPSIO::default_ext=".asc"; //filename extension
ARPSIO::ARPSIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
ARPSIO::ARPSIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
fin(NULL), fout(), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), ext(default_ext), dimx(0), dimy(0), dimz(0), cellsize(0.),
xcoord(IOUtils::nodata), ycoord(IOUtils::nodata), zcoord(), is_true_arps(true)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
dimx=dimy=dimz=0;
cellsize=0.;
fin=NULL;
is_true_arps=true;
setOptions();
}
ARPSIO::ARPSIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
ARPSIO::ARPSIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
fin(NULL), fout(), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), ext(default_ext), dimx(0), dimy(0), dimz(0), cellsize(0.),
xcoord(IOUtils::nodata), ycoord(IOUtils::nodata), zcoord(), is_true_arps(true)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
dimx=dimy=dimz=0;
cellsize=0.;
fin=NULL;
is_true_arps=true;
setOptions();
}
ARPSIO::ARPSIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
ARPSIO::ARPSIO(const Config& cfgreader)
: IOInterface(NULL), cfg(cfgreader),
fin(NULL), fout(), filename(), coordin(), coordinparam(), coordout(), coordoutparam(),
grid2dpath_in(), ext(default_ext), dimx(0), dimy(0), dimz(0), cellsize(0.),
xcoord(IOUtils::nodata), ycoord(IOUtils::nodata), zcoord(), is_true_arps(true)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
dimx=dimy=dimz=0;
cellsize=0.;
fin=NULL;
is_true_arps=true;
setOptions();
}
......@@ -89,7 +89,7 @@ void ARPSIO::setOptions()
cfg.getValue("ARPS_XCOORD", "Input", xcoord, Config::dothrow);
cfg.getValue("ARPS_YCOORD", "Input", ycoord, Config::dothrow);
ext = default_ext;
//default value has been set in constructor
cfg.getValue("GRID2DEXT", "Input", ext, Config::nothrow);
if(ext=="none") ext="";
}
......
......@@ -47,19 +47,28 @@ namespace mio {
const double PGMIO::plugin_nodata = 0.; //plugin specific nodata value. It can also be read by the plugin (depending on what is appropriate)
PGMIO::PGMIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
PGMIO::PGMIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
coordin(), coordinparam(), coordout(), coordoutparam(),
fin(), fout(), grid2dpath_in(), grid2dpath_out()
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
getGridPaths();
}
PGMIO::PGMIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
PGMIO::PGMIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
coordin(), coordinparam(), coordout(), coordoutparam(),
fin(), fout(), grid2dpath_in(), grid2dpath_out()
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
getGridPaths();
}
PGMIO::PGMIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
PGMIO::PGMIO(const Config& cfgreader)
: IOInterface(NULL), cfg(cfgreader),
coordin(), coordinparam(), coordout(), coordoutparam(),
fin(), fout(), grid2dpath_in(), grid2dpath_out()
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
getGridPaths();
......
......@@ -98,26 +98,42 @@ const unsigned char PNGIO::channel_depth = 8;
const unsigned char PNGIO::channel_max_color = 255;
const unsigned char PNGIO::transparent_grey = channel_max_color;
PNGIO::PNGIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
PNGIO::PNGIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
fp(NULL), autoscale(true), has_legend(true), has_world_file(false), optimize_for_speed(true),
indexed_png(true), nr_levels(30),
coordout(), coordoutparam(), grid2dpath(),
scaling("bilinear"), min_w(IOUtils::unodata), min_h(IOUtils::unodata), max_w(IOUtils::unodata), max_h(IOUtils::unodata),
metadata_key(), metadata_text()
{
fp=NULL;
setOptions();
}
PNGIO::PNGIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
PNGIO::PNGIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
fp(NULL), autoscale(true), has_legend(true), has_world_file(false), optimize_for_speed(true),
indexed_png(true), nr_levels(30),
coordout(), coordoutparam(), grid2dpath(),
scaling("bilinear"), min_w(IOUtils::unodata), min_h(IOUtils::unodata), max_w(IOUtils::unodata), max_h(IOUtils::unodata),
metadata_key(), metadata_text()
{
fp=NULL;
setOptions();
}
PNGIO::PNGIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
PNGIO::PNGIO(const Config& cfgreader)
: IOInterface(NULL), cfg(cfgreader),
fp(NULL), autoscale(true), has_legend(true), has_world_file(false), optimize_for_speed(true),
indexed_png(true), nr_levels(30),
coordout(), coordoutparam(), grid2dpath(),
scaling("bilinear"), min_w(IOUtils::unodata), min_h(IOUtils::unodata), max_w(IOUtils::unodata), max_h(IOUtils::unodata),
metadata_key(), metadata_text()
{
fp=NULL;
setOptions();
}
void PNGIO::setOptions()
{
//default values have been set by the constructors
cfg.getValue("COORDSYS", "Output", coordout);
cfg.getValue("COORDPARAM", "Output", coordoutparam, Config::nothrow);
cfg.getValue("GRID2DPATH", "Output", grid2dpath);
......@@ -125,19 +141,14 @@ void PNGIO::setOptions()
//get size specifications
std::string min_size, max_size;
min_w = min_h = max_w = max_h = IOUtils::unodata;
cfg.getValue("PNG_MIN_SIZE", "Output", min_size, Config::nothrow);
if(min_size!="") parse_size(min_size, min_w, min_h);
cfg.getValue("PNG_MAX_SIZE", "Output", max_size, Config::nothrow);
if(max_size!="") parse_size(max_size, max_w, max_h);
autoscale = true;
cfg.getValue("PNG_AUTOSCALE", "Output", autoscale, Config::nothrow);
has_legend = true;
cfg.getValue("PNG_LEGEND", "Output", has_legend, Config::nothrow);
scaling = "bilinear";
cfg.getValue("PNG_SCALING", "Output", scaling, Config::nothrow);
has_world_file=false;
cfg.getValue("PNG_WORLD_FILE", "Output", has_world_file, Config::nothrow);
if(has_legend) { //we need to save room for the legend
......@@ -145,11 +156,8 @@ void PNGIO::setOptions()
if(max_w!=IOUtils::unodata) max_w -= legend::getLegendWidth();
}
indexed_png = true;
cfg.getValue("PNG_INDEXED", "Output", indexed_png, Config::nothrow);
optimize_for_speed = true;
cfg.getValue("PNG_SPEED_OPTIMIZE", "Output", optimize_for_speed, Config::nothrow);
nr_levels = 30;
unsigned int tmp=IOUtils::unodata;
cfg.getValue("PNG_NR_LEVELS", "Output", tmp, Config::nothrow);
if(tmp!=IOUtils::unodata && (tmp>255 || tmp<5)) {
......
......@@ -69,22 +69,31 @@ namespace mio {
const std::string SMETIO::dflt_extension = ".smet";
SMETIO::SMETIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
SMETIO::SMETIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
coordin(), coordinparam(), coordout(), coordoutparam(),
vec_smet_reader(), vecFiles(), outpath(), in_dflt_TZ(0.), out_dflt_TZ(0.),
plugin_nodata(IOUtils::nodata), nr_stations(0), outputIsAscii(true), outputIsGzipped(false)
{
parseInputOutputSection();
plugin_nodata = IOUtils::nodata;
}
SMETIO::SMETIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
SMETIO::SMETIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
coordin(), coordinparam(), coordout(), coordoutparam(),
vec_smet_reader(), vecFiles(), outpath(), in_dflt_TZ(0.), out_dflt_TZ(0.),
plugin_nodata(IOUtils::nodata), nr_stations(0), outputIsAscii(true), outputIsGzipped(false)
{
parseInputOutputSection();
plugin_nodata = IOUtils::nodata;
}
SMETIO::SMETIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
SMETIO::SMETIO(const Config& cfgreader)
: IOInterface(NULL), cfg(cfgreader),
coordin(), coordinparam(), coordout(), coordoutparam(),
vec_smet_reader(), vecFiles(), outpath(), in_dflt_TZ(0.), out_dflt_TZ(0.),
plugin_nodata(IOUtils::nodata), nr_stations(0), outputIsAscii(true), outputIsGzipped(false)
{
parseInputOutputSection();
plugin_nodata = IOUtils::nodata;
}
SMETIO::~SMETIO() throw()
......
......@@ -77,44 +77,50 @@ const double SNIO::plugin_nodata = -999.0; //plugin specific nodata value
const size_t SNIO::min_nr_meteoData = 15;
const std::string SNIO::dflt_extension = ".inp";
SNIO::SNIO(void (*delObj)(void*), const Config& i_cfg) : IOInterface(delObj), cfg(i_cfg)
SNIO::SNIO(void (*delObj)(void*), const Config& i_cfg)
: IOInterface(delObj), cfg(i_cfg),
vecAllStations(), vec_streampos(), fin(), fout(),
coordin(), coordinparam(), coordout(), coordoutparam(),
in_tz(0.), out_tz(0.), nr_meteoData(min_nr_meteoData),
iswr_inp(true), rswr_inp(true)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
cfg.getValue("TIME_ZONE","Input",in_tz,Config::nothrow);
cfg.getValue("TIME_ZONE","Output",out_tz,Config::nothrow);
iswr_inp = rswr_inp = true;
cfg.getValue("ISWR_INP","Input",iswr_inp,Config::nothrow);
cfg.getValue("RSWR_INP","Input",rswr_inp,Config::nothrow);
nr_meteoData = min_nr_meteoData;
if (!iswr_inp || !rswr_inp)
nr_meteoData = min_nr_meteoData - 1;
}
SNIO::SNIO(const std::string& configfile) : IOInterface(NULL), cfg(configfile)
SNIO::SNIO(const std::string& configfile)
: IOInterface(NULL), cfg(configfile),
vecAllStations(), vec_streampos(), fin(), fout(),
coordin(), coordinparam(), coordout(), coordoutparam(),
in_tz(0.), out_tz(0.), nr_meteoData(min_nr_meteoData),
iswr_inp(true), rswr_inp(true)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
cfg.getValue("TIME_ZONE","Input",in_tz,Config::nothrow);
cfg.getValue("TIME_ZONE","Output",out_tz,Config::nothrow);
iswr_inp = rswr_inp = true;
cfg.getValue("ISWR_INP","Input",iswr_inp,Config::nothrow);
cfg.getValue("RSWR_INP","Input",rswr_inp,Config::nothrow);
nr_meteoData = min_nr_meteoData;
if (!iswr_inp || !rswr_inp)
nr_meteoData = min_nr_meteoData - 1;
}
SNIO::SNIO(const Config& cfgreader) : IOInterface(NULL), cfg(cfgreader)
SNIO::SNIO(const Config& cfgreader)
: IOInterface(NULL), cfg(cfgreader),
vecAllStations(), vec_streampos(), fin(), fout(),
coordin(), coordinparam(), coordout(), coordoutparam(),
in_tz(0.), out_tz(0.), nr_meteoData(min_nr_meteoData),
iswr_inp(true), rswr_inp(true)
{
IOUtils::getProjectionParameters(cfg, coordin, coordinparam, coordout, coordoutparam);
in_tz = out_tz = 0.;
cfg.getValue("TIME_ZONE","Input",in_tz,Config::nothrow);
cfg.getValue("TIME_ZONE","Output",out_tz,Config::nothrow);
iswr_inp = rswr_inp = true;
cfg.getValue("ISWR_INP","Input",iswr_inp,Config::nothrow);
cfg.getValue("RSWR_INP","Input",rswr_inp,Config::nothrow);
nr_meteoData = min_nr_meteoData;
if (!iswr_inp || !rswr_inp)
nr_meteoData = min_nr_meteoData - 1;
}
......
......@@ -81,14 +81,14 @@ class SNIO : public IOInterface {
void parseMetaDataLine(const std::vector<std::string>& vecLine, StationData& sd);
void cleanup() throw();
const Config& cfg;
std::vector<StationData> vecAllStations;
std::vector< std::map <Date, std::streampos> > vec_streampos; //in order to save file pointers
std::ifstream fin; //Input file streams
std::ofstream fout;//Output file streams
const Config& cfg;
static const std::string dflt_extension;
std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
double in_tz, out_tz;
static const std::string dflt_extension;
static const double plugin_nodata; //plugin specific nodata value, e.g. -999
static const int sn_julian_offset;
static const size_t min_nr_meteoData; // minimal number of parameters on data input lines
......
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