[GRASS-SVN] r69024 - sandbox/moritz/r.object.geometry

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 22 03:57:47 PDT 2016


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;



More information about the grass-commit mailing list