20{
21 TCLAP::CmdLine cmd(
22 "Converts ascii raster files (e.g. Surfer *.grd files or *.xyz files) "
23 "into ASC raster files.\n\n"
24 "OpenGeoSys-6 software, version " +
26 ".\n"
27 "Copyright (c) 2012-2024, OpenGeoSys Community "
28 "(http://www.opengeosys.org)",
30
31 TCLAP::ValueArg<std::string> output_arg(
32 "o", "output", "filename for output raster", true, "", "output file");
33 cmd.add(output_arg);
34
35 TCLAP::ValueArg<std::string> input_arg(
36 "i", "input", "filename for input raster", true, "", "input file");
37 cmd.add(input_arg);
38
39 cmd.parse(argc, argv);
40
42
43 std::unique_ptr<GeoLib::Raster> raster(
45
46 if (raster == nullptr)
47 {
48 ERR(
"Couldn't read input raster file.");
49 return EXIT_FAILURE;
50 }
51
52 std::string output_name = output_arg.getValue();
53 if (output_name.substr(output_name.length() - 4, 4) != ".asc")
54 {
55 output_name = output_name.append(".asc");
56 }
57
59 return EXIT_SUCCESS;
60}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
static void writeRasterAsASC(GeoLib::Raster const &raster, std::string const &file_name)
Writes an Esri asc-file.
static GeoLib::Raster * readRaster(std::string const &fname)
GITINFOLIB_EXPORT const std::string ogs_version