Skip to content

Commit

Permalink
[ew2sc] Correct loccode search algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
gempa-jabe committed Feb 24, 2021
1 parent b59e812 commit 745293a
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions apps/ew2sc/ew2sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,13 @@ int EW2SC::extractOrigin(char* msg) {
for (size_t i = 0; i < inv->networkCount(); ++i) {
NetworkPtr n = inv->network(i);

if ( n->code() != network )
if ( n->code() != strip_space(network) )
continue;

for (size_t j = 0; j < n->stationCount(); ++j) {
StationPtr station = n->station(j);

if ( station->code() != site )
if ( station->code() != strip_space(site) )
continue;

for (size_t l = 0; l < station->sensorLocationCount();
Expand All @@ -978,9 +978,39 @@ int EW2SC::extractOrigin(char* msg) {
if ( sloc->start() > ot )
continue;

sensor = sloc;
for (size_t c = 0; c < sloc->streamCount();
++c) {
StreamPtr schan = sloc->stream(c);

// channel's is finished (out of date)
try {
if ( schan->end() <= ot )
continue;
} catch ( ... ) {}

// channel's hasn't even begin yet
if ( schan->start() > ot )
continue;

if ( schan->code() != strip_space(component) )
continue;

// channel found, store sensor location code and break channel loop
sensor = sloc;
SEISCOMP_DEBUG("Loccode sensor found : %s.%s.%s", network.c_str(),station->code().c_str(),sensor->code().c_str());
break;
}
// sensor location code found, break sensor loop
if ( sensor )
break;
}
// sensor location code found, break station loop
if ( sensor )
break;
}
// sensor location code found, break network loop
if ( sensor )
break;
}
}
else
Expand Down Expand Up @@ -1368,4 +1398,3 @@ void EW2SC::strExplode(const string& s, char c, vector<string>& v) {
}
}
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

0 comments on commit 745293a

Please sign in to comment.