range.c File Reference

#include <unistd.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
#include "G.h"
#include <grass/glocale.h>

Include dependency graph for range.c:

Go to the source code of this file.

Defines

#define DEFAULT_CELL_MIN   1
#define DEFAULT_CELL_MAX   255

Functions

int G__remove_fp_range (char *name)
int G_construct_default_range (struct Range *range)
 Sets the integer range r to [1,255].
int G_read_fp_range (char *name, char *mapset, struct FPRange *drange)
 Read the floating point range file f_range. This file is written in binary using XDR format. If there is no defined min/max in r, an empty f_rangefile 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 G_construct_default_range().
int G_read_range (char *name, char *mapset, struct Range *range)
 read raster range
int G_write_range (char *name, struct Range *range)
 write raster range file
int G_write_fp_range (char *name, struct FPRange *range)
 Write the floating point range file f_range. This file is written in binary using XDR format. If there is no defined min/max in r, an empty f_rangefile is created.
int G_update_range (CELL cat, struct Range *range)
 update range structure
int G_update_fp_range (DCELL val, struct FPRange *range)
int G_row_update_range (CELL *cell, int n, struct Range *range)
 update range structure
int G__row_update_range (CELL *cell, int n, struct Range *range, int ignore_zeros)
int G_row_update_fp_range (void *rast, int n, struct FPRange *range, RASTER_MAP_TYPE data_type)
int G_init_range (struct Range *range)
 initialize range structure
int G_get_range_min_max (struct Range *range, CELL *min, CELL *max)
 get range min and max
int G_init_fp_range (struct FPRange *range)
 Must set a flag in the range structure that indicates that no min/max have been defined - probably a "first" boolean flag.
int G_get_fp_range_min_max (struct FPRange *range, DCELL *min, DCELL *max)
 Extract the min/max from the range structure r. 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.


Define Documentation

#define DEFAULT_CELL_MAX   255

Definition at line 85 of file range.c.

Referenced by G_construct_default_range().

#define DEFAULT_CELL_MIN   1

Definition at line 84 of file range.c.

Referenced by G_construct_default_range().


Function Documentation

int G__remove_fp_range ( char *  name  ) 

Definition at line 93 of file range.c.

References G_remove().

int G__row_update_range ( CELL *  cell,
int  n,
struct Range *  range,
int  ignore_zeros 
)

Definition at line 512 of file range.c.

References G_is_c_null_value().

Referenced by G_row_update_range().

int G_construct_default_range ( struct Range *  range  ) 

Sets the integer range r to [1,255].

Parameters:
r 
Returns:
int

Definition at line 113 of file range.c.

References DEFAULT_CELL_MAX, DEFAULT_CELL_MIN, and G_update_range().

int G_get_fp_range_min_max ( struct FPRange *  range,
DCELL *  min,
DCELL *  max 
)

Extract the min/max from the range structure r. 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.

Parameters:
r 
min 
max 
Returns:
int

Definition at line 690 of file range.c.

References G_is_d_null_value(), and G_set_d_null_value().

Referenced by G_make_colors(), G_quantize_fp_map(), G_read_colors(), and G_read_range().

int G_get_range_min_max ( struct Range *  range,
CELL *  min,
CELL *  max 
)

get range min and max

The mininum and maximum CELL values are extracted from the range 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.

Parameters:
range 
min 
max 
Returns:
int

Definition at line 627 of file range.c.

References G_is_c_null_value(), and G_set_c_null_value().

Referenced by G_number_of_cats(), and G_read_colors().

int G_init_fp_range ( struct FPRange *  range  ) 

Must set a flag in the range structure that indicates that no min/max have been defined - probably a "first" boolean flag.

Parameters:
r 
Returns:
int

Definition at line 665 of file range.c.

References G_set_d_null_value().

Referenced by G_read_fp_range().

int G_init_range ( struct Range *  range  ) 

initialize range structure

Initializes the range structure for updates by G_update_range and G_row_update_range.

Must set a flag in the range structure that indicates that no min/max have been defined - probably a "first" boolean flag.

Parameters:
range 
Returns:
int

Definition at line 598 of file range.c.

References G_set_c_null_value().

Referenced by G_read_range().

int G_read_fp_range ( char *  name,
char *  mapset,
struct FPRange *  drange 
)

Read the floating point range file f_range. This file is written in binary using XDR format. If there is no defined min/max in r, an empty f_rangefile 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 G_construct_default_range().

Parameters:
r 
name 
mapset 
Returns:
int

Definition at line 140 of file range.c.

References G_find_file2(), G_init_fp_range(), G_open_old(), G_raster_map_type(), G_read_range(), G_update_fp_range(), G_warning(), and XDR_DOUBLE_NBYTES.

Referenced by G_make_colors(), G_quantize_fp_map(), G_read_colors(), and G_read_range().

int G_read_range ( char *  name,
char *  mapset,
struct Range *  range 
)

read raster range

This routine reads the range information for the raster file name in mapset into the range structure. A diagnostic message is printed and -1 is returned if there is an error reading the range file. Otherwise, 0 is returned.

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). 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 G_construct_default_range().

Parameters:
name 
mapset 
range 
Returns:
int

Definition at line 233 of file range.c.

References G_find_file2(), G_fopen_old(), G_get_fp_range_min_max(), G_init_range(), G_quant_get_limits(), G_quant_is_round(), G_quant_is_truncate(), G_raster_map_type(), G_read_fp_range(), G_read_quant(), G_update_range(), G_warning(), and NULL.

Referenced by G_number_of_cats(), G_read_colors(), and G_read_fp_range().

int G_row_update_fp_range ( void *  rast,
int  n,
struct FPRange *  range,
RASTER_MAP_TYPE  data_type 
)

Definition at line 542 of file range.c.

References G_incr_void_ptr(), G_is_null_value(), and G_raster_size().

int G_row_update_range ( CELL *  cell,
int  n,
struct Range *  range 
)

update range structure

This routine updates the range data just like G_update_range, but for n values from the cell array.

Parameters:
cell 
n 
range 
Returns:
int

Definition at line 503 of file range.c.

References G__row_update_range().

Referenced by G_put_map_row_random().

int G_update_fp_range ( DCELL  val,
struct FPRange *  range 
)

Definition at line 468 of file range.c.

References G_is_d_null_value().

Referenced by G_read_fp_range().

int G_update_range ( CELL  cat,
struct Range *  range 
)

update range structure

Compares the cat value with the minimum and maximum values in the range structure, modifying the range if cat extends the range.

NULL-values must be detected and ignored.

Parameters:
cat 
range 
Returns:
int

Definition at line 446 of file range.c.

References G_is_c_null_value().

Referenced by G_construct_default_range(), and G_read_range().

int G_write_fp_range ( char *  name,
struct FPRange *  range 
)

Write the floating point range file f_range. This file is written in binary using XDR format. If there is no defined min/max in r, an empty f_rangefile is created.

Parameters:
r 
Returns:
int

Definition at line 392 of file range.c.

References G_mapset(), G_open_new(), G_remove(), G_warning(), and XDR_DOUBLE_NBYTES.

int G_write_range ( char *  name,
struct Range *  range 
)

write raster range file

This routine writes the range information for the raster file name in the current mapset from the range structure. A diagnostic message is printed and -1 is returned if there is an error writing the range file. Otherwise, 0 is returned.

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.

Parameters:
name 
range 
Returns:
int

Definition at line 343 of file range.c.

References G_fopen_new(), G_mapset(), G_raster_map_type(), G_remove(), and G_warning().


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