Skip to content

Commit

Permalink
Merge pull request #4626 from alexbruy/otb-update
Browse files Browse the repository at this point in the history
update Processing OTB provider for 2.18
  • Loading branch information
alexbruy committed Jun 6, 2017
2 parents 413c6e5 + ad1ba64 commit cda8866
Show file tree
Hide file tree
Showing 583 changed files with 26,641 additions and 233 deletions.
4 changes: 4 additions & 0 deletions ci/travis/linux/qt4/before_install.sh
Expand Up @@ -20,5 +20,9 @@ pushd ${HOME}
curl -L https://github.com/opengisch/osgeo4travis/archive/qt4bin.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 --user autopep8 nose2 pyyaml mock future
5 changes: 4 additions & 1 deletion ci/travis/linux/qt4/script.sh
Expand Up @@ -14,7 +14,7 @@
###########################################################################

export PYTHONPATH=${HOME}/osgeo4travis/lib/python2.7/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_CPP2=yes
Expand All @@ -24,4 +24,7 @@ if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
chmod -R ugo-w ~/.ccache
fi

# 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_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|PyQgsDBManagerGpkg' -S ./qgis-test-travis.ctest --output-on-failure
4 changes: 4 additions & 0 deletions ci/travis/linux/qt5/before_install.sh
Expand Up @@ -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
5 changes: 4 additions & 1 deletion ci/travis/linux/qt5/script.sh
Expand Up @@ -14,7 +14,7 @@
###########################################################################

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
Expand All @@ -25,5 +25,8 @@ fi

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_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|qgis_ogcutilstest|$(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
13 changes: 13 additions & 0 deletions python/plugins/processing/algs/otb/CMakeLists.txt
Expand Up @@ -3,7 +3,20 @@ FILE(GLOB HELPER_FILES helper/*.py)
FILE(GLOB DESCR_FILES description/5.0.0/*.xml)
FiLE(GLOB HELP_FILES description/5.0.0/doc/*.html)

FILE(GLOB DESCR_FILES description/5.6.0/*.xml)
FiLE(GLOB HELP_FILES description/5.6.0/doc/*.html)

FILE(GLOB DESCR_FILES description/5.8.0/*.xml)
FiLE(GLOB HELP_FILES description/5.8.0/doc/*.html)

PLUGIN_INSTALL(processing ./algs/otb ${PY_FILES})
PLUGIN_INSTALL(processing ./algs/otb/helper ${HELPER_FILES})

PLUGIN_INSTALL(processing ./algs/otb/description/5.0.0 ${DESCR_FILES})
PLUGIN_INSTALL(processing ./algs/otb/description/5.0.0/doc ${HELP_FILES})

PLUGIN_INSTALL(processing ./algs/otb/description/5.6.0 ${DESCR_FILES})
PLUGIN_INSTALL(processing ./algs/otb/description/5.6.0/doc ${HELP_FILES})

PLUGIN_INSTALL(processing ./algs/otb/description/5.8.0 ${DESCR_FILES})
PLUGIN_INSTALL(processing ./algs/otb/description/5.8.0/doc ${HELP_FILES})
11 changes: 7 additions & 4 deletions python/plugins/processing/algs/otb/OTBAlgorithm.py
Expand Up @@ -63,6 +63,7 @@ def __init__(self, descriptionfile):
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
self.hasROI = None
self._icon = None

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

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'otb.png'))
return self._icon

def help(self):
version = OTBUtils.getInstalledVersion()
Expand Down Expand Up @@ -124,8 +127,8 @@ def get_list_from_node(self, myet):
return all_params

def defineCharacteristicsFromFile(self):
content = open(self.descriptionFile).read()
dom_model = ET.fromstring(content)
with open(self.descriptionFile) as content:
dom_model = ET.fromstring(content.read())

self.appkey = dom_model.find('key').text
self.cliName = dom_model.find('exec').text
Expand Down Expand Up @@ -175,7 +178,7 @@ def processAlgorithm(self, progress):
path = OTBUtils.otbPath()

commands = []
commands.append(path + os.sep + self.cliName)
commands.append(os.path.join(path, self.cliName))

self.roiVectors = {}
self.roiRasters = {}
Expand Down
2 changes: 0 additions & 2 deletions python/plugins/processing/algs/otb/OTBAlgorithmProvider.py
Expand Up @@ -60,8 +60,6 @@ def _loadAlgorithms(self):

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

folder = OTBUtils.compatibleDescriptionPath(version)
Expand Down
13 changes: 8 additions & 5 deletions python/plugins/processing/algs/otb/OTBUtils.py
Expand Up @@ -116,6 +116,7 @@ def otbGeoidPath():
def otbDescriptionPath():
return os.path.join(os.path.dirname(__file__), "description")


_installedVersion = None
_installedVersionFound = False

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


def compatibleDescriptionPath(version):
supportedVersions = {"5.0.0": "5.0.0"}
supportedVersions = {"5.0.0": "5.0.0",
"5.4.0": "5.4.0",
"5.6.0": "5.6.0",
"5.8.0": "5.8.0"}
if version is None:
return None
if version not in supportedVersions:
Expand Down Expand Up @@ -274,10 +278,9 @@ def remove_parameter_by_criteria(doc, criteria):


def defaultWrite(available_app, original_dom_document):
fh = open("description/%s.xml" % available_app, "w")
the_root = original_dom_document
ET.ElementTree(the_root).write(fh)
fh.close()
with open("description/%s.xml" % available_app, "w") as fh:
the_root = original_dom_document
ET.ElementTree(the_root).write(fh)


def defaultSplit(available_app, original_dom_document, parameter):
Expand Down
42 changes: 42 additions & 0 deletions python/plugins/processing/algs/otb/description/5.6.0/BandMath.xml
@@ -0,0 +1,42 @@
<root>
<key>BandMath</key>
<exec>otbcli_BandMath</exec>
<longname>Band Math</longname>
<group>Miscellaneous</group>
<description>Perform a mathematical operation on monoband images</description>
<parameter>
<parameter_type source_parameter_type="ParameterType_InputImageList">ParameterMultipleInput</parameter_type>
<key>il</key>
<name>Input image list</name>
<description>Image list to perform computation on.</description>
<datatype />
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputRaster</parameter_type>
<key>out</key>
<name>Output Image</name>
<description>Output image.</description>
<hidden />
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
<key>ram</key>
<name>Available RAM (Mb)</name>
<description>Available memory for processing (in MB)</description>
<minValue />
<maxValue />
<default>128</default>
<optional>True</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_String">ParameterString</parameter_type>
<key>exp</key>
<name>Expression</name>
<description>The mathematical expression to apply.
Use im1b1 for the first band, im1b2 for the second one...</description>
<default />
<multiline />
<optional>False</optional>
</parameter>
</root>
@@ -0,0 +1,77 @@
<root>
<key>BinaryMorphologicalOperation-closing</key>
<exec>otbcli_BinaryMorphologicalOperation</exec>
<longname>BinaryMorphologicalOperation (closing)</longname>
<group>Feature Extraction</group>
<description>Performs morphological operations on an input image channel</description>
<parameter>
<parameter_type source_parameter_type="ParameterType_InputImage">ParameterRaster</parameter_type>
<key>in</key>
<name>Input Image</name>
<description>The input image to be filtered.</description>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputRaster</parameter_type>
<key>out</key>
<name>Feature Output Image</name>
<description>Output image containing the filtered output image.</description>
<hidden />
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Int">ParameterNumber</parameter_type>
<key>channel</key>
<name>Selected Channel</name>
<description>The selected channel index</description>
<minValue />
<maxValue />
<default>1</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
<key>ram</key>
<name>Available RAM (Mb)</name>
<description>Available memory for processing (in MB)</description>
<minValue />
<maxValue />
<default>128</default>
<optional>True</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Choice">ParameterSelection</parameter_type>
<key>structype</key>
<name>Structuring Element Type</name>
<description>Choice of the structuring element type</description>
<options>
<choices>
<choice>ball</choice>
</choices>
</options>
<default>0</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Int">ParameterNumber</parameter_type>
<key>structype.ball.xradius</key>
<name>The Structuring Element Radius</name>
<description>The Structuring Element Radius</description>
<minValue />
<maxValue />
<default>5</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Choice">ParameterSelection</parameter_type>
<key>filter</key>
<name>Morphological Operation</name>
<description>Choice of the morphological operation</description>
<options>
<choices>
<choice>closing</choice>
</choices>
</options>
<default>0</default>
<optional>False</optional>
</parameter>
</root>
@@ -0,0 +1,97 @@
<root>
<key>BinaryMorphologicalOperation-dilate</key>
<exec>otbcli_BinaryMorphologicalOperation</exec>
<longname>BinaryMorphologicalOperation (dilate)</longname>
<group>Feature Extraction</group>
<description>Performs morphological operations on an input image channel</description>
<parameter>
<parameter_type source_parameter_type="ParameterType_InputImage">ParameterRaster</parameter_type>
<key>in</key>
<name>Input Image</name>
<description>The input image to be filtered.</description>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputRaster</parameter_type>
<key>out</key>
<name>Feature Output Image</name>
<description>Output image containing the filtered output image.</description>
<hidden />
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Int">ParameterNumber</parameter_type>
<key>channel</key>
<name>Selected Channel</name>
<description>The selected channel index</description>
<minValue />
<maxValue />
<default>1</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
<key>ram</key>
<name>Available RAM (Mb)</name>
<description>Available memory for processing (in MB)</description>
<minValue />
<maxValue />
<default>128</default>
<optional>True</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Choice">ParameterSelection</parameter_type>
<key>structype</key>
<name>Structuring Element Type</name>
<description>Choice of the structuring element type</description>
<options>
<choices>
<choice>ball</choice>
</choices>
</options>
<default>0</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Int">ParameterNumber</parameter_type>
<key>structype.ball.xradius</key>
<name>The Structuring Element Radius</name>
<description>The Structuring Element Radius</description>
<minValue />
<maxValue />
<default>5</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Choice">ParameterSelection</parameter_type>
<key>filter</key>
<name>Morphological Operation</name>
<description>Choice of the morphological operation</description>
<options>
<choices>
<choice>dilate</choice>
</choices>
</options>
<default>0</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Float">ParameterNumber</parameter_type>
<key>filter.dilate.foreval</key>
<name>Foreground Value</name>
<description>The Foreground Value</description>
<minValue />
<maxValue />
<default>1</default>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_Float">ParameterNumber</parameter_type>
<key>filter.dilate.backval</key>
<name>Background Value</name>
<description>The Background Value</description>
<minValue />
<maxValue />
<default>0</default>
<optional>False</optional>
</parameter>
</root>

0 comments on commit cda8866

Please sign in to comment.