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):
archive.clearProjectFile()
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):
return False
......
......@@ -1212,14 +1212,13 @@ class MapCanvas(QgsMapCanvas):
dtg = self.tsd().date().astype(object)
dt1 = QDateTime(dtg, QTime(0, 0))
dt2 = QDateTime(dtg, QTime(QTime(23, 59, 59)))
print(f'## LAYER DTG: {dtg}')
tprop.setFixedTemporalRange(QgsDateTimeRange(dt1, dt2))
layers.append(l)
else:
layers.append(l)
if len(layers) > 0 and isinstance(qgis.utils.iface, QgisInterface):
QgsProject.instance().addMapLayers(layers, True)
QgsProject.instance().addMapLayers(layers)
def onPasteStyleFromClipboard(self, lyr):
from .externals.qps.layerproperties import pasteStyleFromClipboard
......
......@@ -207,17 +207,6 @@ class SensorInstrument(QObject):
SensorNameSettingsPrefix = 'SensorName.'
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):
super(SensorInstrument, self).__init__()
......@@ -267,7 +256,20 @@ class SensorInstrument(QObject):
if self.wlu is not None:
self.mMockupDS.SetMetadataItem('wavelength units', self.wlu)
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):
......@@ -666,7 +668,7 @@ class TimeSeriesSource(object):
loptions = QgsRasterLayer.LayerOptions(loadDefaultStyle=loadDefaultStyle)
lyr = QgsRasterLayer(self.uri(), self.name(), 'gdal', options=loptions)
tprop: QgsRasterLayerTemporalProperties = lyr.temporalProperties()
tprop.setActive(True)
tprop.setIsActive(True)
tprop.setMode(QgsRasterLayerTemporalProperties.ModeFixedTemporalRange)
dtg = self.date().astype(object)
dt1 = QDateTime(dtg, QTime(0, 0))
......@@ -2161,10 +2163,10 @@ class TimeSeries(QAbstractItemModel):
def writeXml(self, node: QDomElement, doc: QDomDocument) -> bool:
"""
Writes the TimeSeires to a QDomNode
:param node:
:param doc:
:return:
Writes the TimeSeries to a QDomNode
:param node: QDomElement
:param doc: QDomDocument
:return: bool
"""
tsNode = doc.createElement('TimeSeries')
......@@ -2416,10 +2418,8 @@ class TimeSeriesTreeView(QTreeView):
a.setEnabled(len(selectedTSSs) > 0)
a.triggered.connect(lambda _, tss=selectedTSSs: self.setClipboardUris(tss))
a.setToolTip('Copy path(s) to clipboard.')
a = menu.addAction('Copy value(s)')
a.triggered.connect(lambda: self.onCopyValues())
menu.addSeparator()
if isinstance(node, TimeSeriesDate):
......@@ -2470,10 +2470,9 @@ class TimeSeriesTreeView(QTreeView):
iface = qgis.utils.iface
if isinstance(iface, QgisInterface):
layers = [tss.asRasterLayer() for tss in tssList]
QgsProject.instance().addMapLayers(layers, True)
QgsProject.instance().addMapLayers(layers)
def setClipboardUris(self, tssList: typing.List[TimeSeriesSource]):
urls = []
paths = []
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