OGS
FileIO Namespace Reference

Namespaces

namespace  GMSH
namespace  Gocad
namespace  Legacy

Classes

class  AsciiRasterInterface
class  CsvInterface
class  FEFLOWGeoInterface
class  FEFLOWMeshInterface
class  GMSInterface
 Manages the import and export of Aquaveo GMS files into and out of GeoLib. More...
class  PetrelInterface
class  SHPInterface
 Manages the import of ESRI shape files into GeoLib. More...
class  SwmmInterface
class  TetGenInterface
class  XmlLutReader
 Reader for vtk-Lookup-Tables (in XML / ParaView Format) More...
class  XmlPrjInterface

Enumerations

enum class  SwmmObject { SUBCATCHMENT = 0 , NODE = 1 , LINK = 2 , SYSTEM = 3 }
 SWMM object types. More...

Functions

bool createSurface (GeoLib::Polyline const &ply, GeoLib::GEOObjects &geometries, std::string const &geometry_name, std::string const &gmsh_binary)
std::unique_ptr< GeoLib::SurfacecreateSurfaceWithEarClipping (GeoLib::Polyline const &line)
static std::string readLine (std::istream &in)
static std::list< std::string > split (std::string const &line)
static void printListInfo (const std::list< std::string > &str_list, std::string_view const prefix, std::string_view const message)
static double getLastNumberFromList (const std::list< std::string > &str_list)
void readGeometryFromFile (std::string const &fname, GeoLib::GEOObjects &geo_objs, std::string const &gmsh_path)
auto constructPointsFromNodes (std::vector< MeshLib::Node * > nodes)
void writeGeometryToFile (std::string const &geo_name, GeoLib::GEOObjects &geo_objs, std::string const &fname)
void addTextNode (QDomDocument &doc, QDomElement &parent, QString const &node_name, QString const &content)
bool PVarExists (std::string const &name, std::vector< DataHolderLib::ProcessVariable > const &p_vars)
static double readDoubleFromStream (std::istream &in)
 Reads a double replacing comma by point.
static std::optional< GeoLib::RasterHeaderreadASCHeader (std::ifstream &in)
static std::optional< std::tuple< GeoLib::RasterHeader, double, double > > readSurferHeader (std::ifstream &in)
std::vector< std::string > readFile (std::istream &in)
std::optional< std::array< double, 3 > > readXyzCoordinates (std::string const &line)
GeoLib::RasterHeader getXyzHeader (std::vector< std::string > const &lines)
static bool allRastersExist (std::vector< std::string > const &raster_paths)
 Checks if all raster files actually exist.
std::optional< std::vector< GeoLib::Raster const * > > readRasters (std::vector< std::string > const &raster_paths)

Variables

const std::array< std::string, 9 > subcatchment_vars
 Variables that always exist for subcatchments. There might be more.
const std::array< std::string, 7 > node_vars
 Variables that always exist for nodes. There might be more.
const std::array< std::string, 6 > link_vars
 Variables that always exist for links. There might be more.
const std::array< std::string, 15 > system_vars
 All variables that exist for the system.
std::array< std::size_t, 4 > const n_obj_params = {8, 6, 5, 15}

Enumeration Type Documentation

◆ SwmmObject

enum class FileIO::SwmmObject
strong

SWMM object types.

Enumerator
SUBCATCHMENT 
NODE 
LINK 
SYSTEM 

Definition at line 30 of file SWMMInterface.h.

Function Documentation

◆ addTextNode()

void FileIO::addTextNode ( QDomDocument & doc,
QDomElement & parent,
QString const & node_name,
QString const & content )

Definition at line 419 of file XmlPrjInterface.cpp.

423{
424 QDomElement tag = doc.createElement(node_name);
425 parent.appendChild(tag);
426 QDomText order_text = doc.createTextNode(content);
427 tag.appendChild(order_text);
428}

