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

hd/cooset [FEATURE]: add new features

  - automatically convert comma to whitespace in
    coordinate parameters
  - support creation of info data
parent 01e4b31f
......@@ -30,16 +30,21 @@
* - 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
* - 18/08/2017 V1.3 new features:
* - automatically convert comma to whitespace in
* coordinate parameters
* - support creation of info data
*
* ============================================================================
*/
#define COOSET_VERSION \
"COOSET V1.2 set coordinates"
"COOSET V1.3 set coordinates"
#include <fstream>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <datrwxx/readany.h>
#include <datrwxx/writeany.h>
#include <aff/series.h>
......@@ -48,6 +53,7 @@
#include <tfxx/commandline.h>
#include <tfxx/error.h>
#include <tfxx/stringfunc.h>
#include <sffxx.h>
using std::cout;
using std::cerr;
......@@ -56,7 +62,7 @@ using std::endl;
struct Options {
bool verbose, overwrite, dostations, debug, single, integer;
std::string stationsystem, stationfile, sourcetime, sourcecoo;
bool sesot, sesoc, createsrce;
bool sesot, sesoc, createsrce, createinfo;
std::string itype, otype;
}; // struct Options
......@@ -118,6 +124,9 @@ int main(int iargc, char* argv[])
"-screate create source header, if not yet present\n"
" without this option, the program will only modify\n"
" existing source header data\n"
"-icreate create info trace header, if not yet present\n"
" without this option, the program will only modify\n"
" existing info trace header data\n"
"-v be verbose" "\n"
"-o overwrite" "\n"
"-itype f input file data format type\'f\'\n"
......@@ -170,6 +179,8 @@ int main(int iargc, char* argv[])
{"float",arg_no,"-"},
// 13: create source header if not yet present
{"screate",arg_no,"-"},
// 14: create info trace header if not yet present
{"icreate",arg_no,"-"},
{NULL}
};
......@@ -220,12 +231,15 @@ int main(int iargc, char* argv[])
opt.integer=cmdline.optset(11);
opt.single=cmdline.optset(12);
opt.createsrce=cmdline.optset(13);
opt.createinfo=cmdline.optset(14);
TFXX_assert(cmdline.extra(),"ERROR: missing input file name!");
std::string infile=cmdline.next();
TFXX_assert(cmdline.extra(),"ERROR: missing output file name!");
std::string outfile=cmdline.next();
std::replace(opt.sourcecoo.begin(), opt.sourcecoo.end(), ',', ' ');
/*----------------------------------------------------------------------*/
// read station file if needed
......@@ -315,11 +329,12 @@ int main(int iargc, char* argv[])
{
filefree.append("set source coordinates");
std::istringstream socospec(opt.sourcecoo);
cout << opt.sourcecoo << endl;
char syst;
double x,y,z;
socospec >> syst >> x >> y >> z;
std::ostringstream message;
message << "new coordinates: " << syst << ","
message << "new source coordinates: " << syst << ","
<< x << "," << y << "," << z;
srceline.cs=sff::coosysID(syst);
srceline.cx=x;
......@@ -327,6 +342,7 @@ int main(int iargc, char* argv[])
srceline.cz=z;
filefree.append(message.str());
}
if (opt.verbose) { sff::verbose(cout, srceline); }
} // if (opt.createsrce || is.hassrce())
// write file FREE block
......@@ -436,7 +452,7 @@ int main(int iargc, char* argv[])
} // if (is.hasfree())
// modify INFO
if (is.hasinfo())
if (opt.createinfo || is.hasinfo())
{
if (os.handlesinfo())
{
......
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