Split FileIO MeshLib dependency in LayeredMeshGenerator#1143
Split FileIO MeshLib dependency in LayeredMeshGenerator#1143endJunction merged 6 commits intoufz:masterfrom endJunction:SplitFileIOMeshLibDependency
Conversation
|
|
||
| /// Reads a vector of rasters given by file names. On error nothing is returned, | ||
| /// otherwise the returned vector contains pointers to the read rasters. | ||
| boost::optional<std::vector<GeoLib::Raster const*>> readRasters( |
There was a problem hiding this comment.
it looks bit redundant for me to use boost::optional for std::vector, because one can do the same thing using std::vector::empty().
|
looks good. I have just one minor comment about usage of boost optional. the comment is not critical so go ahead if you don't like it |
|
@norihiro-w I had the empty vector before and it works. Reasons for optional: When looking on the algorithm it is a one-to-one transformation of strings to rasters, and boost::optional indicates if everything was ok. Therefore one can distinguish if an error happened or nothing was to be read at all. |
| boost::optional<std::vector<GeoLib::Raster const*>> readRasters( | ||
| std::vector<std::string> const& raster_paths) | ||
| { | ||
| if (!allRastersExist(raster_paths)) return boost::none; |
There was a problem hiding this comment.
Only a note: Actually it is dangerous to first check if files exist, then believe that they exist and just try to read them blindly. The files could have vanished in between. @endJunction, you shouldn't spend time on that now, especially since the problem has not been introduced in this PR. But for the future we should keep in mind that files should be read in one go and not be checked for existence prior to opening.
|
👍 |
|
OpenGeoSys development has been moved to GitLab. |
Move reading of raster files out of layered mesh generator.
Add convenience function to read all raster files given by a list of file names.