Commit a652e7f5 authored by thomas.forbriger's avatar thomas.forbriger

ts/hd/cooset [FEATURE]: create source header data if not yet present

parent 1967a735
......@@ -29,11 +29,12 @@
* REVISIONS and CHANGES
* - 08/09/2004 V1.0 Thomas Forbriger
* - 14/11/2016 V1.1 support all libdatrwxx I/O formats
* - 01/12/2016 V1.2 create SRCE header, if not yet present
*
* ============================================================================
*/
#define COOSET_VERSION \
"COOSET V1.1 set coordinates"
"COOSET V1.2 set coordinates"
#include <fstream>
#include <iostream>
......@@ -55,7 +56,7 @@ using std::endl;
struct Options {
bool verbose, overwrite, dostations, debug, single, integer;
std::string stationsystem, stationfile, sourcetime, sourcecoo;
bool sesot, sesoc;
bool sesot, sesoc, createsrce;
std::string itype, otype;
}; // struct Options
......@@ -97,7 +98,7 @@ int main(int iargc, char* argv[])
{
COOSET_VERSION "\n"
"usage: cooset [-stc s] [-stf file] [-soc \"C x y z\"] [-sot date]" "\n"
" [-itype f] [-otype f] [-integer] [-float]\n"
" [-itype f] [-otype f] [-integer] [-float] [-screate]\n"
" [-v] [-o] infile outfile" "\n"
" or: cooset --help|-h" "\n"
" or: cooset --xhelp" "\n"
......@@ -114,6 +115,9 @@ int main(int iargc, char* argv[])
"-stf file station coordinates file" "\n"
"-soc C,x,y,z source coordinates" "\n"
"-sot date source time" "\n"
"-screate create source header, if not yet present\n"
" without this option, the program will only modify\n"
" existing source header data\n"
"-v be verbose" "\n"
"-o overwrite" "\n"
"-itype f input file data format type\'f\'\n"
......@@ -164,6 +168,8 @@ int main(int iargc, char* argv[])
{"integer",arg_no,"-"},
// 12: single precision values
{"float",arg_no,"-"},
// 13: create source header if not yet present
{"screate",arg_no,"-"},
{NULL}
};
......@@ -213,6 +219,7 @@ int main(int iargc, char* argv[])
opt.otype=cmdline.string_arg(9);
opt.integer=cmdline.optset(11);
opt.single=cmdline.optset(12);
opt.createsrce=cmdline.optset(13);
TFXX_assert(cmdline.extra(),"ERROR: missing input file name!");
std::string infile=cmdline.next();
......@@ -295,6 +302,9 @@ int main(int iargc, char* argv[])
is >> srceline;
// modify file header
filefree.append("input file has SRCE line");
} // if (is.hassrce())
if (opt.createsrce || is.hassrce())
{
if (opt.sesot)
{
filefree.append("set source time");
......@@ -317,7 +327,7 @@ int main(int iargc, char* argv[])
srceline.cz=z;
filefree.append(message.str());
}
} // if (is.hassrce())
} // if (opt.createsrce || is.hassrce())
// write file FREE block
if (os.handlesfilefree())
......@@ -326,7 +336,7 @@ int main(int iargc, char* argv[])
}
// write SRCE line
if (is.hassrce())
if (is.hassrce() || opt.createsrce)
{
if (os.handlessrce())
{
......@@ -340,7 +350,7 @@ int main(int iargc, char* argv[])
cout << " SRCE line is discarded." << endl;
}
}
} // if (is.hassrce())
} // if (is.hassrce() || opt.createsrce)
// report
if (opt.verbose)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment