Skip to content

Commit

Permalink
[otb] add options for saving dem options
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@98 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
julien.malik@gmail.com committed Apr 14, 2012
1 parent b862f9e commit aef7734
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/sextante/otb/OTBAlgorithm.py
Expand Up @@ -46,7 +46,15 @@ def defineCharacteristicsFromFile(self):
try:
line = line.strip("\n").strip()
if line.startswith("Parameter"):
self.addParameter(ParameterFactory.getFromString(line))
param = ParameterFactory.getFromString(line)

# Hack for initializing the elevation parameters from Sextante configuration
if param.name == "-elev.dem.path":
param.default = OTBUtils.otbSRTMPath()
if param.name == "-elev.dem.geoid":
param.default = OTBUtils.otbGeoidPath()

self.addParameter(param)
else:
self.addOutput(OutputFactory.getFromString(line))
line = lines.readline().strip("\n").strip()
Expand Down
6 changes: 4 additions & 2 deletions src/sextante/otb/OTBAlgorithmProvider.py
Expand Up @@ -38,8 +38,10 @@ def createAlgsList(self):

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)
SextanteConfig.addSetting(Setting("OTB", OTBUtils.OTB_FOLDER, "OTB folder", OTBUtils.otbPath()))
SextanteConfig.addSetting(Setting("OTB", OTBUtils.OTB_LIB_FOLDER, "OTB library folder", OTBUtils.otbLibPath()))
SextanteConfig.addSetting(Setting("OTB", OTBUtils.OTB_FOLDER, "OTB command line tools folder", OTBUtils.otbPath()))
SextanteConfig.addSetting(Setting("OTB", OTBUtils.OTB_LIB_FOLDER, "OTB applications folder", OTBUtils.otbLibPath()))
SextanteConfig.addSetting(Setting("OTB", OTBUtils.OTB_SRTM_FOLDER, "SRTM tiles folder", OTBUtils.otbSRTMPath()))
SextanteConfig.addSetting(Setting("OTB", OTBUtils.OTB_GEOID_FILE, "Geoid file", OTBUtils.otbGeoidPath()))

def unload(self):
AlgorithmProvider.unload(self)
Expand Down
16 changes: 15 additions & 1 deletion src/sextante/otb/OTBUtils.py
Expand Up @@ -8,23 +8,37 @@ class OTBUtils:

OTB_FOLDER = "OTB_FOLDER"
OTB_LIB_FOLDER = "OTB_LIB_FOLDER"
OTB_SRTM_FOLDER = "OTB_SRTM_FOLDER"
OTB_GEOID_FILE = "OTB_GEOID_FILE"

@staticmethod
def otbPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_FOLDER)
if folder == None:
folder =""

return folder

@staticmethod
def otbLibPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_LIB_FOLDER)
if folder == None:
folder =""
return folder

@staticmethod
def otbSRTMPath():
folder = SextanteConfig.getSetting(OTBUtils.OTB_SRTM_FOLDER)
if folder == None:
folder =""
return folder

@staticmethod
def otbGeoidPath():
filepath = SextanteConfig.getSetting(OTBUtils.OTB_GEOID_FILE)
if filepath == None:
filepath =""
return filepath

@staticmethod
def otbDescriptionPath():
return os.path.join(os.path.dirname(__file__), "description")
Expand Down

0 comments on commit aef7734

Please sign in to comment.