[GRASS-SVN] r59412 - grass-addons/grass7/raster/r.stream.segment

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Mar 27 06:43:23 PDT 2014


Author: martinl
Date: 2014-03-27 06:43:20 -0700 (Thu, 27 Mar 2014)
New Revision: 59412

Modified:
   grass-addons/grass7/raster/r.stream.segment/Makefile
   grass-addons/grass7/raster/r.stream.segment/io.c
   grass-addons/grass7/raster/r.stream.segment/io.h
   grass-addons/grass7/raster/r.stream.segment/local_vars.h
   grass-addons/grass7/raster/r.stream.segment/main.c
   grass-addons/grass7/raster/r.stream.segment/stream_segment.c
   grass-addons/grass7/raster/r.stream.segment/stream_topology.c
   grass-addons/grass7/raster/r.stream.segment/stream_vector.c
Log:
r.stream.segment: more guisection, message correction
                  various minor cosmetics


Modified: grass-addons/grass7/raster/r.stream.segment/Makefile
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/Makefile	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/Makefile	2014-03-27 13:43:20 UTC (rev 59412)
@@ -11,4 +11,3 @@
 include $(MODULE_TOPDIR)/include/Make/Module.make
 
 default: cmd
-

Modified: grass-addons/grass7/raster/r.stream.segment/io.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/io.c	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/io.c	2014-03-27 13:43:20 UTC (rev 59412)
@@ -14,7 +14,7 @@
     int r;
 
     if (data_type < 0 || data_type > 2)
-	G_fatal_error(_("ram_creat: Cannot create map of unrecognised type"));
+	G_fatal_error(_("Unable to create raster map of unrecognised type"));
 
     map->data_type = data_type;
     map->map_name = NULL;
@@ -76,9 +76,9 @@
     if (check_res)
 	if (this_window.ew_res != cellhd.ew_res ||
 	    this_window.ns_res != cellhd.ns_res)
-	    G_fatal_error(_("Region resolution and map %s resolution differs. \
-		Run g.region rast=%s to set proper region resolution"),
-			  input_map_name, input_map_name);
+          G_fatal_error(_("Region resolution and raster map <%s> resolution differs. "
+                          "Run 'g.region rast=%s' to set proper region resolution."),
+                        input_map_name, input_map_name);
 
     /* checking if input map is of required type */
     if (check_data_type != map->data_type)
@@ -87,7 +87,7 @@
     input_data_type = Rast_map_type(input_map_name, mapset);
     if (check_data_type != -1)
 	if (input_data_type != check_data_type)
-	    G_fatal_error(_("<%s> is not of type %s"),
+	    G_fatal_error(_("Raster map <%s> is not of type '%s'"),
 			  input_map_name, maptypes[check_data_type]);
 
     input_map_fd = Rast_open_old(input_map_name, mapset);
@@ -117,7 +117,7 @@
     input_buffer = Rast_allocate_buf(input_data_type);
 
     /* start reading */
-    G_message(_("Reading map <%s>"), input_map_name);
+    G_message(_("Reading raster map <%s>..."), input_map_name);
 
     for (r = 0; r < map->nrows; ++r) {
 	G_percent(r, map->nrows, 2);
@@ -145,7 +145,7 @@
 					 input_data_type);
 		    break;
 		default:
-		    G_fatal_error(_("ram_open:Wrong internal data type"));
+		    G_fatal_error(_("Wrong internal data type"));
 		    break;
 		}
     }				/*end for r */
@@ -192,7 +192,7 @@
 	G_debug(1,
 		"ram_write:required map type and internal map type differs: conversion forced!");
 
-    G_message(_("Writing map <%s>"), output_map_name);
+    G_message(_("Writing raster map <%s>..."), output_map_name);
     output_fd = Rast_open_new(output_map_name, output_data_type);
 
     /* writing */
@@ -229,7 +229,7 @@
     Rast_short_history(output_map_name, "raster", &history);
     Rast_command_history(&history);
     Rast_write_history(output_map_name, &history);
