swh:1:snp:6088ab52ef49920e01e3f334cdf4d5d6c8a822b9
Raw File
Tip revision: 70aa34fa4ff15e4d7efc7ddfb9530860e5b435ab authored by Lars Bilke on 31 August 2021, 08:50:53 UTC
[pre-commit] Run git clang-format as a pre-commit check.
Tip revision: 70aa34f
writeGeometryToFile.cpp
/**
 *
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "writeGeometryToFile.h"

#include "BaseLib/FileTools.h"
#include "GeoLib/GEOObjects.h"
#include "GeoLib/IO/XmlIO/Boost/BoostXmlGmlInterface.h"
#include "Legacy/OGSIOVer4.h"

namespace FileIO
{
void writeGeometryToFile(std::string const& geo_name,
                         GeoLib::GEOObjects& geo_objs, std::string const& fname)
{
    std::string const extension(BaseLib::getFileExtension(fname));
    if (extension == ".gml" || extension == ".GML")
    {
        GeoLib::IO::BoostXmlGmlInterface xml(geo_objs);
        xml.export_name = geo_name;
        BaseLib::IO::writeStringToFile(xml.writeToString(), fname);
    }
    else if (extension == "gli" || extension == "GLI")
    {
        FileIO::Legacy::writeGLIFileV4(fname, geo_name, geo_objs);
    }
    else
    {
        ERR("Writing of geometry failed, since it was not possible to determine"
            " the required format from file extension.");
    }
}
}  // namespace FileIO
back to top