From bca09fa52411d45aa25670094b280c3880bac2af Mon Sep 17 00:00:00 2001
From: remi cresson <remi.cresson@teledetection.fr>
Date: Mon, 20 Feb 2017 16:33:29 +0000
Subject: [PATCH] ENH: default temporary directory path is the same as output
 image, when -tmpdir parameter is empty

---
 app/otbLSGRM.cxx | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/app/otbLSGRM.cxx b/app/otbLSGRM.cxx
index f3c0bdc..0c15b64 100644
--- a/app/otbLSGRM.cxx
+++ b/app/otbLSGRM.cxx
@@ -97,6 +97,7 @@ private:
 
     // For large scale
     AddParameter(ParameterType_Directory, "tmpdir", "Directory for temporary files");
+    MandatoryOff("tmpdir");
     AddParameter(ParameterType_Choice, "tiling", "Tiling layout for the large scale segmentation");
     AddChoice("tiling.auto", "Automatic tiling layout");
     AddChoice("tiling.user", "User tiling layout");
@@ -124,7 +125,16 @@ private:
     std::string outbfname = itksys::SystemTools::GetFilenameWithoutExtension(outfname.c_str());
 
     // Get specified temporary directory
-    std::string tmpdir = GetParameterAsString("tmpdir");
+    std::string tmpdir;
+    if (HasValue("tmpdir"))
+      {
+      tmpdir= GetParameterAsString("tmpdir");
+      }
+    else
+      {
+      tmpdir = itksys::SystemTools::GetFilenamePath(outfname);
+      }
+
     if (!tmpdir.empty())
       {
       // A temporary directory is specified: we check that it ends with a POSIX separator
@@ -140,6 +150,7 @@ private:
       {
       otbAppLogFATAL("The directory " << tmpdir << " does not exist.");
       }
+    otbAppLogINFO("Using temporary directory " << tmpdir);
 
     // Return the prefix
     std::string prefix = tmpdir + outbfname;
-- 
GitLab