[GRASS-SVN] r35377 - grass/branches/releasebranch_6_4/vector/lidar/v.surf.bspline

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 12 17:39:55 EST 2009


Author: neteler
Date: 2009-01-12 17:39:55 -0500 (Mon, 12 Jan 2009)
New Revision: 35377

Modified:
   grass/branches/releasebranch_6_4/vector/lidar/v.surf.bspline/main.c
Log:
Roberto Antol?\195?\173n: generate better messages (usage error tracking) (merge from trunk, r35375)

Modified: grass/branches/releasebranch_6_4/vector/lidar/v.surf.bspline/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/lidar/v.surf.bspline/main.c	2009-01-12 22:39:29 UTC (rev 35376)
+++ grass/branches/releasebranch_6_4/vector/lidar/v.surf.bspline/main.c	2009-01-12 22:39:55 UTC (rev 35377)
@@ -36,9 +36,11 @@
 {
 
     /* Variables' declarations */
-    int nsply, nsplx, nlines, nrows, ncols, subregion_row, subregion_col;
+    int nsply, nsplx, nlines, nrows, ncols;
+    int nsubregion_col, nsubregion_row, subregion_row, subregion_col;
     int last_row, last_column, grid, bilin, ext, flag_auxiliar, cross;	/* booleans */
     double passoN, passoE, lambda, mean;
+    double N_extension, E_extension, orloE, orloN;
 
     char *mapset, *dvr, *db, *vector, *map, table_name[1024], title[64];
 
@@ -215,7 +217,7 @@
 
     if (vector && map)
 	G_fatal_error(_("Choose either vector or raster output, not both"));
-#ifdef nodef
+#ifdef notdef
     if (!vector && !map && !cross_corr_flag->answer)
 	G_fatal_error(_("No raster nor vector output"));
 #endif
@@ -231,13 +233,13 @@
     /* Open input ext vector */
     if (!in_ext_opt->answer) {
 	ext = FALSE;
-	G_warning(_("No vector map to interpolate. "
+	G_message(_("No vector map of sparse points to interpolate. "
 		    "Interpolation will be done with <%s> vector map"),
 		  in_opt->answer);
     }
     else {
 	ext = TRUE;
-	G_warning(_("<%s> vector map will be interpolated"),
+	G_message(_("Vector map <%s> of sparse points will be interpolated"),
 		  in_ext_opt->answer);
 
 	if ((mapset = G_find_vector2(in_ext_opt->answer, "")) == NULL)
@@ -353,6 +355,16 @@
     /* Interpolation begins */
     G_debug(1, "Interpolation()");
 
+    if (map) {
+	nrows = G_window_rows();
+	ncols = G_window_cols();
+
+	if (!G_alloc_matrix(nrows, ncols))
+	    G_fatal_error(_("Interpolation: The region resolution is too high: "
+			   "%d cells. Consider to change it."),
+			  nrows * ncols);
+    }
+
     /* Open driver and database */
     driver = db_start_driver_open_database(dvr, db);
     if (driver == NULL)
@@ -367,21 +379,11 @@
     Vect_region_box(&elaboration_reg, &general_box);
 
     /* Alloc raster matrix */
-    if (raster) {
-	double nrows_ncols;
+    if (map)
+	if (!(raster_matrix = G_alloc_matrix(nrows, ncols)))
+	    G_fatal_error(_("Cannot allocate memory for auxiliar matrix."
+			    "Consider changing region resolution"));
 
-	nrows = G_window_rows();
-	ncols = G_window_cols();
-	nrows_ncols = (double)nrows *ncols;
-
-	if ((nrows_ncols) > 30000000)	/* about 5500x5500 cells */
-	    G_fatal_error(_("Interpolation: The region resolution is too high: %d cells. "
-			   "Consider to change it."), nrows_ncols);
-
-	/*raster_matrix = G_alloc_fmatrix (nrows, ncols);  Is it neccesary a double precision?? */
-	raster_matrix = G_alloc_matrix(nrows, ncols);
-    }
-
     /* Fixxing parameters of the elaboration region */
     P_zero_dim(&dims);		/* Set to zero the dim struct */
     dims.latoE = NSPLX_MAX * passoE;
@@ -389,6 +391,18 @@
     dims.overlap = OVERLAP_SIZE * passoE;
     P_get_orlo(bilin, &dims, passoE, passoN);	/* Set the last two dim elements */
 
+    N_extension = original_reg.ns_res * original_reg.rows;
+    E_extension = original_reg.ew_res * original_reg.cols;
+    orloE = dims.latoE - dims.overlap - 2 * dims.orlo_h;
+    orloN = dims.latoN - dims.overlap - 2 * dims.orlo_v;
+    nsubregion_col = 2 + ((E_extension - dims.latoE) / orloE);
+    nsubregion_row = 2 + ((N_extension - dims.latoN) / orloN);
+
+    if (nsubregion_col < 0)
+	nsubregion_col = 0;
+    if (nsubregion_row < 0)
+	nsubregion_row = 0;
+
     /* Creating line and categories structs */
     points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
@@ -403,6 +417,7 @@
 
     elaboration_reg.south = original_reg.north;
 
+    G_percent(0, 1, 10);
     subregion_row = 0;
     last_row = FALSE;
     while (last_row == FALSE) {	/* For each row */
@@ -441,6 +456,7 @@
 	subregion_col = 0;
 	while (last_column == FALSE) {	/* For each column */
 	    int npoints = 0;
+	    int nsubzones = 0, subzone = 0;
 
 	    subregion_col++;
 	    P_set_regions(&elaboration_reg, &general_box, &overlap_box, dims,
@@ -518,6 +534,8 @@
 		    if (bspline_field > 0) {
 			int cat, ival, ret, type;
 
+			if (!(type & GV_POINTS))
+			    continue;
 			cat = observ[i].cat;
 			if (cat < 0)
 			    continue;
@@ -670,6 +688,14 @@
 		}
 		G_free_ivector(lineVect);
 	    }
+	    else
+		G_warning(_("No data within this subzone. "
+			    "Consider changing the spline step."));
+
+	    subzone = (subregion_row - 1) * nsubregion_col + subregion_col;
+	    nsubzones = nsubregion_row * nsubregion_col;
+	    G_percent(subzone, nsubzones, 10);
+
 	}			/*! END WHILE; last_column = TRUE */
     }				/*! END WHILE; last_row = TRUE */
 
@@ -713,7 +739,7 @@
 	G_write_history(out_map_opt->answer, &history);
     }
 
-    G_done_msg("");
+    G_done_msg(" ");
 
     exit(EXIT_SUCCESS);
 }				/*END MAIN */



More information about the grass-commit mailing list