MeteoIODoc 20240503.aefd3c94
PGMIO.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2/***********************************************************************************/
3/* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
4/***********************************************************************************/
5/* This file is part of MeteoIO.
6 MeteoIO is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 MeteoIO is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef PGMIO_H
20#define PGMIO_H
21
22#include <meteoio/IOInterface.h>
23
24#include <string>
25#include <sstream>
26
27namespace mio {
28
37class PGMIO : public IOInterface {
38 public:
39 PGMIO(const std::string& configfile);
40 PGMIO(const PGMIO&);
41 PGMIO(const Config& cfgreader);
42
43 virtual bool list2DGrids(const Date& start, const Date& end, std::map<Date, std::set<size_t> > &list);
44 virtual void read2DGrid(Grid2DObject& grid_out, const std::string& parameter="");
45 virtual void read2DGrid(Grid2DObject& grid_out, const MeteoGrids::Parameters& parameter, const Date& date);
46
47 virtual void readDEM(DEMObject& dem_out);
48
49 virtual void write2DGrid(const Grid2DObject& grid_in, const std::string& filename);
50 virtual void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);
51
52 private:
53 void getGridPaths();
54 static bool readGridded(std::ifstream& fin, const std::string& full_name, const double& scale_factor, const double& val_min, Grid2DObject& grid_out);
55 static void readColumn(std::ifstream& fin, const std::string& full_name, const double& scale_factor, const double& val_min, Grid2DObject& grid_out);
56 void read2DGrid_internal(Grid2DObject& grid_out, const std::string& full_name) const;
57 static size_t getNextHeader(std::vector<std::string>& vecString, const std::string& filename, std::ifstream& fin);
58
59 const Config cfg;
60 static const double plugin_nodata; //plugin specific nodata value, e.g. -999
61 std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
62 std::string grid2dpath_in, grid2dpath_out;
63};
64
65} //namespace
66#endif
A class that reads a key/value file. These files (typically named *.ini) follow the INI file format s...
Definition: Config.h:79
A class to represent DEMs and automatically compute some properties. This class stores elevation grid...
Definition: DEMObject.h:40
A class to handle timestamps. This class handles conversion between different time display formats (I...
Definition: Date.h:87
A class to represent 2D Grids. Typical application as DEM or Landuse Model.
Definition: Grid2DObject.h:42
A class representing the IO Layer of the software Alpine3D. For each type of IO (File,...
Definition: IOInterface.h:98
Parameters
this enum provides names for possible meteogrids (from an ARPS file, etc)
Definition: MeteoData.h:46
This class writes 2D grids as Portable Grey Map file format.
Definition: PGMIO.h:37
PGMIO(const PGMIO &)
virtual void readDEM(DEMObject &dem_out)
Parse the DEM (Digital Elevation Model) into the Grid2DObject.
Definition: PGMIO.cc:286
PGMIO(const std::string &configfile)
Definition: PGMIO.cc:71
virtual bool list2DGrids(const Date &start, const Date &end, std::map< Date, std::set< size_t > > &list)
Return the list of grids within a given time period that could be read by the plugin,...
Definition: PGMIO.cc:251
virtual void read2DGrid(Grid2DObject &grid_out, const std::string &parameter="")
A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for a...
Definition: PGMIO.cc:247
virtual void write2DGrid(const Grid2DObject &grid_in, const std::string &filename)
Write a Grid2DObject The filename is specified relative to GRID2DPATH for most plugins.
Definition: PGMIO.cc:293
Definition: Config.cc:31