Referenced by FileIO::XmlPrjInterface::writeCondition(), and FileIO::XmlPrjInterface::writeProcessVariables().

◆ allRastersExist()

bool FileIO::allRastersExist ( std::vector< std::string > const & raster_paths)
static

Checks if all raster files actually exist.

Definition at line 371 of file AsciiRasterInterface.cpp.

372{
373 return std::all_of(raster_paths.begin(), raster_paths.end(),
374 [](std::string const& raster_path)
375 {
376 if (BaseLib::IsFileExisting(raster_path))
377 {
378 return true;
379 }
380 ERR("Opening raster file {} failed.", raster_path);
381 return false;
382 });
383}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40

References ERR().

Referenced by readRasters().

◆ constructPointsFromNodes()

auto FileIO::constructPointsFromNodes ( std::vector< MeshLib::Node * > nodes)

Definition at line 25 of file TetGenInterface.cpp.

26{
27 std::vector<GeoLib::Point*> points;
28 points.reserve(nodes.size());
29 std::transform(nodes.begin(), nodes.end(), std::back_inserter(points),
30 [](auto const* node)
31 { return new GeoLib::Point(*node, node->getID()); });
32 return points;
33}

Referenced by FileIO::TetGenInterface::readTetGenGeometry().

◆ createSurface()

bool FileIO::createSurface ( GeoLib::Polyline const & ply,
GeoLib::GEOObjects & geometries,
std::string const & geometry_name,
std::string const & gmsh_binary )

Creates a plane surface from the given polyline. The polyline has to be closed, i.e. the first and the last point have to be the identical. The triangulation of the polyline is done by the finite element meshing tool Gmsh. Finally, the resulting mesh is converted into a GeoLib::Surface which is inserted into the GeoLib::GEOObjects instance geometries using the name geometry_name.

Definition at line 25 of file createSurface.cpp.

