[GRASS-SVN] r37819 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jun 11 09:07:54 EDT 2009


Author: martinl
Date: 2009-06-11 09:07:54 -0400 (Thu, 11 Jun 2009)
New Revision: 37819

Modified:
   grass/trunk/lib/gis/gisrasterlib.dox
   grass/trunk/lib/gis/quant.c
   grass/trunk/lib/gis/quant_rw.c
Log:
libgis: doxygen updates (quant fns)


Modified: grass/trunk/lib/gis/gisrasterlib.dox
===================================================================
--- grass/trunk/lib/gis/gisrasterlib.dox	2009-06-11 08:27:44 UTC (rev 37818)
+++ grass/trunk/lib/gis/gisrasterlib.dox	2009-06-11 13:07:54 UTC (rev 37819)
@@ -1303,277 +1303,232 @@
 
 \section Upgraded_color_functions Upgraded color functions
 
-<P>
-int G_read_colors() This routine reads the rules from the color
-  file. If the input raster map is is a floating-point map it calls <TT>G_mark_colors_as_fp()</TT>.
+ - G_read_colors()
 
-<P>
-int G_write_colors() The rules are written out using
-  floating-point format, removing trailing zeros (possibly producing integers) .
-  The flag marking the colors as floating-point is <B>not</B> written.
+This routine reads the rules from the color file. If the input raster
+map is is a floating-point map (FCELL or DCELL) it calls
+G_mark_colors_as_fp().
 