-    G_message(_("<%s> Done"), output_map_name);
+    /* G_message(_("<%s> Done"), output_map_name); */
     return 0;
 }
 
@@ -294,7 +294,7 @@
 	seg->data_size = sizeof(DCELL);
 	break;
     default:
-	G_fatal_error(_("seg_create: unrecognisable data type"));
+	G_fatal_error(_("Unrecognisable data type"));
     }
 
     filename = G_tempfile();
@@ -305,18 +305,18 @@
 		       seg->data_size)) {
 	close(fd);
 	unlink(filename);
-	G_fatal_error(_("seg_create: cannot format segment"));
+	G_fatal_error(_("Unable to format segment"));
     }
 
     close(fd);
     if (0 > (fd = open(filename, 2))) {
 	unlink(filename);
-	G_fatal_error(_("seg_create: cannot re-open file"));
+	G_fatal_error(_("Unable to re-open file '%s'"), filename);
     }
 
     if (0 > (fd = segment_init(&(seg->seg), fd, number_of_segs))) {
 	unlink(filename);
-	G_fatal_error(_("seg_create: cannot init segment file or out of memory"));
+	G_fatal_error(_("Unable to init segment file or out of memory"));
     }
 
     seg->filename = G_store(filename);
@@ -351,7 +351,7 @@
     /* checking if map exist */
     mapset = (char *)G_find_raster2(input_map_name, "");
     if (mapset == NULL)
