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

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