Commit 1166c518 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files
parent 1772dde7
......@@ -1733,30 +1733,30 @@ class EOTimeSeriesViewer(QgisInterface, QObject):
return vectorLayers
def addTimeSeriesImages(self, files: list, loadAsync: bool = True):
def addTimeSeriesImages(self, image_sources: list, loadAsync: bool = True):
"""
Adds images to the time series
:param files:
:param image_sources:
"""
if files is None:
if image_sources is None:
s = settings.settings()
defDir = s.value('dir_datasources')
filters = QgsProviderRegistry.instance().fileRasterFilters()
files, filter = QFileDialog.getOpenFileNames(
image_sources, filter = QFileDialog.getOpenFileNames(
directory=defDir,
filter=filters,
parent=self.ui,
# options=QFileDialog.DontUseNativeDialog #none-native is too slow
)
if len(files) > 0 and os.path.exists(files[0]):
dn = os.path.dirname(files[0])
if len(image_sources) > 0 and os.path.exists(image_sources[0]):
dn = os.path.dirname(image_sources[0])
s.setValue('dir_datasources', dn)
if files:
self.mTimeSeries.addSources(files, runAsync=loadAsync)
if image_sources:
self.mTimeSeries.addSources(image_sources, runAsync=loadAsync)
def clearTimeSeries(self):
......
......@@ -34,7 +34,7 @@ import urllib
from osgeo import osr, ogr, gdal_array
from eotimeseriesviewer import DIR_UI
from eotimeseriesviewer.utils import relativePath
from eotimeseriesviewer.utils import relativePath, gdalDataset
from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtWidgets import *
......@@ -439,7 +439,7 @@ class TimeSeriesSource(object):
@classmethod
def fromJson(cls, jsonData: str):
"""
Returs a TimeSeriesSource from its JSON representation
Returns a TimeSeriesSource from its JSON representation
:param json:
:return:
"""
......@@ -529,8 +529,8 @@ class TimeSeriesSource(object):
self.mSpatialExtent = None
self.mTimeSeriesDate = None
if isinstance(dataset, str):
dataset = gdal.Open(dataset)
dataset = gdalDataset(dataset)
if isinstance(dataset, gdal.Dataset):
assert dataset.RasterCount > 0
......@@ -760,14 +760,6 @@ class TimeSeriesSource(object):
"""
return gdal.Open(self.uri())
def asArray(self) -> np.ndarray:
"""
Returns the entire image as numpy array
:return:
:rtype:
"""
return gdal_array.LoadFile(self.uri())
def isVisible(self) -> bool:
return self.mIsVisible
......
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