cats.c File Reference

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

Include dependency graph for cats.c:

Go to the source code of this file.

Functions

struct line_cats * Vect__new_cats_struct (void)
struct line_cats * Vect_new_cats_struct ()
 creates and initializes a struct line_cats. This structure is used for reading and writing vector cats. The library routines handle all memory allocation.
int Vect_destroy_cats_struct (struct line_cats *p)
 frees all memory associated with a struct line_cats, including the struct itself
int Vect_cat_set (struct line_cats *Cats, int field, int cat)
 add new field/cat to category structure if doesn't exist yet.
int Vect_cat_get (struct line_cats *Cats, int field, int *cat)
 get first found category of given field 'cat' is set to first category found or -1 if field was not found
int Vect_cat_del (struct line_cats *Cats, int field)
 delete all categories of given field
int Vect_field_cat_del (struct line_cats *Cats, int field, int cat)
 delete field/cat from line_cats structure
int Vect_reset_cats (struct line_cats *Cats)
 reset category structure to make sure cats structure is clean to be re-used. I.e. it has no cats associated with it. Cats must have previously been created with Vect_new_cats_struct()
struct cat_list * Vect_new_cat_list ()
 ADD TEXT.
int Vect_destroy_cat_list (struct cat_list *p)
 ADD TEXT.
int Vect_str_to_cat_list (char *str, struct cat_list *list)
 Convert string of categories and cat ranges separated by commas to cat_list. Examples of string: 2,3,5-9,20. str - input string.
int Vect_array_to_cat_list (int *vals, int nvals, struct cat_list *list)
 Convert ordered array of integers to cat_list.
int Vect_cat_in_cat_list (int cat, struct cat_list *list)
 check if category is in list
int Vect_cat_in_array (int cat, int *array, int ncats)
 check if category is in ordered array of integers


Function Documentation

struct line_cats * Vect__new_cats_struct ( void   )  [read]

Definition at line 48 of file cats.c.

Referenced by Vect_new_cats_struct().

int Vect_array_to_cat_list ( int *  vals,
int  nvals,
struct cat_list *  list 
)

Convert ordered array of integers to cat_list.

Returns:
number of ranges
Parameters:
array of integers ?, number of values ?, line_cats structure

Definition at line 393 of file cats.c.

int Vect_cat_del ( struct line_cats *  Cats,
int  field 
)

delete all categories of given field

Returns:
1 deleted, 0 category number does not exist
Parameters:
Cats 
field 

Definition at line 180 of file cats.c.

int Vect_cat_get ( struct line_cats *  Cats,
int  field,
int *  cat 
)

get first found category of given field 'cat' is set to first category found or -1 if field was not found

Returns:
1 found, 0 field does not exist
Parameters:
Cats 
field 
cat pointer to variable where cat will be written

Definition at line 146 of file cats.c.

Referenced by Vect_get_line_cat(), Vect_net_build_graph(), and Vect_set_varray_from_cat_list().

int Vect_cat_in_array ( int  cat,
int *  array,
int  ncats 
)

check if category is in ordered array of integers

Returns:
TRUE if cat is in list, FALSE if it is not
Parameters:
category number, ordered array of integers, line_cats structure

Definition at line 451 of file cats.c.

References FALSE, and TRUE.

int Vect_cat_in_cat_list ( int  cat,
struct cat_list *  list 
)

check if category is in list

Returns:
TRUE if cat is in list, FALSE if it is not
Parameters:
category number, line_cats structure

Definition at line 433 of file cats.c.

References FALSE, and TRUE.

Referenced by Vect_set_varray_from_cat_list().

int Vect_cat_set ( struct line_cats *  Cats,
int  field,
int  cat 
)

add new field/cat to category structure if doesn't exist yet.

Returns:
new number of categories 0 if no space for new category in structure, n_cats would be > GV_NCATS_MAX -1 on out of memory -2 if field out of range: 1 - GV_FIELD_MAX or cat out of range: 1 - GV_CAT_MAX
Parameters:
Cats 
field 
cat 

Definition at line 98 of file cats.c.

References dig_alloc_cats().

Referenced by Vect_clean_small_angles_at_nodes(), Vect_overlay_and(), and Vect_remove_duplicates().

int Vect_destroy_cat_list ( struct cat_list *  p  ) 

ADD TEXT.

Returns:
ADD
Parameters:
line_cats structure

Definition at line 289 of file cats.c.

Referenced by Vect_set_varray_from_cat_string().

int Vect_destroy_cats_struct ( struct line_cats *  p  ) 

frees all memory associated with a struct line_cats, including the struct itself

Returns:
0
Parameters:
line_cats structure

Definition at line 71 of file cats.c.

Referenced by Vect_copy_map_lines(), Vect_set_varray_from_cat_list(), Vect_set_varray_from_db(), and Vect_snap_lines().

int Vect_field_cat_del ( struct line_cats *  Cats,
int  field,
int  cat 
)

delete field/cat from line_cats structure

Returns:
1 deleted, 0 field/category number does not exist
Parameters:
Cats 
field 
cat category to be deleted or -1 to delete all cats of given field

Definition at line 215 of file cats.c.

struct cat_list * Vect_new_cat_list (  )  [read]

ADD TEXT.

Returns:
ADD
Parameters:
- 

Definition at line 263 of file cats.c.

Referenced by Vect_set_varray_from_cat_string().

struct line_cats * Vect_new_cats_struct (  )  [read]

creates and initializes a struct line_cats. This structure is used for reading and writing vector cats. The library routines handle all memory allocation.

Returns:
struct line_cats * or NULL on error
Parameters:
- 

Definition at line 37 of file cats.c.

References Vect__new_cats_struct().

Referenced by add_area_cats_to_cidx(), delete_area_cats_from_cidx(), remove_bridges(), remove_dangles(), V1_rewrite_line_nat(), V2_delete_line_nat(), Vect_break_lines(), Vect_break_polygons(), Vect_build_nat(), Vect_clean_small_angles_at_nodes(), Vect_copy_map_lines(), Vect_get_area_cat(), Vect_get_line_cat(), Vect_net_build_graph(), Vect_overlay_and(), Vect_remove_duplicates(), Vect_remove_small_areas(), Vect_set_varray_from_cat_list(), Vect_set_varray_from_db(), and Vect_snap_lines().

int Vect_reset_cats ( struct line_cats *  Cats  ) 

reset category structure to make sure cats structure is clean to be re-used. I.e. it has no cats associated with it. Cats must have previously been created with Vect_new_cats_struct()

Returns:
0
Parameters:
line_cats structure

Definition at line 249 of file cats.c.

Referenced by Vect_break_polygons(), Vect_clean_small_angles_at_nodes(), Vect_get_area_cat(), Vect_get_area_cats(), and Vect_overlay_and().

int Vect_str_to_cat_list ( char *  str,
struct cat_list *  list 
)

Convert string of categories and cat ranges separated by commas to cat_list. Examples of string: 2,3,5-9,20. str - input string.

Returns:
number of errors in ranges
Parameters:
string,line_cats structure

Definition at line 314 of file cats.c.

Referenced by Vect_set_varray_from_cat_string().


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