[prev in list] [next in list] [prev in thread] [next in thread] 

List:       grass-commit
Subject:    [GRASS-SVN] r69024 - sandbox/moritz/r.object.geometry
From:       svn_grass () osgeo ! org
Date:       2016-07-22 10:57:47
Message-ID: 20160722105748.08BF8390156 () trac ! osgeo ! org
[Download RAW message or body]

Author: mlennert
Date: 2016-07-22 03:57:47 -0700 (Fri, 22 Jul 2016)
New Revision: 69024

Modified:
   sandbox/moritz/r.object.geometry/main.c
Log:
r.object.geometry: implement write to output file


Modified: sandbox/moritz/r.object.geometry/main.c
===================================================================
--- sandbox/moritz/r.object.geometry/main.c	2016-07-21 21:34:00 UTC (rev 69023)
+++ sandbox/moritz/r.object.geometry/main.c	2016-07-22 10:57:47 UTC (rev 69024)
@@ -94,8 +94,12 @@
     if (Rast_get_map_type(in_fd) != CELL_TYPE)
 	G_fatal_error(_("Input raster mus be of type CELL"));
 
-    out_fp = stdout;
-    /* TODO: open optional output file */
+    if (opt_out->answer != NULL && strcmp(opt_out->answer, "-") != 0) {
+        if(! (out_fp = fopen(opt_out->answer, "w")))
+            G_fatal_error(_("Unable to open file <%s> for writing"), opt_out->answer);
+    } else {
+    	out_fp = stdout;
+    }
 
     Rast_get_window(&cellhd);
     nrows = cellhd.rows;

_______________________________________________
grass-commit mailing list
grass-commit@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-commit
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic