Skip to content

Commit

Permalink
Revisão da exportação de arquivos e remoção da edição de endereço do …
Browse files Browse the repository at this point in the history
…serviço WTSS brazil-data-cube#103
  • Loading branch information
AbnerErnaniADSFatec committed Jan 21, 2025
1 parent 6564915 commit 61372f0
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 127 deletions.
Binary file added wtss_plugin/controller/assets/save-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions wtss_plugin/controller/files_export/files_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ def __init__(self):
"""Set the default values for files format."""
self.files_format = FilesFormat()

def getExportOptions(self):
"""Set options to export result."""
return ["CSV", "JSON", "Python"]

def generateCode(self, file_name, attributes):
"""Generate a python code file filling WTSS blank spaces.
Expand Down
55 changes: 22 additions & 33 deletions wtss_plugin/wtss_qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def initControls(self):
self.addCanvasControlPoint(self.enabled_click)
self.dlg.input_longitude.valueChanged.connect(self.checkFilters)
self.dlg.input_latitude.valueChanged.connect(self.checkFilters)
self.selectCoverage()

def initLoadingControls(self):
"""Enable loading label."""
Expand Down Expand Up @@ -244,22 +245,25 @@ def initIcons(self):
self.dlg.search_button.setIcon(icon)
icon = QIcon(str(Path(Config.BASE_DIR) / 'assets' / 'zoom-icon.png'))
self.dlg.zoom_selected_point.setIcon(icon)
icon = QIcon(str(Path(Config.BASE_DIR) / 'assets' / 'save-icon.png'))
self.dlg.export_result.setIcon(icon)
self.points_layer_icon_path = str(Path(Config.BASE_DIR) / 'assets' / 'marker-icon.png')

def initButtons(self):
"""Init the main buttons to manage services and the results."""
self.dlg.show_help_button.clicked.connect(self.showHelp)
self.dlg.show_coverage_description.clicked.connect(self.showCoverageDescription)
self.dlg.export_as_json.clicked.connect(self.exportJSON)
self.dlg.export_as_json.setEnabled(False)
self.dlg.export_as_csv.clicked.connect(self.exportCSV)
self.dlg.export_as_csv.setEnabled(False)
self.dlg.export_as_python.clicked.connect(self.exportPython)
self.dlg.export_as_python.setEnabled(False)
self.dlg.export_result.clicked.connect(self.exportAsType)
self.dlg.zoom_selected_point.clicked.connect(self.zoom_to_selected_point)
self.dlg.zoom_selected_point.setEnabled(True)
self.dlg.search_button.clicked.connect(self.getTimeSeriesButton)
self.dlg.search_button.setEnabled(False)
self.initExportOptions()
self.enabledSearchButtons(False)

def initExportOptions(self):
"""Init the combo box select option to export"""
self.dlg.export_result_as_type.addItems(self.files_controls.getExportOptions())

def initHistory(self):
"""Init and update location history."""
Expand All @@ -279,28 +283,6 @@ def initRasterHistory(self):
"""Add a event listener when a layer is added to check the history of vrt layers."""
QgsProject.instance().layersAdded.connect(self.updateRasterHistory)

def initServices(self):
"""Load the wtss server."""
self.wtss_server_edit = False
self.dlg.wtss_server_label.setText(self.wtss_controls.getService())
self.dlg.wtss_server_label.setEnabled(self.wtss_server_edit)
self.dlg.wtss_server_label_update.clicked.connect(self.updateService)
self.selectCoverage()

def updateService(self):
"""Edit the selected service."""
self.wtss_server_edit = not self.wtss_server_edit
self.dlg.wtss_server_label.setEnabled(self.wtss_server_edit)
if self.wtss_server_edit:
self.dlg.coverage_selection.clear()
self.dlg.coverage_selection.setEnabled(False)
self.dlg.bands_scroll.setWidget(QWidget())
self.dlg.search_button.setEnabled(False)
else:
self.wtss_controls.setService(self.dlg.wtss_server_label.text())
self.dlg.coverage_selection.setEnabled(True)
self.selectCoverage()

def initRasterPathControls(self):
"""Init raster path location controls."""
self.enabled_output_path_raster_edit = False
Expand Down Expand Up @@ -562,6 +544,16 @@ def plotTimeSeries(self):
else:
self.basic_controls.alert("error", "AttributeError", "The times series service returns empty, no data to show!")

def exportAsType(self):
"""Export result based on combo box selection."""
ext = self.dlg.export_result_as_type.currentText()
if ext == "CSV":
self.exportCSV()
elif ext == "JSON":
self.exportJSON()
elif ext == "Python":
self.exportPython()

def getLayers(self):
"""Storage the layers in QGIS project."""
self.layers = QgsProject.instance().layerTreeRoot().children()
Expand Down Expand Up @@ -709,9 +701,8 @@ def addCanvasControlPoint(self, enable):
def enabledSearchButtons(self, enable):
"""Enable the buttons to load time series."""
self.dlg.search_button.setEnabled(enable)
self.dlg.export_as_python.setEnabled(enable)
self.dlg.export_as_csv.setEnabled(enable)
self.dlg.export_as_json.setEnabled(enable)
self.dlg.export_result_as_type.setEnabled(enable)
self.dlg.export_result.setEnabled(enable)

def checkFilters(self):
"""Check if lat lng are selected."""
Expand Down Expand Up @@ -755,8 +746,6 @@ def run(self):
self.dlg = wtss_qgisDialog()
# Init Controls
self.initControls()
# Services
self.initServices()
# Virtual Raster History
self.initRasterHistory()
# Output vrt path
Expand Down
126 changes: 32 additions & 94 deletions wtss_plugin/wtss_qgis_dialog_base.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>741</width>
<height>510</height>
<width>732</width>
<height>492</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -24,8 +24,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>741</width>
<height>511</height>
<width>731</width>
<height>491</height>
</rect>
</property>
<property name="tabPosition">
Expand All @@ -45,7 +45,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<y>10</y>
<width>451</width>
<height>61</height>
</rect>
Expand Down Expand Up @@ -77,60 +77,24 @@
</property>
</widget>
</widget>
<widget class="QGroupBox" name="services_group">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>451</width>
<height>61</height>
</rect>
</property>
<property name="title">
<string>Active Service</string>
</property>
<widget class="QLineEdit" name="wtss_server_label">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>331</width>
<height>27</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="wtss_server_label_update">
<property name="geometry">
<rect>
<x>350</x>
<y>30</y>
<width>91</width>
<height>25</height>
</rect>
</property>
<property name="text">
<string>Update</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="exporting_files">
<property name="geometry">
<rect>
<x>480</x>
<y>410</y>
<width>251</width>
<y>390</y>
<width>241</width>
<height>61</height>
</rect>
</property>
<property name="title">
<string>Export result as</string>
</property>
<widget class="QPushButton" name="export_as_csv">
<widget class="QPushButton" name="export_result">
<property name="geometry">
<rect>
<x>90</x>
<x>200</x>
<y>30</y>
<width>71</width>
<width>31</width>
<height>25</height>
</rect>
</property>
Expand All @@ -140,53 +104,27 @@
</font>
</property>
<property name="text">
<string>CSV</string>
<string/>
</property>
</widget>
<widget class="QPushButton" name="export_as_json">
<widget class="QComboBox" name="export_result_as_type">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>71</width>
<height>25</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>JSON</string>
</property>
</widget>
<widget class="QPushButton" name="export_as_python">
<property name="geometry">
<rect>
<x>170</x>
<y>30</y>
<width>71</width>
<height>25</height>
<width>181</width>
<height>27</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>Python</string>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="history">
<property name="geometry">
<rect>
<x>480</x>
<y>10</y>
<width>251</width>
<height>391</height>
<width>241</width>
<height>371</height>
</rect>
</property>
<property name="title">
Expand All @@ -197,8 +135,8 @@
<rect>
<x>10</x>
<y>30</y>
<width>231</width>
<height>351</height>
<width>221</width>
<height>331</height>
</rect>
</property>
<property name="editTriggers">
Expand All @@ -210,7 +148,7 @@
<property name="geometry">
<rect>
<x>20</x>
<y>300</y>
<y>280</y>
<width>201</width>
<height>51</height>
</rect>
Expand Down Expand Up @@ -246,9 +184,9 @@
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<y>80</y>
<width>451</width>
<height>141</height>
<height>191</height>
</rect>
</property>
<property name="title">
Expand All @@ -260,7 +198,7 @@
<x>10</x>
<y>30</y>
<width>431</width>
<height>101</height>
<height>151</height>
</rect>
</property>
<property name="widgetResizable">
Expand All @@ -272,7 +210,7 @@
<x>0</x>
<y>0</y>
<width>429</width>
<height>99</height>
<height>149</height>
</rect>
</property>
</widget>
Expand All @@ -284,8 +222,8 @@
</property>
<property name="geometry">
<rect>
<x>100</x>
<y>440</y>
<x>90</x>
<y>420</y>
<width>231</width>
<height>25</height>
</rect>
Expand All @@ -304,7 +242,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>360</y>
<y>340</y>
<width>451</width>
<height>71</height>
</rect>
Expand Down Expand Up @@ -379,8 +317,8 @@
<widget class="QPushButton" name="show_help_button">
<property name="geometry">
<rect>
<x>340</x>
<y>440</y>
<x>330</x>
<y>420</y>
<width>31</width>
<height>25</height>
</rect>
Expand All @@ -393,7 +331,7 @@
<property name="geometry">
<rect>
<x>250</x>
<y>300</y>
<y>280</y>
<width>201</width>
<height>51</height>
</rect>
Expand Down Expand Up @@ -576,10 +514,10 @@
<widget class="QLabel" name="loading_label">
<property name="geometry">
<rect>
<x>-1</x>
<x>5</x>
<y>0</y>
<width>741</width>
<height>511</height>
<width>731</width>
<height>491</height>
</rect>
</property>
<property name="text">
Expand Down

0 comments on commit 61372f0

Please sign in to comment.