-	G_fatal_error(_("seg_read:Raster map <%s> not found"),
+	G_fatal_error(_("Raster map <%s> not found"),
 		      input_map_name);
     seg->mapset = mapset;
 
@@ -363,8 +363,8 @@
     if (check_res)
 	if (this_window.ew_res != cellhd.ew_res ||
 	    this_window.ns_res != cellhd.ns_res)
-	    G_fatal_error(_("Region resolution and map %s resolution differs. \
-		Run g.region rast=%s to set proper region resolution"),
+          G_fatal_error(_("Region resolution and raster map <%s> resolution differs. "
+                          "Run 'g.region rast=%s' to set proper region resolution."),
 			  input_map_name, input_map_name);
 
     if (check_data_type != seg->data_type)
@@ -373,7 +373,7 @@
     input_data_type = Rast_map_type(input_map_name, mapset);
     if (check_data_type != -1)
 	if (input_data_type != check_data_type)
-	    G_fatal_error(_("<%s> is not of type %s"),
+	    G_fatal_error(_("Raster map <%s> is not of type '%s'"),
 			  input_map_name, maptypes[check_data_type]);
 
     input_fd = Rast_open_old(input_map_name, mapset);
@@ -401,7 +401,7 @@
 
     /* end opening and checking */
 
-    G_message(_("Reading map <%s>"), input_map_name);
+    G_message(_("Reading raster map <%s>..."), input_map_name);
     input_buffer = Rast_allocate_buf(input_data_type);
 
     target_buffer = Rast_allocate_buf(seg->data_type);
@@ -495,7 +495,7 @@
 	G_debug(1,
 		"ram_write:required map type and internal map type differs: conversion forced!");
 
-    G_message(_("Writing map <%s>"), output_map_name);
+    G_message(_("Writing raster map <%s>..."), output_map_name);
     output_fd = Rast_open_new(output_map_name, output_data_type);
     output_buffer = Rast_allocate_buf(output_data_type);
     segment_flush(&(seg->seg));
@@ -505,7 +505,7 @@
 
 	G_percent(r, seg->nrows, 2);
 	if (0 > segment_get_row(&(seg->seg), output_buffer, r))
-	    G_warning(_("seg_write: Cannot segment read row %d for map %s"),
+	    G_warning(_("Unable to segment read row %d for raster map <%s>"),
 		      r, output_map_name);
 
 	if (convert_to_null) {
@@ -528,7 +528,7 @@
 			Rast_set_d_null_value(row + c * (seg->data_size), 1);
 		break;
 	    default:
-		G_warning(_("ram_null:Cannot convert to null at: %d %d"), r,
+		G_warning(_("Unable to convert to NULL at: %d %d"), r,
 			  c);
 	    }
 	}
@@ -541,7 +541,7 @@
     Rast_short_history(output_map_name, "raster", &history);
     Rast_command_history(&history);
     Rast_write_history(output_map_name, &history);
-    G_message(_("%s Done"), output_map_name);
+    /* G_message(_("%s Done"), output_map_name); */
 
     return 0;
 }

Modified: grass-addons/grass7/raster/r.stream.segment/io.h
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/io.h	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/io.h	2014-03-27 13:43:20 UTC (rev 59412)
@@ -56,4 +56,3 @@
 int seg_reset_map (SEG *, int);
 int seg_write_map(SEG *, char *, RASTER_MAP_TYPE, int, double);
 int seg_release_map(SEG *);
-

Modified: grass-addons/grass7/raster/r.stream.segment/local_vars.h
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/local_vars.h	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/local_vars.h	2014-03-27 13:43:20 UTC (rev 59412)
@@ -10,8 +10,6 @@
 
 #define SQRT2 1.414214
 	
-
-	
 typedef struct {
 	int stream;
 	int next_stream;
@@ -71,5 +69,3 @@
 GLOBAL STREAM* stream_attributes;
 
 GLOBAL struct Cell_head window;
-
-

Modified: grass-addons/grass7/raster/r.stream.segment/main.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/main.c	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/main.c	2014-03-27 13:43:20 UTC (rev 59412)
@@ -1,23 +1,23 @@
 
 /****************************************************************************
  *
- * MODULE:			 r.stream.segment
+ * MODULE:		 r.stream.segment
  * AUTHOR(S):		 Jarek Jasiewicz jarekj amu.edu.pl
  *							 
- * PURPOSE:			 Calculate geometrical attributes for segments of current order, 
- * 							 divide segments on near straight line portions and 
- * 							 and segment orientation and angles between streams and its
- *               tributaries. For stream direction it use algorithm to divide
- *               particular streams of the same order into near-straight line
- *               portions.
+ * PURPOSE:		 Calculate geometrical attributes for segments of current order, 
+ * 			 divide segments on near straight line portions and 
+ * 			 and segment orientation and angles between streams and its
+ *                       tributaries. For stream direction it use algorithm to divide
+ *                       particular streams of the same order into near-straight line
+ *                       portions.
  * 				
  *							
  *
- * COPYRIGHT:		 (C) 2002,2010 by the GRASS Development Team
+ * COPYRIGHT:		 (C) 2002,2010-2014 by the GRASS Development Team
  *
- *							 This program is free software under the GNU General Public
- *							 License (>=v2). Read the file COPYING that comes with GRASS
- *							 for details.
+ *			 This program is free software under the GNU General Public
+ *			 License (>=v2). Read the file COPYING that comes with GRASS
+ *			 for details.
  *
  *****************************************************************************/
 #define MAIN
@@ -53,34 +53,31 @@
     /* initialize module */
     module = G_define_module();
     module->description =
-	_("Divide network into near straight-line segments and calculate its order");
+	_("Divides network into near straight-line segments and calculate its order.");
     G_add_keyword(_("raster"));
     G_add_keyword(_("hydrology"));
-    G_add_keyword("Stream divide");
-    G_add_keyword("Stream direction");
-    G_add_keyword("Stream gradient");
+    G_add_keyword(_("stream network"));
+    G_add_keyword(_("stream divide"));
 
     in_stm_opt = G_define_standard_option(G_OPT_R_INPUT);
     in_stm_opt->key = "streams";
-    in_stm_opt->description = "Name of streams mask input map";
+    in_stm_opt->description = _("Name of input streams mask raster map");
 
     in_dir_opt = G_define_standard_option(G_OPT_R_INPUT);
     in_dir_opt->key = "dirs";
-    in_dir_opt->description = "Name of flow direction input map";
+    in_dir_opt->description = _("Name of input flow direction raster map");
 
-    in_elev_opt = G_define_standard_option(G_OPT_R_INPUT);
-    in_elev_opt->key = "elevation";
-    in_elev_opt->description = "Name of elevation map";
+    in_elev_opt = G_define_standard_option(G_OPT_R_ELEV);
 
     out_segment_opt = G_define_standard_option(G_OPT_V_OUTPUT);
     out_segment_opt->key = "segments";
     out_segment_opt->description =
-	_("OUTPUT vector file to write segment attributes");
+	_("Name for output vector map to write segment attributes");
 
     out_sector_opt = G_define_standard_option(G_OPT_V_OUTPUT);
     out_sector_opt->key = "sectors";
     out_sector_opt->description =
-	_("OUTPUT vector file to write segment attributes");
+	_("Name for output vector map to write segment attributes");
 
     opt_length = G_define_option();
     opt_length->key = "length";
@@ -88,7 +85,6 @@
     opt_length->description = _("Must be > 0");
     opt_length->answer = "15";
     opt_length->type = TYPE_INTEGER;
-    opt_length->guisection = _("Optional");
 
     opt_skip = G_define_option();
     opt_skip->key = "skip";
@@ -96,7 +92,6 @@
     opt_skip->description = _("Must be >= 0");
     opt_skip->answer = "5";
     opt_skip->type = TYPE_INTEGER;
-    opt_skip->guisection = _("Optional");
 
     opt_threshold = G_define_option();
     opt_threshold->key = "threshold";
@@ -104,14 +99,13 @@
     opt_threshold->description = _("Must be > 0");
     opt_threshold->answer = "160";
     opt_threshold->type = TYPE_DOUBLE;
-    opt_threshold->guisection = _("Optional");
 
     opt_swapsize = G_define_option();
     opt_swapsize->key = "memory";
     opt_swapsize->type = TYPE_INTEGER;
     opt_swapsize->answer = "300";
     opt_swapsize->description = _("Max memory used in memory swap mode (MB)");
-    opt_swapsize->guisection = _("Optional");
+    opt_swapsize->guisection = _("Memory setings");
 
     flag_radians = G_define_flag();
     flag_radians->key = 'r';
@@ -121,8 +115,8 @@
     flag_segmentation = G_define_flag();
     flag_segmentation->key = 'm';
     flag_segmentation->description = _("Use memory swap (operation is slow)");
+    flag_segmentation->guisection = _("Memory setings");
 
-
     if (G_parser(argc, argv))	/* parser */
 	exit(EXIT_FAILURE);
 
@@ -133,11 +127,11 @@
     segmentation = (flag_segmentation->answer != 0);
 
     if (seg_length <= 0)
-	G_fatal_error("Search's length must be > 0");
+        G_fatal_error(_("Search's length must be > 0"));
     if (seg_treshold < 0 || seg_treshold > 180)
-	G_fatal_error("Threshold must be between 0 and 180");
+	G_fatal_error(_("Threshold must be between 0 and 180"));
     if (seg_skip < 0)
-	G_fatal_error("Segment's length must be >= 0");
+	G_fatal_error(_("Segment's length must be >= 0"));
 
     seg_treshold = DEG2RAD(seg_treshold);
     nrows = Rast_window_rows();
@@ -152,7 +146,7 @@
 	CELL **streams, **dirs, **unique_streams = NULL;
 	FCELL **elevation;
 
-	G_message(_("ALL IN RAM CALCULATION"));
+	G_message(_("All in RAM calculation..."));
 	ram_create_map(&map_streams, CELL_TYPE);
 	ram_read_map(&map_streams, in_stm_opt->answer, 1, CELL_TYPE);
 	ram_create_map(&map_dirs, CELL_TYPE);
@@ -190,7 +184,7 @@
 	SEGMENT *elevation;
 	int number_of_segs;
 
-	G_message(_("MEMORY SWAP CALCULATION - MAY TAKE SOME TIME"));
+        G_message(_("Memory swap calculation (may take some time)..."));
 	number_of_segs = (int)atof(opt_swapsize->answer);
 	number_of_segs = number_of_segs < 32 ? (int)(32 / 0.18) : number_of_segs / 0.18;
 
@@ -246,7 +240,7 @@
        stream_attributes[i].outlet);
 
      */
-    G_message("Creating sectors and calculating attributes...");
+    G_message(_("Creating sectors and calculating attributes..."));
 
     for (i = 1; i < number_of_streams; ++i) {
 	create_sectors(&stream_attributes[i], seg_length, seg_skip,

Modified: grass-addons/grass7/raster/r.stream.segment/stream_segment.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/stream_segment.c	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/stream_segment.c	2014-03-27 13:43:20 UTC (rev 59412)
@@ -225,10 +225,11 @@
     STREAM *SA = stream_attributes;
     unsigned long int *P = cur_stream->points;
     int next_stream = cur_stream->next_stream;
-    int outlet = cur_stream->outlet;
+    unsigned int outlet = cur_stream->outlet;
     int last_cell = cur_stream->number_of_cells - 1;
     int reached_end = 1;
 
+    G_debug(3, "calc_tangents(): number_streams=%d", number_streams);
     /*before calc tangents add rest of streamline attributes */
     r_up = (int)P[1] / ncols;
     c_up = (int)P[1] % ncols;

Modified: grass-addons/grass7/raster/r.stream.segment/stream_topology.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/stream_topology.c	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/stream_topology.c	2014-03-27 13:43:20 UTC (rev 59412)
@@ -47,9 +47,9 @@
 	}
 
     if (trib_num > 5)
-	G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match..."));
+	G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match."));
     if (trib_num > 3)
-	G_warning(_("Stream network may be too dense..."));
+	G_warning(_("Stream network may be too dense"));
 
     return trib_num;
 }				/* end trib_num */
@@ -96,9 +96,9 @@
 	}
 
     if (trib_num > 5)
-	G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match..."));
+	G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match."));
     if (trib_num > 3)
-	G_warning(_("Stream network may be too dense..."));
+	G_warning(_("Stream network may be too dense"));
 
     return trib_num;
 }				/* end trib_num */
@@ -164,7 +164,7 @@
 
     stream_attributes =
 	(STREAM *) G_malloc(number_of_streams * sizeof(STREAM));
-    G_message("Finding inits...");
+    G_message(_("Finding inits..."));
     SA = stream_attributes;
 
     for (r = 0; r < nrows; ++r)
@@ -172,7 +172,7 @@
 	    if (streams[r][c])
 		if (ram_trib_nums(r, c, streams, dirs) != 1) {	/* adding inits */
 		    if (stream_num > number_of_streams)
-			G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match..."));
+			G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match."));
 
 		    SA[stream_num].stream = stream_num;
 		    SA[stream_num].init = INDEX(r, c);
@@ -251,7 +251,7 @@
 	    SA[i].distance[cell_num] = get_distance(r, c, next_d);
 	    cell_num++;
 	    if (cell_num > SA[i].number_of_cells)
-		G_fatal_error(_("To much points in stream line..."));
+		G_fatal_error(_("To much points in stream line"));
 	} while (streams[r][c] == SA[i].order);
 
 	if (SA[i].elevation[0] == -99999)
@@ -277,7 +277,7 @@
 
     stream_attributes =
 	(STREAM *) G_malloc(number_of_streams * sizeof(STREAM));
-    G_message("Finding inits...");
+    G_message(_("Finding inits..."));
     SA = stream_attributes;
 
     /* finding inits */
@@ -288,7 +288,7 @@
 	    if (streams_cell)
 		if (seg_trib_nums(r, c, streams, dirs) != 1) {	/* adding inits */
 		    if (stream_num > number_of_streams)
-			G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match..."));
+			G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match."));
 
 		    SA[stream_num].stream = stream_num;
 		    SA[stream_num].init = INDEX(r, c);
@@ -381,7 +381,7 @@
 	    SA[i].distance[cell_num] = get_distance(r, c, next_d);
 	    cell_num++;
 	    if (cell_num > SA[i].number_of_cells)
-		G_fatal_error(_("To much points in stream line..."));
+		G_fatal_error(_("To much points in stream line"));
 	    segment_get(streams, &streams_cell, r, c);
 	} while (streams_cell == SA[i].order);
 

Modified: grass-addons/grass7/raster/r.stream.segment/stream_vector.c
===================================================================
--- grass-addons/grass7/raster/r.stream.segment/stream_vector.c	2014-03-27 13:15:18 UTC (rev 59411)
+++ grass-addons/grass7/raster/r.stream.segment/stream_vector.c	2014-03-27 13:43:20 UTC (rev 59412)
@@ -70,36 +70,34 @@
     }
 
     /* create table */
