Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255,616 changes: 198,756 additions & 56,860 deletions libs/seiscomp/client/data/cities.xml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion libs/seiscomp/gui/datamodel/eventlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3892,7 +3892,6 @@ void EventListView::setEventModificationsEnabled(bool e) {




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void EventListView::initTree() {
SC_D._treeWidget->clear();
Expand Down
25 changes: 21 additions & 4 deletions libs/seiscomp/gui/datamodel/eventsummaryview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,17 @@ void EventSummaryView::init() {
QRectF displayRect;
displayRect.setRect(lonmin, latmin, lonmax-lonmin, latmax-latmin);

// Store bounds for reuse when recentering on an event, so that
// display.lonmin/max/latmin/max are honored beyond initial startup.
// Takes priority over display.defaultEventRadius.
bool hasCustomBounds = lonmin != -180 || lonmax != 180 || latmin != -90 || latmax != 90;
_displayRect = hasCustomBounds ? displayRect : QRectF();

// Configurable event radius (like olv.map.event.defaultRadius in scolv).
// Only used when no custom bounds are set.
try { _defaultEventRadius = SCApp->configGetDouble("display.defaultEventRadius"); }
catch ( ... ) { _defaultEventRadius = -1; }

_uiHypocenter->labelVDistance->setText(QString());
_uiHypocenter->labelVDistanceAutomatic->setText(QString());
_uiHypocenter->labelFrameInfoSpacer->setText(QString());
Expand Down Expand Up @@ -2384,10 +2395,16 @@ void EventSummaryView::updateMap(bool realignView){
_map->setOrigin(_currentOrigin.get());

if ( _currentOrigin && realignView ) {
if ( _recenterMap && _recenterMapConfig ) {
double radius = 30;
try { radius = std::min(radius, _currentOrigin->quality().maximumDistance()+0.1); }
catch ( ... ) {}
if ( !_displayRect.isNull() ) {
// Anchored region: always show the configured bounds
_map->canvas().displayRect(_displayRect);
}
else if ( _recenterMap && _recenterMapConfig ) {
double radius = _defaultEventRadius > 0 ? _defaultEventRadius : 30;
if ( _defaultEventRadius <= 0 ) {
try { radius = std::min(radius, _currentOrigin->quality().maximumDistance()+0.1); }
catch ( ... ) {}
}
_map->canvas().displayRect(QRectF(_currentOrigin->longitude()-radius, _currentOrigin->latitude()-radius, radius*2, radius*2));
}
else {
Expand Down
8 changes: 5 additions & 3 deletions libs/seiscomp/gui/datamodel/eventsummaryview.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,11 @@ class SC_GUI_API EventSummaryView : public QWidget
bool _interactive;
bool _autoSelect;
bool _displayFocMechs;
bool _recenterMap;
bool _recenterMapConfig;
bool _ignoreOtherEvents;
bool _recenterMap;
bool _recenterMapConfig;
bool _ignoreOtherEvents;
QRectF _displayRect;
double _defaultEventRadius{-1};
bool _showLastAutomaticSolution;
bool _showOnlyMostRecentEvent;
bool _enableFullTensor;
Expand Down
75 changes: 75 additions & 0 deletions libs/seiscomp/math/coord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ void Coord<T>::serialize(Archive& ar) {
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// AdminRegion implementation


// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void AdminRegion::serialize(Core::BaseObject::Archive& ar) {
ar & NAMED_OBJECT("abbr", abbr);
ar & NAMED_OBJECT_HINT("name", name, Core::BaseObject::Archive::XML_ELEMENT);
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


// NamedCoord<T> implementation


Expand Down Expand Up @@ -229,6 +240,26 @@ const std::string &City<T>::countryID() const {



// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
void City<T>::setCountry(const std::string &c) {
_country = c;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
const std::string &City<T>::country() const {
return _country;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
void City<T>::setCategory(std::string &c) {
Expand All @@ -249,12 +280,56 @@ const std::string &City<T>::category() const {



// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
void City<T>::setType(CityType t) {
_type = t;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
CityType City<T>::type() const {
return _type.value_or(CityType{});
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
void City<T>::setAdminRegion(const AdminRegion &r) {
_adminRegion = r;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
const AdminRegion &City<T>::adminRegion() const {
static const AdminRegion empty{};
return _adminRegion ? *_adminRegion : empty;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
template<typename T>
void City<T>::serialize(Core::BaseObject::Archive& ar) {
NamedCoord<T>::serialize(ar);
ar & NAMED_OBJECT("countryID", _countryID);
ar & NAMED_OBJECT("category", _category);
ar & NAMED_OBJECT("type", _type);
ar & NAMED_OBJECT_HINT("country", _country, Core::BaseObject::Archive::XML_ELEMENT);
ar & NAMED_OBJECT_HINT("state", _adminRegion, Core::BaseObject::Archive::XML_ELEMENT);
ar & NAMED_OBJECT_HINT("population", _population, Core::BaseObject::Archive::XML_ELEMENT);
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Expand Down
71 changes: 71 additions & 0 deletions libs/seiscomp/math/coord.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#define SEISCOMP_MATH_GEO_COORD_H

#include <seiscomp/core/baseobject.h>
#include <seiscomp/core/enumeration.h>
#include <seiscomp/core/optional.h>
#include <string>


Expand Down Expand Up @@ -81,6 +83,52 @@ typedef NamedCoord<float> NamedCoordF;
typedef NamedCoord<double> NamedCoordD;


/**
* Location type of a city derived from GeoNames feature codes.
* Serializes as a lowercase string attribute in XML.
*/
MAKEENUM(
CityType,
EVALUES(
CITYTYPE_UNKNOWN, //!< Absent or unrecognized type attribute
CITYTYPE_CITY, //!< Capital or administrative center (PPLC, PPLA, PPLA2)
CITYTYPE_TOWN, //!< Populated place or minor admin center (PPL, PPLA3, PPLA4)
CITYTYPE_VILLAGE, //!< Small settlement (PPLF, PPLL, PPLR, PPLS, etc.)
CITYTYPE_SUBURB //!< Section of a populated place (PPLX)
),
ENAMES(
"",
"city",
"town",
"village",
"suburb"
)
);


/**
* @brief Administrative region (state, province, etc.) associated with a city.
*
* Serializes as an XML child element carrying an optional abbreviation
* attribute and the full name as element text, e.g.:
* @code
* <state abbr="NSW">New South Wales</state>
* @endcode
*
* The @c abbr field holds the ISO 3166-2 subdivision suffix (alphabetic
* portion only, e.g. "NSW" from "AU-NSW", "CA" from "US-CA"). It is left
* empty for subdivisions that use numeric codes or where no ISO code exists.
*/
struct SC_SYSTEM_CORE_API AdminRegion : public Core::BaseObject {
DECLARE_SERIALIZATION;

std::string abbr; //!< ISO 3166-2 suffix, e.g. "NSW", "CA" (may be empty)
std::string name; //!< Full region name, e.g. "New South Wales"

bool empty() const { return name.empty(); }
};


template<typename T>
class City : public NamedCoord<T> {
public:
Expand All @@ -101,15 +149,38 @@ class City : public NamedCoord<T> {
void setCountryID(const std::string &);
const std::string &countryID() const;

//! Full country name, e.g. "Australia". Serializes as <country> child element.
void setCountry(const std::string &);
const std::string &country() const;

void setCategory(std::string &);
const std::string &category() const;

void setType(CityType);
CityType type() const;

/**
* @brief Administrative region (state/province).
*
* Serializes as a child element, e.g.:
* @code
* <state abbr="NSW"><name>New South Wales</name></state>
* @endcode
* The @c abbr field holds the ISO 3166-2 subdivision suffix (alphabetic
* portion only). It is left empty where no alphabetic ISO code exists.
*/
void setAdminRegion(const AdminRegion &);
const AdminRegion &adminRegion() const;

void serialize(Core::BaseObject::Archive& ar) override;

private:
std::string _countryID;
std::string _country;
double _population;
std::string _category;
OPT(CityType) _type;
OPT(AdminRegion) _adminRegion;
};


Expand Down
48 changes: 46 additions & 2 deletions libs/seiscomp/processing/amplitudes/Mwp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

#include <seiscomp/processing/amplitudes/Mwp.h>
#include <seiscomp/math/filter/iirintegrate.h>
#include<seiscomp/math/filter/butterworth.h>
#include <seiscomp/math/filter/butterworth.h>
#include <seiscomp/logging/log.h>
#include <seiscomp/config/config.h>

#include <seiscomp/math/geo.h>

Expand Down Expand Up @@ -112,6 +114,26 @@ double Mwp_amplitude(int n, double *f, int i0, int *pos) {
}


// Tsuboi et al. (1995) original algorithm: first local peak after P onset,
// not the global maximum. Stops as soon as amplitude starts decreasing.
double Mwp_first_peak_amplitude(int n, double *f, int i0, int *pos) {
double prev = 0.0;
*pos = i0;

for (int i = i0; i < n - 1; i++) {
double s = fabs(f[i]);
if (s >= prev) {
*pos = i;
prev = s;
}
else {
return prev; // first local maximum found
}
}
return prev;
}


void Mwp_double_integration(int n, double *f, int i0, double fsamp) {
Mwp_integr(n, f, i0);
Mwp_integr(n, f, i0);
Expand All @@ -138,6 +160,26 @@ AmplitudeProcessor_Mwp::AmplitudeProcessor_Mwp()



// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
bool AmplitudeProcessor_Mwp::setup(const Settings &settings) {
if ( !AmplitudeProcessor::setup(settings) ) {
return false;
}

const Seiscomp::Config::Config *cfg = settings.localConfiguration;
if ( cfg ) {
cfg->getBool(_useFirstPeak, "amplitudes.Mwp.useFirstPeak");
}

SEISCOMP_DEBUG(" + useFirstPeak = %s", _useFirstPeak ? "true" : "false");

return true;
}
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<




// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void AmplitudeProcessor_Mwp::init() {
setSignalEnd("min(D * 11.5, 95)");
Expand Down Expand Up @@ -209,7 +251,9 @@ bool AmplitudeProcessor_Mwp::computeAmplitude(const DoubleArray &data,
delete hp;

// Amplitude in nanometers
amplitude->value = 1.E9*Mwp_amplitude(si2, _processedData.typedData(), si1, &onset);
amplitude->value = _useFirstPeak
? 1.E9 * Mwp_first_peak_amplitude(si2, _processedData.typedData(), si1, &onset)
: 1.E9 * Mwp_amplitude(si2, _processedData.typedData(), si1, &onset);

dt->index = onset; // FIXME
*period = 0.0;
Expand Down
2 changes: 2 additions & 0 deletions libs/seiscomp/processing/amplitudes/Mwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SC_SYSTEM_CLIENT_API AmplitudeProcessor_Mwp : public AmplitudeProcessor {
AmplitudeProcessor_Mwp();

public:
bool setup(const Settings &settings) override;
const DoubleArray *processedData(Component comp) const override;

protected:
Expand All @@ -50,6 +51,7 @@ class SC_SYSTEM_CLIENT_API AmplitudeProcessor_Mwp : public AmplitudeProcessor {

private:
DoubleArray _processedData;
bool _useFirstPeak{false};
};


Expand Down
Loading