cell_stats.c File Reference

#include <grass/gis.h>
#include <stdlib.h>

Include dependency graph for cell_stats.c:

Go to the source code of this file.

Defines

#define INCR   10
#define SHIFT   6
#define NODE   struct Cell_stats_node

Functions

int G_init_cell_stats (struct Cell_stats *s)
 initialize cell stats
int G_update_cell_stats (CELL *cell, int n, struct Cell_stats *s)
 add data to cell stats
int G_find_cell_stat (CELL cat, long *count, struct Cell_stats *s)
 random query of cell stats
int G_rewind_cell_stats (struct Cell_stats *s)
 reset/rewind cell stats
int G_next_cell_stat (CELL *cat, long *count, struct Cell_stats *s)
 retrieve sorted cell stats
int G_get_stats_for_null_value (long *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.
int G_free_cell_stats (struct Cell_stats *s)
 free cell stats


Define Documentation

#define INCR   10

Definition at line 4 of file cell_stats.c.

Referenced by G_init_cell_stats(), and G_update_cell_stats().

#define NODE   struct Cell_stats_node

Definition at line 9 of file cell_stats.c.

Referenced by G_init_cell_stats(), and G_update_cell_stats().

#define SHIFT   6

Definition at line 5 of file cell_stats.c.

Referenced by G_find_cell_stat(), G_next_cell_stat(), and G_update_cell_stats().


Function Documentation

int G_find_cell_stat ( CELL  cat,
long *  count,
struct Cell_stats *  s 
)

random query of cell stats

This routine allows a random query of the Cell_stats structure s. The count associated with the raster value cat is set. The routine returns 1 if cat was found in the structure, 0 otherwise.

Parameters:
cat 
count 
s 
Returns:
int
Allow finding the count for the NULL-value

Returns:
int

Definition at line 215 of file cell_stats.c.

References G_is_c_null_value(), and SHIFT.

int G_free_cell_stats ( struct Cell_stats *  s  ) 

free cell stats

The memory associated with structure s is freed. This routine may be called any time after callingG_init_cell_stats.

Parameters:
s 
Returns:
int

Definition at line 439 of file cell_stats.c.

References G_free().

int G_get_stats_for_null_value ( long *  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.

Parameters:
count 
s 
Returns:
int

Definition at line 422 of file cell_stats.c.

int G_init_cell_stats ( struct Cell_stats *  s  ) 

initialize cell stats

This routine, which must be called first, initializes the Cell_stats structure s.

Parameters:
s 
Returns:
int
Set the count for NULL-values to zero.

Returns:
int

Definition at line 34 of file cell_stats.c.

References G_malloc(), INCR, and NODE.

int G_next_cell_stat ( CELL *  cat,
long *  count,
struct Cell_stats *  s 
)

retrieve sorted cell stats

Retrieves the next cat,count combination from the structure s. Returns 0 if there are no more items, non-zero if there are more. For example:

  struct Cell_stats s;
  CELL cat;
  long count;
  
  // updating <b>s</b> occurs here
  
  G_rewind_cell_stats(&s);
  while (G_next_cell_stat(&cat,&count,&s)
  fprintf(stdout, "%ld %ld\n", (long) cat, count);

Parameters:
cat 
count 
s 
Returns:
int
Do not return a record for the NULL-value

Returns:
int

Definition at line 358 of file cell_stats.c.

References SHIFT.

Referenced by G_cell_stats_histo_eq(), G_make_histogram_cs(), G_make_histogram_eq_colors(), G_make_histogram_log_colors(), and G_write_histogram_cs().

int G_rewind_cell_stats ( struct Cell_stats *  s  ) 

reset/rewind cell stats

The structure s is rewound (i.e., positioned at the first raster category) so that sorted sequential retrieval can begin.

Parameters:
s 
Returns:
int

Definition at line 284 of file cell_stats.c.

Referenced by G_cell_stats_histo_eq(), G_make_histogram_cs(), G_make_histogram_eq_colors(), G_make_histogram_log_colors(), and G_write_histogram_cs().

int G_update_cell_stats ( CELL *  cell,
int  n,
struct Cell_stats *  s 
)

add data to cell stats

The n CELL values in the data array are inserted (and counted) in the Cell_stats structure s.

Parameters:
data 
n 
s 
Returns:
int
Look for NULLs and update the NULL-value count.

Returns:
int

Definition at line 67 of file cell_stats.c.

References G_is_c_null_value(), G_realloc(), INCR, NODE, and SHIFT.

Referenced by G_put_map_row_random().


Generated on Sun Apr 6 17:32:15 2008 for GRASS by  doxygen 1.5.5