-    sprintf(buf, "create table %s (%s integer, \
-		segment integer, \
-		sector integer, \
-		s_order integer, \
-		direction double precision, \
-		azimuth double precision, \
-		length double precision, \
-		stright double precision, \
-		sinusoid double precision, \
-		elev_min double precision, \
-		elev_max double precision, \
-		s_drop double precision, \
-		gradient double precision)", Fi->table, cat_col_name);
-
-    //printf("%s \n",buf);
-
+    sprintf(buf, "create table %s (%s integer, "
+            "segment integer, "
+            "sector integer, "
+            "s_order integer, "
+            "direction double precision, "
+            "azimuth double precision, "
+            "length double precision, "
+            "stright double precision, "
+            "sinusoid double precision, "
+            "elev_min double precision, "
+            "elev_max double precision, "
+            "s_drop double precision, "
+            "gradient double precision)", Fi->table, cat_col_name);
+    
     db_set_string(&db_sql, buf);
 
     if (db_execute_immediate(driver, &db_sql) != DB_OK) {
 	db_close_database(driver);
 	db_shutdown_driver(driver);
-	G_fatal_error("Cannot create table: '%s'", db_get_string(&db_sql));
+	G_fatal_error(_("Unable to create table: '%s'"), db_get_string(&db_sql));
     }
 
     if (db_create_index2(driver, Fi->table, cat_col_name) != DB_OK)
