Commit 1a49a2fb authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

modified CHANGELOG.rst


refactored file loading
Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow benjamin.jakimow@geo.hu-berlin.de <benjamin.jakimow@geo.hu-berlin.de>
parent 8042b062
Pipeline #17094 failed with stage
in 2 minutes and 1 second
==============
Changelog
==============
2021-02-23 (version 1.17):
2021-03-10 (version 1.17):
* fixed bug that crashed plugin on plugin unload
* added bulk loading from time series definition files
* fixes to run with QGIS 3.18+
* move to next/previous observation with arrow right/left
* move to next/previous observation window with CTRL + arrow right/left or A/D
......
......@@ -1107,6 +1107,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
self.mapWidget().setCrs(iface.mapCanvas().mapSettings().destinationCrs())
def onShowLayerProperties(self, lyr=None):
if not isinstance(lyr, QgsMapLayer):
lyr = self.currentLayer()
......@@ -1388,15 +1389,23 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
"""
return self.ui.mMapWidget.messageBar()
def loadTimeSeriesDefinition(self, path: str = None, n_max: int = None, runAsync=True):
def loadTimeSeriesDefinition(self,
files: typing.List[typing.Union[str, pathlib.Path]] = None,
n_max: int = None,
runAsync=True):
"""
Loads a time series definition file
:param path:
:param files:
:param n_max:
:return:
"""
if isinstance(files, bool):
files = None
if isinstance(files, (str, pathlib.Path)):
files = [files]
s = settings.settings()
if not (isinstance(path, str) and os.path.isfile(path)):
if files is None:
defFile = s.value('file_ts_definition')
defDir = None
......@@ -1406,13 +1415,14 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
filters = "CSV (*.csv *.txt);;" + \
"All files (*.*)"
path, filter = QFileDialog.getOpenFileName(caption='Load Time Series definition', directory=defDir,
filter=filters)
files, filter = QFileDialog.getOpenFileNames(caption='Load Time Series definition', directory=defDir,
filter=filters)
if path is not None and os.path.exists(path):
s.setValue('file_ts_definition', path)
if isinstance(files, list):
# self.clearTimeSeries()
self.mTimeSeries.loadFromFile(path, n_max=n_max, runAsync=runAsync)
for file in sorted(files):
s.setValue('file_ts_definition', file)
self.mTimeSeries.loadFromFile(file, n_max=n_max, runAsync=runAsync)
def currentLayer(self) -> QgsMapLayer:
"""
......
......@@ -1671,7 +1671,7 @@ class TimeSeries(QAbstractItemModel):
"""
return self.mSensors[:]
def loadFromFile(self, path, n_max=None, runAsync: bool = None):
def loadFromFile(self, path:typing.Union[str, pathlib.Path], n_max=None, runAsync: bool = None):
"""
Loads a CSV file with source images of a TimeSeries
:param path: str, Path of CSV file
......
......@@ -49,6 +49,16 @@ class TestMain(EOTSVTestCase):
super().tearDown()
def test_TimeSeriesViewer(self):
from qgis.utils import iface
c = iface.mapCanvas()
self.assertIsInstance(c, QgsMapCanvas)
def onCRSChanged():
print(f'QGIS MapCanvas CRS changed to {c.mapSettings().destinationCrs().description()}', flush=True)
c.destinationCrsChanged.connect(onCRSChanged)
crs = QgsCoordinateReferenceSystem('EPSG:32633')
c.setDestinationCrs(crs)
from eotimeseriesviewer.main import EOTimeSeriesViewer
TSV = EOTimeSeriesViewer()
TSV.createMapView('True Color')
......@@ -140,8 +150,12 @@ class TestMain(EOTSVTestCase):
self.showGui(TSV)
def test_fail(self):
self.assertTrue(False)
if __name__ == '__main__':
print('\nRun 1 test in 5.373s\n\nFAILED (failures=1)', file=sys.stderr, flush=True)
unittest.main(testRunner=xmlrunner.XMLTestRunner(output='test-reports'), buffer=False)
exit(0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment