OGS 6.1.0-1721-g6382411ad
readGeometryFromFile.cpp
Go to the documentation of this file.
1 
11 #include "readGeometryFromFile.h"
12 
13 #include <vector>
14 
15 #include "BaseLib/Error.h"
16 #include "BaseLib/FileTools.h"
17 
19 #include "Legacy/OGSIOVer4.h"
20 
21 #include "GeoLib/GEOObjects.h"
22 
23 namespace FileIO
24 {
25 void
26 readGeometryFromFile(std::string const& fname, GeoLib::GEOObjects & geo_objs)
27 {
28  if (BaseLib::getFileExtension(fname) == "gml")
29  {
31  xml.readFile(fname);
32  } else {
33  std::vector<std::string> errors;
34  std::string geo_name; // geo_name is output of the reading function
35  FileIO::Legacy::readGLIFileV4(fname, geo_objs, geo_name, errors);
36  }
37 
38  std::vector<std::string> geo_names;
39  geo_objs.getGeometryNames(geo_names);
40  if (geo_names.empty()) {
41  OGS_FATAL("GEOObjects has no geometry name after reading the geometry file. "
42  "Something is wrong in the reading function.");
43  }
44 }
45 }
void readGeometryFromFile(std::string const &fname, GeoLib::GEOObjects &geo_objs)
Container class for geometric objects.
Definition: GEOObjects.h:62
Definition of the BoostXmlGmlInterface class.
void getGeometryNames(std::vector< std::string > &names) const
Returns the names of all geometry vectors.
Definition: GEOObjects.cpp:350
Definition of the OGSIOVer4 class.
bool readFile(const std::string &fname) override
Reads an xml-file containing OGS geometry.
std::string getFileExtension(const std::string &path)
Definition: FileTools.cpp:122
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
Filename manipulation routines.
bool readGLIFileV4(const std::string &fname, GeoLib::GEOObjects &geo, std::string &unique_name, std::vector< std::string > &errors)
Definition: OGSIOVer4.cpp:433