29{
30 if (!ply.isClosed())
31 {
32 WARN("Error in createSurface() - Polyline is not closed.");
33 return false;
34 }
35
36 if (ply.getNumberOfPoints() <= 2)
37 {
38 WARN(
39 "Error in createSurface() - Polyline consists of less "
40 "than three points and therefore cannot be triangulated.");
41 return false;
42 }
43
44 // create new GEOObjects and insert a copy of the polyline
45 std::vector<GeoLib::Point*> polyline_points;
46 GeoLib::GEOObjects geo;
47 auto ply_points = ply.getPointsVec();
48 std::transform(ply_points.begin(), ply_points.end(),
49 std::back_inserter(polyline_points),
50 [](auto const* p) { return new GeoLib::Point(*p); });
51 std::string ply_name = "temporary_polyline_name";
52 geo.addPointVec(std::move(polyline_points), ply_name,
53 std::map<std::string, std::size_t>{});
54 auto polyline =
55 std::make_unique<GeoLib::Polyline>(*geo.getPointVec(ply_name));
56 for (std::size_t k(0); k < ply.getNumberOfPoints(); ++k)
57 {
58 polyline->addPoint(ply.getPointID(k));
59 }
60 std::vector<GeoLib::Polyline*> polylines;
61 polylines.push_back(polyline.release());
62 geo.addPolylineVec(std::move(polylines), ply_name,
64
65 // use GMSHInterface to create a mesh from the closed polyline
66 auto const geo_names = geo.getGeometryNames();
67 FileIO::GMSH::GMSHInterface gmsh_io(
69 0.0, 0, geo_names, false, false);
70
71 // write to random file in temp directory
72 auto geo_file = std::filesystem::temp_directory_path() /=
74 auto msh_file = std::filesystem::temp_directory_path() /=
76
77 BaseLib::IO::writeStringToFile(gmsh_io.writeToString(), geo_file);
78 // Using GMSH's vtk output here so we don't have to deal with GMSH and it's
79 // various file format versions here
80 std::string gmsh_command = "\"" + gmsh_binary +
81 "\" -2 -algo meshadapt -format vtk -o " +
82 msh_file.string() + " " + geo_file.string();
83
84 int const gmsh_return_value = std::system(gmsh_command.c_str());
85 if (gmsh_return_value != 0)
86 {
87 WARN("Call to '{:s}' returned non-zero value {:d}.", gmsh_command,
88 gmsh_return_value);
89 }
90 auto const* surface_mesh = MeshLib::IO::readMeshFromFile(
91 msh_file.string(), true /* compute_element_neighbors */);
92 if (!surface_mesh)
93 {
94 WARN("The surface mesh could not be created.");
95 return false;
96 }
97 if (!(std::filesystem::remove(geo_file) &&
98 std::filesystem::remove(msh_file)))
99 {
100 WARN("Could not remove temporary files in createSurface.");
101 }
102
103 // convert the surface mesh into a geometric surface
104 if (!MeshToolsLib::convertMeshToGeo(*surface_mesh, geometries,
105 std::numeric_limits<double>::epsilon()))
106 {
107 WARN("The surface mesh could not be converted to a geometry.");
108 return false;
109 }
110 std::string merged_geometry_name("geometry_with_surfaces");
111 geometries.mergeGeometries({geometry_name, surface_mesh->getName()},
112 merged_geometry_name);
113 geometries.removeSurfaceVec(geometry_name);
114 geometries.removePolylineVec(geometry_name);
115 geometries.removePointVec(geometry_name);
116 geometries.removeSurfaceVec(surface_mesh->getName());
117 geometries.removePolylineVec(surface_mesh->getName());
118 geometries.removePointVec(surface_mesh->getName());
119 geometries.renameGeometry(merged_geometry_name, geometry_name);
120
121 return true;
122}
void WARN(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:34
std::vector< std::string > getGeometryNames() const
Returns the names of all geometry vectors.
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
const std::vector< Point * > * getPointVec(const std::string &name) const
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
void renameGeometry(std::string const &old_name, std::string const &new_name)
bool removePointVec(const std::string &name)
bool removeSurfaceVec(const std::string &name)
int mergeGeometries(std::vector< std::string > const &geo_names, std::string &merged_geo_name)
bool removePolylineVec(const std::string &name)
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:30
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:34
std::string randomString(std::size_t const length)
Returns a random string of the given length containing just a-z,A-Z,0-9.
@ FixedMeshDensity
set the parameter with a fixed value
MeshLib::Mesh * readMeshFromFile(const std::string &file_name, bool const compute_element_neighbors)
bool convertMeshToGeo(const MeshLib::Mesh &mesh, GeoLib::GEOObjects &geo_objects, double const eps)

References GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addPolylineVec(), MeshToolsLib::convertMeshToGeo(), FileIO::GMSH::FixedMeshDensity, GeoLib::GEOObjects::getGeometryNames(), GeoLib::Polyline::getNumberOfPoints(), GeoLib::Polyline::getPointID(), GeoLib::Polyline::getPointsVec(), GeoLib::GEOObjects::getPointVec(), GeoLib::Polyline::isClosed(), GeoLib::GEOObjects::mergeGeometries(), BaseLib::randomString(), MeshLib::IO::readMeshFromFile(), GeoLib::GEOObjects::removePointVec(), GeoLib::GEOObjects::removePolylineVec(), GeoLib::GEOObjects::removeSurfaceVec(), GeoLib::GEOObjects::renameGeometry(), WARN(), BaseLib::IO::writeStringToFile(), and BaseLib::IO::Writer::writeToString().

Referenced by FileIO::SHPInterface::readPolygons(), and FileIO::Legacy::readSurfaces().

◆ createSurfaceWithEarClipping()

std::unique_ptr< GeoLib::Surface > FileIO::createSurfaceWithEarClipping ( GeoLib::Polyline const & line)

Creates a plane surface from the given polyline. The polyline has to be closed, i.e. the first and the last point have to be the identical. The triangulation of the polyline is done via a simple ear clipping algorithm.

Definition at line 124 of file createSurface.cpp.

126{
127 if (!line.isClosed())
128 {
129 WARN("Error in Surface::createSurface() - Polyline is not closed.");
130 return nullptr;
131 }
132
133 if (line.getNumberOfPoints() <= 2)
134 {
135 WARN(
136 "Error in Surface::createSurface() - Polyline consists of less "
137 "than three points and therefore cannot be triangulated.");
138 return nullptr;
139 }
140
141 // create empty surface
142 auto sfc = std::make_unique<GeoLib::Surface>(line.getPointsVec());
143 auto polygon = std::make_unique<GeoLib::Polygon>(GeoLib::Polygon(line));
144 std::list<GeoLib::Polygon*> const& list_of_simple_polygons =
145 polygon->computeListOfSimplePolygons();
146
147 for (auto const& simple_polygon : list_of_simple_polygons)
148 {
149 std::list<GeoLib::Triangle> triangles;
150 GeoLib::EarClippingTriangulation(*simple_polygon, triangles);
151
152 // add Triangles to Surface
153 for (auto const& t : triangles)
154 {
155 sfc->addTriangle(t[0], t[1], t[2]);
156 }
157 }
158 if (sfc->getNumberOfTriangles() == 0)
159 {
160 WARN(
161 "Surface::createSurface(): Triangulation does not contain any "
162 "triangles.");
163 return nullptr;
164 }
165 return sfc;
166}

References GeoLib::Polyline::getNumberOfPoints(), GeoLib::Polyline::getPointsVec(), GeoLib::Polyline::isClosed(), and WARN().

Referenced by GEOModels::connectPolylineSegments().

◆ getLastNumberFromList()

double FileIO::getLastNumberFromList ( const std::list< std::string > & str_list)
static

Definition at line 127 of file PetrelInterface.cpp.

128{
129 return std::stod(*(--str_list.end()));
130}

Referenced by FileIO::PetrelInterface::readPetrelWellTrace().

◆ getXyzHeader()

GeoLib::RasterHeader FileIO::getXyzHeader ( std::vector< std::string > const & lines)

Definition at line 263 of file AsciiRasterInterface.cpp.

264{
265 double x_min = std::numeric_limits<double>::max();
266 double x_max = -std::numeric_limits<double>::max();
267 double y_min = std::numeric_limits<double>::max();
268 double y_max = -std::numeric_limits<double>::max();
269 double cellsize = std::numeric_limits<double>::max();
270 std::optional<std::array<double, 3>> coords;
271
272 std::size_t const n_lines(lines.size());
273 for (std::size_t i = 0; i < n_lines; ++i)
274 {
275 coords = readXyzCoordinates(lines[i]);
276 if (coords == std::nullopt)
277 {
278 MathLib::Point3d org(std::array<double, 3>{{0, 0, 0}});
279 GeoLib::RasterHeader fail = {0, 0, 0, org, 0, 0};
280 return fail;
281 }
282 double const diff = (*coords)[0] - x_min;
283 if (diff > 0)
284 {
285 cellsize = std::min(cellsize, diff);
286 }
287 x_min = std::min((*coords)[0], x_min);
288 x_max = std::max((*coords)[0], x_max);
289 y_min = std::min((*coords)[1], y_min);
290 y_max = std::max((*coords)[1], y_max);
291 }
292
293 GeoLib::RasterHeader header;
294 header.cell_size = cellsize;
295 header.no_data = -9999;
296 header.n_cols = static_cast<std::size_t>(((x_max - x_min) / cellsize) + 1);
297 header.n_rows = static_cast<std::size_t>(((y_max - y_min) / cellsize) + 1);
298 header.n_depth = 1;
299 header.origin[0] = x_min;
300 header.origin[1] = y_min;
301 return header;
302}
std::optional< std::array< double, 3 > > readXyzCoordinates(std::string const &line)
std::size_t n_depth
Definition Raster.h:21
MathLib::Point3d origin
Definition Raster.h:22
std::size_t n_cols
Definition Raster.h:19
std::size_t n_rows
Definition Raster.h:20

References GeoLib::RasterHeader::cell_size, GeoLib::RasterHeader::n_cols, GeoLib::RasterHeader::n_depth, GeoLib::RasterHeader::n_rows, GeoLib::RasterHeader::no_data, GeoLib::RasterHeader::origin, and readXyzCoordinates().

Referenced by FileIO::AsciiRasterInterface::getRasterFromXyzFile().

◆ printListInfo()

void FileIO::printListInfo ( const std::list< std::string > & str_list,
std::string_view const prefix,
std::string_view const message )
static

Definition at line 117 of file PetrelInterface.cpp.

120{
121 for (auto const& str : str_list)
122 {
123 INFO("PetrelInterface::{:s}(): {:s}: {:s}.", prefix, message, str);
124 }
125}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28

References INFO().

Referenced by FileIO::PetrelInterface::readPetrelWellTrace(), and FileIO::PetrelInterface::readPetrelWellTraceData().

◆ PVarExists()

bool FileIO::PVarExists ( std::string const & name,
std::vector< DataHolderLib::ProcessVariable > const & p_vars )

Definition at line 430 of file XmlPrjInterface.cpp.

432{
433 return std::any_of(p_vars.begin(), p_vars.end(),
434 [&](auto const& p_var) { return p_var.name == name; });
435}

Referenced by FileIO::XmlPrjInterface::getPrimaryVariableVec().

◆ readASCHeader()

std::optional< GeoLib::RasterHeader > FileIO::readASCHeader ( std::ifstream & in)
static

Reads the header of a Esri asc-file. If the return value is empty, reading was not successful.

Definition at line 46 of file AsciiRasterInterface.cpp.

47{
49
50 std::string tag;
51 std::string value;
52
53 in >> tag;
54 if (tag == "ncols")
55 {
56 in >> value;
57 header.n_cols = atoi(value.c_str());
58 }
59 else
60 {
61 return {};
62 }
63
64 in >> tag;
65 if (tag == "nrows")
66 {
67 in >> value;
68 header.n_rows = atoi(value.c_str());
69 }
70 else
71 {
72 return {};
73 }
74
75 header.n_depth = 1;
76
77 in >> tag;
78 if (tag == "xllcorner" || tag == "xllcenter")
79 {
80 header.origin[0] = readDoubleFromStream(in);
81 }
82 else
83 {
84 return {};
85 }
86
87 in >> tag;
88 if (tag == "yllcorner" || tag == "yllcenter")
89 {
90 header.origin[1] = readDoubleFromStream(in);
91 }
92 else
93 {
94 return {};
95 }
96 header.origin[2] = 0;
97
98 in >> tag;
99 if (tag == "cellsize")
100 {
101 header.cell_size = readDoubleFromStream(in);
102 }
103 else
104 {
105 return {};
106 }
107
108 in >> tag;
109 if (tag == "NODATA_value" || tag == "nodata_value")
110 {
111 header.no_data = readDoubleFromStream(in);
112 }
113 else
114 {
115 return {};
116 }
117
118 return header;
119}
static double readDoubleFromStream(std::istream &in)
Reads a double replacing comma by point.
Contains the relevant information when storing a geoscientific raster data.
Definition Raster.h:18

References GeoLib::RasterHeader::cell_size, GeoLib::RasterHeader::n_cols, GeoLib::RasterHeader::n_depth, GeoLib::RasterHeader::n_rows, GeoLib::RasterHeader::no_data, GeoLib::RasterHeader::origin, and readDoubleFromStream().

Referenced by FileIO::AsciiRasterInterface::getRasterFromASCFile().

◆ readDoubleFromStream()

double FileIO::readDoubleFromStream ( std::istream & in)
static

Reads a double replacing comma by point.

Definition at line 36 of file AsciiRasterInterface.cpp.

37{
38 std::string value;
39 in >> value;
40 return std::strtod(BaseLib::replaceString(",", ".", value).c_str(),
41 nullptr);
42}
std::string replaceString(const std::string &searchString, const std::string &replaceString, std::string stringToReplace)

References BaseLib::replaceString().

Referenced by FileIO::AsciiRasterInterface::getRasterFromASCFile(), FileIO::AsciiRasterInterface::getRasterFromSurferFile(), and readASCHeader().

◆ readFile()

std::vector< std::string > FileIO::readFile ( std::istream & in)

Definition at line 237 of file AsciiRasterInterface.cpp.

238{
239 std::vector<std::string> lines;
240 std::string line("");
241 while (std::getline(in, line))
242 {
243 lines.emplace_back(line);
244 }
245 return lines;
246}

Referenced by FileIO::AsciiRasterInterface::getRasterFromXyzFile().

◆ readGeometryFromFile()

void FileIO::readGeometryFromFile ( std::string const & fname,
GeoLib::GEOObjects & geo_objs,
std::string const & gmsh_path )

Definition at line 16 of file readGeometryFromFile.cpp.

19{
20 if (BaseLib::getFileExtension(fname) == ".gml")
21 {
23 xml.readFile(fname);
24 }
25 else
26 {
27 std::vector<std::string> errors;
28 std::string geo_name; // geo_name is output of the reading function
30 fname, geo_objs, geo_name, errors, gmsh_path);
31 }
32
33 if (geo_objs.getGeometryNames().empty())
34 {
36 "GEOObjects has no geometry name after reading the geometry file. "
37 "Something is wrong in the reading function.");
38 }
39}
#define OGS_FATAL(...)
Definition Error.h:19
std::string getFileExtension(const std::string &path)
bool readGLIFileV4(const std::string &fname, GeoLib::GEOObjects &geo, std::string &unique_name, std::vector< std::string > &errors, std::string const &gmsh_path)