-	G_warning("cannot create index");
+        G_warning(_("Unable to create create index on table <%s>"), Fi->table);
 
     if (db_grant_on_table(driver, Fi->table,
 			  DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK)
-	G_fatal_error("cannot grant privileges on table %s", Fi->table);
+	G_fatal_error(_("Unable to grant privileges on table <%s>"), Fi->table);
 
     db_begin_transaction(driver);
 
@@ -129,21 +127,18 @@
 		azimuth = RAD2DEG(azimuth);
 	    }
 
-	    sprintf(buf, "insert into %s values( %d, %d, %d, %d, \
-																			%f, %f, %f, %f, %f, \
-																			%f, %f, %f, %f)", Fi->table, sector_category, segment, sector, order,	/*4 */
+	    sprintf(buf, "insert into %s values( %d, %d, %d, %d, "
+                    "%f, %f, %f, %f, %f, "
+                    "%f, %f, %f, %f)", Fi->table, sector_category, segment, sector, order,	/*4 */
 		    direction, azimuth, length, stright, sinusoid,	/*9 */
 		    elev_max, elev_min, drop, gradient);	/*13 */
-
-	    //printf("%s  \n",buf); }}
-
-
+            
 	    db_set_string(&db_sql, buf);
 
 	    if (db_execute_immediate(driver, &db_sql) != DB_OK) {
 		db_close_database(driver);
 		db_shutdown_driver(driver);
-		G_fatal_error(_("Cannot inset new row: %s"),
+		G_fatal_error(_("Unable to inset new row: '%s'"),
 			      db_get_string(&db_sql));
 	    }
 	}
@@ -227,46 +222,44 @@
     }
 
     /* create table */
