[GRASS-SVN] r49786 - grass/trunk/raster/r.viewshed

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Dec 16 06:30:32 EST 2011


Author: mmetz
Date: 2011-12-16 03:30:32 -0800 (Fri, 16 Dec 2011)
New Revision: 49786

Modified:
   grass/trunk/raster/r.viewshed/main.cpp
Log:
r.viewshed: use GRASS .tmp dir for temp data

Modified: grass/trunk/raster/r.viewshed/main.cpp
===================================================================
--- grass/trunk/raster/r.viewshed/main.cpp	2011-12-16 11:30:10 UTC (rev 49785)
+++ grass/trunk/raster/r.viewshed/main.cpp	2011-12-16 11:30:32 UTC (rev 49786)
@@ -574,11 +574,7 @@
     streamdirOpt->key        = "stream_dir";
     streamdirOpt->type       = TYPE_STRING;
     streamdirOpt->required   = NO;
-#ifdef __MINGW32__
-    streamdirOpt->answer     = G_convert_dirseps_from_host(G_store(getenv("TEMP")));
-#else
-    streamdirOpt->answer     = "/var/tmp/";
-#endif
+    //streamdirOpt->answer     = "";
     streamdirOpt->description=
        _("Directory to hold temporary files (they can be large)");
 
@@ -590,8 +586,17 @@
     /* store the parameters into a structure to be used along the way */
     strcpy(viewOptions->inputfname, inputOpt->answer);
     strcpy(viewOptions->outputfname, outputOpt->answer);
-    strcpy(viewOptions->streamdir,streamdirOpt->answer);
-
+    
+    if (!streamdirOpt->answer) {
+	const char *tmpdir = G_tempfile();
+	
+	if (G_mkdir(tmpdir) == -1)
+	    G_fatal_error(_("Unable to create temp dir"));
+	strcpy(viewOptions->streamdir, tmpdir);
+    }
+    else
+	strcpy(viewOptions->streamdir,streamdirOpt->answer);
+	
     viewOptions->obsElev = atof(obsElevOpt->answer);
     if(tgtElevOpt->answer)
 	viewOptions->tgtElev = atof(tgtElevOpt->answer);



More information about the grass-commit mailing list