[GRASS-SVN] r55030 - grass/trunk/vector/v.vol.rst

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 13 01:22:27 PST 2013


Author: martinl
Date: 2013-02-13 01:22:26 -0800 (Wed, 13 Feb 2013)
New Revision: 55030

Modified:
   grass/trunk/vector/v.vol.rst/main.c
Log:
partly revert accidental commit r55029


Modified: grass/trunk/vector/v.vol.rst/main.c
===================================================================
--- grass/trunk/vector/v.vol.rst/main.c	2013-02-13 09:14:56 UTC (rev 55029)
+++ grass/trunk/vector/v.vol.rst/main.c	2013-02-13 09:22:26 UTC (rev 55030)
@@ -36,16 +36,18 @@
 #include <grass/raster.h>
 #include <grass/site.h>
 #include <grass/vector.h>
-#include <grass/bitmap.h>
-#include <grass/dbmi.h>
-#include <grass/glocale.h>
+#include "userglobs.h"
+
+/* include G3d defs */
 #include <grass/raster3d.h>
 
-#include "userglobs.h"
 #include "oct.h"
 #include "surf.h"
 #include "dataoct.h"
 #include "user.h"
+#include <grass/bitmap.h>
+#include <grass/dbmi.h>
+#include <grass/glocale.h>
 
 double /* pargr */ xmin, xmax, ymin, ymax, zmin, zmax, wmin, wmax;
 double /* norm */ xmin0, xmax0, ymin0, ymax0, zmin0, zmax0, wmin0, wmax0,
@@ -205,7 +207,7 @@
     double amin1(double, double);
     int max1();
     int min1();
-    int npmin;
+    int per, npmin;
     int ii, i, n_rows, n_cols, n_levs;
     double x_orig, y_orig, z_orig;
     char dminchar[64];
@@ -244,23 +246,29 @@
 	_("Interpolates point data to a 3D raster map using "
 	  "regularized spline with tension (RST) algorithm.");
 
-    parm.input = G_define_standard_option(G_OPT_V_INPUT);
+    parm.input = G_define_option();
+    parm.input->key = "input";
+    parm.input->type = TYPE_STRING;
     parm.input->required = YES;
-    parm.input->label = _("Name of input 3D vector points map");
-    parm.input->description = NULL; /* no OGR support */
-    
-    parm.cellinp = G_define_standard_option(G_OPT_R_INPUT);
+    parm.input->gisprompt = "old,vector,vector";
+    parm.input->description = _("Name of the vector map with input x,y,z,w");
+
+    parm.cellinp = G_define_option();
     parm.cellinp->key = "cellinp";
+    parm.cellinp->type = TYPE_STRING;
     parm.cellinp->required = NO;
+    parm.cellinp->gisprompt = "old,cell,raster";
     parm.cellinp->description =
-	_("Name of input surface raster map for cross-section");
+	_("Name of the surface raster map for cross-section");
 
-    parm.colnum = G_define_standard_option(G_OPT_DB_COLUMN);
+    parm.colnum = G_define_option();
     parm.colnum->key = "wcolumn";
+    parm.colnum->type = TYPE_STRING;
     parm.colnum->required = NO;
     parm.colnum->description =
-	_("Name of column containing w attribute to interpolate");
-    
+	_("Name of the column containing w attribute to interpolate");
+    parm.colnum->answer = "flt1";
+
     parm.fi = G_define_option();
     parm.fi->key = "tension";
     parm.fi->type = TYPE_DOUBLE;
@@ -277,31 +285,38 @@
     parm.rsm->description = _("Smoothing parameter");
     parm.rsm->guisection = _("Settings");
 
-    parm.scol = G_define_standard_option(G_OPT_DB_COLUMN);
+    parm.scol = G_define_option();
     parm.scol->key = "scolumn";
+    parm.scol->type = TYPE_STRING;
     parm.scol->required = NO;
     parm.scol->description =
-	_("Name of column with smoothing parameters");
+	_("Name of the column with smoothing parameters");
     parm.scol->guisection = _("Settings");
 
     parm.wheresql = G_define_standard_option(G_OPT_DB_WHERE);
 
-    parm.devi = G_define_standard_option(G_OPT_V_OUTPUT);
+    parm.devi = G_define_option();
     parm.devi->key = "devi";
+    parm.devi->type = TYPE_STRING;
     parm.devi->required = NO;
