OGS
writeGeometryToFile.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
6#include "BaseLib/FileTools.h"
7#include "GeoLib/GEOObjects.h"
9#include "Legacy/OGSIOVer4.h"
10
11namespace FileIO
12{
13void writeGeometryToFile(std::string const& geo_name,
14 GeoLib::GEOObjects& geo_objs, std::string const& fname)
15{
16 std::string const extension(BaseLib::getFileExtension(fname));
17 if (extension == ".gml" || extension == ".GML")
18 {
20 xml.export_name = geo_name;
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}
33} // namespace FileIO
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
std::string writeToString()
Writes the object to a string.
Definition Writer.cpp:20
Container class for geometric objects.
Definition GEOObjects.h:46
int writeStringToFile(std::string_view content, std::filesystem::path const &file_path)
Definition Writer.cpp:34
std::string getFileExtension(const std::string &path)
void writeGLIFileV4(const std::string &fname, const std::string &geo_name, const GeoLib::GEOObjects &geo)
void writeGeometryToFile(std::string const &geo_name, GeoLib::GEOObjects &geo_objs, std::string const &fname)