References BaseLib::getFileExtension(), GeoLib::GEOObjects::getGeometryNames(), OGS_FATAL, GeoLib::IO::BoostXmlGmlInterface::readFile(), and FileIO::Legacy::readGLIFileV4().

Referenced by main().

◆ readLine()

std::string FileIO::readLine ( std::istream & in)
static

Definition at line 67 of file PetrelInterface.cpp.

68{
69 std::string line;
70 std::getline(in, line);
71 return line;
72}

Referenced by FileIO::PetrelInterface::readPetrelSurfacePoints(), FileIO::PetrelInterface::readPetrelWellTrace(), and FileIO::PetrelInterface::readPetrelWellTraceData().

◆ readRasters()

std::optional< std::vector< GeoLib::Raster const * > > FileIO::readRasters ( std::vector< std::string > const & raster_paths)

Reads a vector of rasters given by file names. On error nothing is returned, otherwise the returned vector contains pointers to the read rasters.

Definition at line 385 of file AsciiRasterInterface.cpp.

387{
388 if (!allRastersExist(raster_paths))
389 {
390 return std::nullopt;
391 }
392
393 std::vector<GeoLib::Raster const*> rasters;
394 rasters.reserve(raster_paths.size());
395 std::transform(raster_paths.begin(), raster_paths.end(),
396 std::back_inserter(rasters),
397 [](auto const& path)
398 { return FileIO::AsciiRasterInterface::readRaster(path); });
399 return std::make_optional(rasters);
400}
static bool allRastersExist(std::vector< std::string > const &raster_paths)
Checks if all raster files actually exist.

