[GRASS-SVN] r31320 - grass/branches/develbranch_6/lib/ogsf

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 12 08:33:34 EDT 2008


Author: martinl
Date: 2008-05-12 08:33:34 -0400 (Mon, 12 May 2008)
New Revision: 31320

Modified:
   grass/branches/develbranch_6/lib/ogsf/Gs3.c
   grass/branches/develbranch_6/lib/ogsf/gs.c
   grass/branches/develbranch_6/lib/ogsf/gsd_legend.c
Log:
ogsflib: doxygenization in progress
minor cleaning: i18, use G_e/w/m() instead of fprintf()


Modified: grass/branches/develbranch_6/lib/ogsf/Gs3.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/Gs3.c	2008-05-11 19:21:43 UTC (rev 31319)
+++ grass/branches/develbranch_6/lib/ogsf/Gs3.c	2008-05-12 12:33:34 UTC (rev 31320)
@@ -13,6 +13,7 @@
   for details.
   
   \author Bill Brown USACERL, GMSL/University of Illinois (January 1993)
+  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
 */
 
 #include <stdlib.h>
@@ -20,6 +21,7 @@
 #include <string.h>
 
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include <grass/bitmap.h>
 
 #include <grass/gsurf.h>
@@ -28,8 +30,9 @@
 #include "gsget.h"
 /* for update_attrange - might be able to move this func now */
 
-
-/* The following macros are only used in the function Gs_update_attrange() */
+/*!
+  \brief Used in the function Gs_update_attrange()
+*/
 #define INIT_MINMAX(p, nm, size, min, max, found) \
 	found = 0; \
 	p+=(size-1); \
@@ -44,6 +47,9 @@
 	    p--; \
 	}
 
+/*!
+  \brief Used in the function Gs_update_attrange()
+*/
 #define SET_MINMAX(p, nm, size, min, max) \
 	p+=(size-1); \
 	while(size--) \
@@ -66,22 +72,6 @@
 
 #define NO_DATA_COL 0xffffff
 
-/*!
-  \brief Warning handling
-
-  This should be a function variable that 
-  may be replaced by a user's function. 
-  Or else use G_set_error_routine().
-
-  \param str message
-*/
-void Gs_warning(char *str)
-{
-    G_warning("%s", str);
-
-    return;
-}
-
 /************************************************************************/
 /* This should be a function variable that 
  * may be replaced by a user's function. 
@@ -94,8 +84,16 @@
     return;
 }
 
-/************************************************************************/
-/* calculates distance in METERS between two points in current projection */
+/*!
+  \brief Calculates distance in METERS between two points in current projection (2D)
+
+  Uses G_distance().
+
+  \param from 'from' point (X, Y)
+  \param to 'to' point (X, Y)
+
+  \return distance
+*/
 double Gs_distance(double *from, double *to)
 {
     static int first = 1;
@@ -108,44 +106,48 @@
     return G_distance(from[0], from[1], to[0], to[1]);
 }
 
-/************************************************************************/
-/* Calling function must have already allocated space in buff for
-   wind->rows * wind->cols floats.
-   This routine simply loads the map into a 2d array by repetitve calls
-   to get_f_raster_row.
+/*!
+  \brief Load raster map as floating point map
+
+  Calling function must have already allocated space in buff for
+  wind->rows * wind->cols floats.
+
+  This routine simply loads the map into a 2d array by repetitve calls
+  to get_f_raster_row.
+
+  \param wind current window
+  \param map_name raster map name
+  \param[out] buff data buffer
+  \param[out] nullmap null map buffer
+  \param[out] has_null indicates if raster map contains null-data
+
+  \return 1
 */
 int Gs_loadmap_as_float(struct Cell_head *wind, char *map_name, float *buff,
 			struct BM *nullmap, int *has_null)
 {
     FILEDESC cellfile;
     char *map_set, *nullflags;
-    char err_buff[100];
     int offset, row, col;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("Gs_loadmap_as_float");
-    }
-#endif
+    G_debug(3, "Gs_loadmap_as_float");
 
     map_set = G_find_file2("cell", map_name, "");
+    if (!map_set) {
+	G_fatal_error(_("Raster map <%s> not found"), map_name);
+    }
     *has_null = 0;
 
-    if (NULL == (nullflags = G_allocate_null_buf())) {
-	sprintf(err_buff, "Not able to allocate null buffer for [%s]",
-		map_name);
-	Gs_warning(err_buff);
-
-	exit(0);
+    nullflags = G_allocate_null_buf(); /* G_fatal_error */
+    if (!nullflags) {
+	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
 
     if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
-	sprintf(err_buff, "Not able to open cellfile for [%s]", map_name);
-	Gs_warning(err_buff);
-	exit(0);
+	G_fatal_error(_("Unable to open raster map <%s>"));
     }
 
-    Gs_status("Loading Data");
+    G_verbose_message(_("Loading data..."));
 
     for (row = 0; row < wind->rows; row++) {
 	offset = row * wind->cols;
@@ -159,61 +161,63 @@
 		*has_null = 1;
 		BM_set(nullmap, col, row, 1);
 	    }
-
 	    /* set nm */
 	}
     }
 
-#ifdef DEBUG_MSG
-    {
-	fprintf(stderr, "_HAS-NULL_ = %d\n", *has_null);
-    }
-#endif
+    G_debug(3, "_HAS-NULL_ = %d", *has_null);
 
     G_close_cell(cellfile);
 
-    free(nullflags);
+    G_free(nullflags);
 
     return (1);
 }
 
-/************************************************************************/
-/* Calling function must have already allocated space in buff for
-   wind->rows * wind->cols integers.
-   This routine simply loads the map into a 2d array by repetitve calls
-   to get_map_row.
+/*!
+  \brief Load raster map as integer map
+
+  Calling function must have already allocated space in buff for
+  wind->rows * wind->cols floats.
+
+  This routine simply loads the map into a 2d array by repetitve calls
+  to get_f_raster_row.
+
+  \todo fn body of Gs_loadmap_as_float()
+
+  \param wind current window
+  \param map_name raster map name
+  \param[out] buff data buffer
+  \param[out] nullmap null map buffer
+  \param[out] has_null indicates if raster map contains null-data
+
+  \return 1
 */
 int Gs_loadmap_as_int(struct Cell_head *wind, char *map_name, int *buff,
 		      struct BM *nullmap, int *has_null)
 {
     FILEDESC cellfile;
     char *map_set, *nullflags;
-    char err_buff[100];
     int offset, row, col;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("Gs_loadmap_as_int");
-    }
-#endif
+    G_debug(3, "Gs_loadmap_as_int");
 
     map_set = G_find_file2("cell", map_name, "");
