Skip to content

Commit b9c2ab2

Browse files
authored
Merge pull request #3646 from alexbruy/processing-otb-test
[processing] add tests for OTB algorithms
2 parents a3ebc7b + df90e6b commit b9c2ab2

File tree

7 files changed

+107
-17
lines changed

7 files changed

+107
-17
lines changed

ci/travis/linux/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 termcolor

ci/travis/linux/script.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
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
2121

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def getInstalledVersion(runOtb=False):
143143

144144

145145
def compatibleDescriptionPath(version):
146-
supportedVersions = {"5.0.0": "5.0.0", "5.6.0": "5.6.0"}
146+
supportedVersions = {"5.0.0": "5.0.0", "5.4.0": "5.4.0", "5.6.0": "5.6.0"}
147147
if version is None:
148148
return None
149149
if version not in supportedVersions:
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
Requirements
22
============
33

4-
QGIS
5-
----
6-
Python plugins
7-
--------------
84
Set OTB environment
95
--------------------
10-
6+
```
117
export PYTHONPATH=/path/to/OTB/install/lib/otb/python/:$PYTHONPATH
12-
# Environment variable for old OTB versions
8+
# Environment variable for old OTB versions (< 5.2)
139
export ITK_AUTOLOAD_PATH=/path/to/OTB/install/lib/otb/applications/
14-
# Environment variable for new OTB versions
10+
# Environment variable for new OTB versions (>= 5.2)
1511
export OTB_APPLICATION_PATH=/path/to/OTB/install/lib/otb/applications/
1612
# Set LD_LIBRARY_PATH
1713
export LD_LIBRARY_PATH=/path/to/OTB/install/lib/:$LD_LIBRARY_PATH
14+
```
1815

1916
Set QGIS environment
2017
---------------------
18+
19+
```
2120
export QGIS_PREFIX_PATH=/path/to/QGIS/install
22-
export PYTHONPATH=:/usr/share/qgis/python/plugins:~/.qgis3/python/plugins:$PYTHONPATH
21+
export PYTHONPATH=$QGIS_PREFIX_PATH/share/qgis/python:$QGIS_PREFIX_PATH/share/qgis/python/plugins:$PYTHONPATH
2322
# Set LD_LIBRARY_PATH
2423
export LD_LIBRARY_PATH=$QGIS_PREFIX_PATH/lib/:$LD_LIBRARY_PATH
2524
# Add maintenance folder to python path
2625
export PYTHONPATH=/path/to/QGIS/src/python/plugins/processing/algs/otb/maintenance:$PYTHONPATH
26+
```
2727

2828
Check the white and black list for the current OTB version
2929
----------------------------------------------------------
30-
In the maintenance directory, the OTB applications are split in two files black_list.xml and white_list.xml.
31-
These files are organized as follows :
32-
For each OTB version, a new node version with id as attribute is added to the node data.
33-
Each application is then added in the node app_name.
30+
In the maintenance directory, the OTB applications are split in two files `black_list.xml` and `white_list.xml`.
31+
These files are organized as follows. For each OTB version, a new node version with id as attribute is added
32+
to the node data. Each application is then added in the node app_name.
33+
3434
```xml
3535
<?xml version="1.0"?>
3636
<data>
@@ -52,14 +52,18 @@ Each application is then added in the node app_name.
5252
</version>
5353
</data>
5454
```
55+
5556
The list of available applications for each version is not fixed.
5657

5758
OTBSpecific_XMLcreation.py
5859
--------------------------
59-
Warning : Some of the applications needs to be split to be user-friendly. Here comes the file OTBSpecific_XMLcreation.py.
60-
Each function follows the pattern getNameOfTheOTBApplication().
60+
Warning: Some of the applications needs to be split to be user-friendly. Here comes the file `OTBSpecific_XMLcreation.py`.
61+
Each function follows the pattern `getNameOfTheOTBApplication()`.
6162

6263
Creating xml files
6364
------------------
65+
66+
```
6467
cd /path/to/QGIS/src/python/plugins/processing/algs/otb/maintenance
65-
python ./OTBHelper.py
68+
python ./OTBHelper.py
69+
```

python/plugins/processing/tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ IF(ENABLE_TESTS)
1212
ADD_PYTHON_TEST(ProcessingGdalAlgorithmsTest GdalAlgorithmsTest.py)
1313
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsImageryTest Grass7AlgorithmsImageryTest.py)
1414
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTest Grass7AlgorithmsRasterTest.py)
15+
ADD_PYTHON_TEST(ProcessingOTBAlgorithmsTest OTBAlgorithmsTest.py)
1516
ENDIF(ENABLE_TESTS)
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
OTBAlgorithmTests.py
6+
---------------------
7+
Date : August 2016
8+
Copyright : (C) 2016 by Manuel Grizonnet
9+
Email : manuel.grizonnet@cnes.fr
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Manuel Grizonnet'
21+
__date__ = 'August 2016'
22+
__copyright__ = '(C) 2016, Manuel Grizonnet'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = ':%H$'
27+
28+
import AlgorithmsTestBase
29+
30+
import nose2
31+
import shutil
32+
33+
from qgis.testing import (
34+
start_app,
35+
unittest
36+
)
37+
38+
39+
class TestOTBAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):
40+
41+
@classmethod
42+
def setUpClass(cls):
43+
start_app()
44+
from processing.core.Processing import Processing
45+
Processing.initialize()
46+
cls.cleanup_paths = []
47+
48+
@classmethod
49+
def tearDownClass(cls):
50+
for path in cls.cleanup_paths:
51+
shutil.rmtree(path)
52+
53+
def test_definition_file(self):
54+
return 'otb_algorithm_tests.yaml'
55+
56+
57+
if __name__ == '__main__':
58+
nose2.main()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# See ../README.md for a description of the file format
2+
3+
tests:
4+
5+
- algorithm: otb:imageconversion
6+
name: Test (otb:imageconversion)
7+
params:
8+
-hcp.high: 2
9+
-hcp.low: 2
10+
-in:
11+
name: raster.tif
12+
type: raster
13+
-ram: 128
14+
-type: '1'
15+
-type.linear.gamma: 1
16+
results:
17+
-out:
18+
hash: b3657f4d848b64f688db41638ea6d86d9de1d0a169bc1bafef8af82a
19+
type: rasterhash
20+

0 commit comments

Comments
 (0)