References allRastersExist(), and readRasters().

Referenced by MeshLayerEditDialog::createPrismMesh(), MeshLayerEditDialog::createTetMesh(), main(), and readRasters().

◆ readSurferHeader()

std::optional< std::tuple< GeoLib::RasterHeader, double, double > > FileIO::readSurferHeader ( std::ifstream & in)
static

Reads the header of a Surfer grd-file with minimum and maximum values. If the return value is empty, reading was not successful.

Definition at line 160 of file AsciiRasterInterface.cpp.

161{
162 std::string tag;
163
164 in >> tag;
165
166 if (tag != "DSAA")
167 {
168 ERR("Error in readSurferHeader() - No Surfer file.");
169 return {};
170 }
171
172 GeoLib::RasterHeader header;
173 in >> header.n_cols >> header.n_rows;
174 double min, max;
175 in >> min >> max;
176 header.origin[0] = min;
177 header.cell_size = (max - min) / static_cast<double>(header.n_cols);
178
179 in >> min >> max;
180 header.origin[1] = min;
181 header.origin[2] = 0;
182
183 if (ceil((max - min) / static_cast<double>(header.n_rows)) ==
184 ceil(header.cell_size))
185 {
186 header.cell_size = ceil(header.cell_size);
187 }
188 else
189 {
190 ERR("Error in readSurferHeader() - Anisotropic cellsize detected.");
191 return {};
192 }
193 header.n_depth = 1;
194 header.no_data = -9999;
195 in >> min >> max;
196
197 return {{header, min, max}};
198}