-    sprintf(buf, "create table %s (%s integer, \
-		segment integer, \
-		next_segment integer, \
-		s_order integer, \
-		next_order integer, \
-		direction double precision, \
-		azimuth double precision, \
-		length double precision, \
-		stright double precision, \
-		sinusoid double precision, \
-		elev_min double precision, \
-		elev_max double precision, \
-		s_drop double precision, \
-		gradient double precision, \
-		out_direction double precision, \
-		out_azimuth double precision, \
-		out_length double precision, \
-		out_drop double precision, \
-		out_gradient double precision, \
-		tangent_dir double precision, \
-		tangent_azimuth double precision, \
-		next_direction double precision, \
-		next_azimuth double precision)", Fi->table, cat_col_name);
-
-    //printf("%s \n",buf);
-
+    sprintf(buf, "create table %s (%s integer, "
+            "segment integer, "
+            "next_segment integer, "
+            "s_order integer, "
+            "next_order integer, "
+            "direction double precision, "
+            "azimuth double precision, "
+            "length double precision, "
+            "stright double precision, "
+            "sinusoid double precision, "
+            "elev_min double precision, "
+            "elev_max double precision, "
+            "s_drop double precision, "
+            "gradient double precision, "
+            "out_direction double precision, "
+            "out_azimuth double precision, "
+            "out_length double precision, "
+            "out_drop double precision, "
+            "out_gradient double precision, "
+            "tangent_dir double precision, "
+            "tangent_azimuth double precision, "
+            "next_direction double precision, "
+            "next_azimuth double precision)", Fi->table, cat_col_name);
+    
     db_set_string(&db_sql, buf);
 
     if (db_execute_immediate(driver, &db_sql) != DB_OK) {
 	db_close_database(driver);
 	db_shutdown_driver(driver);
-	G_fatal_error("Cannot create table %s", db_get_string(&db_sql));
+	G_fatal_error(_("Unable to create table '%s'"), db_get_string(&db_sql));
     }
 
     if (db_create_index2(driver, Fi->table, cat_col_name) != DB_OK)
