Commit 7881f4b6 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files

added dummy VRT files (raster/vector)

improved rendering dialog (WIP)
parent de5dcc4e
......@@ -107,30 +107,8 @@ def icon():
path = os.path.join(os.path.dirname(__file__), 'icon.png')
return QIcon(path)
def file_search(rootdir, pattern, recursive=False, ignoreCase=False):
assert os.path.isdir(rootdir), "Path is not a directory:{}".format(rootdir)
regType = type(re.compile('.*'))
results = []
for root, dirs, files in os.walk(rootdir):
for file in files:
if isinstance(pattern, regType):
if pattern.search(file):
path = os.path.join(root, file)
results.append(path)
elif (ignoreCase and fnmatch.fnmatch(file.lower(), pattern.lower())) \
or fnmatch.fnmatch(file, pattern):
path = os.path.join(root, file)
results.append(path)
if not recursive:
break
pass
return results
import timeseriesviewer.utils
file_search = timeseriesviewer.utils.file_search
def getFileAndAttributes(file):
......
<VRTDataset rasterXSize="1" rasterYSize="1">
<GeoTransform> 0.0000000000000000e+00, 1.0000000000000000e+00, 0.0000000000000000e+00, 0.0000000000000000e+00, 0.0000000000000000e+00, -1.0000000000000000e+00</GeoTransform>
<VRTRasterBand dataType="Float32" band="1">
<Metadata>
<MDI key="STATISTICS_MAXIMUM">0</MDI>
<MDI key="STATISTICS_MEAN">0</MDI>
<MDI key="STATISTICS_MINIMUM">0</MDI>
<MDI key="STATISTICS_STDDEV">0</MDI>
</Metadata>
<Description>Band 1</Description>
</VRTRasterBand>
</VRTDataset>
<OGRVRTDataSource>
<OGRVRTLayer name="dummy_layer1">
</OGRVRTLayer>
</OGRVRTDataSource>
\ No newline at end of file
......@@ -277,7 +277,9 @@ class MapLayerInfo(object):
self.mProvider == 'gdal' and isinstance(renderer, QgsRasterRenderer):
self.mRenderer = renderer
if self.isInitialized():
from timeseriesviewer.mapvisualization import cloneRenderer
copyRenderer(self.mRenderer, self.mLayer)
#self.mLayer.repaintRequested.emit()
def setIsVisible(self, b):
......
This diff is collapsed.
......@@ -71,14 +71,18 @@ def setCurrentComboBoxValue(comboBox, value):
class Option(object):
def __init__(self, value, name=None, tooltip='', icon=QIcon()):
def __init__(self, value, name=None, tooltip='', icon=None, **kwargs ):
self.mValue = value
if name is None:
name = str(value)
self.mName = name
self.mTooltip = tooltip
self.mIcon = None
self.mIcon = icon
for k, v in kwargs.items():
assert k not in self.__dict__.keys()
self.__dict__[k] = v
def value(self):
return self.mValue
......@@ -110,6 +114,10 @@ class OptionListModel(QAbstractListModel):
def __iter__(self):
return iter(self.mOptions)
def __len__(self):
return len(self.mOptions)
def containsValue(self, value):
return value in self.optionValues()
......
......@@ -496,7 +496,7 @@ class TimeSeries(QObject):
_sep = ';'
def sensors(self):
return self.Sensors.keys()
return list(self.Sensors.keys())
def loadFromFile(self, path, n_max=None):
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>286</width>
<height>339</height>
<width>290</width>
<height>241</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -18,7 +18,7 @@
</property>
<property name="maximumSize">
<size>
<width>290</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
......@@ -75,12 +75,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>263</width>
<height>333</height>
<width>267</width>
<height>235</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
......@@ -356,25 +356,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="renderSettingsLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
</layout>
</item>
</layout>
</widget>
</item>
......@@ -383,10 +364,13 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>25</height>
<height>0</height>
</size>
</property>
</spacer>
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MapViewRenderSettings</class>
<widget class="QGroupBox" name="MapViewRenderSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>86</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="windowTitle">
<string>RenderSettings</string>
</property>
<property name="styleSheet">
<string notr="true">QFrame::title{color: rgb(0, 0, 127);}</string>
</property>
<property name="title">
<string>&lt;sensor/product&gt;</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelRenderer">
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
<kerning>true</kerning>
</font>
</property>
<property name="toolTip">
<string>Sensor name</string>
</property>
<property name="text">
<string>Style</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cbRenderType">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnPasteStyle">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnCopyStyle">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnApplyStyle">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/timeseriesviewer/icons/mActionRefresh.png</normaloff>:/timeseriesviewer/icons/mActionRefresh.png</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
<action name="actionSetDefaultMB">
<property name="text">
<string>Def</string>
</property>
<property name="toolTip">
<string>Set default band selection</string>
</property>
</action>
<action name="actionSetTrueColor">
<property name="text">
<string>True</string>
</property>
<property name="toolTip">
<string>Set to true color (red-green-blue)</string>
</property>
</action>
<action name="actionSetCIR">
<property name="text">
<string>CIR1</string>
</property>
<property name="toolTip">
<string>Set to coloured infra red (swIR-red-green)</string>
</property>
</action>
<action name="actionSet453">
<property name="text">
<string>CIR2</string>
</property>
<property name="toolTip">
<string>Set to swIR-mwIR-red</string>
</property>
</action>
<action name="actionCopyStyle">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</normaloff>:/timeseriesviewer/icons/mActionEditCopy.svg</iconset>
</property>
<property name="text">
<string>Copy style</string>
</property>
<property name="toolTip">
<string>Copy style to clipboard</string>
</property>
</action>
<action name="actionPasteStyle">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</normaloff>:/timeseriesviewer/icons/mActionEditPaste.svg</iconset>
</property>
<property name="text">
<string>Paste Style</string>
</property>
<property name="toolTip">
<string>Paste style from clipboard</string>
</property>
</action>
<action name="actionApplyStyle">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/timeseriesviewer/icons/mActionRefresh.png</normaloff>:/timeseriesviewer/icons/mActionRefresh.png</iconset>
</property>
<property name="text">
<string>ApplySettings</string>
</property>
<property name="toolTip">
<string>Apply Style</string>
</property>
</action>
<action name="actionSetR">
<property name="text">
<string>R</string>
</property>
</action>
<action name="actionSetG">
<property name="text">
<string>G</string>
</property>
</action>
<action name="actionSetB">
<property name="text">
<string>B</string>
</property>
</action>
<action name="actionSetNIR">
<property name="text">
<string>nIR</string>
</property>
</action>
<action name="actionSetSWIR">
<property name="text">
<string>swIR</string>
</property>
</action>
<action name="actionSetDefaultSB">
<property name="text">
<string>Def</string>
</property>
</action>
</widget>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>cbRenderType</sender>
<signal>currentIndexChanged(int)</signal>
<receiver>stackedWidget</receiver>
<slot>setCurrentIndex(int)</slot>
<hints>
<hint type="sourcelabel">
<x>107</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>144</x>
<y>54</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -20,7 +20,7 @@
"""
# noinspection PyPep8Naming
import os, sys, math, re, io
import os, sys, math, re, io, fnmatch
from collections import defaultdict
......@@ -58,6 +58,30 @@ def qgisInstance():
return None
def file_search(rootdir, pattern, recursive=False, ignoreCase=False):
assert os.path.isdir(rootdir), "Path is not a directory:{}".format(rootdir)
regType = type(re.compile('.*'))
results = []
for root, dirs, files in os.walk(rootdir):
for file in files:
if isinstance(pattern, regType):
if pattern.search(file):
path = os.path.join(root, file)
results.append(path)
elif (ignoreCase and fnmatch.fnmatch(file.lower(), pattern.lower())) \
or fnmatch.fnmatch(file, pattern):
path = os.path.join(root, file)
results.append(path)
if not recursive:
break
pass
return results
def appendItemsToMenu(menu, itemsToAdd):
"""
Appends items to QMenu "menu"
......@@ -555,6 +579,172 @@ class KeepRefs(object):
def defaultBands(dataset):
"""
Returns a list of 3 default bands
:param dataset:
:return:
"""
if isinstance(dataset, str):
return defaultBands(gdal.Open(dataset))
elif isinstance(dataset, QgsRasterDataProvider):
return defaultBands(dataset.dataSourceUri())
elif isinstance(dataset, QgsRasterLayer):
return defaultBands(dataset.source())
elif isinstance(dataset, gdal.Dataset):
db = dataset.GetMetadataItem(str('default_bands'), str('ENVI'))
if db != None:
db = [int(n) for n in re.findall('\d+')]
return db
db = [0, 0, 0]
cis = [gdal.GCI_RedBand, gdal.GCI_GreenBand, gdal.GCI_BlueBand]
for b in range(dataset.RasterCount):
band = dataset.GetRasterBand(b + 1)
assert isinstance(band, gdal.Band)
ci = band.GetColorInterpretation()
if ci in cis:
db[cis.index(ci)] = b
if db != [0, 0, 0]:
return db
rl = QgsRasterLayer(dataset.GetFileList()[0])
defaultRenderer = rl.renderer()
if isinstance(defaultRenderer, QgsRasterRenderer):
db = defaultRenderer.usesBands()
if len(db) == 0:
return [0, 1, 2]
if len(db) > 3:
db = db[0:3]
db = [b-1 for b in db]
return db
else:
raise Exception()
######### Lookup tables
METRIC_EXPONENTS = {
"nm": -9, "um": -6, u"µm": -6, "mm": -3, "cm": -2, "dm": -1, "m": 0, "hm": 2, "km": 3
}
# add synonyms
METRIC_EXPONENTS['nanometers'] = METRIC_EXPONENTS['nm']
METRIC_EXPONENTS['micrometers'] = METRIC_EXPONENTS['um']
METRIC_EXPONENTS['millimeters'] = METRIC_EXPONENTS['mm']
METRIC_EXPONENTS['centimeters'] = METRIC_EXPONENTS['cm']
METRIC_EXPONENTS['decimeters'] = METRIC_EXPONENTS['dm']
METRIC_EXPONENTS['meters'] = METRIC_EXPONENTS['m']