-    parm.devi->description = _("Name for output deviations vector map");
-    parm.devi->guisection = _("Outputs");
+    parm.devi->gisprompt = "new,vector,vector";
+    parm.devi->description = _("Output deviations vector point file");
+    parm.devi->guisection = _("Analysis");
 
-    parm.cvdev = G_define_standard_option(G_OPT_V_OUTPUT);
+    parm.cvdev = G_define_option();
     parm.cvdev->key = "cvdev";
+    parm.cvdev->type = TYPE_STRING;
     parm.cvdev->required = NO;
-    parm.cvdev->description = _("Name for output cross-validation vector map");
-    parm.cvdev->guisection = _("Outputs");
+    parm.cvdev->gisprompt = "new,vector,vector";
+    parm.cvdev->description = _("Output cross-validation vector map");
+    parm.cvdev->guisection = _("Analysis");
 
-    parm.maskmap = G_define_standard_option(G_OPT_R_INPUT);
+    parm.maskmap = G_define_option();
     parm.maskmap->key = "maskmap";
+    parm.maskmap->type = TYPE_STRING;
     parm.maskmap->required = NO;
-    parm.maskmap->description = _("Name of input raster map used as mask");
+    parm.maskmap->gisprompt = "old,cell,raster";
+    parm.maskmap->description = _("Name of the raster map used as mask");
 
     parm.segmax = G_define_option();
     parm.segmax->key = "segmax";
@@ -354,53 +369,76 @@
     parm.zmult->description = _("Conversion factor for z-values");
     parm.zmult->guisection = _("Settings");
 
-    parm.cellout = G_define_standard_option(G_OPT_R_OUTPUT);
+    parm.cellout = G_define_option();
     parm.cellout->key = "cellout";
+    parm.cellout->type = TYPE_STRING;
     parm.cellout->required = NO;
-    parm.cellout->description = _("Name for output cross-section raster map");
-    parm.cellout->guisection = _("Outputs");
+    parm.cellout->gisprompt = "new,cell,raster";
+    parm.cellout->description = _("Output cross-section raster map");
+    parm.cellout->guisection = _("Output_options");
 
-    parm.outz = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.outz = G_define_option();
     parm.outz->key = "elev";
+    parm.outz->type = TYPE_STRING;
     parm.outz->required = NO;
-    parm.outz->description = _("Name for output elevation 3D raster map");
+    parm.outz->multiple = NO;
+    parm.outz->gisprompt = "new,grid3,3d raster";
+    parm.outz->description = _("Output elevation g3d-file");
 
-    parm.gradient = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.gradient = G_define_option();
     parm.gradient->key = "gradient";
+    parm.gradient->type = TYPE_STRING;
     parm.gradient->required = NO;
-    parm.gradient->description = _("Name for output gradient magnitude 3D raster map");
-    parm.gradient->guisection = _("Outputs");
+    parm.gradient->multiple = NO;
+    parm.gradient->gisprompt = "new,grid3,3d raster";
+    parm.gradient->description = _("Output gradient magnitude g3d-file");
+    parm.gradient->guisection = _("Output_options");
 
-    parm.aspect1 = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.aspect1 = G_define_option();
     parm.aspect1->key = "aspect1";
+    parm.aspect1->type = TYPE_STRING;
     parm.aspect1->required = NO;
+    parm.aspect1->multiple = NO;
+    parm.aspect1->gisprompt = "new,grid3,3d raster";
     parm.aspect1->description =
-	_("Name for output gradient horizontal angle 3D raster map");
-    parm.aspect1->guisection = _("Outputs");
+	_("Output gradient horizontal angle g3d-file");
+    parm.aspect1->guisection = _("Output_options");
 
-    parm.aspect2 = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.aspect2 = G_define_option();
     parm.aspect2->key = "aspect2";
+    parm.aspect2->type = TYPE_STRING;
     parm.aspect2->required = NO;
-    parm.aspect2->description = _("Name for output gradient vertical angle 3D raster map");
-    parm.aspect2->guisection = _("Outputs");
+    parm.aspect2->multiple = NO;
+    parm.aspect2->gisprompt = "new,grid3,3d raster";
+    parm.aspect2->description = _("Output gradient vertical angle g3d-file");
+    parm.aspect2->guisection = _("Output_options");
 
-    parm.ncurv = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.ncurv = G_define_option();
     parm.ncurv->key = "ncurv";
+    parm.ncurv->type = TYPE_STRING;
     parm.ncurv->required = NO;
