histogram.c File Reference

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

Include dependency graph for histogram.c:

Go to the source code of this file.

Defines

#define LIST   struct Histogram_list

Functions

int G_init_histogram (struct Histogram *histogram)
 initializes the histogram structure
int G_read_histogram (char *name, char *mapset, struct Histogram *histogram)
 read the histogram information
int G_write_histogram (char *name, struct Histogram *histogram)
 Writes the histogram information.
int G_write_histogram_cs (char *name, struct Cell_stats *statf)
 Writes the histogram information to file.
int G_make_histogram_cs (struct Cell_stats *statf, struct Histogram *histogram)
int G_get_histogram_num (struct Histogram *histogram)
 Sorts the histogram in ascending order by counts then category.
CELL G_get_histogram_cat (int n, struct Histogram *histogram)
 Returns cat for the nth element in the histogram.
long G_get_histogram_count (int n, struct Histogram *histogram)
 Returns count for the nth element in the histogram.
int G_free_histogram (struct Histogram *histogram)
 frees the memory allocated for the histogram
int G_sort_histogram (struct Histogram *histogram)
 Sorts the histogram.
int G_sort_histogram_by_count (struct Histogram *histogram)
 Sorts the histogram by counts.
int G_remove_histogram (char *name)
 Removes the histogram.
int G_add_histogram (CELL cat, long count, struct Histogram *histogram)
 adds count to the histogram value for cat
int G_set_histogram (CELL cat, long count, struct Histogram *histogram)
 sets the histogram value for cat to count
int G_extend_histogram (CELL cat, long count, struct Histogram *histogram)
int G_zero_histogram (struct Histogram *histogram)


Define Documentation

#define LIST   struct Histogram_list


Function Documentation

int G_add_histogram ( CELL  cat,
long  count,
struct Histogram *  histogram 
)

adds count to the histogram value for cat

adds count to the histogram value for cat

Parameters:
cat,: category
count 
histogram,: struct for histogram
Returns:
0 if successful, 1 on fail

Definition at line 375 of file histogram.c.

References G_extend_histogram().

Referenced by G_make_histogram_cs().

int G_extend_histogram ( CELL  cat,
long  count,
struct Histogram *  histogram 
)

Parameters:
cat,: category
count 
histogram,: struct for histogram
Returns:

Definition at line 431 of file histogram.c.

References G_realloc(), and LIST.

Referenced by G_add_histogram(), G_read_histogram(), and G_set_histogram().

int G_free_histogram ( struct Histogram *  histogram  ) 

frees the memory allocated for the histogram

frees the memory allocated for the histogram

Parameters:
histogram,: struct for histogram
Returns:

Definition at line 229 of file histogram.c.

References G_free(), and NULL.

Referenced by G_read_histogram().

CELL G_get_histogram_cat ( int  n,
struct Histogram *  histogram 
)

Returns cat for the nth element in the histogram.

Returns cat for the nth element in the histogram

Parameters:
histogram,: struct for histogram
Returns:
CELL

Definition at line 200 of file histogram.c.

Referenced by G_histogram_eq().

long G_get_histogram_count ( int  n,
struct Histogram *  histogram 
)

Returns count for the nth element in the histogram.

Returns count for the nth element in the histogram

Parameters:
n,: nth element
histogram,: struct for histogram
Returns:
count

Definition at line 215 of file histogram.c.

Referenced by G_histogram_eq().

int G_get_histogram_num ( struct Histogram *  histogram  ) 

Sorts the histogram in ascending order by counts then category.

Sorts the histogram in ascending order by counts then category. No combining is done.

Parameters:
histogram,: struct for histogram
Returns:
1 if successful, -1 on fail

Definition at line 188 of file histogram.c.

Referenced by G_histogram_eq().

int G_init_histogram ( struct Histogram *  histogram  ) 

initializes the histogram structure

initializes the histogram structure for calls to G_set_histogram() and G_add_histogram()

Parameters:
histogram 
Returns:
int

Definition at line 20 of file histogram.c.

References NULL.

Referenced by G_make_histogram_cs(), and G_read_histogram().

int G_make_histogram_cs ( struct Cell_stats *  statf,
struct Histogram *  histogram 
)

Parameters:
\return 

Definition at line 163 of file histogram.c.

References G_add_histogram(), G_init_histogram(), G_next_cell_stat(), G_rewind_cell_stats(), and G_sort_histogram().

int G_read_histogram ( char *  name,
char *  mapset,
struct Histogram *  histogram 
)

read the histogram information

Reads the histogram information associated with map layer "map" in mapset "mapset" into the structure "histogram".

note: a warning message is printed if the file is missing or incorrect

Parameters:
name,: name of map
mapset,: mapset that map belongs to
histogram,: struct for histogram
Returns:
1 if successful, 0 if no histogram file, -1 on fail

Definition at line 44 of file histogram.c.

References G_extend_histogram(), G_find_file(), G_fopen_old(), G_free_histogram(), G_init_histogram(), G_sort_histogram(), G_warning(), and NULL.

int G_remove_histogram ( char *  name  ) 

Removes the histogram.

Removes the histogram information associated with map layer "name"

Parameters:
name,: name of map
Returns:
0

Definition at line 355 of file histogram.c.

References G_remove().

int G_set_histogram ( CELL  cat,
long  count,
struct Histogram *  histogram 
)

sets the histogram value for cat to count

sets the histogram value for cat to count

Parameters:
cat,: category
count 
histogram,: struct for histogram
Returns:
0 if successful, 1 on fail

Definition at line 404 of file histogram.c.

References G_extend_histogram().

int G_sort_histogram ( struct Histogram *  histogram  ) 

Sorts the histogram.

Sorts the histogram in ascending order by category, combining (by adding) elements that have the same category.

Parameters:
histogram,: struct for histogram
Returns:
0 if successful, 1 on fail

Definition at line 247 of file histogram.c.

References b, and LIST.

Referenced by G_make_histogram_cs(), and G_read_histogram().

int G_sort_histogram_by_count ( struct Histogram *  histogram  ) 

Sorts the histogram by counts.

Sorts the histogram in ascending order by counts then category. No combining is done.

Parameters:
histogram,: struct for histogram
Returns:
0 if successful, 1 on fail

Definition at line 302 of file histogram.c.

References LIST.

int G_write_histogram ( char *  name,
struct Histogram *  histogram 
)

Writes the histogram information.

Writes the histogram information associated with map layer "name"

Parameters:
name,: name of map
histogram,: struct for histogram
Returns:
1 if successful, -1 on fail

Definition at line 106 of file histogram.c.

References LIST, and NULL.

int G_write_histogram_cs ( char *  name,
struct Cell_stats *  statf 
)

Writes the histogram information to file.

Parameters:
name,: name of map
statf 
Returns:

Definition at line 136 of file histogram.c.

References G_next_cell_stat(), G_rewind_cell_stats(), and NULL.

int G_zero_histogram ( struct Histogram *  histogram  ) 

Parameters:
histogram,: struct for histogram
Returns:

Definition at line 451 of file histogram.c.


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