References GeoLib::RasterHeader::cell_size, ERR(), GeoLib::RasterHeader::n_cols, GeoLib::RasterHeader::n_depth, GeoLib::RasterHeader::n_rows, GeoLib::RasterHeader::no_data, and GeoLib::RasterHeader::origin.

Referenced by FileIO::AsciiRasterInterface::getRasterFromSurferFile().

◆ readXyzCoordinates()

std::optional< std::array< double, 3 > > FileIO::readXyzCoordinates ( std::string const & line)

Definition at line 248 of file AsciiRasterInterface.cpp.

249{
250 std::array<double, 3> coords = {0, 0, 0};
251 if (auto const n = std::sscanf(line.c_str(), "%lf %lf %lf", &coords[0],
252 &coords[1], &coords[2]);
253 n != 3)
254 {
255 ERR("Raster::readXyzCoordinates() - Read {:d} doubles out of 3 "
256 "expected from the following line:\n{:s}",
257 n, line);
258 return std::nullopt;
259 }
260 return coords;
261}
constexpr ranges::views::view_closure coords
Definition Mesh.h:223

References ERR().

Referenced by FileIO::AsciiRasterInterface::getRasterFromXyzFile(), and getXyzHeader().

◆ split()

std::list< std::string > FileIO::split ( std::string const & line)
static

