Skip to content
This repository was archived by the owner on May 10, 2023. It is now read-only.

Commit 9cfb442

Browse files
committed
Merge branch 'release/jakarta' into build/jakarta/2017.334
2 parents d193ecc + 8945124 commit 9cfb442

File tree

11 files changed

+269
-102
lines changed

11 files changed

+269
-102
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
* trunk
66

7-
* fix crash in FDSNWS recordstream if server cannot be reached
7+
* Fix crash in FDSNWS recordstream if server cannot be reached
88
* Updated sc3ml_0.10.xsd
99
* Use correct name in connection info for Python scripts
1010

@@ -18,6 +18,12 @@
1818
* Event list shows only the full summary tooltip if the mouse hovers
1919
the ID column (last column)
2020

21+
22+
* scmapcut
23+
24+
* Add new module documentation
25+
* Allow float values for the region parameter
26+
2127
## Release 2017.334
2228

2329
```SC_API_VERSION 11.0.0```
1.22 MB
Loading
1.22 MB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
*scmapcut* is a commandline tool to create image files containing maps of specific
2+
regions and for selected events. When plotting events given by their eventID, the
3+
event parameters must be provided in a SeisComP3 event XML file. The XML file can
4+
be retrieved from the database using :ref:`scxmldump`.
5+
6+
Examples
7+
========
8+
9+
1. Draw a map for the event with event ID <eventID>. Plot a region of at least
10+
3 degrees around the epicentre. The created image has 800x400 px.
11+
12+
.. code-block:: sh
13+
14+
scmapcut -E <eventID> --ep <eventID>.xml -m 3 -d 800x400 -o <eventID>.png
15+
16+
.. _fig-workflow:
17+
18+
.. figure:: media/gempa2017xxxx.png
19+
:align: center
20+
:width: 10cm
21+
22+
Image example.
23+
24+
#. Draw a map for a generic event with magnitude 4. The size of the event shown
25+
on the map scales with magnitude. Plot a region of at least 3 degrees around
26+
the epicentre. The created image has 800x400 px.
27+
28+
29+
.. code-block:: sh
30+
31+
scmapcut --lat 44 --lon 12 --depth 10 --mag 4 -m 0.5 -d 800x400 -o generic.png
32+
33+
.. _fig-workflow:
34+
35+
.. figure:: media/generic.png
36+
:align: center
37+
:width: 10cm
38+
39+
Generic example.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<seiscomp>
3+
<module name="scmapcut" category="Utilities">
4+
<description>Create image files containing maps of specific regions.</description>
5+
<command-line>
6+
<group name="Generic">
7+
<optionReference>generic#help</optionReference>
8+
<optionReference>generic#version</optionReference>
9+
<optionReference>generic#config-file</optionReference>
10+
<optionReference>generic#plugins</optionReference>
11+
<optionReference>generic#daemon</optionReference>
12+
<optionReference>generic#auto-shutdown</optionReference>
13+
<optionReference>generic#shutdown-master-module</optionReference>
14+
<optionReference>generic#shutdown-master-username</optionReference>
15+
</group>
16+
17+
<group name="Verbosity">
18+
<optionReference>verbosity#verbosity</optionReference>
19+
<optionReference>verbosity#v</optionReference>
20+
<optionReference>verbosity#quiet</optionReference>
21+
<optionReference>verbosity#component</optionReference>
22+
<optionReference>verbosity#syslog</optionReference>
23+
<optionReference>verbosity#lockfile</optionReference>
24+
<optionReference>verbosity#console</optionReference>
25+
<optionReference>verbosity#debug</optionReference>
26+
<optionReference>verbosity#log-file</optionReference>
27+
</group>
28+
29+
<group name="Cities">
30+
<option flag="" long-flag="city-xml" argument="arg" type="string">
31+
<description>
32+
Path to the cities.xml file. If undefined the data is read from
33+
@CONFIGDIR@/cities.xml@ or @DATADIR@/cities.xml@.
34+
</description>
35+
</option>
36+
</group>
37+
38+
<group name="Options">
39+
<option flag="r" long-flag="region" argument="arg" type="string" unit="degree">
40+
<description>
41+
Cut region ([lat_dim]x[lon_dim]+lat0+lon0 or +lat0+lon+lat1+lon1)
42+
</description>
43+
</option>
44+
<option flag="m" long-flag="margin" argument="arg" type="string" unit="degree">
45+
<description>
46+
Margin in degrees around origin (margin|margin_latxmargin_lon)
47+
</description>
48+
</option>
49+
<option flag="d" long-flag="dimension" argument="arg" type="string" unit="px">
50+
<description>
51+
Output image dimension (wxh)
52+
</description>
53+
</option>
54+
<option flag="o" long-flag="output" argument="arg" type="string" unit="">
55+
<description>
56+
Output image, file name
57+
</description>
58+
</option>
59+
<option flag="" long-flag="lat" argument="arg" type="float" unit="degree">
60+
<description>
61+
Latitude of symbol
62+
</description>
63+
</option>
64+
<option flag="" long-flag="long" argument="arg" unit="degree">
65+
<description>
66+
Longitude of symbol
67+
</description>
68+
</option>
69+
<option flag="" long-flag="depth" argument="arg" unit="km">
70+
<description>
71+
Depth of event
72+
</description>
73+
</option>
74+
<option flag="" long-flag="mag" argument="arg" unit="">
75+
<description>
76+
Magnitude of event
77+
</description>
78+
</option>
79+
<option flag="" long-flag="layers" argument="arg" unit="">
80+
<description>
81+
Draw polygonal layers
82+
</description>
83+
</option>
84+
<option flag="" long-flag="ep" argument="arg" unit="">
85+
<description>
86+
Name of XML file containing the event parameters to load
87+
</description>
88+
</option>
89+
<option flag="E" long-flag="event-id" argument="arg" unit="">
90+
<description>
91+
EventID of the event to plot on map
92+
</description>
93+
</option>
94+
<option flag="" long-flag="html-area" argument="arg" unit="">
95+
<description>
96+
Print html/area section
97+
</description>
98+
</option>
99+
</group>
100+
</command-line>
101+
</module>
102+
</seiscomp>

