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
16 changes: 9 additions & 7 deletions DMI_Open_Data_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from qgis.PyQt.QtCore import QVariant
import webbrowser

from .dmi_dialog_tabs.information import DMIInformationWidget
from .api.station import get_stations, StationApi, StationId, Station, Parameter
from .settings import DMISettingsManager, DMISettingKeys

Expand All @@ -37,6 +38,7 @@ def __init__(self, settings_manager: DMISettingsManager, parent=None):
"""Constructor."""
super(DMIOpenDataDialog, self).__init__(parent)
self.settings_manager = settings_manager

load_ui_options = {}
try:
self.stations_ocean, self.oceanobs_parameters = self.get_stations_and_parameters_if_settings_allow(
Expand Down Expand Up @@ -70,6 +72,12 @@ def __init__(self, settings_manager: DMISettingsManager, parent=None):
load_ui_options['invalid_metobs_api_key'] = True

super(DMIOpenDataDialog, self).setupUi(self)

# Initializing information widget
information_widget = DMIInformationWidget(self.settings_manager, parent=self.information_tab)
layout = self.information_tab.findChildren(QtWidgets.QVBoxLayout)[0]
layout.addWidget(information_widget)

self.load_station_and_parameter_ui(**load_ui_options)

# All the radiobuttons that by default is checked
Expand Down Expand Up @@ -116,9 +124,6 @@ def __init__(self, settings_manager: DMISettingsManager, parent=None):
self.grid20_type.clicked.connect(self.grid20_typeR)
self.munic_type.clicked.connect(self.municipality_typeR)
self.country_type.clicked.connect(self.country_typeR)
self.dmi_open_data.clicked.connect(self.open_openData)
self.dmi_open_data_2.clicked.connect(self.open_openData_2)
self.dmi_dk.clicked.connect(self.open_dmi_dk)
self.stackedWidget.setCurrentWidget(self.stat_clima)
self.stackedWidget_2.setCurrentWidget(self.stat_para)
self.stackedWidget_3.setCurrentWidget(self.met_stat_page)
Expand All @@ -128,6 +133,7 @@ def __init__(self, settings_manager: DMISettingsManager, parent=None):
self.radioButton_11.clicked.connect(self.enable_time)
self.radioButton_21.clicked.connect(self.disable_time_oce)
self.radioButton_22.clicked.connect(self.enable_time_oce)
self.dmi_open_data_2.clicked.connect(self.open_openData_2)
# Sets the time in "Stations and parameters" unavailable untill "Defined Time" has been checked
self.groupBox_25.setEnabled(False)
self.groupBox_26.setEnabled(False)
Expand Down Expand Up @@ -275,12 +281,8 @@ def infoLight(self):
def infoTide(self):
self.stackedWidget_3.setCurrentWidget(self.tide_page)
# Actions for buttons to go to dmi.dk
def open_openData(self):
webbrowser.open('https://confluence.govcloud.dk/display/FDAPI/Danish+Meteorological+Institute+-+Open+Data')
def open_openData_2(self):
webbrowser.open('https://confluence.govcloud.dk/display/FDAPI/Danish+Meteorological+Institute+-+Open+Data')
def open_dmi_dk(self):
webbrowser.open('https://www.dmi.dk/')
# Actions when saving as .csv
def browse_files_cli(self):
fname = QFileDialog.getSaveFileName(self, 'Open File', 'C:')
Expand Down
73 changes: 13 additions & 60 deletions DMI_Open_Data_dialog_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>3</number>
<number>6</number>
</property>
<property name="documentMode">
<bool>false</bool>
Expand Down Expand Up @@ -367,8 +367,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>66</width>
<height>18</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_14"/>
Expand Down Expand Up @@ -421,8 +421,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>66</width>
<height>18</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_36"/>
Expand All @@ -443,8 +443,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>66</width>
<height>18</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_40"/>
Expand All @@ -465,8 +465,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>66</width>
<height>18</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_34"/>
Expand Down Expand Up @@ -993,8 +993,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>18</width>
<height>18</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout"/>
Expand Down Expand Up @@ -1254,58 +1254,11 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<widget class="QWidget" name="information_tab">
<attribute name="title">
<string>Information</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_30">
<item>
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:18px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:14pt; font-weight:600;&quot;&gt;Plugin for DMIs Open Data &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;&quot;&gt;Before starting&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Documentation and more information about DMI Open Data can be found &lt;/span&gt;&lt;a href=&quot;https://confluence.govcloud.dk/display/FDAPI/Danish+Meteorological+Institute+-+Open+Data&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#0000ff;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;. This guide will only briefly cover the plugin - not the data, stations etc.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;A thorough guide of how to use this plugin, along with examples, can be found here. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;The plugin allows the user to easily import data from DMIs Open Data from Meteorological Observations (metObs), Climate Data (climateData), Lightning Data (lightningData), Radar Data (radarData) and Oceanographic Observations (oceanObs). At each tab, the users API-key has to be inserted in order to get data. An API-key can be created &lt;/span&gt;&lt;a href=&quot;https://confluence.govcloud.dk/display/FDAPI/User+Creation&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#0000ff;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:12pt; font-weight:600;&quot;&gt;How to use this plugin&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;In order to get data, an API Key must be configured in QGIS settings menu. To configure API keys, please go to Settings -&amp;gt; Options -&amp;gt; DMI Open Data. Note that each type of data requires one specific API Key corresponding to that UI. &lt;br /&gt;After the API Key has been configured in settings, stations and parameters will be accessible, and the plugin will work as intended. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Things to note when using the plugin: &lt;/span&gt;&lt;/p&gt;
&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-family:'MS Shell Dlg 2';&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Maximum amount of parameters available is 7.&lt;/li&gt;
&lt;li style=&quot; font-family:'MS Shell Dlg 2';&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Internet is neccessary in order to open the plugin and get data.&lt;/li&gt;
&lt;li style=&quot; font-family:'MS Shell Dlg 2';&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Sort the data in a manner that your QGIS can handle. Otherwise there is a risk of crashing.&lt;/li&gt;
&lt;li style=&quot; font-family:'MS Shell Dlg 2';&quot; style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Be sure to read about the stations and parameters, as not all stations measure all parameters. A list of meteorological stations and their associated parameters can also be found &lt;a href=&quot;https://confluence.govcloud.dk/pages/viewpage.action?pageId=53086560&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;If you have any questions about the plugin or DMI Open Data then please contact us. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Go to &lt;/span&gt;&lt;a href=&quot;https://www.dmi.dk/kontakt/frie-data/&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; text-decoration: underline; color:#0000ff;&quot;&gt;Contact form&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2';&quot;&gt;Call DMI support: +45 39 15 75 00&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;https://confluence.govcloud.dk/download/thumbnails/41718638/Open%20Data%20-%20Hvid%20baggrund%20med%20bl%C3%A5%20cirkler%20og%20tekst.png?version=1&amp;amp;modificationDate=1622790552000&amp;amp;api=v2&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QCommandLinkButton" name="dmi_open_data">
<property name="text">
<string>Go to DMI Open Data</string>
</property>
</widget>
</item>
<item>
<widget class="QCommandLinkButton" name="dmi_dk">
<property name="text">
<string>Go to dmi.dk</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<layout class="QVBoxLayout" name="verticalLayout_30"/>
</widget>
</widget>
</item>
Expand Down
Empty file added dmi_dialog_tabs/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions dmi_dialog_tabs/information/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
import os
import webbrowser
from qgis.PyQt import QtWidgets, uic

from ...settings import DMISettingsManager

FORM_CLASS, _ = uic.loadUiType(os.path.join(os.path.dirname(__file__), 'information.ui'))

print(os.path.join(os.path.dirname(__file__), 'information.ui'))

class DMIInformationWidget(QtWidgets.QWidget, FORM_CLASS):
def __init__(self, settings_manager: DMISettingsManager, parent=None):
super(DMIInformationWidget, self).__init__(parent)
super(DMIInformationWidget, self).setupUi(self)

self.dmi_open_data.clicked.connect(self.open_openData)
self.dmi_dk.clicked.connect(self.open_dmi_dk)

# Actions for buttons to go to dmi.dk
def open_openData(self):
webbrowser.open('https://confluence.govcloud.dk/display/FDAPI/Danish+Meteorological+Institute+-+Open+Data')
def open_dmi_dk(self):
webbrowser.open('https://www.dmi.dk/')
Loading