Skip to content

Commit cda8866

Browse files
authored
Merge pull request #4626 from alexbruy/otb-update
update Processing OTB provider for 2.18
2 parents 413c6e5 + ad1ba64 commit cda8866

File tree

583 files changed

+26641
-233
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

583 files changed

+26641
-233
lines changed

ci/travis/linux/qt4/before_install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ pushd ${HOME}
2020
curl -L https://github.com/opengisch/osgeo4travis/archive/qt4bin.tar.gz | tar -xzC /home/travis --strip-components=1
2121
curl -L https://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz | tar --strip-components=1 -zxC /home/travis/osgeo4travis
2222

23+
# Download OTB package for Processing tests
24+
wget https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-5.6.0-Linux64.run -O /home/travis/OTB-5.6.0-Linux64.run && sh /home/travis/OTB-5.6.0-Linux64.run
25+
2326
popd
27+
2428
pip install --user autopep8 nose2 pyyaml mock future

ci/travis/linux/qt4/script.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
###########################################################################
1515

1616
export PYTHONPATH=${HOME}/osgeo4travis/lib/python2.7/site-packages/
17-
export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${PATH}
17+
export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${HOME}/OTB-5.6.0-Linux64/bin:${PATH}
1818
export LD_LIBRARY_PATH=${HOME}/osgeo4travis/lib
1919
export CTEST_PARALLEL_LEVEL=1
2020
export CCACHE_CPP2=yes
@@ -24,4 +24,7 @@ if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
2424
chmod -R ugo-w ~/.ccache
2525
fi
2626

27+
# Set OTB application path (installed in before_install.sh script)
28+
export OTB_APPLICATION_PATH=${HOME}/OTB-5.6.0-Linux64/lib/otb/applications
29+
2730
xvfb-run ctest -V -E 'qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|PyQgsDBManagerGpkg' -S ./qgis-test-travis.ctest --output-on-failure

ci/travis/linux/qt5/before_install.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ pushd ${HOME}
2626

2727
curl -L https://github.com/opengisch/osgeo4travis/archive/qt5bin.tar.gz | tar -xzC /home/travis --strip-components=1
2828
curl -L https://cmake.org/files/v3.5/cmake-3.5.0-Linux-x86_64.tar.gz | tar --strip-components=1 -zxC /home/travis/osgeo4travis
29+
30+
# Download OTB package for Processing tests
31+
wget https://www.orfeo-toolbox.org/packages/archives/OTB/OTB-5.6.0-Linux64.run -O /home/travis/OTB-5.6.0-Linux64.run && sh /home/travis/OTB-5.6.0-Linux64.run
32+
2933
popd
3034

3135
pip install psycopg2 numpy nose2 pyyaml mock future

ci/travis/linux/qt5/script.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
###########################################################################
1515

1616
export PYTHONPATH=${HOME}/osgeo4travis/lib/python3.3/site-packages/
17-
export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${PATH}
17+
export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${HOME}/OTB-5.6.0-Linux64/bin:${PATH}
1818
export LD_LIBRARY_PATH=${HOME}/osgeo4travis/lib
1919
export CTEST_PARALLEL_LEVEL=1
2020
export CCACHE_TEMPDIR=/tmp
@@ -25,5 +25,8 @@ fi
2525

2626
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2727

28+
# Set OTB application path (installed in before_install.sh script)
29+
export OTB_APPLICATION_PATH=${HOME}/OTB-5.6.0-Linux64/lib/otb/applications
30+
2831
xvfb-run ctest -V -E "qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|qgis_ogcutilstest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
2932
# xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest" -S ./qgis-test-travis.ctest --output-on-failure