-	G_warning("cannot create index");
+	G_warning(_("Unable to create index on table <%s>"), Fi->table);
 
     if (db_grant_on_table(driver, Fi->table,
 			  DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK)
-	G_fatal_error("cannot grant privileges on table %s", Fi->table);
+	G_fatal_error(_("Unable grant privileges on table <%s>"), Fi->table);
 
     db_begin_transaction(driver);
 
@@ -309,25 +302,22 @@
 	    next_azimuth = RAD2DEG(next_azimuth);
 	}
 
-	sprintf(buf, "insert into %s values( %d, %d, %d, %d, %d, \
-																			%f, %f, %f, %f, %f, \
-																			%f, %f, %f, %f,			\
-																			%f, %f, %f, %f, %f, \
-																			%f, %f, %f, %f)", Fi->table, i, segment, next_segment, order, next_order,	/*5 */
+	sprintf(buf, "insert into %s values( %d, %d, %d, %d, %d, "
+                "%f, %f, %f, %f, %f, "
+                "%f, %f, %f, %f, "
+                "%f, %f, %f, %f, %f, "
+                "%f, %f, %f, %f)", Fi->table, i, segment, next_segment, order, next_order,	/*5 */
 		direction, azimuth, length, stright, sinusoid,	/*10 */
 		elev_max, elev_min, drop, gradient,	/*14 */
 		out_direction, out_azimuth, out_length, out_drop, out_gradient,	/*19 */
 		tangent_dir, tangent_azimuth, next_direction, next_azimuth);	/*23 */
 
-	/* printf("%s  \n",buf); */
-
-
 	db_set_string(&db_sql, buf);
 
 	if (db_execute_immediate(driver, &db_sql) != DB_OK) {
 	    db_close_database(driver);
 	    db_shutdown_driver(driver);
-	    G_fatal_error(_("Cannot inset new row: %s"),
+	    G_fatal_error(_("Unable to insert new row: '%s'"),
 			  db_get_string(&db_sql));
 	}
 



More information about the grass-commit mailing list