+    if (!map_set) {
+	G_fatal_error(_("Raster map <%s> not found"), map_name);
+    }
     *has_null = 0;
 
-    if (NULL == (nullflags = G_allocate_null_buf())) {
-	sprintf(err_buff, "Not able to allocate null buffer for [%s]",
-		map_name);
-	Gs_warning(err_buff);
-	exit(0);
+    nullflags = G_allocate_null_buf(); /* G_fatal_error */
+    if (!nullflags) {
+	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
 
     if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
-	sprintf(err_buff, "Not able to open cellfile for [%s]", map_name);
-	Gs_warning(err_buff);
-	exit(0);
+	G_fatal_error(_("Unable to open raster map <%s>"));
     }
 
-    Gs_status("Loading Data");
+    G_verbose_message(_("Loading data..."));
 
     for (row = 0; row < wind->rows; row++) {
 	offset = row * wind->cols;
@@ -234,13 +238,20 @@
 
     G_close_cell(cellfile);
 
-    free(nullflags);
+    G_free(nullflags);
 
     return (1);
 }
 
-/*********************************************************************/
-/* returns -1 if map is integer and G_read_range fails !! */
+/*!
+  \brief Get map data type
+
+  \param filename raster map name
+  \param negflag
+
+  \return -1 if map is integer and G_read_range() fails
+  \return data type (ARRY_*)
+*/
 int Gs_numtype(char *filename, int *negflag)
 {
     CELL max = 0, min = 0;
@@ -250,7 +261,6 @@
     static int max_short, max_char;
     static int first = 1;
 
-
     if (first) {
 	max_short = max_char = 1;
 	shortbits = 8 * sizeof(short);
@@ -275,13 +285,12 @@
     }
 
     mapset = G_find_file2("cell", filename, "");
+    if (!mapset) {
+	G_fatal_error(_("Raster map <%s> not found"), filename);
+    }
 
     if (G_raster_map_is_fp(filename, mapset)) {
-#ifdef DEBUG_MSG
-	{
-	    fprintf(stderr, "fp map detected \n");
-	}
-#endif
+	G_debug(3, "Gs_numtype(): fp map detected");
 
 	return (ATTY_FLOAT);
     }
@@ -304,30 +313,36 @@
     return (ATTY_INT);
 }
 
-/************************************************************************/
-/* Calling function must have already allocated space in buff for
-   wind->rows * wind->cols shorts.  
-   This routine simply loads the map into a 2d array by repetitve calls
-   to get_map_row.
-   Returns 1 on success, -1 on failure, -2 if read ok, but 1 or more values
-   were too large (small) to fit into a short.
-   (in which case the max (min) short is used)
+/*!
+  \brief Load raster map as integer map
+
+  Calling function must have already allocated space in buff for
+  wind->rows * wind->cols shorts.  
+  
+  This routine simply loads the map into a 2d array by repetitve calls
+  to get_map_row.
+  
+  \param wind current window
+  \param map_name raster map name
+  \param[out] buff data buffer
+  \param[out] nullmap null map buffer
+  \param[out] has_null indicates if raster map contains null-data
+
+  \return 1 on success
+  \return -1 on failure,
+  \return -2 if read ok, but 1 or more values were too large (small)
+  to fit into a short (in which case the max (min) short is used)
 */
 int Gs_loadmap_as_short(struct Cell_head *wind, char *map_name, short *buff,
 			struct BM *nullmap, int *has_null)
 {
     FILEDESC cellfile;
     char *map_set, *nullflags;
-    char err_buff[100];
     int *ti, *tmp_buf;
     int offset, row, col, val, max_short, overflow, shortsize, bitplace;
     short *ts;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("Gs_loadmap_as_short");
-    }
-#endif
+    G_debug(3, "Gs_loadmap_as_short");
 
     overflow = 0;
     shortsize = 8 * sizeof(short);
@@ -341,28 +356,26 @@
     max_short -= 1;
 
     map_set = G_find_file2("cell", map_name, "");
+    if (!map_set) {
+	G_fatal_error(_("Raster map <%s> not found"), map_name);
+    }
     *has_null = 0;
 
-    if (NULL == (nullflags = G_allocate_null_buf())) {
-	sprintf(err_buff, "Not able to allocate null buffer for [%s]",
-		map_name);
-	Gs_warning(err_buff);
-	exit(0);
+    nullflags = G_allocate_null_buf();
+    if (!nullflags) {
+	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
 
     if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
-	sprintf(err_buff, "Not able to open cellfile for [%s]", map_name);
-	Gs_warning(err_buff);
-	exit(0);
+	G_fatal_error(_("Unable to open raster map <%s>"));
     }
 
-    if (NULL == (tmp_buf = (int *) G_malloc(wind->cols * sizeof(int)))) {
-	sprintf(err_buff, "out of memory");
-	Gs_warning(err_buff);
-	exit(0);
+    tmp_buf = (int *) G_malloc(wind->cols * sizeof(int)); /* G_fatal_error */
+    if (!tmp_buf) {
+	return -1;
     }
 
-    Gs_status("Loading Data");
+    G_verbose_message(_("Loading data..."));
 
     for (row = 0; row < wind->rows; row++) {
 	offset = row * wind->cols;
@@ -398,38 +411,49 @@
     }
 
     G_close_cell(cellfile);
-    free(tmp_buf);
-    free(nullflags);
 
+    G_free(tmp_buf);
+    G_free(nullflags);
+
     return (overflow ? -2 : 1);
 }
 
-/************************************************************************/
-/* Calling function must have already allocated space in buff for
-   wind->rows * wind->cols unsigned chars.  
-   This routine simply loads the map into a 2d array by repetitve calls
-   to get_map_row.
-   Returns 1 on success, -1 on failure, -2 if read ok, but 1 or more values
-   were too large (small) to fit into an unsigned char.
-   (in which case the max (min) char is used)
-   Since signs of chars can be tricky, we only load positive chars
-   between 0-255.
+/*!
+  \brief Load raster map as integer map
+
+  Calling function must have already allocated space in buff for
+  wind->rows * wind->cols unsigned chars.  
+
+  This routine simply loads the map into a 2d array by repetitve calls
+  to get_map_row.
+
+  Since signs of chars can be tricky, we only load positive chars
+  between 0-255.
+
+  \todo fn body Gs_loadmap_as_float()
+
+  \param wind current window
+  \param map_name raster map name
+  \param[out] buff data buffer
+  \param[out] nullmap null map buffer
+  \param[out] has_null indicates if raster map contains null-data
+
+  \return 1 on success
+  \return -1 on failure
+  \return -2 if read ok, but 1 or more values
+  were too large (small) to fit into an unsigned char.
+  (in which case the max (min) char is used)
 */
 int Gs_loadmap_as_char(struct Cell_head *wind, char *map_name,
 		       unsigned char *buff, struct BM *nullmap, int *has_null)
 {
     FILEDESC cellfile;
     char *map_set, *nullflags;
-    char err_buff[100];
     int *ti, *tmp_buf;
     int offset, row, col, val, max_char, overflow, charsize, bitplace;
     unsigned char *tc;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("Gs_loadmap_as_char");
-    }
-#endif
+    G_debug(3, "Gs_loadmap_as_char");
 
     overflow = 0;
     charsize = 8 * sizeof(unsigned char);
@@ -444,29 +468,26 @@
     max_char -= 1;
 
     map_set = G_find_file2("cell", map_name, "");
+    if (!map_set) {
+	G_fatal_error(_("Raster map <%s> not found"), map_name);
+    }
     *has_null = 0;
 
-    if (NULL == (nullflags = G_allocate_null_buf())) {
-	sprintf(err_buff, "Not able to allocate null buffer for [%s]",
-		map_name);
-	Gs_warning(err_buff);
-	exit(0);
+    nullflags = G_allocate_null_buf(); /* G_fatal_error */
+    if (!nullflags) {
+	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
 
-
     if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
-	sprintf(err_buff, "Not able to open cellfile for [%s]", map_name);
-	Gs_warning(err_buff);
-	exit(0);
+	G_fatal_error(_("Unable to open raster map <%s>"));
     }
 
-    if (NULL == (tmp_buf = (int *) G_malloc(wind->cols * sizeof(int)))) {
-	sprintf(err_buff, "out of memory");
-	Gs_warning(err_buff);
-	exit(0);
+    tmp_buf = (int *) G_malloc(wind->cols * sizeof(int)); /* G_fatal_error */
+    if (!tmp_buf) {
+	return -1;
     }
 
-    Gs_status("Loading Data");
+    G_verbose_message(_("Loading data..."));
 
     for (row = 0; row < wind->rows; row++) {
 	offset = row * wind->cols;
@@ -503,58 +524,62 @@
     }
 
     G_close_cell(cellfile);
-    free(tmp_buf);
-    free(nullflags);
 
+    G_free(tmp_buf);
+    G_free(nullflags);
+
     return (overflow ? -2 : 1);
 }
 
-/************************************************************************/
-/* Calling function must have already allocated space in buff for
-   struct BM of wind->rows & wind->cols.
-   This routine simply loads the map into the bitmap by repetitve calls
-   to get_map_row.  Any value other than 0 in the map will set the bitmap.
-   (may want to change later to allow specific value to set)
-   Returns 1 on success, -1 on failure.
-   CHANGED TO USE NULLS 
+/*!
+  \brief Load raster map as integer map
+
+  Calling function must have already allocated space in buff for
+  struct BM of wind->rows & wind->cols.
+  
+  This routine simply loads the map into the bitmap by repetitve calls
+  to get_map_row.  Any value other than 0 in the map will set the bitmap.
+  (may want to change later to allow specific value to set)
+
+  Changed to use null.
+  
+  \param wind current window
+  \param map_name raster map name
+  \param[out] buff data buffer
+
+  \returns 1 on success
+  \return -1 on failure
 */
 int Gs_loadmap_as_bitmap(struct Cell_head *wind, char *map_name,
 			 struct BM *buff)
 {
     FILEDESC cellfile;
     char *map_set, *nullflags;
-    char err_buff[100];
     int *tmp_buf;
     int row, col;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("Gs_loadmap_as_bitmap");
-    }
-#endif
+    G_debug(3, "Gs_loadmap_as_bitmap");
 
     map_set = G_find_file2("cell", map_name, "");
+    if (!map_set) {
+	G_fatal_error(_("Raster map <%s> not found"), map_name);
+    }
 
     if ((cellfile = G_open_cell_old(map_name, map_set)) == -1) {
-	sprintf(err_buff, "Not able to open cellfile for [%s]", map_name);
-	Gs_warning(err_buff);
-	exit(0);
+	G_fatal_error(_("Unable to open raster map <%s>"));
     }
 
-    if (NULL == (tmp_buf = (int *) G_malloc(wind->cols * sizeof(int)))) {
-	sprintf(err_buff, "out of memory");
-	Gs_warning(err_buff);
-	exit(0);
+    tmp_buf = (int *) G_malloc(wind->cols * sizeof(int)); /* G_fatal_error */
+    if (!tmp_buf) {
+	return -1;
     }
 
-    if (NULL == (nullflags = G_allocate_null_buf())) {
-	sprintf(err_buff, "Not able to allocate null buffer for [%s]",
-		map_name);
-	Gs_warning(err_buff);
-	exit(0);
+    nullflags = G_allocate_null_buf();
+    if (!nullflags) {
+	G_fatal_error(_("Unable to allocate memory for a null buffer"));
     }
 
-    Gs_status("Loading Data");
+    G_verbose_message(_("Loading data..."));
 
     for (row = 0; row < wind->rows; row++) {
 	G_get_null_value_row(cellfile, nullflags, row);
@@ -571,15 +596,24 @@
     }
 
     G_close_cell(cellfile);
-    free(tmp_buf);
-    free(nullflags);
 
+    G_free(tmp_buf);
+    G_free(nullflags);
+
     return (1);
 }
 
-/************************************************************************/
-/* Calling function must have already allocated space in buff for range of
-data (256 for now) - simply calls get_color for each cat in color range */
+/*!
+  \brief Build color table (256)
+
+  Calling function must have already allocated space in buff for range of
+  data (256 for now) - simply calls get_color for each cat in color range
+  
+  \param filename raster map name
+  \param[out] buff data buffer
+
+  \return 1
+*/
 int Gs_build_256lookup(char *filename, int *buff)
 {
     char *map;
@@ -588,15 +622,18 @@
     int i;
     unsigned char r[256], g[256], b[256], set[256];
 
-    Gs_status("building color table");
+    G_debug(3, "building color table");
 
     map = G_find_file2("cell", filename, "");
+    if (!map) {
+	G_fatal_error(_("Raster map <%s> not found"), filename);
+    }
+
     G_read_colors(filename, map, &colrules);
     G_get_color_range(&min, &max, &colrules);
 
     if (min < 0 || max > 255) {
-	fprintf(stderr, "mincol: %d, maxcol: %d\n", min, max);
-	fprintf(stderr, "WARNING: color table range doesn't match data\n");
+	G_warning(_("Color table range doesn't match data (mincol=%d, maxcol=%d"), min, max);
 
 	min = min < 0 ? 0 : min;
 	max = max > 255 ? 255 : max;
@@ -624,9 +661,16 @@
     return (1);
 }
 
-/************************************************************************/
-/* passed an array of 32 bit ints that is converted from cell values
-   to packed colors (0xbbggrr) 
+/*!
+  \brief Pack color table
+
+  Passed an array of 32 bit ints that is converted from cell values
+  to packed colors (0xbbggrr) 
+
+  \param filename raster map name
+  \param buff
+  \param rows number of rows
+  \param cols number of cols
 */
 void Gs_pack_colors(char *filename, int *buff, int rows, int cols)
 {
@@ -635,17 +679,23 @@
     unsigned char *r, *g, *b, *set;
     int *cur, i, j;
 
-    Gs_status("translating colors");
+    map = G_find_file2("cell", filename, "");
+    if (!map) {
+	G_fatal_error(_("Raster map <%s> not found"), filename);
+    }
 
     r = (unsigned char *) G_malloc(cols);
     g = (unsigned char *) G_malloc(cols);
     b = (unsigned char *) G_malloc(cols);
     set = (unsigned char *) G_malloc(cols);
-    map = G_find_file2("cell", filename, "");
+
     G_read_colors(filename, map, &colrules);
 
     cur = buff;
 
+    G_verbose_message(_("Translating colors for raster map <%s>..."),
+		      filename);
+
     for (i = 0; i < rows; i++) {
 	G_lookup_colors(cur, r, g, b, set, cols, &colrules);
 	G_percent(i, rows, 2);
@@ -664,19 +714,29 @@
     }
 
     G_free_colors(&colrules);
-    free(r);
-    free(g);
-    free(b);
-    free(set);
 
+    G_free(r);
+    G_free(g);
+    G_free(b);
+    
+    G_free(set);
+
     return;
 }
 
-/************************************************************************/
-/* passed a array of floats that will be converted from cell values
-   to packed colors (0xbbggrr) and float to int 
-   ** floating point data not freed here, use: 
-      gsds_free_data_buff(id, ATTY_FLOAT)
+/*!
+  \brief Pack color table (floating-point map)
+
+  Passed a array of floats that will be converted from cell values
+  to packed colors (0xbbggrr) and float to int 
+  Floating point data not freed here, use: 
+  gsds_free_data_buff(id, ATTY_FLOAT)
+
+  \param filename raster map name
+  \param fbuf
+  \param ibuf
+  \param rows number of rows
+  \param cols number of cols
 */
 void Gs_pack_colors_float(char *filename, float *fbuf, int *ibuf, int rows,
 			  int cols)
@@ -687,18 +747,24 @@
     int i, j, *icur;
     FCELL *fcur;
 
-    Gs_status("translating colors from fp");
+    map = G_find_file2("cell", filename, "");
+    if (!map) {
+	G_fatal_error(_("Raster map <%s> not found"), filename);
+    }
 
     r = (unsigned char *) G_malloc(cols);
     g = (unsigned char *) G_malloc(cols);
     b = (unsigned char *) G_malloc(cols);
     set = (unsigned char *) G_malloc(cols);
-    map = G_find_file2("cell", filename, "");
+
     G_read_colors(filename, map, &colrules);
 
     fcur = fbuf;
     icur = ibuf;
 
+    G_verbose_message(_("Translating colors from fp raster map <%s>"),
+		      filename);
+
     for (i = 0; i < rows; i++) {
 	G_lookup_f_raster_colors(fcur, r, g, b, set, cols, &colrules);
 	G_percent(i, rows, 2);
@@ -718,18 +784,26 @@
     }
 
     G_free_colors(&colrules);
-    free(r);
-    free(g);
-    free(b);
-    free(set);
 
+    G_free(r);
+    G_free(g);
+    G_free(b);
+    G_free(set);
+
     return;
 }
 
-/************************************************************************/
-/* Formats label as in d.what.rast -> (catval) catlabel 
- * 
- *
+/*!
+  \brief Get categories/labels
+
+  Formats label as in d.what.rast -> (catval) catlabel 
+
+  \param filename raster map name
+  \param drow
+  \param dcol
+  \param catstr category string
+
+  \return 1
 */
 int Gs_get_cat_label(char *filename, int drow, int dcol, char *catstr)
 {
@@ -741,8 +815,7 @@
     int fd;
 
     if ((mapset = G_find_cell(filename, "")) == NULL) {
-	sprintf(catstr, "error");
-	exit(0);
+	G_fatal_error(_("Raster map <%s> not found"), filename);
     }
 
     if (-1 != G_read_cats(filename, mapset, &cats)) {
@@ -764,7 +837,7 @@
 			G_get_c_raster_cat(&buf[dcol], &cats));
 	    }
 
-	    free(buf);
+	    G_free(buf);
 	}
 
 	else {
@@ -783,7 +856,7 @@
 			G_get_d_raster_cat(&dbuf[dcol], &cats));
 	    }
 
-	    free(dbuf);
+	    G_free(dbuf);
 	}
     }
     else {
@@ -798,7 +871,18 @@
     return (1);
 }
 