src/gui-qt4/apps/scmapcut/main.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ bool parseMargin(const string &str, QSizeF *size) {
5656

5757
size_t pos = str.find('x');
5858

59-
if ( size ) *size = QSize(0,0);
59+
if ( size ) *size = QSizeF(0,0);
6060

6161
if ( pos == string::npos )
6262
symmetric = true;
6363

64-
int w,h;
64+
qreal w,h;
6565

6666
if ( !Core::fromString(h, str.substr(0,pos)) )
6767
return false;
@@ -71,7 +71,7 @@ bool parseMargin(const string &str, QSizeF *size) {
7171
else if ( !Core::fromString(w, str.substr(pos+1)) )
7272
return false;
7373

74-
if ( size ) *size = QSize(w,h);
74+
if ( size ) *size = QSizeF(w,h);
7575
return true;
7676
}
7777

@@ -326,13 +326,14 @@ bool MapCut::run() {
326326
_margins.width()*2, _margins.height()*2);
327327
}
328328

329-
330329
Map::ImageTreePtr mapTree = new Map::ImageTree(mapsDesc());
331330

332331
_canvas = new Map::Canvas(mapTree.get());
333332
_canvas->setParent(this);
334333
_canvas->setSize(_dim.width(), _dim.height());
335334

335+
_image = QImage(_canvas->size(), QImage::Format_ARGB32);
336+
336337
setupView(_canvas, QRectF(_reg.left(),_reg.top(),_reg.width(),_reg.height()));
337338

338339
_canvas->setPreviewMode(false);
@@ -361,7 +362,7 @@ bool MapCut::run() {
361362
return Application::run();
362363
}
363364

364-
if ( !_canvas->buffer().save(_output.c_str(), NULL, 100) ) {
365+
if ( !_image.save(_output.c_str(), NULL, 100) ) {
365366
cerr << "Saving the image failed" << endl;
366367
return false;
367368
}
@@ -371,7 +372,7 @@ bool MapCut::run() {
371372

372373

373374
void MapCut::renderCanvas() {
374-
QPainter p(&_canvas->buffer());
375+
QPainter p(&_image);
375376
_canvas->draw(p);
376377
}
377378

src/gui-qt4/apps/scmapcut/mapcut.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class MapCut : public Seiscomp::Gui::Application {
5959
QRectF _reg;
6060
QSizeF _margins;
6161
QSize _dim;
62+
QImage _image;
6263

6364
bool _htmlArea;
6465

src/gui-qt4/libs/seiscomp3/gui/map/imagetree.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <seiscomp3/logging/log.h>
1919

2020
#include <cstdio>
21+
#include <clocale>
2122

2223

2324
IMPLEMENT_INTERFACE_FACTORY(Seiscomp::Gui::Map::TileStore, SC_GUI_API);
@@ -203,6 +204,8 @@ ImageTree::ImageTree(const MapsDesc &meta) {
203204

204205
MapsDesc desc(meta);
205206

207+
const char *oldLocale = setlocale(LC_ALL, NULL);
208+
206209
if ( !_store->open(desc) ) {
207210
SEISCOMP_ERROR("Failed to open tile store at %s",
208211
(const char*)desc.location.toAscii());
@@ -212,6 +215,8 @@ ImageTree::ImageTree(const MapsDesc &meta) {
212215
_isMercatorProjected = desc.isMercatorProjected;
213216
_cacheSize = desc.cacheSize;
214217
}
218+
219+
setlocale(LC_ALL, oldLocale);
215220
}
216221
else {
217222
SEISCOMP_ERROR("Could not create tile store: %s",

src/trunk/libs/seiscomp3/datamodel/databasearchive.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ const std::string& toSQL(const std::string& str) {
108108
if ( pos == std::string::npos )
109109
return str;
110110

111-
if ( pos > 0 ) {
112-
converted.clear();
111+
converted.clear();
112+
113+
if ( pos > 0 )
113114
converted.append(str, 0, pos);
114-
}
115115

116116
++pos;
117117
converted.append("''");

src/trunk/libs/seiscomp3/io/recordstream/fdsnws.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ Record *FDSNWSConnectionBase::next() {
371371
_sock->startTimer();
372372

373373
if ( !_readingData ) {
374-
_sock->open(_host);
375374
try {
375+
_sock->open(_host);
376376
handshake();
377377
}
378378
catch ( const GeneralException &e ) {

0 commit comments

Comments
 (0)