Definition at line 74 of file PetrelInterface.cpp.

75{
76 return BaseLib::splitString(line, ' ');
77}
std::vector< std::string > splitString(std::string const &str)

References BaseLib::splitString().

Referenced by FileIO::PetrelInterface::readPetrelWellTrace(), and FileIO::PetrelInterface::readPetrelWellTraceData().

◆ writeGeometryToFile()

void FileIO::writeGeometryToFile ( std::string const & geo_name,
GeoLib::GEOObjects & geo_objs,
std::string const & fname )

Write geometry given by the geo_objs object and specified by the name stored in param geo_name either to a gml or a gli file. If the extension given in the fname parameter is "gml" or "GML" a gml file is written. In case the extension is "gli" or "GLI" a gli file is written.

Definition at line 13 of file writeGeometryToFile.cpp.

15{
16 std::string const extension(BaseLib::getFileExtension(fname));
17 if (extension == ".gml" || extension == ".GML")
18 {
20 xml.export_name = geo_name;
21 BaseLib::IO::writeStringToFile(xml.writeToString(), fname);
22 }
23 else if (extension == "gli" || extension == "GLI")
24 {
25 FileIO::Legacy::writeGLIFileV4(fname, geo_name, geo_objs);
26 }
27 else
28 {
29 ERR("Writing of geometry failed, since it was not possible to determine"
30 " the required format from file extension.");
31 }
32}
void writeGLIFileV4(const std::string &fname, const std::string &geo_name, const GeoLib::GEOObjects &geo)