-    parm.ncurv->description = _("Name for output change of gradient 3D raster map");
-    parm.ncurv->guisection = _("Outputs");
+    parm.ncurv->multiple = NO;
+    parm.ncurv->gisprompt = "new,grid3,3d raster";
+    parm.ncurv->description = _("Output change of gradient g3d-file");
+    parm.ncurv->guisection = _("Output_options");
 
-    parm.gcurv = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.gcurv = G_define_option();
     parm.gcurv->key = "gcurv";
+    parm.gcurv->type = TYPE_STRING;
     parm.gcurv->required = NO;
-    parm.gcurv->description = _("Name for output gaussian curvature 3D raster map");
-    parm.gcurv->guisection = _("Outputs");
+    parm.gcurv->multiple = NO;
+    parm.gcurv->gisprompt = "new,grid3,3d raster";
+    parm.gcurv->description = _("Output gaussian curvature g3d-file");
+    parm.gcurv->guisection = _("Output_options");
 
-    parm.mcurv = G_define_standard_option(G_OPT_R3_OUTPUT);
+    parm.mcurv = G_define_option();
     parm.mcurv->key = "mcurv";
+    parm.mcurv->type = TYPE_STRING;
     parm.mcurv->required = NO;
-    parm.mcurv->description = _("Name for output mean curvature 3D raster map");
-    parm.mcurv->guisection = _("Outputs");
+    parm.mcurv->multiple = NO;
+    parm.mcurv->gisprompt = "new,grid3,3d raster";
+    parm.mcurv->description = _("Output mean curvature g3d-file");
+    parm.mcurv->guisection = _("Output_options");
 
     flag.cv = G_define_flag();
     flag.cv->key = 'c';
@@ -437,6 +475,7 @@
     if (!parm.dmin1->answer)
 	parm.dmin1->answer = dminchar;
 
+    per = 1;			/*flag.per->answer; */
     iw2 = 1;
     sig1 = 0;
     input = parm.input->answer;
@@ -474,10 +513,9 @@
 	rsm = -1;		/* used in InterpLib to indicate variable smoothing */
 
     if (cv != (cvdev != NULL))
-        G_fatal_error(_("Both crossvalidation options (-%c, %s) must be specified"),
-                      flag.cv->key, parm.cvdev->key);
+	G_fatal_error(_("Both crossvalidation options (-c, cvdev) must be specified"));
     if (cv && devi != NULL)
-	G_fatal_error(_("Both crossvalidation and deviations must be specified"));
+	G_fatal_error(_("Both crossvalidation and deviations file specified"));
     if (cellinp == NULL && outz == NULL && cellout == NULL && gradient == NULL
 	&& aspect1 == NULL && aspect2 == NULL && ncurv == NULL &&
 	gcurv == NULL && mcurv == NULL) {
@@ -488,8 +526,8 @@
 	(cellinp != NULL || outz != NULL || cellout != NULL ||
 	 gradient != NULL || aspect1 != NULL || aspect2 != NULL ||
 	 ncurv != NULL || gcurv != NULL || mcurv != NULL || devi != NULL))
-	G_fatal_error("Crossvalidation cannot be computed simultanuously "
-                      "with output grids or devi file");
+	G_fatal_error
+	    ("The crossvalidation cannot be computed simultanuously with output grids or devi file");
 
     z_orig_in = z_orig;
     tb_res_in = tb_res;
@@ -536,14 +574,14 @@
 
     if ((data =
 	 data_new(x_orig, y_orig, z_orig, n_rows, n_cols, n_levs, 0)) == NULL)
-	G_fatal_error("Unable to create octdata");
+	G_fatal_error("cannot create octdata");
     if ((functions =
 	 OT_functions_new(oct_compare, oct_divide_data, oct_add_data,
 			  oct_intersect, oct_division_check,
 			  oct_get_points)) == NULL)
-	G_fatal_error("Unable to create octfunc");
+	G_fatal_error("cannot create octfunc");
     if ((tree = OT_tree_new(data, NULL, NULL, functions, 0)) == NULL)
-	G_fatal_error("Unable to create octtree");
+	G_fatal_error("cannot create octtree");
 
     root = tree;
 
@@ -552,7 +590,7 @@
      */
     if (TESTOUT) {
 	if ((fd4 = fopen("testout", "w+")) == NULL)
-	    G_fatal_error("Unable To open testout");
+	    G_fatal_error("Cannot open testout");
     }
 
     Vect_set_open_level(1);