-<P>
-int G_get_colors_min_max() If the color table is marked as
-  <TT>"float"</TT>, then return the minimum as -(255&#94;3 * 128) and the maximum
-  as (255&#94;3 * 128).
- This is to simulate a very <B>large</B> range so that
-  GRASS doesn't attempt to use <EM>colormode float</EM> to allow interactive
-  toggling of colors.
+ - G_write_colors()
 
-<P>
-int G_lookup_colors() Modified to return a color for NULL-values.
+The rules are written out using floating-point format, removing
+trailing zeros (possibly producing integers). The flag marking the
+colors as floating-point is <b>not</b> written.
 
-<P>
-int G_get_color() Modified to return a color for the NULL-value.
+ - G_get_colors_min_max()
 
-<P>
+If the color table is marked as <tt>"float"</tt>, then return the
+minimum as -(255&#94;3 * 128) and the maximum as (255&#94;3 *
+128). This is to simulate a very <em>large</em> range so that GRASS
+doesn't attempt to use <em>colormode float</em> to allow interactive
+toggling of colors.
 
-\section Changes_to_the_Colors_structure Changes to the <TT>Colors</TT> structure
+ - G_lookup_colors()
 
-<P>
-Modifications to the <TT>Colors</TT> structure to support colors for floating-point data and
-the NULL-value consist of
+Modified to return a color for NULL-values.
 
-<P>
+ - G_get_color()
 
-<UL>
-<LI>the _Color_Rule_ struct was changed to have DCELL value (instead of
-  CELL cat) to have the range be floating-point values instead of integer cats.
-</LI>
-<LI>a color for NULL was added
-</LI>
-<LI>the special color for zero was eliminated
-</LI>
-<LI>a default color for values which have no assigned color was added
-</LI>
-<LI>a flag was added to the Colors structure to indicate if either the map
-  itself is floating-point (If the map is integer and the floating point
-  functions are used to lookup colors, the values are checked to see if they
-  are integer, and if they are, the integer mechanism is used) 
-</LI>
-<LI>fp_lookup - a lookup table for floating point numbers is added. It
-  orders the end points of fp intervals into array with a pointer to a color
-  rule for each inteval, and the binary search is then used when looking up
-  colors instead of linearly searching through all color rules.
-</LI>
-</UL>
+Modified to return a color for the NULL-value.
 
-<P>
+\section Changes_to_the_Colors_structure Changes to the <TT>Colors</TT> structure
 
+
+Modifications to the Colors structure to support colors for
+floating-point data and the NULL-value consist of
+
+ - the _Color_Rule_ struct was changed to have DCELL value (instead of
+CELL cat) to have the range be floating-point values instead of
+integer cats.
+ - a color for NULL was added
+ - the special color for zero was eliminated
+ - a default color for values which have no assigned color was added
+ - a flag was added to the Colors structure to indicate if either the
+map itself is floating-point (If the map is integer and the floating
+point functions are used to lookup colors, the values are checked to
+see if they are integer, and if they are, the integer mechanism is
+used)
+ - fp_lookup - a lookup table for floating point numbers is added. It
+orders the end points of fp intervals into array with a pointer to a
+color rule for each inteval, and the binary search is then used when
+looking up colors instead of linearly searching through all color
+rules.
+
 \section Changes_to_the_colr_file Changes to the <TT>colr</TT> file
 
-<UL>
-<LI>The rules are written out using floating-point format, removing trailing
-  zeros (possibly producing integers) . For example, to ramp from red to green
-  for the range [1.3,5.0]:
-<PRE>
+
+ - The rules are written out using floating-point format, removing trailing zeros (possibly producing integers) . For example, to ramp from red to green for the range [1.3,5.0]:
+\verbatim
             1.3:255:0:0  5:0:255:0
-</PRE>
-</LI>
-<LI>The NULL-value color is written as:
-<PRE>
+\endverbatim
+
+ - The NULL-value color is written as:
+\verbatim
             nv:red:grn:blu
-</PRE>
-</LI>
-<LI>The default color (for values that don't have an explicit rule) is written
+\endverbatim
+
+ - The default color (for values that don't have an explicit rule) is written
 as:
-<PRE>
+\verbatim
             *:red:grn:blu
-</PRE>
-</LI>
-</UL>
+\endverbatim
 
-<P>
 
 \section Range_functions Range functions (new and upgraded)
 
 \subsection Modified_range_functions Modified range functions
 
+ - G_read_range()
 
-<P>
-int G_read_range() Old range file (those with 4 numbers) should
-  treat zeros in this file as NULL-values. New range files (those with just 2
-  numbers) should treat these numbers as real data (zeros are real data in this
-  case) .
+Old range file (those with 4 numbers) should treat zeros in this file
+as NULL-values. New range files (those with just 2 numbers) should
+treat these numbers as real data (zeros are real data in this case).
 
-<P>
-An empty range file indicates that the min, max are undefined. This is a
-  valid case, and the result should be an initialized range struct with no
-  defined min/max.
+An empty range file indicates that the min, max are undefined. This is
+a valid case, and the result should be an initialized range struct
+with no defined min/max.
 
-<P>
 If the range file is missing and the map is a floating-point map, this
-  function will create a default range by calling <TT>G_construct_default_range()</TT>.
+function will create a default range by calling
+G_construct_default_range().
 
-<P>
-int G_init_range() Must set a flag in the range structure that indicates that
-  no min/max have been defined - probably a <TT>"first"</TT> boolean flag.
+ - G_init_range()
 
-<P>
-int G_update_range() NULL-values must be detected and ignored.
+Must set a flag in the range structure that indicates that no min/max
+have been defined - probably a "first" boolean flag.
 
-<P>
-int G_get_range_min_max() If the range structure has no defined min/max
-  (first!=0) there will not be a valid range. In this case the min and max returned must
-  be the NULL-value.
+ - G_update_range()
 
-<P>
-int G_write_range() This routine only writes 2 numbers (min,max) to the range
-  file, instead of the 4 (pmin,pmax,nmin,nmax) previously written. If there is no defined
-  min,max, an empty file is written.
+NULL-values must be detected and ignored.
 
-<P>
+ - G_get_range_min_max()
 
+If the range structure has no defined min/max (first!=0) there will
+not be a valid range. In this case the min and max returned must be
+the NULL-value.
+
+ - G_write_range()
+
+This routine only writes 2 numbers (min,max) to the range file,
+instead of the 4 (pmin,pmax,nmin,nmax) previously written. If there is
+no defined min,max, an empty file is written.
+
 \section New_range_functions New range functions
 
+ - G_construct_default_range()
 
-<P>
-int G_construct_default_range(struct Range *r) Sets the integer
-  range <EM>r</EM> to [1,255]
+Sets the integer range to [1,255].
 
-<P>
-int G_read_raster_range(void *r, char *name, char *mapset,
-  RASTER_MAP_TYPEmap_type) If <EM>map_type</EM> is CELL_TYPE, calls
-  G_read_range((struct Range *) r, name, mapset) ; otherwise calls
-  G_read_fp_range((struct FPRange *) r, name, mapset) ;
+ - G_read_raster_range()
 
-<P>
-int G_read_fp_range(struct FPRange *r, char *name, char
-  *mapset) Read the floating point range file <TT>f_range</TT>. This file is
-  written in binary using XDR format. If there is no defined min/max in <EM>r</EM>, 
-  an empty <TT>f_range</TT>file is created.
+If raster type is CELL_TYPE, calls G_read_range(), otherwise calls
+G_read_fp_range().
 
-<P>
-An empty range file indicates that the min, max are undefined. This is a
-  valid case, and the result should be an initialized range struct with no
-  defined min/max.
+ - G_read_fp_range()
 
-<P>
+Read the floating point range file <tt>f_range</tt>. This file is
+written in binary using XDR format. If there is no defined min/max in
+FPRange structure, an empty <tt>f_range</tt> file is created.
+
+An empty range file indicates that the min, max are undefined. This is
+a valid case, and the result should be an initialized range struct
+with no defined min/max.
+
 If the range file is missing and the map is a floating-point map, this
-  function will create a default range by calling <TT>G_construct_default_range()</TT>.
+function will create a default range by calling
+G_construct_default_range().
 
-<P>
-int G_init_raster_range (FPRange *r, RASTER_MAP_TYPE
-  map_type) If <EM>map_type</EM> is CELL_TYPE, calls G_init_range(struct
-  Range *) r) ; otherwise calls G_init_fp_range((struct FPRange *) r) ;
+ - G_init_raster_range()
 
-<P>
-int G_init_fp_range (FPRange *r) Must set a flag in the range
-  structure that indicates that no min/max have been defined - probably a
-  <TT>"first"</TT> boolean flag.
+If raster type is CELL_TYPE, calls G_init_range(), otherwise calls
+G_init_fp_range().
 
-<P>
-int G_update_f_range (FPRange *r, FCELL *fcell, int n) Updates the
-floating-point range <EM>r</EM> from the <EM>n</EM> <TT>FCELL</TT> values in <EM>fcell</EM>
-NULL-values must be detected and ignored.
+ - G_init_fp_range()
 
-<P>
-int G_update_d_range (FPRange *r, DCELL *dcell, int n) Updates
-  the floating-point range <EM>r</EM> from the <EM>n</EM> <TT>DCELL</TT> values in 
-  <EM>dcell</EM> NULL-values must be detected and ignored.
+Must set a flag in the range structure that indicates that no min/max
+have been defined - probably a "first" boolean flag.
 
-<P>
-int G_get_fp_range_min_max (FPRange *r, DCELL *min, DCELL
-  *max) Extract the min/max from the range structure <EM>r</EM>.
+ - G_update_f_range()
+ - G_update_d_range()
 
-<P>
-If the range structure has no defined min/max (first!=0) there will not be a
-  valid range. In this case the min and max returned must be the NULL-value.
+Updates the floating-point range from the values in NULL-values must
+be detected and ignored.
 
-<P>
-int G_write_fp_range (FPRange *r) Write the floating point range
-  file <TT>f_range</TT>. This file is written in binary using XDR format. If
-  there is no defined min/max in <EM>r</EM>, an empty <TT>f_range</TT>file is
-  created.
+ - G_get_fp_range_min_max()
 
-<P>
+Extract the min/max from the FPRange structure. If the range structure
+has no defined min/max (first!=0) there will not be a valid range. In
+this case the min and max returned must be the NULL-value.
 
+ - G_write_fp_range()
+
+Write the floating point range file <tt>f_range</tt>. This file is
+written in binary using XDR format. If there is no defined min/max in
+<EM>r</EM>, an empty <tt>f_range</tt> file is created.
+
 \section New_and_Upgraded_Cell_stats_functions New and Upgraded Cell_stats functions
 
+Modified Cell_stats functions to handle NULL-values:
 
-<P>
-Modified <TT>Cell_stats</TT> functions to handle NULL-values:
+ - G_init_cell_stats()
 
-<P>
-int G_init_cell_stats() Set the count for NULL-values to zero.
+Set the count for NULL-values to zero.
 
-<P>
-int G_update_cell_stats() Look for NULLs and update the
-  NULL-value count.
+ - G_update_cell_stats()
 
-<P>
-int G_next_cell_stat() Do not return a record for the
-  NULL-value
+Look for NULLs and update the NULL-value count.
 
-<P>
-int G_find_cell_stat() Allow finding the count for the
-  NULL-value
+ - G_next_cell_stat()
 
-<P>
-int G_get_stats_for_null_value(int *count, struct Cell_stats
-  *s) Get a number of null values from stats structure. Note: when reporting
-  values which appear in a map using G_next_cell_stats() , to get stats for
-  null, call G_get_stats_for_null_value() first, since
-  G_next_cell_stats() does not report stats for null.
+Do not return a record for the NULL-value.
 
-<P>
+ - G_find_cell_stat()
 
-\section New_Quantization_Functions New Quantization Functions
+Allow finding the count for the NULL-value.
 
+ - G_get_stats_for_null_value()
 
-<P>
+Get a number of null values from stats structure. Note: when reporting
+values which appear in a map using G_next_cell_stats() , to get stats
+for null, call G_get_stats_for_null_value() first, since
+G_next_cell_stats() does not report stats for null.
+
+\section New_Quantization_Functions New Quantization Functions
+
 New functions to support quantization of floating-point to integer:
 
-<P>
-int G_write_quant(char *name, char *mapset, struct Quant
-  *q) Writes the <TT>f_quant</TT> file for the raster map <EM>name</EM> from <EM>q</EM>.
+ - G_write_quant()
 
-<P>
-if mapset==G_mapset() i.e. the map is in current mapset, then the original
-  quant file in cell_misc/map/f_quant is written. Otherwise <EM>q</EM> is
-  written into quant2/mapset/name (much like colr2 element) . This results in
-  map&#64;mapset being read using quant rules stored in <EM>q</EM> from
-  G_mapset() .  See G_read_quant() for detailes.
+Writes the <tt>f_quant</tt> file for the raster map. If
+mapset==G_mapset() i.e. the map is in current mapset, then the
+original quant file in <tt>cell_misc/map/f_quant</tt> is
+written. Othewise is written into <tt>quant2/mapset/name</tt> (much
+like colr2 element). This results in map&#64;mapset being read using
+quant rules stored G_mapset(). See G_read_quant() for detailes.
 
-<P>
-int G_set_quant_rules (int fd, struct Quant *q) Sets quant
-  translation rules for raster map opened for reading. fd is a file descriptor
-  returned by G_open_cell_old() . After calling this function,
-  G_get_c_raster_row() and G_get_map_row() will use rules defined by q
-  (instead of using rules defined in map's quant file) to convert floats to
-  ints.
+ - G_set_quant_rules()
 
-<P>
-int G_read_quant(char *name, char *mapset, struct Quant *q) reads
-  quantization rules for <TT>"name"</TT> in <TT>"mapset"</TT> and stores them
-  in the quantization structure <TT>"quant"</TT>. If the map is in another
-  mapset, first checks for quant2 table for this map in current mapset.
+Sets quant translation rules for raster map opened for reading. After
+calling this function, G_get_c_raster_row() and G_get_map_row() will
+use defined rules (instead of using rules defined in map's quant file)
+to convert floats to ints.
 
-<P>
-Return codes:
+ - G_read_quant()
 
-<P>
--2 if raster map is of type integer
+Reads quantization rules for raster map and stores them in the
+quantization structure. If the map is in another mapset, first checks
+for quant2 table for this map in current mapset.
 
-<P>
--1 if (! G__name_is_fully_qualified () ) 
+ - G_quant_init()
 
-<P>
-0 if quantization file does not exist, or the file is empty or has wrong
-  format.
+Initializes the Quant struct.
 
-<P>
-1 if non-empty quantization file exists.
+ - G_quant_free()
 
-<P>
-int G_quant_init(struct Quant *q) Initializes the <EM>q</EM>
-  struct.
+Frees any memory allocated in Quant structure and re-initializes the
+structure by calling G_quant_init().
 
 <P>
-int G_quant_free(struct Quant *q) Frees any memory allocated in
-  <EM>q</EM> and re-initializes <EM>q</EM> by calling <TT>G_quant_init()</TT>.
-
-<P>
 int G_quant_truncate(struct Quant *q) sets the quant for <EM>q</EM>
   rules to perform simple truncation on floats.
 

Modified: grass/trunk/lib/gis/quant.c
===================================================================
--- grass/trunk/lib/gis/quant.c	2009-06-11 08:27:44 UTC (rev 37818)
+++ grass/trunk/lib/gis/quant.c	2009-06-11 13:07:54 UTC (rev 37819)
@@ -1,291 +1,26 @@
-
-/**********************************************************************
+/*!
+ * \file gis/quant.c
+ * 
+ * \brief GIS Library - Quantization rules.
  *
- *  G_quant_init (quant)
- *       struct Quant *quant;
+ * The quantization table is stored as a linear array. rules are added
+ * starting from index 0. redundant rules are not eliminated. rules
+ * are tested from the highest index downto 0. there are two
+ * "infinite" rules. support is provided to reverse the order of the
+ * rules.
  *
- *  initializes new quantization structure. calls
- *  G_quant_clear() before it returns.
- *  
- *  note: dies if G_malloc dies.
+ * (C) 1999-2009 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.
  *
- *  G_quant_is_truncate (quant)
- *       struct Quant *quant;
- *
- *  Returns wether or not quant rules are set to truncate map
- *  
- **********************************************************************
- *
- *  G_quant_is_round (quant)
- *       struct Quant *quant;
- *
- *  Returns wether or not quant rules are set to round map
- *  
- **********************************************************************
- *
- *  G_quant_truncate (quant)
- *       struct Quant *quant;
- *
- *  sets the quant rules to perform simple truncation on floats.
- *  
- **********************************************************************
- *
- *  G_quant_round (quant)
- *       struct Quant *quant;
- *
- *  sets the quant rules to perform simple rounding on floats.
- *  
- **********************************************************************
- *
- *  G_quant_organize_fp_lookup (quant)
- *       struct Quant *quant;
- *
- *  Organizes fp_lookup table for faster (logarithmic) lookup time
- *  G_quant_organize_fp_lookup() creates a list of min and max for
- *  each quant rule, sorts this list, and stores the pointer to quant
- *  rule that should be used inbetween any 2 numbers in this list.
- *  Also it stores extreme points for 2 infinite rules, if exist.
- *  After the call to G_quant_organize_fp_lookup()
- *  instead of linearly searching through list of rules to find
- *  a rule to apply, quant lookup will perform a binary search
- *  to find an interval containing floating point value, and then use
- *  the rule associated with this interval.
- *  when the value doesn't fall within any interval, check for the
- *  infinite rules.
- *  
- **********************************************************************
- *
- *  void
- *  G_quant_free (q)
- *  
- *       struct Quant *q;
- *
- *  resets the number of defined rules to 0 and free's space allocated
- *  for rules. calls G_quant_clear ().
- *
- **********************************************************************
- *
- *  void
- *  G_quant_clear (q)
- *  
- *       struct Quant *q;
- *
- *  resets the number of defined rules and number of infinite rules to 0. 
- *
- **********************************************************************
- *
- *  int
- *  G_quant_get_limits (q, dMin, dMax, cMin, cMax)
- *  
- *       struct Quant *q;
- *       DCELL *dMin, *dMax;
- *       CELL *cMin, *cMax;
- *
- *  returns the minimum and maximum cell and dcell values of all
- *  the ranges defined.
- *  
- *  returns: -1 if q->truncate or q->round are true or
-		   after G_quant_init (), or any call to 
- *                 G_quant_clear () or G_quant_free () 
- *                 no explicit rules have been added
- *                 In this case the returned minimum and maximum 
- *                 CELL and DCELL values are null.
- *            1 otherwise. in this case the values returned correspond
- *                 to the extreme values of the defined rules 
- *
- **********************************************************************
- *  
- *  int
- *  G_quant_nof_rules (q)
- *  
- *       struct Quant *q;
- *  
- *  returns the number of quantization rules defined. This number does
- *  not include the 2 infinite intervals.
- *  
- **********************************************************************
- *  
- *  void
- *  G_quant_get_ith_rule (q, i, dLow, dHigh, cLow, cHigh)
- *  
- *       struct Quant *q;
- *       int i;
- *       DCELL *dLow, *dHigh;
- *       CELL *cLow, *cHigh;
- *  
- *  returns the i'th quantization rule, for 0 <= i < G_quant_nof_rules().
- *  a larger value for i means that the rule has been added later.
- *  
- **********************************************************************
- *   void
- *   G_quant_set_neg_infinite_rule (q, dLeft, c)
- *
- *       struct Quant *q;
- *       DCELL dLeft;
- *       CELL c;
- *
- *   defines a rule for values "dLeft" and smaller. values in this range
- *   are mapped to "c" if none of the "finite" quantization rules applies.
- *
- * **********************************************************************
- *
- *  int
- *  G_quant_get_neg_infinite_rule (q, dLeft, c)
- *
- *       struct Quant *q;
- *       DCELL *dLeft;
- *       CELL *c;
- *
- *  returns in "dLeft" and "c" the rule values for the negative infinite
- *  interval (see G_quant_set_neg_infinite_rule ()).
- *
- *  returns: 0 if this rule is not defined
- *           1 otherwise.
- *
- * **********************************************************************
- *
- *  struct Quant_table *
- *  G__quant_get_rule_for_d_raster_val (q, val)
- *
- *       struct Quant *q;
- *       DCELL val;
- *
- *  returns quant rule which will be applied when looking up  the
- *  integer quant value for val. (used when organizing fp_lookup.
- *
- *  returns: pointer to the Quant_table (color rule)
- *           NULL otherwise.
- *
- **********************************************************************
- *   void
- *   G_quant_set_pos_infinite_rule (q, dRight, c)
- *
- *       struct Quant *q;
- *       DCELL dRight;
- *       CELL c;
- *
- *   defines a rule for values "dRight" and larger. values in this range
- *   are mapped to "c" if none of the "finite" quantization rules or the
- *   negative infinite rule applies.
- *
- * **********************************************************************
- *
- *  int
- *  G_quant_get_pos_infinite_rule (q, dRight, c)
- *
- *       struct Quant *q;
- *       DCELL *dRight;
- *       CELL *c;
- *
- *  returns in "dRight" and "c" the rule values for the positive infinite
- *  interval (see G_quant_set_pos_infinite_rule ()).
- *
- *  returns: 0 if this rule is not defined
- *           1 otherwise.
- *
- **********************************************************************
- *  
- *  void
- *  G_quant_reverse_rule_order (q)
- *
- *        struct Quant *q;
- *
- *  reverses the order in which the qunatization rules are stored. (see
- *  also G_quant_get_ith_rule () and G_quant_perform_d ()).
- *  
- **********************************************************************
- *  
- *  void
- *  G_quant_add_rule (q, dLow, dHigh, cLow, cHigh)
- *  
- *       struct Quant *q;
- *       DCELL dLow, dHigh;
- *       CELL cLow, cHigh;
- *  
- *  adds a new rule to the set of quantization rules. if dLow < dHigh
- *  the rule will be stored with the low and high values interchanged.
- *  
- *  Note: currently no cleanup of rules is performed, i.e. redundant
- *        rules are not removed. This can't be changed because Categories
- *        structure HEAVILY depends of quant rules stored in exactly the
- *        same order they are entered. So if the cleanup or rearrangement 
- *        is done in the future make a flag for add_rule wether or not
- *        to do it, then quant will not set this flag.
- *  
- **********************************************************************
- *  
- *  CELL
- *  G_quant_get_cell_value (q, cellValue)
- *  
- *       struct Quant *q;
- *       DCELL *cellValue;
- *  
- *  returns in "cell" the quantized CELL values corresponding to the
- *  DCELL value "cellValue".
- *
- *  if several quantization rules apply for cellValue, the one which has 
- *  been inserted latest (i.e. the one of them which is returned by 
- *  G_quant_get_ith_rule() for the largest i) is used. if no such rule
- *  applies the cellValue is first tested against the negative infinite
- *  rule, and finally against the positive infinite rule. if none of
- *  these rules apply, NO_DATA is returned. the actual value of NO_DATA 
- *  is found by calling G_c_set_null_value().
- *
- *  NOTE: see G_quant_organize_fp_lookup() for details on how
- *  the values are looked up from fp_lookup table when it is active.
- *  
- *  if after G_quant_init (), or any call to G_quant_clear () or 
- *  G_quant_free () neither G_quant_add_rule (),
- *  G_quant_set_neg_infinite_rule (),  G_quant_set_pos_infinite_rule ()
- *  are used NO_DATA is returned independently 
- *  of cellValue.
- *
- **********************************************************************
- *  
- *  void
- *  G_quant_perform_d (q, dcell, cell, n)
- *  
- *       struct Quant *q;
- *       DCELL *dcell;
- *       CELL *cell;
- *       int n;
- *  
- *  returns in "cell" the quantized CELL values corresponding to the
- *  DCELL values stored in "dcell". the number of elements quantized
- *  is n. quantization is performed by repeated application of 
- *  G_quant_get_cell_value ().
- *  
- **********************************************************************
- *  
- *  void
- *  G_quant_perform_f (q, fcell, cell, n)
- *  
- *       struct Quant *q;
- *       FCELL *fcell;
- *       CELL *cell;
- *       int n;
- *  
- *  same as G_quant_perform_d (), except the type.
- *  
- **********************************************************************/
-
-/*--------------------------------------------------------------------------*/
-
-/*
-   the quantization table is stored as a linear array. rules are added starting
-   from index 0. redundant rules are not eliminated. rules are tested from the 
-   highest index downto 0. there are two "infinite" rules. support is provided 
-   to reverse the order of the rules.
+ * \author USACERL and many others
  */
 
-/*--------------------------------------------------------------------------*/
-
 #include <stdlib.h>
 #include <grass/gis.h>
 
-/*--------------------------------------------------------------------------*/
 static int double_comp(const void *, const void *);
 
 #define USE_LOOKUP 1
@@ -303,16 +38,25 @@
 #define NO_EXPLICIT_RULE (NO_FINITE_RULE && \
 			  NO_LEFT_INFINITE_RULE && NO_RIGHT_INFINITE_RULE)
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Resets the number of defined rules and number of infinite rules to 0
 
+  \param q pointer to Quant structure to be reset
+*/
 void G_quant_clear(struct Quant *q)
 {
     q->nofRules = 0;
     q->infiniteRightSet = q->infiniteLeftSet = 0;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Resets and frees allocated memory
 
+  Resets the number of defined rules to 0 and free's space allocated
+  for rules. Calls G_quant_clear().
+ 
+  \param q pointer to Quant structure to be reset
+*/
 void G_quant_free(struct Quant *q)
 {
     G_quant_clear(q);
@@ -328,8 +72,26 @@
     q->maxNofRules = 0;
 }
 
-/*--------------------------------------------------------------------------*/
-
+/*!
+ * \brief Organized fp_lookup table.
+ *
+ *  Organizes fp_lookup table for faster (logarithmic) lookup time
+ *  G_quant_organize_fp_lookup() creates a list of min and max for
+ *  each quant rule, sorts this list, and stores the pointer to quant
+ *  rule that should be used inbetween any 2 numbers in this list.
+ *  Also it stores extreme points for 2 infinite rules, if exist.
+ *  After the call to G_quant_organize_fp_lookup()
+ *  instead of linearly searching through list of rules to find
+ *  a rule to apply, quant lookup will perform a binary search
+ *  to find an interval containing floating point value, and then use
+ *  the rule associated with this interval.
+ *  when the value doesn't fall within any interval, check for the
+ *  infinite rules.
+ *
+ * \param q pointer to Quant structure which holds quant rules info
+ *
+ * \return 1 on success
+ */
 int G__quant_organize_fp_lookup(struct Quant *q)
 {
     int i;
@@ -407,18 +169,13 @@
     return 1;
 }
 
-/*--------------------------------------------------------------------------*/
-
-
 /*!
- * \brief 
+ * \brief Initialize the structure
  *
- * Initializes the <em>q</em> struct.
+ * Initializes the <i>q</i> struct.
  *
- *  \param q
- *  \return
+ * \param quant pointer to Quant structure to be initialized
  */
-
 void G_quant_init(struct Quant *quant)
 {
     quant->fp_lookup.active = 0;
@@ -428,56 +185,57 @@
     G_quant_clear(quant);
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns wether or not quant rules are set to truncate map
 
+  \param quant pointer to Quant structure which holds quant rules info
+
+  \return 1 if truncate is enable
+  \return 0 if not truncated
+*/
 int G_quant_is_truncate(const struct Quant *quant)
 {
     return quant->truncate_only;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief  Returns wether or not quant rules are set to round map
+  \param quant pointer to Quant structure which holds quant rules info
 
+  \return 1 is round
+  \return 0 not round
+*/
 int G_quant_is_round(const struct Quant *quant)
 {
     return quant->round_only;
 }
 
-/*--------------------------------------------------------------------------*/
-
 /*!
- * \brief 
+ * \brief Sets the quant rules to perform simple truncation on floats.
  *
- * sets the quant for <em>q</em>
- * rules to perform simple truncation on floats.
+ * Sets the quant for <i>q</i> rules to perform simple truncation on
+ * floats.
  *
- *  \param q
- *  \return
+ * \param quant pointer to Quant structure which holds quant rules info
  */
-
 void G_quant_truncate(struct Quant *quant)
 {
     quant->truncate_only = 1;
 }
 
-/*--------------------------------------------------------------------------*/
-
 /*!
- * \brief 
+ * \brief Sets the quant rules to perform simple rounding on floats.
  *
- * sets the quant for <em>q</em>
- * rules to perform simple rounding on floats.
+ * Sets the quant for <i>q</i> rules to perform simple rounding on
+ * floats.
  *
- *  \param q
- *  \return
+ * \param quant pointer to Quant structure which holds quant rules info
  */
-
 void G_quant_round(struct Quant *quant)
 {
     quant->round_only = 1;
 }
 
-/*--------------------------------------------------------------------------*/
-
 static void quant_set_limits(struct Quant *q,
 			     DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
 {
@@ -487,8 +245,6 @@
     q->cMax = cHigh;
 }
 
-/*--------------------------------------------------------------------------*/
-
 static void quant_update_limits(struct Quant *q,
 				DCELL dLow, DCELL dHigh,
 				CELL cLow, DCELL cHigh)
@@ -504,27 +260,29 @@
     q->cMax = MAX(q->cMax, MAX(cLow, cHigh));
 }
 
-/*--------------------------------------------------------------------------*/
-
-
 /*!
- * \brief 
+ * \brief Returns the minimum and maximum cell and dcell values of all
+ *  the ranges defined.
  *
- * Extracts the minimum and maximum floating-point
- * and integer values from all the rules (except the <tt>"infinite"</tt> rules)
- * in <em>q</em> into <em>dmin</em>, <em>dmax</em>, <em>cmin</em>, and <em>cmax</em>. Returns 1
- * if there are any explicit rules. If there are no explicit rules, (this
- * includes cases when q is set to truncate or round map), it returns 0 and sets
- * <em>dmin</em>, <em>dmax</em>, <em>cmin</em>, and <em>cmax</em> to NULL.
+ * Extracts the minimum and maximum floating-point and integer values
+ * from all the rules (except the "infinite" rules) in <i>q</i> into
+ * <i>dmin</i>, <i>dmax</i>, <i>cmin</i>, and <i>cmax</i>.
  *
- *  \param q
- *  \param dmin
- *  \param dmax
- *  \param cmin
- *  \param cmax
- *  \return int
+ * \param quant pointer to Quant structure which holds quant rules info
+ * \param[out] dmin minimum fp value
+ * \param[out] dmax maximum fp value
+ * \param[out] cmin minimum value
+ * \param[out] cmax maximum value
+ *
+ * \return -1 if q->truncate or q->round are true or after
+ * G_quant_init (), or any call to G_quant_clear () or G_quant_free()
+ * no explicit rules have been added. In this case the returned
+ * minimum and maximum CELL and DCELL values are null.
+ * \return 1 if there are any explicit rules
+ * \return 0 if there are no explicit rules (this includes cases when
+ * q is set to truncate or round map), and sets <i>dmin</i>,
+ * <i>dmax</i>, <i>cmin</i>, and <i>cmax</i> to NULL.
  */
-
 int G_quant_get_limits(const struct Quant *q,
 		       DCELL * dMin, DCELL * dMax, CELL * cMin, CELL * cMax)
 {
@@ -544,15 +302,33 @@
     return 1;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns the number of quantization rules defined.
 
+  This number does not include the 2 infinite intervals.
+
+  \param q pointer to Quant structure which holds quant rules info
+  
+  \return number of quantization rules
+*/
 int G_quant_nof_rules(const struct Quant *q)
 {
     return q->nofRules;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns the i'th quantization rule.
 
+  For 0 <= i < G_quant_nof_rules(). A larger value for i means that
+  the rule has been added later.
+ 
+  \param q pointer to Quant structure which holds quant rules info
+  \param i index
+  \param[out] dLow minimum fp value
+  \param[out] dHigh maximum fp value
+  \param[out] cLow minimum value
+  \param[out] cHigh maximum value
+*/
 void G_quant_get_ith_rule(const struct Quant *q,
 			  int i,
 			  DCELL * dLow, DCELL * dHigh,
@@ -564,8 +340,6 @@
     *cHigh = q->table[i].cHigh;
 }
 
-/*--------------------------------------------------------------------------*/
-
 static void quant_table_increase(struct Quant *q)
 {
     if (q->nofRules < q->maxNofRules)
@@ -584,8 +358,17 @@
     }
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Defines a rule for values "dLeft" and smaller.
 
+  Values in this range are mapped to "c" if none of the "finite"
+  quantization rules applies.
+ 
+  \param q pointer to Quant structure which holds quant rules info
+
+  \param dLeft fp value
+  \param c value
+*/
 void G_quant_set_neg_infinite_rule(struct Quant *q, DCELL dLeft, CELL c)
 {
     q->infiniteDLeft = dLeft;
@@ -600,8 +383,18 @@
     q->infiniteLeftSet = 1;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns in "dLeft" and "c" the rule values.
 
+  For the negative infinite interval (see G_quant_set_neg_infinite_rule()).
+  
+  \param q pointer to Quant structure which holds quant rules info
+  \param[out] dLeft fp value
+  \param[out] c value
+
+  \return 0 if this rule is not defined
+  \return 1 otherwise
+*/
 int G_quant_get_neg_infinite_rule(const struct Quant *q,
 				  DCELL * dLeft, CELL * c)
 {
@@ -614,8 +407,16 @@
     return 1;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Defines a rule for values "dRight" and larger.
 
+  Values in this range are mapped to "c" if none of the "finite"
+  quantization rules or the negative infinite rule applies.
+
+  \param q pointer to Quant structure which holds quant rules info
+  \param dRight fp value
+  \param c value
+*/
 void G_quant_set_pos_infinite_rule(struct Quant *q, DCELL dRight, CELL c)
 {
     q->infiniteDRight = dRight;
@@ -630,8 +431,18 @@
     q->infiniteRightSet = 1;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns in "dRight" and "c" the rule values.
 
+  For the positive infinite interval (see G_quant_set_pos_infinite_rule()).
+
+  \param q pointer to Quant structure which holds quant rules info
+  \param[out] dRight fp value
+  \param[out] c value
+
+  \return 0 if this rule is not defined
+  \return 1 otherwise
+*/
 int G_quant_get_pos_infinite_rule(const struct Quant *q,
 				  DCELL * dRight, CELL * c)
 {
@@ -644,8 +455,25 @@
     return 1;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+ \brief Adds a new rule to the set of quantization rules.
 
+ If dLow < dHigh the rule will be stored with the low and high values
+ interchanged.
+ 
+ Note: currently no cleanup of rules is performed, i.e. redundant
+ rules are not removed. This can't be changed because Categories
+ structure HEAVILY depends of quant rules stored in exactly the same
+ order they are entered. So if the cleanup or rearrangement is done in
+ the future make a flag for add_rule wether or not to do it, then
+ quant will not set this flag.
+
+ \param q pointer to Quant structure which holds quant rules info
+ \param dLow minimum fp value
+ \param dHigh maximum fp value
+ \param cLow minimum value
+ \param cHigh maximum value
+*/
 void G_quant_add_rule(struct Quant *q,
 		      DCELL dLow, DCELL dHigh, CELL cLow, CELL cHigh)
 {
@@ -683,8 +511,13 @@
     q->nofRules++;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Rreverses the order in which the qunatization rules are stored.
 
+  See also G_quant_get_ith_rule() and G_quant_perform_d()).
+
+  \param q pointer to Quant rules which holds quant rules info
+*/
 void G_quant_reverse_rule_order(struct Quant *q)
 {
     struct Quant_table tmp;
@@ -714,8 +547,6 @@
     }
 }
 
-/*--------------------------------------------------------------------------*/
-
 static CELL quant_interpolate(DCELL dLow, DCELL dHigh,
 			      CELL cLow, CELL cHigh, DCELL dValue)
 {
@@ -728,7 +559,6 @@
 		   (DCELL) cLow);
 }
 
-/*--------------------------------------------------------------------------*/
 static int less_or_equal(double x, double y)
 {
     if (x <= y)
@@ -745,27 +575,28 @@
 	return 0;
 }
 
-
 /*!
  * \brief 
  *
  * 
- * Returns a CELL category for the floating-point <em>value</em> based on the
- * quantization rules in <em>q</em>. The first rule found that applies is used.
- * The rules are searched in the reverse order they are added to <em>q</em>.  If no
- * rule is found, the <em>value</em> is first tested against the negative infinite
- * rule, and finally against the positive infinite rule. if none of these rules
- * apply, the NULL-value is returned.
- * <b>NOTE.</b> See G_quant_organize_fp_lookup() for details on how the
- * values are looked up from fp_lookup table when it is active. (Right now
- * fp_lookup is automatically organized during the first call to
- * G_quant_get_cell_value()
+ * Returns a CELL category for the floating-point <i>value</i> based
+ * on the quantization rules in <i>q</i>. The first rule found that
+ * applies is used. The rules are searched in the reverse order they
+ * are added to <i>q</i>. If no rule is found, the <i>value</i>
+ * is first tested against the negative infinite rule, and finally
+ * against the positive infinite rule. If none of these rules apply,
+ * the NULL-value is returned.
  *
- *  \param q
- *  \param value
- *  \return CELL
+ * <b>Note:</b> See G_quant_organize_fp_lookup() for details on how
+ * the values are looked up from fp_lookup table when it is
+ * active. Right now fp_lookup is automatically organized during the
+ * first call to G_quant_get_cell_value().
+ *
+ * \param q pointer to Quant structure which holds quant rules info
+ * \param dcellValue fp cell value
+ *
+ * \return cell value (integer)
  */
-
 CELL G_quant_get_cell_value(struct Quant * q, DCELL dcellVal)
 {
     CELL tmp;
@@ -873,8 +704,19 @@
     return q->infiniteCRight;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns in "cell" the quantized CELL values.
 
+  Returns in "cell" the quantized CELL values corresponding to the
+  DCELL values stored in "dcell". the number of elements quantized
+  is n. quantization is performed by repeated application of 
+  G_quant_get_cell_value().
+
+  \param q pointer to Quant structure which holds quant rules info
+  \param dcell pointer to fp cell values array
+  \param[out] cell pointer cell values array
+  \param n number of cells
+*/
 void G_quant_perform_d(struct Quant *q,
 		       const DCELL * dcell, CELL * cell, int n)
 {
@@ -887,8 +729,14 @@
 	    G_set_c_null_value(cell++, 1);
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Same as G_quant_perform_d(), except the type.
 
+  \param q pointer to Quant structure which holds quant rules info
+  \param fcell pointer to fp cell values array
+  \param[out] cell pointer cell values array
+  \param n number of cells
+*/
 void G_quant_perform_f(struct Quant *q,
 		       const FCELL * fcell, CELL * cell, int n)
 {
@@ -901,8 +749,6 @@
 	    G_set_c_null_value(cell++, 1);
 }
 
-/*--------------------------------------------------------------------------*/
-
 static int double_comp(const void *xx, const void *yy)
 {
     const DCELL *x = xx;
@@ -918,8 +764,18 @@
 	return 1;
 }
 
-/*--------------------------------------------------------------------------*/
+/*!
+  \brief Returns quant rule which will be applied.
 
+  Returns quant rule which will be applied when looking up the integer
+  quant value for val (used when organizing fp_lookup).
+
+  \param q pointer to Quant structure which holds quant rules info
+  \param val fp cell value
+  
+  \return pointer to the Quant_table (color rule)
+  \return NULL otherwise
+*/
 struct Quant_table *G__quant_get_rule_for_d_raster_val(const struct Quant *q,
 						       DCELL val)
 {
@@ -933,9 +789,3 @@
     else
 	return (struct Quant_table *)NULL;
 }
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/

Modified: grass/trunk/lib/gis/quant_rw.c
===================================================================
--- grass/trunk/lib/gis/quant_rw.c	2009-06-11 08:27:44 UTC (rev 37818)
+++ grass/trunk/lib/gis/quant_rw.c	2009-06-11 13:07:54 UTC (rev 37819)
@@ -1,66 +1,34 @@
+/*!
+ * \file gis/quant_rw.c
+ * 
+ * \brief GIS Library - Quantization rules (read/write).
+ *
+ * (C) 1999-2009 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.
+ *
+ * \author USACERL and many others
+ */
+
+#include <string.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
-#include <string.h>
 
-/*********************************************************************
-*
-*   G_quantize_fp_map(name, mapset, min, max)
-*   char *name, *mapset;   name of the map
-*   CELL min, max;         resulting int range
-*
-*   Writes necessary quant rules for map <name> so that
-*   a floating range of <name> is mapped into integer range (min, max)
-*
-**********************************************************************
-* 
-*   G_quantize_fp_map_range(name, mapset, d_min, d_max, min, max)
-*   char *name, *mapset;   name of the map
-*   CELL min, max;         resulting int range
-*   DCELL d_min, d_max;    floating point range
-*
-*   Make a rule for map <name> that maps floating range (d_min, d_max)
-*   into integer range (min, max)
-*   This function is useful when the quant rule doesn't depend of the
-*   range of produced float data, for example the slope map whould
-*   want to have a quant rule: 0.0, 90.0 -> 0 , 90
-*   no matter what the min and max slope of this map is.
-*
-**********************************************************************
-* 
-*   G_write_quant(name, mapset, quant)
-*        char *name, *mapset;
-*        struct Quant *quant;
-*   writes the quant rule table for the map <name>
-*
-**********************************************************************
-* 
-*   G_read_quant(name, mapset, quant)
-*        char *name, *mapset;
-*
-*   reads the quant table for name at mapset
-*
-**********************************************************************
-*
-*   G_truncate_fp_map(name, mapset)
-*        char *name, *mapset;
-*        struct Quant *quant;
-*
-*   writes the quant rules which indicate that all floating numbers
-*   should be truncated instead of applying any quant rules from
-*   floats to integers
-*
-**********************************************************************
-*
-*   G_round_fp_map(name, mapset)
-*        char *name, *mapset;
-*        struct Quant *quant;
-*
-*   writes the quant rules which indicate that all floating numbers
-*   should be rounded instead of applying any quant rules from
-*   floats to integers
-*
-**********************************************************************/
+/*!
+  \brief Writes the quant rules.
 
+  Writes the quant rules which indicate that all floating numbers
+  should be truncated instead of applying any quant rules from
+  floats to integers.
+
+  \param name map name
+  \param mapset mapset name
+
+  \return -1 on error
+  \return 1 on success
+*/
 int G_truncate_fp_map(const char *name, const char *mapset)
 {
     struct Quant quant;
@@ -69,14 +37,26 @@
     G_quant_truncate(&quant);
     /* quantize the map */
     if (G_write_quant(name, mapset, &quant) < 0) {
-	G_warning(_("G_truncate_fp_map: can't write quant rules"
-		    " for map %s"),
-		   name);
+	G_warning(_("Unable to write quant rules for raster map <%s>"),
+		  name);
 	return -1;
     }
     return 1;
 }
 
+/*!
+  \brief Writes the quant rules.
+  
+  Writes the quant rules which indicate that all floating numbers
+  should be rounded instead of applying any quant rules from
+  floats to integers.
+  
+  \param name map name
+  \param mapset mapset name
+
+  \return -1 on error
+  \return 1 on success
+*/
 int G_round_fp_map(const char *name, const char *mapset)
 {
     struct Quant quant;
@@ -85,29 +65,36 @@
     G_quant_round(&quant);
     /* round the map */
     if (G_write_quant(name, mapset, &quant) < 0) {
-	G_warning(_("G_truncate_fp_map: can't write quant rules"
-		    " for map %s"),
+	G_warning(_("Unable to write quant rules for raster map <%s>"),
 		  name);
 	return -1;
     }
     return 1;
 }
 
-
 /*!
- * \brief 
+ * \brief Write quant rules (f_quant) for floating-point raster map.
  *
- * Writes
- * the <tt>f_quant</tt> file for the raster map <em>name</em> with one rule. The rule
- * is generated using the floating-point range in <tt>f_range</tt> producing the
- * integer range [<em>cmin,cmax</em>].
+ * Writes the <tt>f_quant</tt> file for the raster map <em>name</em>
+ * with one rule. The rule is generated using the floating-point range
+ * in <tt>f_range</tt> producing the integer range
+ * [<em>cmin,cmax</em>].
  *
- *  \param name
- *  \param cmin
- *  \param cmax
- *  \return int
- */
+ * Make a rule for map <name> that maps floating range (d_min, d_max)
+ * into integer range (min, max)
+ * This function is useful when the quant rule doesn't depend of the
+ * range of produced float data, for example the slope map whould
+ * want to have a quant rule: 0.0, 90.0 -> 0 , 90
+ * no matter what the min and max slope of this map is.
 
+ * \param name map name
+ * \param mapset mapset name
+ * \param cmin minimum value
+ * \param cmax maximum value
+ *
+ * \return -1 on error
+ * \return 1 on success
+ */
 int G_quantize_fp_map(const char *name, const char *mapset,
 		      CELL min, CELL max)
 {
@@ -115,24 +102,21 @@
     struct FPRange fp_range;
 
     if (G_read_fp_range(name, mapset, &fp_range) < 0) {
-	G_warning(_("G_quantize_fp_map: can't read fp range for map %s"),
-		  name);
+	G_warning(_("Unable to read fp range for raster map <%s>"),
+		  G_fully_qualified_name(name, mapset));
 	return -1;
     }
     G_get_fp_range_min_max(&fp_range, &d_min, &d_max);
     if (G_is_d_null_value(&d_min) || G_is_d_null_value(&d_max)) {
-	G_warning(_("G_quantize_fp_map: raster map %s is empty"),
-		  name);
+	G_warning(_("Raster map <%s> is empty"),
+		  G_fully_qualified_name(name, mapset));
 	return -1;
     }
     return G_quantize_fp_map_range(name, mapset, d_min, d_max, min, max);
 }
 
-/*-------------------------------------------------------------------------*/
-
-
 /*!
- * \brief 
+ * \brief Write quant rules (f_quant) for floating-point raster map.
  *
  * Writes the <tt>f_quant</tt> file for the raster map
  * <em>name</em> with one rule. The rule is generated using the floating-point
@@ -144,14 +128,23 @@
  * 90] even if the range of slopes is not 0-90. The aspect map would be
  * quantized from [0.0, 360.0] to [0, 360].
  *
- *  \param name
- *  \param dmin
- *  \param dmax
- *  \param cmin
- *  \param cmax
- *  \return int
+ * Make a rule for map <name> that maps floating range (d_min, d_max)
+ * into integer range (min, max)
+ * This function is useful when the quant rule doesn't depend of the
+ * range of produced float data, for example the slope map whould
+ * want to have a quant rule: 0.0, 90.0 -> 0 , 90
+ * no matter what the min and max slope of this map is.
+ *
+ * \param name map name
+ * \param mapset mapset name
+ * \param d_min minimum fp value
+ * \param d_max maximum fp value
+ * \param min minimum value
+ * \param max maximum value
+ *
+ * \return -1 on error
+ * \return 1 on success
  */
-
 int G_quantize_fp_map_range(const char *name, const char *mapset,
 			    DCELL d_min, DCELL d_max, CELL min, CELL max)
 {
@@ -161,34 +154,31 @@
     G_quant_add_rule(&quant, d_min, d_max, min, max);
     /* quantize the map */
     if (G_write_quant(name, mapset, &quant) < 0) {
-	G_warning(_("G_quantize_fp_map_range: can't write quant rules"
-		    " for map %s"),
+	G_warning(_("Unable to write quant rules for raster map <%s>"),
 		  name);
 	return -1;
     }
     return 1;
 }
 
-/*-------------------------------------------------------------------------*/
-
-
-
 /*!
- * \brief 
+ * \brief Writes the quant rule table for the raster map
  *
- * Writes the <tt>f_quant</tt> file for the raster map <em>name</em> from <em>q</em>.
- * if mapset==G_mapset() i.e. the map is in current mapset, then the original
- * quant file in cell_misc/map/f_quant is written. Otherwise <em>q</em> is
- * written into quant2/mapset/name (much like colr2 element). This results in
- * map at mapset being read using quant rules stored in <em>q</em> from
- * G_mapset().  See G_read_quant() for detailes.
+ * Writes the <tt>f_quant</tt> file for the raster map <em>name</em>
+ * from <em>q</em>.  if mapset==G_mapset() i.e. the map is in current
+ * mapset, then the original quant file in cell_misc/map/f_quant is
+ * written. Otherwise <em>q</em> is written into quant2/mapset/name
+ * (much like colr2 element). This results in map at mapset being read
+ * using quant rules stored in <em>q</em> from G_mapset(). See
+ * G_read_quant() for detailes.
  *
- *  \param name
- *  \param mapset
- *  \param q
- *  \return int
+ * \param name map name
+ * \param mapset mapset name
+ * \param quant pointer to Quant structure which hold quant rules info
+ * 
+ * \return -1 on error
+ * \return 1 on success
  */
-
 int G_write_quant(const char *name, const char *mapset,
 		  const struct Quant *quant)
 {
@@ -196,7 +186,7 @@
     DCELL d_min, d_max;
 
     if (G_raster_map_type(name, mapset) == CELL_TYPE) {
-	G_warning(_("Cannot write quant rules: map %s is integer"),
+	G_warning(_("Unable to write quant rules: raster map <%s> is integer"),
 		  name);
 	return -1;
     }
@@ -205,35 +195,31 @@
 
     /* first actually write the rules */
     if (G__quant_export(name, mapset, quant) < 0) {
-	G_warning (_("Cannot write quant rules for map %s"), name);
+	G_warning (_("Unable to write quant rules for raster map <%s>"),
+		   name);
 	return -1;
     }
 
     return 1;
 }
 
-/*-------------------------------------------------------------------------*/
-
-
 /*!
  * \brief 
  *
- * reads quantization rules for <tt>"name"</tt> in <tt>"mapset"</tt> and stores them
- * in the quantization structure <tt>"quant"</tt>. If the map is in another
- * mapset, first checks for quant2 table for this map in current mapset.
- * Return codes:
- * -2 if raster map is of type integer
- * -1 if (! G__name_is_fully_qualified ())
- * 0 if quantization file does not exist, or the file is empty or has wrong
- * format.
- * 1 if non-empty quantization file exists.
- *
+ * Reads quantization rules for <i>name</i> in <i>mapset</i> and
+ * stores them in the quantization structure. If the map is in another
+ * mapset, first checks for quant2 table for this map in current
+ * mapset. 
  *  \param name
  *  \param mapset
  *  \param q
- *  \return int
+ *
+ * \return -2 if raster map is of type integer
+ * \return -1 if (!G__name_is_fully_qualified())
+ * \return 0 if quantization file does not exist, or the file is empty or has wrong format
+ * \return 1 if non-empty quantization file exists
+ *
  */
-
 int G_read_quant(const char *name, const char *mapset, struct Quant *quant)
 {
     G_quant_init(quant);



More information about the grass-commit mailing list