Commit c9e0f768 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

fixed reading of sensor names QgsProject


Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow <benjamin.jakimow@geo.hu-berlin.de>
parent cd199e14
Pipeline #12588 failed
...@@ -704,7 +704,11 @@ class EOTimeSeriesViewer(QgisInterface, QObject): ...@@ -704,7 +704,11 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
archive.clearProjectFile() archive.clearProjectFile()
def onReadProject(self, doc: QDomDocument) -> bool: def onReadProject(self, doc: QDomDocument) -> bool:
"""
Reads images and visualization settings from a QgsProject QDomDocument
:param doc: QDomDocument
:return: bool
"""
if not isinstance(doc, QDomDocument): if not isinstance(doc, QDomDocument):
return False return False
......
...@@ -1212,14 +1212,13 @@ class MapCanvas(QgsMapCanvas): ...@@ -1212,14 +1212,13 @@ class MapCanvas(QgsMapCanvas):
dtg = self.tsd().date().astype(object) dtg = self.tsd().date().astype(object)
dt1 = QDateTime(dtg, QTime(0, 0)) dt1 = QDateTime(dtg, QTime(0, 0))
dt2 = QDateTime(dtg, QTime(QTime(23, 59, 59))) dt2 = QDateTime(dtg, QTime(QTime(23, 59, 59)))
print(f'## LAYER DTG: {dtg}')
tprop.setFixedTemporalRange(QgsDateTimeRange(dt1, dt2)) tprop.setFixedTemporalRange(QgsDateTimeRange(dt1, dt2))
layers.append(l) layers.append(l)
else: else:
layers.append(l) layers.append(l)
if len(layers) > 0 and isinstance(qgis.utils.iface, QgisInterface): if len(layers) > 0 and isinstance(qgis.utils.iface, QgisInterface):
QgsProject.instance().addMapLayers(layers, True) QgsProject.instance().addMapLayers(layers)
def onPasteStyleFromClipboard(self, lyr): def onPasteStyleFromClipboard(self, lyr):
from .externals.qps.layerproperties import pasteStyleFromClipboard from .externals.qps.layerproperties import pasteStyleFromClipboard
......
...@@ -207,17 +207,6 @@ class SensorInstrument(QObject): ...@@ -207,17 +207,6 @@ class SensorInstrument(QObject):
SensorNameSettingsPrefix = 'SensorName.' SensorNameSettingsPrefix = 'SensorName.'
sigNameChanged = pyqtSignal(str) sigNameChanged = pyqtSignal(str)
@staticmethod
def readXml(node: QDomNode):
sensor: SensorInstrument = None
nodeId = node.firstChildElement('SensorId').toElement()
if nodeId.nodeName() == 'SensorId':
sid = nodeId.firstChild().nodeValue()
sensor = SensorInstrument(sid)
s = ""
return sensor
def __init__(self, sid: str, band_names: list = None): def __init__(self, sid: str, band_names: list = None):
super(SensorInstrument, self).__init__() super(SensorInstrument, self).__init__()
...@@ -267,7 +256,20 @@ class SensorInstrument(QObject): ...@@ -267,7 +256,20 @@ class SensorInstrument(QObject):
if self.wlu is not None: if self.wlu is not None:
self.mMockupDS.SetMetadataItem('wavelength units', self.wlu) self.mMockupDS.SetMetadataItem('wavelength units', self.wlu)
self.mMockupDS.FlushCache() self.mMockupDS.FlushCache()
s = ""
@staticmethod
def readXml(node: QDomNode):
sensor: SensorInstrument = None
nodeId = node.firstChildElement('SensorId').toElement()
if nodeId.nodeName() == 'SensorId':
sid = nodeId.firstChild().nodeValue()
sensor = SensorInstrument(sid)
nodeName = node.firstChildElement('SensorName').toElement()
if isinstance(sensor, SensorInstrument) and nodeName.nodeName() == 'SensorName':
name = nodeName.firstChild().nodeValue()
sensor.setName(name)
return sensor
def writeXml(self, node: QDomNode, doc: QDomDocument): def writeXml(self, node: QDomNode, doc: QDomDocument):
...@@ -666,7 +668,7 @@ class TimeSeriesSource(object): ...@@ -666,7 +668,7 @@ class TimeSeriesSource(object):
loptions = QgsRasterLayer.LayerOptions(loadDefaultStyle=loadDefaultStyle) loptions = QgsRasterLayer.LayerOptions(loadDefaultStyle=loadDefaultStyle)
lyr = QgsRasterLayer(self.uri(), self.name(), 'gdal', options=loptions) lyr = QgsRasterLayer(self.uri(), self.name(), 'gdal', options=loptions)
tprop: QgsRasterLayerTemporalProperties = lyr.temporalProperties() tprop: QgsRasterLayerTemporalProperties = lyr.temporalProperties()
tprop.setActive(True) tprop.setIsActive(True)
tprop.setMode(QgsRasterLayerTemporalProperties.ModeFixedTemporalRange) tprop.setMode(QgsRasterLayerTemporalProperties.ModeFixedTemporalRange)
dtg = self.date().astype(object) dtg = self.date().astype(object)
dt1 = QDateTime(dtg, QTime(0, 0)) dt1 = QDateTime(dtg, QTime(0, 0))
...@@ -2161,10 +2163,10 @@ class TimeSeries(QAbstractItemModel): ...@@ -2161,10 +2163,10 @@ class TimeSeries(QAbstractItemModel):
def writeXml(self, node: QDomElement, doc: QDomDocument) -> bool: def writeXml(self, node: QDomElement, doc: QDomDocument) -> bool:
""" """
Writes the TimeSeires to a QDomNode Writes the TimeSeries to a QDomNode
:param node: :param node: QDomElement
:param doc: :param doc: QDomDocument
:return: :return: bool
""" """
tsNode = doc.createElement('TimeSeries') tsNode = doc.createElement('TimeSeries')
...@@ -2416,10 +2418,8 @@ class TimeSeriesTreeView(QTreeView): ...@@ -2416,10 +2418,8 @@ class TimeSeriesTreeView(QTreeView):
a.setEnabled(len(selectedTSSs) > 0) a.setEnabled(len(selectedTSSs) > 0)
a.triggered.connect(lambda _, tss=selectedTSSs: self.setClipboardUris(tss)) a.triggered.connect(lambda _, tss=selectedTSSs: self.setClipboardUris(tss))
a.setToolTip('Copy path(s) to clipboard.') a.setToolTip('Copy path(s) to clipboard.')
a = menu.addAction('Copy value(s)') a = menu.addAction('Copy value(s)')
a.triggered.connect(lambda: self.onCopyValues()) a.triggered.connect(lambda: self.onCopyValues())
menu.addSeparator() menu.addSeparator()
if isinstance(node, TimeSeriesDate): if isinstance(node, TimeSeriesDate):
...@@ -2470,10 +2470,9 @@ class TimeSeriesTreeView(QTreeView): ...@@ -2470,10 +2470,9 @@ class TimeSeriesTreeView(QTreeView):
iface = qgis.utils.iface iface = qgis.utils.iface
if isinstance(iface, QgisInterface): if isinstance(iface, QgisInterface):
layers = [tss.asRasterLayer() for tss in tssList] layers = [tss.asRasterLayer() for tss in tssList]
QgsProject.instance().addMapLayers(layers, True) QgsProject.instance().addMapLayers(layers)
def setClipboardUris(self, tssList: typing.List[TimeSeriesSource]): def setClipboardUris(self, tssList: typing.List[TimeSeriesSource]):
urls = [] urls = []
paths = [] paths = []
for tss in tssList: for tss in tssList:
......
Supports Markdown
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