python/plugins/processing/algs/otb/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@ FILE(GLOB HELPER_FILES helper/*.py)
33
FILE(GLOB DESCR_FILES description/5.0.0/*.xml)
44
FiLE(GLOB HELP_FILES description/5.0.0/doc/*.html)
55

6+
FILE(GLOB DESCR_FILES description/5.6.0/*.xml)
7+
FiLE(GLOB HELP_FILES description/5.6.0/doc/*.html)
8+
9+
FILE(GLOB DESCR_FILES description/5.8.0/*.xml)
10+
FiLE(GLOB HELP_FILES description/5.8.0/doc/*.html)
11+
612
PLUGIN_INSTALL(processing ./algs/otb ${PY_FILES})
713
PLUGIN_INSTALL(processing ./algs/otb/helper ${HELPER_FILES})
14+
815
PLUGIN_INSTALL(processing ./algs/otb/description/5.0.0 ${DESCR_FILES})
916
PLUGIN_INSTALL(processing ./algs/otb/description/5.0.0/doc ${HELP_FILES})
17+
18+
PLUGIN_INSTALL(processing ./algs/otb/description/5.6.0 ${DESCR_FILES})
19+
PLUGIN_INSTALL(processing ./algs/otb/description/5.6.0/doc ${HELP_FILES})
20+
21+
PLUGIN_INSTALL(processing ./algs/otb/description/5.8.0 ${DESCR_FILES})
22+
PLUGIN_INSTALL(processing ./algs/otb/description/5.8.0/doc ${HELP_FILES})

python/plugins/processing/algs/otb/OTBAlgorithm.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, descriptionfile):
6363
self.defineCharacteristicsFromFile()
6464
self.numExportedLayers = 0
6565
self.hasROI = None
66+
self._icon = None
6667

6768
def __str__(self):
6869
return("Algo : " + self.name + " from app : " + self.cliName + " in : " + self.group)
@@ -73,7 +74,9 @@ def getCopy(self):
7374
return newone
7475

7576
def getIcon(self):
76-
return QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
77+
if self._icon is None:
78+
self._icon = QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
79+
return self._icon
7780

7881
def help(self):
7982
version = OTBUtils.getInstalledVersion()
@@ -124,8 +127,8 @@ def get_list_from_node(self, myet):
124127
return all_params
125128

126129
def defineCharacteristicsFromFile(self):
127-
content = open(self.descriptionFile).read()
128-
dom_model = ET.fromstring(content)
130+
with open(self.descriptionFile) as content:
131+
dom_model = ET.fromstring(content.read())
129132

130133
self.appkey = dom_model.find('key').text
131134
self.cliName = dom_model.find('exec').text
@@ -175,7 +178,7 @@ def processAlgorithm(self, progress):
175178
path = OTBUtils.otbPath()
176179

177180
commands = []
178-
commands.append(path + os.sep + self.cliName)
181+
commands.append(os.path.join(path, self.cliName))
179182

180183
self.roiVectors = {}
181184
self.roiRasters = {}

python/plugins/processing/algs/otb/OTBAlgorithmProvider.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def _loadAlgorithms(self):
6060

6161
version = OTBUtils.getInstalledVersion(True)
6262
if version is None:
63-
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
64-
self.tr('Problem with OTB installation: OTB was not found or is not correctly installed'))
6563
return
6664

6765
folder = OTBUtils.compatibleDescriptionPath(version)

python/plugins/processing/algs/otb/OTBUtils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def otbGeoidPath():
116116
def otbDescriptionPath():
117117
return os.path.join(os.path.dirname(__file__), "description")
118118

119+
119120
_installedVersion = None
120121
_installedVersionFound = False
121122

@@ -142,7 +143,10 @@ def getInstalledVersion(runOtb=False):
142143

143144

144145
def compatibleDescriptionPath(version):
145-
supportedVersions = {"5.0.0": "5.0.0"}
146+
supportedVersions = {"5.0.0": "5.0.0",
147+
"5.4.0": "5.4.0",
148+
"5.6.0": "5.6.0",
149+
"5.8.0": "5.8.0"}
146150
if version is None:
147151
return None
148152
if version not in supportedVersions:
@@ -274,10 +278,9 @@ def remove_parameter_by_criteria(doc, criteria):
274278

275279

276280
def defaultWrite(available_app, original_dom_document):
277-
fh = open("description/%s.xml" % available_app, "w")
278-
the_root = original_dom_document
279-
ET.ElementTree(the_root).write(fh)
280-
fh.close()
281+
with open("description/%s.xml" % available_app, "w") as fh:
282+
the_root = original_dom_document
283+
ET.ElementTree(the_root).write(fh)
281284

282285

283286
def defaultSplit(available_app, original_dom_document, parameter):
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<root>
2+
<key>BandMath</key>
3+
<exec>otbcli_BandMath</exec>
4+
<longname>Band Math</longname>
5+
<group>Miscellaneous</group>
6+
<description>Perform a mathematical operation on monoband images</description>
7+
<parameter>
8+
<parameter_type source_parameter_type="ParameterType_InputImageList">ParameterMultipleInput</parameter_type>
9+
<key>il</key>
10+
<name>Input image list</name>
11+
<description>Image list to perform computation on.</description>
12+
<datatype />
13+
<optional>False</optional>
14+
</parameter>
15+
<parameter>
16+
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputRaster</parameter_type>
17+
<key>out</key>
18+
<name>Output Image</name>
19+
<description>Output image.</description>
20+
<hidden />
21+
</parameter>
22+
<parameter>
23+
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
24+
<key>ram</key>
25+
<name>Available RAM (Mb)</name>
26+
<description>Available memory for processing (in MB)</description>
27+
<minValue />
28+
<maxValue />
29+
<default>128</default>
30+
<optional>True</optional>
31+
</parameter>
32+
<parameter>
33+
<parameter_type source_parameter_type="ParameterType_String">ParameterString</parameter_type>
34+
<key>exp</key>
35+
<name>Expression</name>
36+
<description>The mathematical expression to apply.
37+
Use im1b1 for the first band, im1b2 for the second one...</description>
38+
<default />
39+
<multiline />
40+
<optional>False</optional>
41+
</parameter>
42+
</root>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<root>
2+
<key>BinaryMorphologicalOperation-closing</key>
3+
<exec>otbcli_BinaryMorphologicalOperation</exec>
4+
<longname>BinaryMorphologicalOperation (closing)</longname>
5+
<group>Feature Extraction</group>
6+
<description>Performs morphological operations on an input image channel</description>
7+
<parameter>
8+
<parameter_type source_parameter_type="ParameterType_InputImage">ParameterRaster</parameter_type>
9+
<key>in</key>
10+
<name>Input Image</name>
11+
<description>The input image to be filtered.</description>
12+
<optional>False</optional>
13+
</parameter>
14+
<parameter>
15+
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputRaster</parameter_type>
16+
<key>out</key>
17+
<name>Feature Output Image</name>
18+
<description>Output image containing the filtered output image.</description>
19+
<hidden />
20+
</parameter>
21+
<parameter>
22+
<parameter_type source_parameter_type="ParameterType_Int">ParameterNumber</parameter_type>
23+
<key>channel</key>
24+
<name>Selected Channel</name>
25+
<description>The selected channel index</description>
26+
<minValue />
27+
<maxValue />
28+
<default>1</default>
29+
<optional>False</optional>
30+
</parameter>
31+
<parameter>
32+
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
33+
<key>ram</key>
34+
<name>Available RAM (Mb)</name>
35+
<description>Available memory for processing (in MB)</description>
36+
<minValue />
37+
<maxValue />
38+
<default>128</default>
39+
<optional>True</optional>
40+
</parameter>
41+
<parameter>
42+
<parameter_type source_parameter_type="ParameterType_Choice">ParameterSelection</parameter_type>
43+
<key>structype</key>
44+
<name>Structuring Element Type</name>
45+
<description>Choice of the structuring element type</description>
46+
<options>
47+
<choices>
48+
<choice>ball</choice>
49+
</choices>
50+
</options>
51+
<default>0</default>
52+
<optional>False</optional>
53+
</parameter>
54+
<parameter>
55+
<parameter_type source_parameter_type="ParameterType_Int">ParameterNumber</parameter_type>
56+
<key>structype.ball.xradius</key>
57+
<name>The Structuring Element Radius</name>
58+
<description>The Structuring Element Radius</description>
59+
<minValue />
60+
<maxValue />
61+
<default>5</default>
62+
<optional>False</optional>
63+
</parameter>
64+
<parameter>
65+
<parameter_type source_parameter_type="ParameterType_Choice">ParameterSelection</parameter_type>
66+
<key>filter</key>
67+
<name>Morphological Operation</name>
68+
<description>Choice of the morphological operation</description>
69+
<options>
70+
<choices>
71+
<choice>closing</choice>
72+
</choices>
73+
</options>
74+
<default>0</default>
75+
<optional>False</optional>
76+
</parameter>
77+
</root>

0 commit comments

Comments
 (0)