@@ -599,7 +637,7 @@
 	if (db_execute_immediate(driver, &sql) != DB_OK) {
 	    db_close_database(driver);
 	    db_shutdown_driver(driver);
-	    G_fatal_error(_("Unable To create table: %s"), db_get_string(&sql));
+	    G_fatal_error(_("Cannot create table: %s"), db_get_string(&sql));
 	}
 	count = 1;
     }
@@ -627,11 +665,14 @@
 		if (!
 		    (fwrite
 		     (zero_array_cell, sizeof(FCELL), n_cols, Tmp_fd_cell)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space--cannot write temp files");
 	    }
 	}
 	ertot = 0.;
-        
+	if (per)
+	    fprintf(stderr, "Percent complete: ");
+
 	out_cond1 = (outz != NULL) || (gradient != NULL) || (aspect1 != NULL)
 	    || (aspect2 != NULL) || (gcurv != NULL) || (mcurv != NULL) ||
 	    (ncurv != NULL);
@@ -640,126 +681,133 @@
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array1 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array1)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array1\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array1[i] = 0.;
 	    Tmp_file_z = G_tempfile();
 	    if (NULL == (Tmp_fd_z = fopen(Tmp_file_z, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_z);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_z);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array1, sizeof(float), n_cols, Tmp_fd_z)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	if (gradient != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array2 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array2)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array2\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array2[i] = 0.;
 	    Tmp_file_dx = G_tempfile();
 	    if (NULL == (Tmp_fd_dx = fopen(Tmp_file_dx, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_dx);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_dx);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array2, sizeof(float), n_cols, Tmp_fd_dx)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	if (aspect1 != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array3 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array3)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array3\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array3[i] = 0.;
 	    Tmp_file_dy = G_tempfile();
 	    if (NULL == (Tmp_fd_dy = fopen(Tmp_file_dy, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_dy);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_dy);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array3, sizeof(float), n_cols, Tmp_fd_dy)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	if (aspect2 != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array4 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array4)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array4\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array4[i] = 0.;
 	    Tmp_file_dz = G_tempfile();
 	    if (NULL == (Tmp_fd_dz = fopen(Tmp_file_dz, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_dz);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_dz);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array4, sizeof(float), n_cols, Tmp_fd_dz)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	if (ncurv != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array5 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array5)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array5\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array5[i] = 0.;
 	    Tmp_file_xx = G_tempfile();
 	    if (NULL == (Tmp_fd_xx = fopen(Tmp_file_xx, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_xx);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_xx);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array5, sizeof(float), n_cols, Tmp_fd_xx)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	if (gcurv != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array6 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array6)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array6\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array6[i] = 0.;
 	    Tmp_file_yy = G_tempfile();
 	    if (NULL == (Tmp_fd_yy = fopen(Tmp_file_yy, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_yy);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_yy);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array6, sizeof(float), n_cols, Tmp_fd_yy)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	if (mcurv != NULL) {
 	    /* allocating temp array for writing to corresponding temp file */
 	    zero_array7 = (float *)G_malloc(sizeof(float) * n_cols);
 	    if (!zero_array7)
-		clean_fatal_error(_("Not enough memory"));
+		clean_fatal_error("Not enough memory for zero_array7\n");
 	    for (i = 0; i < n_cols; i++)
 		zero_array7[i] = 0.;
 	    Tmp_file_xy = G_tempfile();
 	    if (NULL == (Tmp_fd_xy = fopen(Tmp_file_xy, "w+"))) {
-		sprintf(msg, _("Unable to open temp file '%s'"), Tmp_file_xy);
+		sprintf(msg, "Can't open temp file [%s] ", Tmp_file_xy);
 		clean_fatal_error(msg);
 	    }
 	    /* filling temp file with zeroes */
 	    for (i = 0; i < n_levs * n_rows; i++) {
 		if (!(fwrite(zero_array7, sizeof(float), n_cols, Tmp_fd_xy)))
-		    clean_fatal_error(_("Not enough disk space - cannot write temp files"));
+		    clean_fatal_error
+			("Not enough disk space -- cannot write temp files");
 	    }
 	}
 	cursegm = 0;
@@ -866,12 +914,12 @@
 
 	}
 	else
-	    clean_fatal_error(_("Interpolation failed"));
+	    clean_fatal_error("Interp_call failed!");
     }
     else
-	clean_fatal_error(_("Input failed"));
+	clean_fatal_error("input failed!");
     if (fd4 != NULL)
 	fclose(fd4);
 
-    return EXIT_SUCCESS;
+    return 0;
 }



More information about the grass-commit mailing list