-/************************************************************************/
+/*!
+  \brief Save 3dview
+
+  \param vname view name
+  \param gv pointer to geoview struct
+  \param gd pointer to geodisplay struct
+  \param w current window
+  \param defsurf default geosurf struct
+
+  \return -1 on error
+  \return ?
+*/
 int Gs_save_3dview(char *vname, geoview * gv, geodisplay * gd,
 		   struct Cell_head *w, geosurf * defsurf)
 {
@@ -886,7 +970,17 @@
     }
 }
 
-/************************************************************************/
+/*!
+  \brief Load 3dview
+
+  \param vname view name
+  \param gv pointer to geoview struct
+  \param gd pointer to geodisplay struct
+  \param w current window
+  \param defsurf default geosurf struct
+
+  \return 1
+*/
 int Gs_load_3dview(char *vname, geoview * gv, geodisplay * gd,
 		   struct Cell_head *w, geosurf * defsurf)
 {
@@ -903,8 +997,8 @@
 
     if (ret >= 0) {
 	if (strcmp((v.pgm_id), "Nvision-ALPHA!")) {
-	    fprintf(stderr, "WARNING: view not saved by this program,\n");
-	    fprintf(stderr, "         there may be some inconsistancies.\n");
+	    G_warning(_("View not saved by this program,"
+			"there may be some inconsistancies"));
 	}
 
 	/* set poly and mesh resolutions */
@@ -1014,10 +1108,14 @@
 
 }
 
-/***********************************************************************/
-/* updates no_zero ranges for att (actually no_null now) */
-/*
-static CELL tmpc;
+/*!
+  \brief Update no_zero ranges for att (actually no_null now)
+  
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+
+  \return -1 on error
+  \return 1 on success
 */
 int Gs_update_attrange(geosurf * gs, int desc)
 {
@@ -1027,8 +1125,7 @@
     struct BM *nm;
     int found;
 
-    gs->att[desc].max_nz = gs->att[desc].min_nz = gs->att[desc].range_nz =
-	0.0;
+    gs->att[desc].max_nz = gs->att[desc].min_nz = gs->att[desc].range_nz = 0.0;
 
     if (CONST_ATT == gs_get_att_src(gs, desc)) {
 	gs->att[desc].max_nz = gs->att[desc].min_nz = gs->att[desc].constant;

Modified: grass/branches/develbranch_6/lib/ogsf/gs.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gs.c	2008-05-11 19:21:43 UTC (rev 31319)
+++ grass/branches/develbranch_6/lib/ogsf/gs.c	2008-05-12 12:33:34 UTC (rev 31320)
@@ -13,12 +13,15 @@
   for details.
   
   \author Bill Brown USACERL, GMSL/University of Illinois (January 1993)
+  \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
 */
 
 #include <stdlib.h>
 #include <stdio.h>
 
 #include <grass/gstypes.h>
+#include <grass/glocale.h>
+
 #include "gsget.h"
 #include "rowcol.h"
 
@@ -35,10 +38,12 @@
     return;
 }
 
-/***********************************************************************/
-/* still need to take care of library initialization, 
-   probably want to define a Surf_top of constant value (i.e., 0) */
-/***********************************************************************/
+/*!
+  \brief Library initialization
+
+  Still need to take care of library initialization, 
+  probably want to define a Surf_top of constant value (i.e., 0)
+*/
 void gs_init(void)
 {
     Surf_top = NULL;
@@ -46,17 +51,19 @@
     return;
 }
 
+/*!
+  \brief Get geosurf struct
 
-/***********************************************************************/
+  \param id surface id
+
+  \return pointer to geosurf struct
+  \return NULL if not found
+*/
 geosurf *gs_get_surf(int id)
 {
     geosurf *gs;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_get_surf");
-    }
-#endif
+    G_debug(3, "gs_get_surf");
 
     for (gs = Surf_top; gs; gs = gs->next) {
 	if (gs->gsurf_id == id) {
@@ -67,16 +74,19 @@
     return (NULL);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get previous geosurf struct
+
+  \param id current surface id
+
+  \return pointer to geosurf struct
+  \return NULL if not found
+*/
 geosurf *gs_get_prev_surface(int id)
 {
     geosurf *ps;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_get_prev_surface");
-    }
-#endif
+    G_debug(3, "gs_get_prev_surface");
 
     for (ps = Surf_top; ps; ps = ps->next) {
 	if (ps->gsurf_id == id - 1) {
@@ -87,44 +97,54 @@
     return (NULL);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get array of geosurf structs
+
+  \param gsurfs pointer to array
+
+  \return number of geosurfs
+*/
 int gs_getall_surfaces(geosurf ** gsurfs)
 {
     geosurf *gs;
     int i;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_num_surfaces");
-    }
-#endif
-
     for (i = 0, gs = Surf_top; gs; gs = gs->next, i++) {
 	gsurfs[i] = gs;
     }
 
+    G_debug(3, "gs_num_surfaces(): num=%d", i);
+
     return (i);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get number of surfaces
+
+  \return number of surfaces
+*/
 int gs_num_surfaces(void)
 {
     geosurf *gs;
     int i;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_num_surfaces");
-    }
-#endif
-
     for (i = 0, gs = Surf_top; gs; gs = gs->next, i++);
 
+    G_debug(3, "gs_num_surfaces(): num=%d", i);
+
     return (i);
 }
 
 
-/***********************************************************************/
+/*!
+  \brief Check if attribute is set
+
+  \param surf pointer to gsurf or NULL to look at all geosurfs
+  \param att attribute id
+
+  \return 1 attribute is set up
+  \return 0 attribute is not set up
+*/
 int gs_att_is_set(geosurf * surf, IFLAG att)
 {
     geosurf *gs;
@@ -143,16 +163,16 @@
     return (0);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get last geosurf struct
+
+  \return pointer to geosurf struct
+*/
 geosurf *gs_get_last_surface(void)
 {
     geosurf *ls;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_get_last_surface");
-    }
-#endif
+    G_debug(3, "gs_get_last_surface():");
 
     if (!Surf_top) {
 	return (NULL);
@@ -160,29 +180,25 @@
 
     for (ls = Surf_top; ls->next; ls = ls->next);
 
-#ifdef DEBUG
-    {
-	fprintf(stderr, "last surface id: %d\n", ls->gsurf_id);
-    }
-#endif
+    G_debug(3, " last surface id: %d", ls->gsurf_id);
 
     return (ls);
 }
 
 
-/***********************************************************************/
+/*!
+  \brief Get new geosurf struct
+
+  \return pointer to geosurf struct
+*/
 geosurf *gs_get_new_surface(void)
 {
     geosurf *ns, *ls;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_get_new_surface");
-    }
-#endif
+    G_debug(3, "gs_get_new_surface");
 
-    if (NULL == (ns = (geosurf *) malloc(sizeof(geosurf)))) {
-	gs_err("gs_get_new_surface");
+    ns = (geosurf *) G_malloc(sizeof(geosurf)); /* G_fatal_error */
+    if (!ns) {
 	return (NULL);
     }
 
@@ -200,30 +216,39 @@
     return (ns);
 }
 
+/*!
+  \brief Init geosurf struct
 
-/***********************************************************************/
-/* Now xmin & ox are the same, right? - get rid of ox, oy in geosurf struct?*/
+  Now xmin & ox are the same, right? - get rid of ox, oy in geosurf struct?
+
+  \param gs pointer to geosurf struct
+  \param ox,oy x/y origin coordinates
+  \param rows number of rows
+  \param cols number of cols
+  \param xres,yres x/y resolution value
+
+  \return -1 on error
+  \return 0 on success
+*/
 int gs_init_surf(geosurf * gs, double ox, double oy, int rows, int cols,
 		 double xres, double yres)
 {
     geosurf *ps;
     int i;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_init_surf");
-    }
-#endif
+    G_debug(3, "gs_init_surf");
 
     if (!gs) {
 	return (-1);
     }
 
+    /* default attributes */
     for (i = 0; i < MAX_ATTS; i++) {
 	gs->att[i].att_src = NOTSET_ATT;
 	gs->att[i].att_type = ATTY_INT;
     }
 
+    /* default values */
     gs->ox = ox;
     gs->oy = oy;
     gs->rows = rows;
@@ -248,6 +273,7 @@
     gs->curmask = NULL;
     gs->norms = NULL;
 
+    /* default z_exag value */
     if (gs->gsurf_id == FIRST_SURF_ID) {
 	gs->z_exag = 1.0;
     }
@@ -259,7 +285,14 @@
     return (0);
 }
 
-/***********************************************************************/
+/*!
+  \brief Init geosurf normbuff
+
+  \param gs pointer to geosurf struct
+
+  \return 0 on error
+  \return 1 on success
+*/
 int gs_init_normbuff(geosurf * gs)
 {
     long size;
@@ -269,13 +302,13 @@
     }
 
     if (gs->norms) {
-	free(gs->norms);
+	G_free(gs->norms);
     }
 
     size = gs->rows * gs->cols * sizeof(unsigned long);
 
-    if (NULL == (gs->norms = (unsigned long *) malloc(size))) {
-	gs_err("gs_init_normbuff");
+    gs->norms = (unsigned long *) G_malloc(size); /* G_fatal_error */
+    if (!gs->norms) {
 	return (-1);
     }
 
@@ -284,8 +317,13 @@
     return (1);
 }
 
+/*!
+  \brief Debugging, print 'from/to' model coordinates to stderr
 
-/***********************************************************************/
+  \todo G_debug ?
+
+  \param ft pointer to coordinates
+*/
 void print_frto(float (*ft)[4])
 {
     fprintf(stderr, "FROM: %f, %f, %f\n", ft[FROM][X], ft[FROM][Y],
@@ -295,7 +333,13 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Debugging, print 'to' real coordinates to stderr
+
+  \todo G_debug ?
+
+  \param ft pointer to coordinates
+*/
 void print_realto(float *rt)
 {
     fprintf(stderr, "REAL TO: %f, %f, %f\n", rt[X], rt[Y], rt[Z]);
@@ -303,7 +347,13 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Debugging, 256 interger values from buffer
+
+  \todo G_debug ?
+
+  \param ft pointer to buffer
+*/
 void print_256lookup(int *buff)
 {
     int i;
@@ -321,10 +371,15 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Debugging, print geosurf fields to stderr
+
+  \todo G_debug ?
+
+  \param s pointer to geosurf struct
+*/
 void print_surf_fields(geosurf * s)
 {
-
     fprintf(stderr, "ID: %d\n", s->gsurf_id);
     fprintf(stderr, "rows: %d cols: %d\n", s->rows, s->cols);
     fprintf(stderr, "draw_mode: %x\n", s->draw_mode);
@@ -344,7 +399,13 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Debugging, print geoview fields to stderr
+
+  \todo G_debug ?
+
+  \param gv pointer to geoview struct
+*/
 void print_view_fields(geoview * gv)
 {
     fprintf(stderr, "coord_sys: %d\n", gv->coord_sys);
@@ -360,16 +421,18 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Set default attributes
+
+  \param gs pointer to geosurf struct
+  \param defs array of default values
+  \param null_defs array of null default values
+*/
 void gs_set_defaults(geosurf * gs, float *defs, float *null_defs)
 {
     int i;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_set_defaults");
-    }
-#endif
+    G_debug(3, "gs_set_defaults");
 
     for (i = 0; i < MAX_ATTS; i++) {
 	gs->att[i].constant = defs[i];
@@ -382,17 +445,17 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Remove geosurf struct from list
+
+  \param id surface id
+*/
 void gs_delete_surf(int id)
 {
     geosurf *fs;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_delete_surf");
-    }
-#endif
-
+    G_debug(3, "gs_delete_surf");
+    
     fs = gs_get_surf(id);
 
     if (fs) {
@@ -402,17 +465,21 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Free geosurf struct
+
+  \param fs pointer to geosurf struct
+
+  \return 1 found
+  \return 0 not found
+  \return -1 on error
+*/
 int gs_free_surf(geosurf * fs)
 {
     geosurf *gs;
     int found = 0;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_free_surf");
-    }
-#endif
+    G_debug(3, "gs_free_surf");
 
     if (Surf_top) {
 	if (fs == Surf_top) {
@@ -425,14 +492,14 @@
 		gs_free_unshared_buffs(fs);
 
 		if (fs->curmask) {
-		    free(fs->curmask);
+		    G_free(fs->curmask);
 		}
 
 		if (fs->norms) {
-		    free(fs->norms);
+		    G_free(fs->norms);
 		}
 
-		free(fs);
+		G_free(fs);
 		Surf_top = NULL;
 	    }
 	}
@@ -451,14 +518,14 @@
 	    gs_free_unshared_buffs(fs);
 
 	    if (fs->curmask) {
-		free(fs->curmask);
+		G_free(fs->curmask);
 	    }
 
 	    if (fs->norms) {
-		free(fs->norms);
+		G_free(fs->norms);
 	    }
 
-	    free(fs);
+	    G_free(fs);
 	    fs = NULL;
 	}
 
@@ -468,20 +535,22 @@
     return (-1);
 }
 
-/***********************************************************************/
-/* fs has already been taken out of the list */
-/* this function is fairly revealing about how shared datsets work */
+/*!
+  \brief Free unshared buffers of geosurf struct
+
+  <i>fs</i> has already been taken out of the list
+
+  This function is fairly revealing about how shared datsets work
+
+  \param fs pointer to geosurf struct
+*/
 void gs_free_unshared_buffs(geosurf * fs)
 {
     geosurf *gs;
     int i, j, same;
     int old_datah;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_free_unshared_buffs");
-    }
-#endif
+    G_debug(3, "gs_free_unshared_buffs");
 
     /* for each attribute 
        if !same, free buff   
@@ -508,17 +577,19 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Get number of reused values
+
+  \param dh value
+
+  \return number of reused values
+*/
 int gs_num_datah_reused(int dh)
 {
     geosurf *gs;
     int ref, j;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_num_datah_reused");
-    }
-#endif
+    G_debug(3, "gs_num_datah_reused");
 
     /* for each attribute 
        if same, ++reference
@@ -537,17 +608,19 @@
     return (ref);
 }
 
+/*!
+  \brief Get attribute type
 
-/***********************************************************************/
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+
+  \return -1 on error
+  \return attribute type
+*/
 int gs_get_att_type(geosurf * gs, int desc)
 {
+    G_debug(3, "gs_get_att_type");
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_get_att_type");
-    }
-#endif
-
     if (!LEGAL_ATT(desc)) {
 	return (-1);
     }
@@ -561,16 +634,19 @@
     return (-1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get attribute source
+
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+
+  \return -1 on error
+  \return attribute source id
+*/
 int gs_get_att_src(geosurf * gs, int desc)
 {
+    G_debug(3, "gs_get_att_src");
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_get_att_src");
-    }
-#endif
-
     if (!LEGAL_ATT(desc)) {
 	return (-1);
     }
@@ -582,7 +658,16 @@
     return (-1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get attribute typbuff
+
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+  \param to_write
+
+  \return NULL on error
+  \return pointer to typbuff
+*/
 typbuff *gs_get_att_typbuff(geosurf * gs, int desc, int to_write)
 {
     typbuff *tb;
@@ -607,16 +692,21 @@
     return (NULL);
 }
 
-/***********************************************************************/
+/*!
+  \brief Allocate attribute buffer
+
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+  \param type buffer type
+
+  \return -1 on error
+  \return pointer to typbuff (casted)
+*/
 int gs_malloc_att_buff(geosurf * gs, int desc, int type)
 {
     int hdata, dims[2], ndims;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_malloc_att_buff");
-    }
-#endif
+    G_debug(3, "gs_malloc_att_buff");
 
     if (gs) {
 	if (0 < (hdata = gs->att[desc].hdata)) {
@@ -632,21 +722,24 @@
     return (-1);
 }
 
+/*!
+  \brief Allocate attribute lookup
 
-/***********************************************************************/
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+
+  \return -1 on error
+  \return pointer to typbuff (casted)
+*/
 int gs_malloc_lookup(geosurf * gs, int desc)
 {
     int size;
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_malloc_lookup");
-    }
-#endif
+    G_debug(3, "gs_malloc_lookup");
 
     if (gs) {
 	if (gs->att[desc].lookup) {
-	    free(gs->att[desc].lookup);
+	    G_free(gs->att[desc].lookup);
 	    gs->att[desc].lookup = NULL;
 	}
 
@@ -655,9 +748,8 @@
 	    size = 32768 * sizeof(int);
 
 	    /* positive integers only, because use as array index */
-	    if (NULL == (gs->att[desc].lookup = (int *) malloc(size))) {
-		gs_err("gs_malloc_lookup");
-
+	    gs->att[desc].lookup = (int *) G_malloc(size); /* G_fatal_error */
+	    if (!gs->att[desc].lookup) {
 		return (-1);
 	    }
 
@@ -666,16 +758,14 @@
 	    size = 256 * sizeof(int);
 
 	    /* unsigned char */
-	    if (NULL == (gs->att[desc].lookup = (int *) malloc(size))) {
-		gs_err("gs_malloc_lookup");
-
+	    gs->att[desc].lookup = (int *) G_malloc(size);
+	    if (!gs->att[desc].lookup) {
 		return (-1);
 	    }
 
 	    break;
 	default:
-	    gs_err("bad type: gs_malloc_lookup");
-
+	    G_warning("bad type: gs_malloc_lookup");
 	    return (-1);
 	}
 
@@ -688,15 +778,21 @@
     return (-1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Set attribute type
+
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+  \param type attribute type
+
+  \return -1 on error
+  \return 0 on success
+*/
 int gs_set_att_type(geosurf * gs, int desc, int type)
 {
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_set_att_type");
-    }
-#endif
+    G_debug(3, "gs_set_att_type(): desc=%d, type=%d",
+	    desc, type);
 
     if (gs && LEGAL_TYPE(type)) {
 	gs->att[desc].att_type = type;
@@ -707,27 +803,31 @@
     return (-1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Set attribute source
+
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+  \param src source id
+
+  \return -1 on error
+  \return 0 on success
+*/
 int gs_set_att_src(geosurf * gs, int desc, int src)
 {
+    G_debug(3, "gs_set_att_src");
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_set_att_src");
-    }
-#endif
-
     /* check if old source was MAP_ATT, free buff */
     if (MAP_ATT == gs_get_att_src(gs, desc)) {
 	if (1 == gs_num_datah_reused(gs->att[desc].hdata)) {
 	    /* only reference */
-	    fprintf(stderr, "replacing existing map\n");
+	    G_warning (_("gs_set_att_src(): replacing existing map"));
 	    gsds_free_datah(gs->att[desc].hdata);
 	}
 
 	if (ATT_TOPO == desc) {
 	    if (gs->norms) {
-		free(gs->norms);
+		G_free(gs->norms);
 	    }
 
 	    gs->norms = NULL;
@@ -744,17 +844,22 @@
     return (-1);
 }
 
-/***********************************************************************/
-/* TODO: set typbuf constant */
+/*!
+  \brief Set attribute constant value
+
+  \todo set typbuf constant
+
+  \param gs pointer to geosurf struct
+  \param desc attribute id
+  \param constant constant value
+
+  \return 0 on success
+  \return -1 on error
+*/
 int gs_set_att_const(geosurf * gs, int desc, float constant)
 {
+    G_debug(3, "gs_set_att_const");
 
-#ifdef TRACE_FUNCS
-    {
-	Gs_status("gs_set_att_const");
-    }
-#endif
-
     if (gs) {
 	gs->att[desc].constant = constant;
 
@@ -773,7 +878,11 @@
     return (-1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Set geosurf mask mode
+
+  \param invert invert mask
+*/
 void gs_set_maskmode(int invert)
 {
     Invertmask = invert;
@@ -781,14 +890,32 @@
     return;
 }
 
-/***********************************************************************/
+/*!
+  \brief Check if mask is defined
+
+  \param gs pointer to geosurf struct
+
+  \return 1 if defined
+  \return 0 not defined
+*/
 int gs_mask_defined(geosurf * gs)
 {
     return (gs->att[ATT_MASK].att_src != NOTSET_ATT);
 }
 
-/***********************************************************************/
-/* should only be called when setting up the current mask (gs_bm.c) */
+/*!
+  \brief
+
+  Should only be called when setting up the current mask (gs_bm.c)
+
+  \param tb pointer to typbuff
+  \param col number of cols
+  \param row number of rows
+  \param offset offset value
+
+  \return 1
+  \return 0
+*/
 int gs_masked(typbuff * tb, int col, int row, int offset)
 {
     int ret;
@@ -814,9 +941,17 @@
     return (Invertmask ? ret : !ret);
 }
 
-/***********************************************************************/
-/* call this one when you already know att_src is MAP_ATT 
-   - returns packed color for catagory at offset */
+/*!
+  \brief
+
+  Call this one when you already know att_src is MAP_ATT 
+
+  \param cobuff
+  \param coloratt color attribute
+  \param offset offset value
+  
+  \return packed color for catagory at offset
+*/
 int gs_mapcolor(typbuff * cobuff, gsurf_att * coloratt, int offset)
 {
     if (coloratt->lookup) {
@@ -828,12 +963,24 @@
     return (cobuff->ib[offset]);
 }
 
-/* In the following functions, "extents" refers to translated extents for 
-a single surface, while "range" refers to accumulated extents of all
-loaded surfaces */
+/*
+  In the following functions, "extents" refers to translated extents for 
+  a single surface, while "range" refers to accumulated extents of all
+  loaded surfaces
+*/
 
-/***********************************************************************/
-/* TODO: pass flag to use zminmasked instead of zmin */
+/*!
+  \brief Get z-extent values
+  
+  \todo pass flag to use zminmasked instead of zmin
+
+  \param gs pointer to geosurf struct
+  \param[out] min z-min value
+  \param[out] max z-max value
+  \param[out] mid z-middle value
+
+  \return 1
+*/
 int gs_get_zextents(geosurf * gs, float *min, float *max, float *mid)
 {
     *min = gs->zmin + gs->z_trans;
@@ -843,7 +990,15 @@
     return (1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get x-extent values
+  
+  \param gs pointer to geosurf struct
+  \param[out] min x-min value
+  \param[out] max x-max value
+
+  \return 1
+*/
 int gs_get_xextents(geosurf * gs, float *min, float *max)
 {
     *min = gs->xmin + gs->x_trans;
@@ -852,7 +1007,15 @@
     return (1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get y-extent values
+  
+  \param gs pointer to geosurf struct
+  \param[out] min y-min value
+  \param[out] max y-max value
+
+  \return 1
+*/
 int gs_get_yextents(geosurf * gs, float *min, float *max)
 {
     *min = gs->ymin + gs->y_trans;
@@ -862,9 +1025,18 @@
 }
 
 
-/***********************************************************************/
-/* TODO: pass flag to use zminmasked instead of zmin */
-/* could also have this return a weighted average for vertical "centroid" */
+/*!
+  \brief Get z-range
+
+  \todo pass flag to use zminmasked instead of zmin
+  could also have this return a weighted average for vertical "centroid"
+
+  \param[out] min z-min value
+  \param[out] max z-max value
+
+  \return -1 on error (no surface)
+  \return 1 on success
+*/
 int gs_get_zrange0(float *min, float *max)
 {
     geosurf *gs;
@@ -890,7 +1062,15 @@
     return (1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get z-range
+
+  \param[out] min z-min value
+  \param[out] max z-max value
+
+  \return -1 on error (no surface)
+  \return 1 on success
+*/
 int gs_get_zrange(float *min, float *max)
 {
     geosurf *gs;
@@ -920,9 +1100,15 @@
     return (1);
 }
 
+/*!
+  \brief Get x-range
 
+  \param[out] min x-min value
+  \param[out] max x-max value
 
-/***********************************************************************/
+  \return -1 on error (no surface)
+  \return 1 on success
+*/
 int gs_get_xrange(float *min, float *max)
 {
     geosurf *gs;
@@ -952,7 +1138,15 @@
     return (1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get y-range
+
+  \param[out] min y-min value
+  \param[out] max y-max value
+
+  \return -1 on error (no surface)
+  \return 1 on success
+*/
 int gs_get_yrange(float *min, float *max)
 {
     geosurf *gs;
@@ -982,10 +1176,16 @@
     return (1);
 }
 
+/*!
+  \brief Get average z-max value
 
+  Useful for setting position of cplane, lighting ball, etc.
 
-/***********************************************************************/
-/* useful for setting position of cplane, lighting ball, etc. */
+  \param[out] azmax average z-max value
+
+  \return -1 on error
+  \return 1 on success
+*/
 int gs_get_data_avg_zmax(float *azmax)
 {
     float zmax;
@@ -1007,7 +1207,14 @@
     return (-1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Get data center point
+
+  \param[out] center (array X,Y,Z)
+
+  \return -1 on error
+  \return 1 on success
+*/
 int gs_get_datacenter(float *cen)
 {
     float zmin, zmax, ymin, ymax, xmin, xmax;
@@ -1060,7 +1267,12 @@
 }
 
 
-/***********************************************************************/
+/*!
+  \brief Set for geosurf need-to-update mark
+
+  \return -1 no surface available
+  \return 1 on success
+*/
 int gs_setall_norm_needupdate(void)
 {
     geosurf *gs;
@@ -1079,7 +1291,15 @@
     return (1);
 }
 
-/***********************************************************************/
+/*!
+  \brief Check if point is masked
+
+  \param gs pointer to geosurf struct
+  \param pt point coordinates (X,Y,Z)
+
+  \return 1 masked
+  \return 0 not masked
+*/
 int gs_point_is_masked(geosurf * gs, float *pt)
 {
     int vrow, vcol, drow, dcol;
@@ -1168,7 +1388,18 @@
     return (0);
 }
 
-/***********************************************************************/
+/*!
+  \brief Calculate distance on surface
+
+  \param gs pointer to geosurf struct
+  \param p1 from point
+  \param p2 to point
+  \param[out] dist distnace
+  \param use_exag use exag for calculation
+
+  \return 0 on error (points not in region)
+  \return 1 on success
+*/
 int gs_distance_onsurf(geosurf * gs, float *p1, float *p2, float *dist,
 		       int use_exag)
 {

Modified: grass/branches/develbranch_6/lib/ogsf/gsd_legend.c
===================================================================
--- grass/branches/develbranch_6/lib/ogsf/gsd_legend.c	2008-05-11 19:21:43 UTC (rev 31319)
+++ grass/branches/develbranch_6/lib/ogsf/gsd_legend.c	2008-05-12 12:33:34 UTC (rev 31320)
@@ -32,14 +32,14 @@
 #endif
 
 #include <grass/gis.h>
+#include <grass/glocale.h>
 #include <grass/gstypes.h>
+
 #include "rgbpack.h"
 
-
 static float *Listcats;
 static int Listnum = 0;
 
-
 /**** TODO
 static int bigger(float *f1, float *f2)
 {
@@ -257,7 +257,7 @@
     }
 
     if (fmin == fmax)
-	Gs_warning("Range request error for legend");
+	G_warning(_("Range request error for legend"));
 
     /* set a reasonable precision */
     if (is_fp) {
@@ -616,11 +616,12 @@
 			else
 			    sprintf(buff, "%d", tcell);
 		    }
-		    else if (cat_vals)
+		    else if (cat_vals) {
 			if (is_fp)
 			    sprintf(buff, "%.*lf", fprec, tdcell);
 			else
 			    sprintf(buff, "%d", tcell);
+		    }
 		}
 		if (horiz) {
 		    labpt[X] = labpos * (sr - sl) + xoff -



More information about the grass-commit mailing list