References ERR(), BaseLib::IO::XMLInterface::export_name, BaseLib::getFileExtension(), FileIO::Legacy::writeGLIFileV4(), BaseLib::IO::writeStringToFile(), and BaseLib::IO::Writer::writeToString().

Referenced by main(), and writeBCsAndGeometry().

Variable Documentation

◆ link_vars

const std::array<std::string, 6> FileIO::link_vars
Initial value:
= {"flow rate",
"flow depth",
"flow velocity",
"flow volume",
"fraction conduit/non-conduit",
"concentration of pollutant"}

Variables that always exist for links. There might be more.

Definition at line 51 of file SWMMInterface.cpp.

51 {"flow rate",
52 "flow depth",
53 "flow velocity",
54 "flow volume",
55 "fraction conduit/non-conduit",
56 "concentration of pollutant"};

Referenced by FileIO::SwmmInterface::getArrayName().

◆ n_obj_params

std::array<std::size_t, 4> const FileIO::n_obj_params = {8, 6, 5, 15}

Number of base variables for the four object types (subcatchments/nodes/links/system).

Definition at line 78 of file SWMMInterface.cpp.

78{8, 6, 5, 15};

Referenced by FileIO::SwmmInterface::getArrayAtTimeStep(), FileIO::SwmmInterface::getArrayForObject(), FileIO::SwmmInterface::getArrayName(), and FileIO::SwmmInterface::getNumberOfParameters().

◆ node_vars

const std::array<std::string, 7> FileIO::node_vars
Initial value:
= {"water depth",
"hydraulic head",
"volume of stored water",
"lateral inflow",
"total inflow",
"flow lost to flooding",
"concentration of pollutant"}

Variables that always exist for nodes. There might be more.

Definition at line 42 of file SWMMInterface.cpp.

42 {"water depth",
43 "hydraulic head",
44 "volume of stored water",
45 "lateral inflow",
46 "total inflow",
47 "flow lost to flooding",
48 "concentration of pollutant"};

Referenced by FileIO::SwmmInterface::getArrayName().

◆ subcatchment_vars

const std::array<std::string, 9> FileIO::subcatchment_vars
Initial value:
= {
"rainfall",
"snow depth",
"evaporation loss",
"infiltration losses",
"runoff rate",
"groundwater outflow",
"groundwater head",
"moisture content",
"concentration of pollutant"}

Variables that always exist for subcatchments. There might be more.

Definition at line 30 of file SWMMInterface.cpp.

30 {
31 "rainfall",
32 "snow depth",
33 "evaporation loss",
34 "infiltration losses",
35 "runoff rate",
36 "groundwater outflow",
37 "groundwater head",
38 "moisture content",
39 "concentration of pollutant"};

Referenced by FileIO::SwmmInterface::getArrayName().

◆ system_vars

const std::array<std::string, 15> FileIO::system_vars
Initial value:
= {
"air temperature",
"rainfall",
"snow depth",
"evaporation + infiltration loss",
"runoff flow",
"dry weather inflow",
"groundwater inflow",
"RDII inflow",
"direct inflow",
"total lateral inflow",
"flow lost to flooding",
"flow leaving through outfalls",
"volume of stored water",
"actual evaporation rate",
"potential evaporation rate"}

All variables that exist for the system.

Definition at line 59 of file SWMMInterface.cpp.

59 {
60 "air temperature",
61 "rainfall",
62 "snow depth",
63 "evaporation + infiltration loss",
64 "runoff flow",
65 "dry weather inflow",
66 "groundwater inflow",
67 "RDII inflow",
68 "direct inflow",
69 "total lateral inflow",
70 "flow lost to flooding",
71 "flow leaving through outfalls",
72 "volume of stored water",
73 "actual evaporation rate",
74 "potential evaporation rate"};

Referenced by FileIO::SwmmInterface::getArrayName().