INGV / qquake

A plugin for QGIS 3.x that relies on web services for loading seismological data
https://www.emidius.eu/qquake/
GNU General Public License v3.0
7 stars 3 forks source link

Various changes to the tab for loading QuakeML #8

Closed MarioLocati closed 3 years ago

MarioLocati commented 3 years ago

Various changes are required for the recently introduced "By URL" for the FDSN-event and for the macroseismic tabs.

  1. It should be tab in its own, because it is not relying on any service

  2. It should be renamed as "Load QuakeML".

  3. It should be introduced the possibility for the user to load a local QuakeML as alternative method to the existing load of remote files.

  4. Only the extended output should be supported, because this tab is meant to allow the user loading a QuakeML file only, nothing else

Below an possible mockup of the final result after these changes image

Please, ensure that the plugin will work with the QuakeML files contained in the zip files that can be downloaded from http://terremoti.ingv.it/en/bsi

@nyalldawson Could you please take care of this?

nyalldawson commented 3 years ago

It should be tab in its own, because it is not relying on any service

This is not a trivial change -- I'll need to discuss a price variation with @ghtmtt before we can proceed with this

MarioLocati commented 3 years ago

There is some adjustment that should be implemented.

  1. I have tested some QuakeML 1.2 file, some is loaded correctly, some don't load at all. Attached a zip with those that cause an error (see at the end of this issue). As far as I understood, files downloaded from the following pages cannot be loaded:

QuakeML_test_files_with_problems.zip

  1. The plugin does not apply any symbology to the loaded data, neither to the epicentres, nor to the layer with macroseismic data in the case of QuakeML 2.0.

  2. When trying to load a local file clicking on "Import from file" the file dialog allow selecting files with the extension ".xml" only, whereas some organisations adopted ".qml" as the extension for QuakeML. Please, add ".qml" among the default filters, and add the possibility to show all files in the folder.

  3. In the current implementation, the name of the the plugin assign as label to the QGIS layer, the name of the service currently selected. This is OK when loading an URL, but in the case of loading a local file, the label of the layer should correspond to the loaded file name.

@nyalldawson Could you please take care of this?

An error has occurred while executing Python code: 

ValueError: could not convert string to float: 'original mag_type: ML' 
Traceback (most recent call last):
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\fetcher.py", line 246, in 
    reply.finished.connect(lambda r=reply: self._reply_finished(r))
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\fetcher.py", line 314, in _reply_finished
    self.result.parse_initial(reply.readAll())
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\quakeml_parser.py", line 1685, in parse_initial
    self.add_events(content)
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\quakeml_parser.py", line 1700, in add_events
    event = Event.from_element(event_element)
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\quakeml_parser.py", line 1644, in from_element
    comments.append(Comment.from_element(comment_nodes.at(e).toElement()))
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\quakeml_parser.py", line 818, in from_element
    return Comment(text=parser.float('text', optional=False),
  File "C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qquake\quakeml_parser.py", line 320, in float
    return float(child.text())
ValueError: could not convert string to float: 'original mag_type: ML'

Python version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] 
QGIS version: 3.16.1-Hannover Hannover, b381a90dca 

Python Path:
C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python
C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/PROGRA~1/QGIS3~1.16/apps/qgis/./python/plugins
C:\PROGRA~1\QGIS3~1.16\apps\Python37
C:\PROGRA~1\QGIS3~1.16\apps\Python37\Scripts
C:\Program Files\QGIS 3.16\bin\python37.zip
C:\PROGRA~1\QGIS3~1.16\apps\Python37\DLLs
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib
C:\Program Files\QGIS 3.16\bin
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\win32
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\win32\lib
C:\PROGRA~1\QGIS3~1.16\apps\Python37\lib\site-packages\Pythonwin
C:/Users/mario/AppData/Roaming/QGIS/QGIS3\profiles\default/python
nyalldawson commented 3 years ago

@MarioLocati I'll look into these.

Regarding:

The plugin does not apply any symbology to the loaded data, neither to the epicentres, nor to the layer with macroseismic data in the case of QuakeML 2.0.

Which style should we be applying here? Given that all the styling information is service specific and we don't have a particular service associated when we are just directly using the xml, I'm not sure which style we should be applying...

MarioLocati commented 3 years ago

@nyalldawson

FDSN-event services The symbology to use should be the first available style of type "events". At the moment we have only one style of this kind, called "CPTI".

Macroseismic services For the events output layer the symbology to use should be the first available style of type "events". At the moment we have only one style of this kind, called "CPTI". For the macroseismic data output layer the symbology to use should be the first available style of type "macroseismic". At the moment we have only one style of this kind, called "AHEAD_intensities".

Below an extract from the "styles" section in the current version of "config.json"

[...]
  "styles": {
    "CPTI": {
      "type": "events",
      "url": "https://www.emidius.eu/qquake/symbology/CPTI15_symbols.qml"
    },
    "AHEAD_intensities": {
      "type": "macroseismic",
      "url": "https://www.emidius.eu/qquake/symbology/AHEAD_intensities.qml"
    },
[...]
nyalldawson commented 3 years ago

This is all fixed now -- I had the wrong issue number in the PR so it didn't get auto-closed