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

fixed CRS issue

added context menu shortcuts
parent 6efeda69
Pipeline #12371 failed
......@@ -21,7 +21,7 @@
# noinspection PyPep8Naming
__version__ = '1.12' # sub-subversion number is added automatically
__version__ = '1.13' # sub-subversion number is added automatically
LICENSE = 'GNU GPL-3'
TITLE = 'EO Time Series Viewer'
LOG_MESSAGE_TAG = TITLE
......
......@@ -40,7 +40,14 @@ if os.path.exists(path):
import qgis.utils
from qgis.core import *
from qgis.core import QgsMapLayer, QgsRasterLayer, QgsVectorLayer, QgsMessageOutput, QgsCoordinateReferenceSystem, \
Qgis, QgsWkbTypes, QgsTask, QgsProviderRegistry, QgsMapLayerStore, QgsFeature, \
QgsTextFormat, QgsProject, QgsSingleSymbolRenderer, QgsGeometry, QgsApplication, QgsFillSymbol
from qgis.gui import *
from qgis.gui import QgsMapCanvas, QgsStatusBar, QgsFileWidget, \
QgsMessageBar, QgsMessageViewer, QgsDockWidget, QgsTaskManagerWidget, QgisInterface
import qgis.utils
from eotimeseriesviewer.utils import *
from eotimeseriesviewer.timeseries import *
......@@ -519,6 +526,7 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
assert isinstance(tstv, TimeSeriesTreeView)
tstv.sigMoveToDateRequest.connect(self.setCurrentDate)
tstv.sigMoveToSource.connect(self.setCurrentSource)
tstv.sigSetMapCrs.connect(self.setCrs)
self.mCurrentMapLocation = None
self.mCurrentMapSpectraLoading = 'TOP'
......@@ -641,11 +649,9 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
self.initQGISConnection()
for toolBar in self.ui.findChildren(QToolBar):
fixMenuButtons(toolBar)
self.ui.dockTimeSeries.setFloating(True)
self.ui.dockTimeSeries.setFloating(False)
......@@ -852,6 +858,9 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
self.mapWidget().setCurrentLayer(layer)
self.updateCurrentLayerActions()
def crs(self) -> QgsCoordinateReferenceSystem:
return self.mapWidget().crs()
def setCurrentSource(self, tss: TimeSeriesSource):
"""
Moves the map view to a TimeSeriesSource
......@@ -859,7 +868,19 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
tss = self.timeSeries().findSource(tss)
if isinstance(tss, TimeSeriesSource):
self.ui.mMapWidget.setCurrentDate(tss.timeSeriesDate())
self.ui.mMapWidget.setSpatialExtent(tss.spatialExtent())
ext = tss.spatialExtent().toCrs(self.crs())
# set to new extent, but do not change the EOTSV CRS
if isinstance(ext, SpatialExtent):
self.setSpatialExtent(ext)
else:
# we cannot transform the coordinate. Try to set the EOTSV center only
center = tss.spatialExtent().spatialCenter().toCrs(self.crs())
if isinstance(center, SpatialPoint):
self.setSpatialCenter(center)
else:
# last resort: we need to change the EOTSV Projection
self.setSpatialExtent(tss.spatialExtent())
def setCurrentDate(self, tsd: TimeSeriesDate):
"""
......@@ -1057,6 +1078,9 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
"""
self.mapWidget().setMapSize(size)
def setCrs(self, crs:QgsCoordinateReferenceSystem):
self.mapWidget().setCrs(crs)
def setSpatialExtent(self, spatialExtent:SpatialExtent):
"""
Sets the map canvas extent
......@@ -1246,7 +1270,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
"""
return self.mapWidget().currentLayer()
def createMapView(self, name:str=None) -> MapView:
"""
Creates a new MapView.
......@@ -1261,7 +1284,6 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
"""
return self.ui.dockMapViews[:]
def icon(self) -> QIcon:
"""
Returns the EO Time Series Viewer icon
......@@ -1316,8 +1338,8 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
extent = self.timeSeries().maxSpatialExtent()
if isinstance(extent, SpatialExtent):
self.ui.dockMapViews.setCrs(extent.crs())
self.ui.mMapWidget.setSpatialExtent(extent)
self.mapWidget().setCrs(extent.crs())
self.mapWidget().setSpatialExtent(extent)
self.mSpatialMapExtentInitialized = True
else:
self.mSpatialMapExtentInitialized = False
......
......@@ -21,26 +21,33 @@
# noinspection PyPep8Naming
KEY_LAST_CLICKED = 'LAST_CLICKED'
import os, time, types, enum
from eotimeseriesviewer import CursorLocationMapTool
from qgis.core import *
from qgis.gui import *
from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtWidgets import *
from qgis.PyQt.QtXml import QDomDocument
import time
from .timeseries import TimeSeriesDate, TimeSeriesSource, SensorProxyLayer, SensorInstrument
import eotimeseriesviewer.settings
import qgis.utils
from .externals.qps.classification.classificationscheme import ClassificationScheme, ClassInfo
from .externals.qps.crosshair.crosshair import CrosshairDialog, CrosshairStyle, CrosshairMapCanvasItem
from .externals.qps.layerproperties import showLayerPropertiesDialog
from .externals.qps.maptools import *
from .labeling import quickLabelLayers, labelShortcutLayerClassificationSchemes, setQuickTSDLabelsForRegisteredLayers
from .externals.qps.classification.classificationscheme import ClassificationScheme, ClassInfo
from .externals.qps.utils import *
from .externals.qps.layerproperties import showLayerPropertiesDialog
import eotimeseriesviewer.settings
from .labeling import quickLabelLayers, setQuickTSDLabelsForRegisteredLayers
from .timeseries import TimeSeriesDate, TimeSeriesSource, SensorProxyLayer
from qgis.core import *
from qgis.gui import *
from qgis.core import QgsMapLayer, QgsRasterLayer, QgsVectorLayer, QgsContrastEnhancement, \
QgsDateTimeRange, QgsProject, QgsTextRenderer, QgsApplication, QgsCoordinateReferenceSystem, \
QgsMapToPixel, QgsRenderContext, QgsMapSettings, \
QgsRasterBandStats, QgsPalettedRasterRenderer, QgsPointXY, \
QgsSingleBandPseudoColorRenderer, QgsWkbTypes, QgsRasterLayerTemporalProperties, QgsRasterDataProvider, \
QgsTextFormat, QgsMapLayerStore, QgsMultiBandColorRenderer, QgsSingleBandGrayRenderer, QgsField, \
QgsRectangle, QgsPolygon, QgsMultiBandColorRenderer , QgsRectangle, QgsSingleBandGrayRenderer, \
QgsLayerTreeGroup
from qgis.gui import QgsMapCanvas, QgisInterface, QgsFloatingWidget, QgsUserInputWidget, \
QgsAdvancedDigitizingDockWidget, \
QgsMapTool, QgsMapToolPan, QgsMapToolZoom, QgsMapToolCapture, QgsMapToolIdentify, \
QgsGeometryRubberBand
PROGRESS_TIMER = QTimer()
PROGRESS_TIMER.start(100)
......@@ -281,7 +288,7 @@ class MapCanvasInfoItem(QgsMapCanvasItem):
class MapCanvasMapTools(QObject):
def __init__(self, canvas:QgsMapCanvas, cadDock:QgsAdvancedDigitizingDockWidget):
def __init__(self, canvas:QgsMapCanvas, cadDock: QgsAdvancedDigitizingDockWidget):
super(MapCanvasMapTools, self).__init__(canvas)
self.mCanvas = canvas
......@@ -421,9 +428,11 @@ class MapCanvas(QgsMapCanvas):
self.setCanvasColor(bg)
self.setContextMenuPolicy(Qt.DefaultContextMenu)
self.extentsChanged.connect(lambda : self.sigSpatialExtentChanged.emit(self.spatialExtent()))
self.extentsChanged.connect(self.onExtentsChanged)
self.destinationCrsChanged.connect(lambda : self.sigDestinationCrsChanged.emit(self.crs()))
def onExtentsChanged(self):
self.sigSpatialExtentChanged.emit(self.spatialExtent())
#self.destinationCrsChanged.connect(lambda: self.sigDestinationCrsChanged.emit(self.crs()))
def userInputWidget(self) -> QgsUserInputWidget:
"""
......@@ -573,14 +582,7 @@ class MapCanvas(QgsMapCanvas):
"""
return self.mTSD
def setSpatialExtent(self, extent:SpatialExtent):
"""
Sets the spatial extent
:param extent: SpatialExtent
"""
assert isinstance(extent, SpatialExtent)
extent = extent.toCrs(self.crs())
self.setExtent(extent)
def setSpatialCenter(self, center:SpatialPoint):
"""
......@@ -600,16 +602,6 @@ class MapCanvas(QgsMapCanvas):
if self.size() != size:
super(MapCanvas, self).setFixedSize(size)
def setCrs(self, crs:QgsCoordinateReferenceSystem):
"""
Sets the
:param crs:
:return:
"""
assert isinstance(crs, QgsCoordinateReferenceSystem)
if self.crs() != crs:
self.setDestinationCrs(crs)
def crs(self) -> QgsCoordinateReferenceSystem:
"""
Shortcut to return self.mapSettings().destinationCrs()
......@@ -617,8 +609,6 @@ class MapCanvas(QgsMapCanvas):
"""
return self.mapSettings().destinationCrs()
def setLayers(self, mapLayers):
"""
Set the map layers and, if necessary, registers the in a QgsMapLayerStore
......@@ -627,7 +617,6 @@ class MapCanvas(QgsMapCanvas):
self.mMapLayerStore.addMapLayers(mapLayers)
super(MapCanvas, self).setLayers(mapLayers)
def isRefreshing(self) -> bool:
return self.mIsRefreshing
......@@ -638,7 +627,6 @@ class MapCanvas(QgsMapCanvas):
"""
return self.visibleRegion().boundingRect().isValid()
def addToRefreshPipeLine(self, arguments: list):
"""
Adds commands or other arguments to a pipeline which will be handled during the next timed refresh.
......@@ -701,6 +689,9 @@ class MapCanvas(QgsMapCanvas):
sourceLayer = SensorProxyLayer(source, sensor=self.tsd().sensor(), options=loptions)
sourceLayer.setName(lyr.name())
sourceLayer.setCustomProperty('eotsv/sensorid', self.tsd().sensor().id())
sourceLayer.mTSS = tss
#tprop:QgsTemporalProperties = sourceLayer.temporalProperties()
try:
renderer = lyr.renderer()
if isinstance(renderer, QgsRasterRenderer):
......@@ -731,19 +722,19 @@ class MapCanvas(QgsMapCanvas):
keys = self.mTimedRefreshPipeLine.keys()
if QgsCoordinateReferenceSystem in keys:
self.setDestinationCrs(self.mTimedRefreshPipeLine[QgsCoordinateReferenceSystem])
self.setDestinationCrs(self.mTimedRefreshPipeLine.pop(QgsCoordinateReferenceSystem))
if SpatialExtent in keys:
self.setSpatialExtent(self.mTimedRefreshPipeLine[SpatialExtent])
self.setSpatialExtent(self.mTimedRefreshPipeLine.pop(SpatialExtent))
if SpatialPoint in keys:
self.setSpatialCenter(self.mTimedRefreshPipeLine[SpatialPoint])
self.setSpatialCenter(self.mTimedRefreshPipeLine.pop(SpatialPoint))
if QColor in keys:
self.setCanvasColor(self.mTimedRefreshPipeLine[QColor])
self.setCanvasColor(self.mTimedRefreshPipeLine.pop(QColor))
if MapCanvas.Command in keys:
commands = self.mTimedRefreshPipeLine[MapCanvas.Command]
commands = self.mTimedRefreshPipeLine.pop(MapCanvas.Command)
for command in commands:
assert isinstance(command, MapCanvas.Command)
if command == MapCanvas.Command.RefreshRenderer:
......@@ -767,7 +758,6 @@ class MapCanvas(QgsMapCanvas):
self.refresh()
# is this really required?
def setLayerVisibility(self, cls, isVisible:bool):
"""
:param cls: type of layer, e.g. QgsRasterLayer to set visibility of all layers of same type
......@@ -900,7 +890,7 @@ class MapCanvas(QgsMapCanvas):
a.setToolTip('Writes the dates and sensor quick labels of selected features in {}.'.format(layerNames))
a.triggered.connect(lambda *args, tsd = self.tsd(), tss=tss: setQuickTSDLabelsForRegisteredLayers(tsd, tss))
from .labeling import CONFKEY_CLASSIFICATIONSCHEME, layerClassSchemes, setQuickClassInfo
from .labeling import layerClassSchemes, setQuickClassInfo
if len(lyrWithSelectedFeatures) == 0:
a = m.addAction('No features selected.')
a.setToolTip('Select feature in the labeling panel to apply Quick label value on.')
......@@ -936,10 +926,8 @@ class MapCanvas(QgsMapCanvas):
action.triggered.connect(lambda *args, lyr=refSensorLayer: self.stretchToExtent(self.spatialExtent(), 'gaussian', layer=lyr, n=3))
menu.addSeparator()
from .externals.qps.layerproperties import pasteStyleFromClipboard, pasteStyleToClipboard
from .externals.qps.layerproperties import pasteStyleToClipboard
b = isinstance(refRasterLayer, QgsRasterLayer)
a = menu.addAction('Copy Style')
......@@ -998,6 +986,12 @@ class MapCanvas(QgsMapCanvas):
a.setEnabled('application/qgis.style' in QApplication.clipboard().mimeData().formats())
a.triggered.connect(lambda *args, lyr=mapLayer: self.onPasteStyleFromClipboard(lyr))
iface = qgis.utils.iface
if isinstance(iface, QgisInterface):
sub.addSeparator()
a = sub.addAction('Open in QGIS')
a.triggered.connect(lambda *args, lyrs=[mapLayer]: self.onOpenLayersInQGIS(lyrs))
menu.addSeparator()
action = menu.addAction('Zoom to full extent')
......@@ -1061,7 +1055,6 @@ class MapCanvas(QgsMapCanvas):
action.triggered.connect(lambda: QApplication.clipboard().setPixmap(mw.grab()))
action.setToolTip('Copies all maps into the clipboard.')
m = menu.addMenu('Map Coordinates...')
ext = self.spatialExtent()
......@@ -1141,7 +1134,7 @@ class MapCanvas(QgsMapCanvas):
return menu
def onSetLayerProperties(self, lyr:QgsRasterLayer):
def onSetLayerProperties(self, lyr: QgsRasterLayer):
# b = isinstance(mapLayer, SensorProxyLayer) == False:
result = showLayerPropertiesDialog(lyr, self, useQGISDialog=True)
......@@ -1152,6 +1145,30 @@ class MapCanvas(QgsMapCanvas):
r.setInput(proxyLayer.dataProvider())
proxyLayer.setRenderer(r)
def onOpenLayersInQGIS(self, mapLayers:typing.List[QgsMapLayer]):
layers = []
for l in mapLayers:
if isinstance(l, SensorProxyLayer):
lyr = QgsRasterLayer(l.source(), l.name(), l.dataProvider().name())
r = l.renderer().clone()
r.setInput(lyr.dataProvider())
lyr.setRenderer(r)
tprop: QgsRasterLayerTemporalProperties = lyr.temporalProperties()
tprop.setMode(QgsRasterLayerTemporalProperties.ModeFixedTemporalRange)
if isinstance(l.mTSS, TimeSeriesSource):
dtg = QDateTime(l.mTSS.date().astype(object))
else:
dtg = QDateTime(self.tsd().date().astype(object))
tprop.setFixedTemporalRange(QgsDateTimeRange(dtg, dtg))
layers.append(l)
else:
layers.append(l)
if len(layers) > 0 and isinstance(qgis.utils.iface, QgisInterface):
QgsProject.instance().addMapLayers(layers, True)
def onPasteStyleFromClipboard(self, lyr):
from .externals.qps.layerproperties import pasteStyleFromClipboard
......@@ -1319,9 +1336,9 @@ class MapCanvas(QgsMapCanvas):
"""
assert isinstance(spatialExtent, SpatialExtent)
if self.spatialExtent() != spatialExtent:
spatialExtent = spatialExtent.toCrs(self.crs())
if isinstance(spatialExtent, SpatialExtent):
self.setExtent(spatialExtent)
if spatialExtent.crs() != self.mapSettings().destinationCrs():
self.mapSettings().setDestinationCrs(spatialExtent.crs())
self.setExtent(spatialExtent)
def setSpatialCenter(self, spatialPoint: SpatialPoint):
"""
......@@ -1337,7 +1354,7 @@ class MapCanvas(QgsMapCanvas):
Returns the map extent as SpatialExtent (extent + CRS)
:return: SpatialExtent
"""
return SpatialExtent.fromMapCanvas(self)
return SpatialExtent(self.crs(), self.extent())
def spatialCenter(self) -> SpatialPoint:
"""
......
......@@ -491,7 +491,7 @@ class MapView(QFrame):
layers = [n.layer() for n in self.mLayerTreeSensorNode.findLayers()]
return [l for l in layers if isinstance(l, SensorProxyLayer)]
def sensorProxyLayer(self, sensor:SensorInstrument) -> SensorProxyLayer:
def sensorProxyLayer(self, sensor: SensorInstrument) -> SensorProxyLayer:
"""
Returns the proxy layer related to a SensorInstrument
:param sensor: SensorInstrument
......@@ -878,7 +878,7 @@ class MapWidget(QFrame):
sigSpatialExtentChanged = pyqtSignal(SpatialExtent)
sigCrosshairPositionChanged = pyqtSignal([SpatialPoint], [SpatialPoint, MapCanvas])
sigCRSChanged = pyqtSignal(QgsCoordinateReferenceSystem)
sigCrsChanged = pyqtSignal(QgsCoordinateReferenceSystem)
sigMapSizeChanged = pyqtSignal(QSize)
sigMapBackgroundColorChanged = pyqtSignal(QColor)
......@@ -920,24 +920,26 @@ class MapWidget(QFrame):
self.mCurrentMapView: MapView = None
self.mCurrentMapCanvas: MapCanvas = None
self.mMapViews = []
self.mCanvases = dict()
self.mMapViews: typing.List[MapView] = []
self.mCanvases: typing.Dict[MapView, typing.List[MapCanvas]] = dict()
self.mCanvasSignals = dict()
self.mTimeSeries = None
self.mTimeSeries: TimeSeries = None
self.mMapToolKey = MapTools.Pan
self.mMapToolKey: MapTools = MapTools.Pan
self.mViewMode = MapWidget.ViewMode.MapViewByRows
self.mMpMV = 3
self.mSpatialExtent = SpatialExtent.world()
self.mCrs = self.mSpatialExtent.crs()
self.mCurrentDate = None
self.mCrosshairPosition = None
self.mSpatialExtent: SpatialExtent = SpatialExtent.world()
self.mCrs: QgsCoordinateReferenceSystem = self.mSpatialExtent.crs()
self.mCrsInitialized = False
self.mCurrentDate: TimeSeriesDate = None
self.mCrosshairPosition: SpatialPoint = None
self.mMapSize = QSize(200, 200)
from eotimeseriesviewer.settings import defaultValues, Keys
DEFAULT_VALUES = defaultValues()
self.mMapTextFormat = DEFAULT_VALUES[Keys.MapTextFormat]
self.mMapRefreshTimer = QTimer(self)
......@@ -1021,26 +1023,32 @@ class MapWidget(QFrame):
"""
return self.mSpatialExtent
def setSpatialExtent(self, extent:SpatialExtent) -> SpatialExtent:
def setSpatialExtent(self, extent: SpatialExtent) -> SpatialExtent:
"""
Sets a SpatialExtent to all MapCanvases.
:param extent: SpatialExtent
:return: SpatialExtent the current SpatialExtent
"""
try:
assert isinstance(extent, SpatialExtent), 'Expected SpatialExtent, but got {} {}'.format(type(extent), extent)
assert isinstance(extent, SpatialExtent), \
'Expected SpatialExtent, but got {} {}'.format(type(extent), extent)
except Exception as ex:
traceback.print_exception(*sys.exc_info())
raise ex
if self.mSpatialExtent == extent:
return
ext = extent.toCrs(self.crs())
if not isinstance(ext, SpatialExtent):
s = ""
# last resort: zoom to CRS boundaries
if self.mSpatialExtent != extent:
self.mSpatialExtent = extent
if isinstance(ext, SpatialExtent) and ext != self.spatialExtent():
self.mSpatialExtent = ext
for c in self.mapCanvases():
assert isinstance(c, MapCanvas)
c.addToRefreshPipeLine(extent)
c.addToRefreshPipeLine(self.mSpatialExtent)
self.sigSpatialExtentChanged.emit(self.mSpatialExtent.__copy__())
return self.spatialExtent()
......@@ -1059,7 +1067,6 @@ class MapWidget(QFrame):
extent.setCenter(centerNew)
self.setSpatialExtent(extent)
def spatialCenter(self) -> SpatialPoint:
"""
Return the center of all map canvas
......@@ -1067,19 +1074,24 @@ class MapWidget(QFrame):
"""
return self.spatialExtent().spatialCenter()
def setCrs(self, crs:QgsCoordinateReferenceSystem) -> QgsCoordinateReferenceSystem:
def setCrs(self, crs: QgsCoordinateReferenceSystem) -> QgsCoordinateReferenceSystem:
"""
Sets the MapCanvas CRS.
:param crs: QgsCoordinateReferenceSystem
:return: QgsCoordinateReferenceSystem
"""
self.mCrs = crs
if isinstance(crs, QgsCoordinateReferenceSystem):
for c in self.mapCanvases():
c.setCrs(crs)
if self.mCrs == crs:
return self.crs()
self.mCrs = QgsCoordinateReferenceSystem(crs)
for i, c in enumerate(self.mapCanvases()):
wasBlocked = c.blockSignals(True)
c.setDestinationCrs(self.mCrs)
if i == 0:
self.mSpatialExtent = SpatialExtent.fromMapCanvas(c)
if not wasBlocked:
c.blockSignals(False)
self.sigCrsChanged.emit(self.crs())
return self.crs()
def timedRefresh(self):
......@@ -1114,7 +1126,6 @@ class MapWidget(QFrame):
if isinstance(mapCanvas.mapView(), MapView):
self.setCurrentMapView(mapCanvas.mapView())
def currentMapView(self) -> MapView:
"""
Returns the last used map view, i.e. the last map view a canvas was clicked on or a layer was selected in
......@@ -1486,8 +1497,8 @@ class MapWidget(QFrame):
# set general canvas properties
mapCanvas.setFixedSize(self.mMapSize)
mapCanvas.setDestinationCrs(self.mCrs)
mapCanvas.setSpatialExtent(self.mSpatialExtent)
mapCanvas.setDestinationCrs(self.crs())
mapCanvas.setSpatialExtent(self.spatialExtent())
# activate the current map tool
mapTools = mapCanvas.mapTools()
......@@ -1499,14 +1510,14 @@ class MapWidget(QFrame):
def _connectCanvasSignals(self, mapCanvas: MapCanvas):
mapCanvas.sigSpatialExtentChanged.connect(self.setSpatialExtent)
mapCanvas.sigDestinationCrsChanged.connect(self.setCrs)
#mapCanvas.sigDestinationCrsChanged.connect(self.setCrs)
mapCanvas.sigCrosshairPositionChanged.connect(self.onCrosshairPositionChanged)
mapCanvas.sigCanvasClicked.connect(self.onCanvasClicked)
mapCanvas.mapTools().mtCursorLocation.sigLocationRequest[SpatialPoint, QgsMapCanvas].connect(self.sigCurrentLocationChanged)
def _disconnectCanvasSignals(self, mapCanvas:MapCanvas):
mapCanvas.sigSpatialExtentChanged.disconnect(self.setSpatialExtent)
mapCanvas.sigDestinationCrsChanged.disconnect(self.setCrs)
#mapCanvas.sigDestinationCrsChanged.disconnect(self.setCrs)
mapCanvas.sigCrosshairPositionChanged.disconnect(self.onCrosshairPositionChanged)
mapCanvas.sigCanvasClicked.disconnect(self.onCanvasClicked)
mapCanvas.mapTools().mtCursorLocation.sigLocationRequest[SpatialPoint, QgsMapCanvas].disconnect(
......@@ -1827,6 +1838,7 @@ class MapViewDock(QgsDockWidget):
self.btnAddMapView.setDefaultAction(self.actionAddMapView)
self.btnRemoveMapView.setDefaultAction(self.actionRemoveMapView)
self.btnCrs:QgsProjectionSelectionWidget
self.btnCrs.setOptionVisible(QgsProjectionSelectionWidget.LayerCrs, True)
self.btnCrs.setOptionVisible(QgsProjectionSelectionWidget.ProjectCrs, True)
self.btnCrs.setOptionVisible(QgsProjectionSelectionWidget.CurrentCrs, True)
......@@ -1867,8 +1879,9 @@ class MapViewDock(QgsDockWidget):
assert mw.timeSeries() == self.mTimeSeries, 'Set the time series first!'
self.mMapWidget = mw
self.btnCrs.setCrs(mw.crs())
self.sigCrsChanged.connect(mw.setCrs)
mw.sigCRSChanged.connect(self.setCrs)
mw.sigCrsChanged.connect(self.setCrs)
self.sigMapSizeChanged.connect(mw.setMapSize)
mw.sigMapSizeChanged.connect(self.setMapSize)
......@@ -1921,7 +1934,7 @@ class MapViewDock(QgsDockWidget):
maps.extend(mapView.mapCanvases())
return maps
def setCrs(self, crs):
def setCrs(self, crs: QgsCoordinateReferenceSystem):
if isinstance(crs, QgsCoordinateReferenceSystem):
old = self.btnCrs.crs()
if old != crs:
......
......@@ -341,12 +341,13 @@ class SensorInstrument(QObject):
return '\n'.join(info)
class SensorProxyLayer(QgsRasterLayer):
def __init__(self, *args, sensor:SensorInstrument, **kwds):
def __init__(self, *args, sensor: SensorInstrument, **kwds):
super(SensorProxyLayer, self).__init__(*args, **kwds)
self.mSensor = sensor
self.mSensor: SensorInstrument = sensor
self.mTSS: TimeSeriesSource = None
def sensor(self) -> SensorInstrument:
"""
......@@ -618,7 +619,12 @@ class TimeSeriesSource(object):
return uri
def asRasterLayer(self) -> QgsRasterLayer:
return QgsRasterLayer(self.uri(), self.name(), 'gdal')
lyr = QgsRasterLayer(self.uri(), self.name(), 'gdal')
tprop: QgsRasterLayerTemporalProperties = lyr.temporalProperties()
tprop.setMode(QgsRasterLayerTemporalProperties.ModeFixedTemporalRange)
dtg = QDateTime(self.date().astype(object))
tprop.setFixedTemporalRange(QgsDateTimeRange(dtg, dtg))
return lyr
def crsWkt(self) -> str:
return self.mWKT
......@@ -1451,6 +1457,7 @@ class TimeSeries(QAbstractItemModel):
idxMin = None
idxMax = None