Commit 1967a735 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

ts/wf/sigval [FIX]: calculate offset only if header data is present

Previous version calculated offset in any case. This resulted in a fatal error
if for example only the receiver coordinates were specified in spherical
coordinates. The default for SRCE if cartesian coordinates. The function
calculating the offset complained because of this inconsistency.
parent c9f350d7
......@@ -4,11 +4,11 @@
* ----------------------------------------------------------------------------
*
* \author Thomas Forbriger
* \date 06/05/2009
* \date 01/12/2016
*
* extract values from input signals
*
* Copyright (c) 2009 by Thomas Forbriger (BFO Schiltach)
* Copyright (c) 2009, 2016 by Thomas Forbriger (BFO Schiltach)
*
* ----
* SIGVAL is free software; you can redistribute it and/or modify
......@@ -35,11 +35,13 @@
* - 08/09/2011 V1.5 support format modifiers
* - 07/11/2011 V1.6 provide source coordinates too
* - 15/04/2014 V1.7 new patterns %HT and %SI
* - 01/12/2016 V1.8 fix: do not calculate offset if either SRCE or INFO
* is missing in input file
*
* ============================================================================
*/
#define SIGVAL_VERSION \
"SIGVAL V1.7 extract values from input signals"
"SIGVAL V1.8 extract values from input signals"
#include <iostream>
#include <tfxx/commandline.h>
......@@ -280,10 +282,19 @@ int main(int iargc, char* argv[])
tfxx::string::trimws(oss.str()));
// pattern to be replaced by trace offset
oss.str("");
oss << " r=" << sff::offset(srce, info) << "m";
retval=tfxx::string::patsubst(retval, "%OFF",
tfxx::string::trimws(oss.str()));
if (is.hassrce() && is.hasinfo())
{
oss.str("");
oss << " r=" << sff::offset(srce, info) << "m";
retval=tfxx::string::patsubst(retval, "%OFF",
tfxx::string::trimws(oss.str()));
}
else
{
TFXX_assert(retval.find("%OFF") == std::string::npos,
"offset cannot be calculated, because either SRCE or INFO\n"
"is missing in input file");
} // else, if (is.hassrce() && is.hasinfo())
// pattern to be replaced by trace number
oss.str("");
......
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