Skip to content
Permalink
Browse files

Merge pull request #3646 from alexbruy/processing-otb-test

[processing] add tests for OTB algorithms
  • Loading branch information
alexbruy committed Oct 20, 2016
2 parents a3ebc7b + df90e6b commit b9c2ab2b74c0ede9a46119161e1c0a5b4a479cf6
@@ -26,6 +26,10 @@ pushd ${HOME}

curl -L https://github.com/opengisch/osgeo4travis/archive/qt5bin.tar.gz | tar -xzC /home/travis --strip-components=1
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

# Download OTB package for Processing tests
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

popd

pip install psycopg2 numpy nose2 pyyaml mock future termcolor
@@ -14,12 +14,15 @@
###########################################################################

export PYTHONPATH=${HOME}/osgeo4travis/lib/python3.3/site-packages/
export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${PATH}
export PATH=${HOME}/osgeo4travis/bin:${HOME}/osgeo4travis/sbin:${HOME}/OTB-5.6.0-Linux64/bin:${PATH}
export LD_LIBRARY_PATH=${HOME}/osgeo4travis/lib
export CTEST_PARALLEL_LEVEL=1
export CCACHE_TEMPDIR=/tmp

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

# Set OTB application path (installed in before_install.sh script)
export OTB_APPLICATION_PATH=${HOME}/OTB-5.6.0-Linux64/lib/otb/applications

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
# xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest" -S ./qgis-test-travis.ctest --output-on-failure
@@ -143,7 +143,7 @@ def getInstalledVersion(runOtb=False):


def compatibleDescriptionPath(version):
supportedVersions = {"5.0.0": "5.0.0", "5.6.0": "5.6.0"}
supportedVersions = {"5.0.0": "5.0.0", "5.4.0": "5.4.0", "5.6.0": "5.6.0"}
if version is None:
return None
if version not in supportedVersions:
@@ -1,36 +1,36 @@
Requirements
============

QGIS
----
Python plugins
--------------
Set OTB environment
--------------------

```
export PYTHONPATH=/path/to/OTB/install/lib/otb/python/:$PYTHONPATH
# Environment variable for old OTB versions
# Environment variable for old OTB versions (< 5.2)
export ITK_AUTOLOAD_PATH=/path/to/OTB/install/lib/otb/applications/
# Environment variable for new OTB versions
# Environment variable for new OTB versions (>= 5.2)
export OTB_APPLICATION_PATH=/path/to/OTB/install/lib/otb/applications/
# Set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/path/to/OTB/install/lib/:$LD_LIBRARY_PATH
```

Set QGIS environment
---------------------

```
export QGIS_PREFIX_PATH=/path/to/QGIS/install
export PYTHONPATH=:/usr/share/qgis/python/plugins:~/.qgis3/python/plugins:$PYTHONPATH
export PYTHONPATH=$QGIS_PREFIX_PATH/share/qgis/python:$QGIS_PREFIX_PATH/share/qgis/python/plugins:$PYTHONPATH
# Set LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$QGIS_PREFIX_PATH/lib/:$LD_LIBRARY_PATH
# Add maintenance folder to python path
export PYTHONPATH=/path/to/QGIS/src/python/plugins/processing/algs/otb/maintenance:$PYTHONPATH
```

Check the white and black list for the current OTB version
----------------------------------------------------------
In the maintenance directory, the OTB applications are split in two files black_list.xml and white_list.xml.
These files are organized as follows :
For each OTB version, a new node version with id as attribute is added to the node data.
Each application is then added in the node app_name.
In the maintenance directory, the OTB applications are split in two files `black_list.xml` and `white_list.xml`.
These files are organized as follows. For each OTB version, a new node version with id as attribute is added
to the node data. Each application is then added in the node app_name.

```xml
<?xml version="1.0"?>
<data>
@@ -52,14 +52,18 @@ Each application is then added in the node app_name.
</version>
</data>
```

The list of available applications for each version is not fixed.

OTBSpecific_XMLcreation.py
--------------------------
Warning : Some of the applications needs to be split to be user-friendly. Here comes the file OTBSpecific_XMLcreation.py.
Each function follows the pattern getNameOfTheOTBApplication().
Warning: Some of the applications needs to be split to be user-friendly. Here comes the file `OTBSpecific_XMLcreation.py`.
Each function follows the pattern `getNameOfTheOTBApplication()`.

Creating xml files
------------------

```
cd /path/to/QGIS/src/python/plugins/processing/algs/otb/maintenance
python ./OTBHelper.py
python ./OTBHelper.py
```
@@ -12,4 +12,5 @@ IF(ENABLE_TESTS)
ADD_PYTHON_TEST(ProcessingGdalAlgorithmsTest GdalAlgorithmsTest.py)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsImageryTest Grass7AlgorithmsImageryTest.py)
ADD_PYTHON_TEST(ProcessingGrass7AlgorithmsRasterTest Grass7AlgorithmsRasterTest.py)
ADD_PYTHON_TEST(ProcessingOTBAlgorithmsTest OTBAlgorithmsTest.py)
ENDIF(ENABLE_TESTS)
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
OTBAlgorithmTests.py
---------------------
Date : August 2016
Copyright : (C) 2016 by Manuel Grizonnet
Email : manuel.grizonnet@cnes.fr
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Manuel Grizonnet'
__date__ = 'August 2016'
__copyright__ = '(C) 2016, Manuel Grizonnet'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = ':%H$'

import AlgorithmsTestBase

import nose2
import shutil

from qgis.testing import (
start_app,
unittest
)


class TestOTBAlgorithms(unittest.TestCase, AlgorithmsTestBase.AlgorithmsTest):

@classmethod
def setUpClass(cls):
start_app()
from processing.core.Processing import Processing
Processing.initialize()
cls.cleanup_paths = []

@classmethod
def tearDownClass(cls):
for path in cls.cleanup_paths:
shutil.rmtree(path)

def test_definition_file(self):
return 'otb_algorithm_tests.yaml'


if __name__ == '__main__':
nose2.main()
@@ -0,0 +1,20 @@
# See ../README.md for a description of the file format

tests:

- algorithm: otb:imageconversion
name: Test (otb:imageconversion)
params:
-hcp.high: 2
-hcp.low: 2
-in:
name: raster.tif
type: raster
-ram: 128
-type: '1'
-type.linear.gamma: 1
results:
-out:
hash: b3657f4d848b64f688db41638ea6d86d9de1d0a169bc1bafef8af82a
type: rasterhash

0 comments on commit b9c2ab2

Please sign in to comment.
You can’t perform that action at this time.