Functions

array.c File Reference

Vector library - array structure. More...

#include <stdlib.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Include dependency graph for array.c:

Go to the source code of this file.

Functions

VARRAY * Vect_new_varray (int size)
 Create new VARRAY and allocate space for given number of items.
int Vect_set_varray_from_cat_string (struct Map_info *Map, int field, const char *cstring, int type, int value, VARRAY *varray)
 Set values in 'varray' to 'value'.
int Vect_set_varray_from_cat_list (struct Map_info *Map, int field, struct cat_list *clist, int type, int value, VARRAY *varray)
 Set values in 'varray' to 'value'.
int Vect_set_varray_from_db (struct Map_info *Map, int field, const char *where, int type, int value, VARRAY *varray)
 Set values in 'varray' to 'value'.

Detailed Description

Vector library - array structure.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2008 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:
Radim Blazek
Date:
2001-2008

Definition in file array.c.


Function Documentation

VARRAY* Vect_new_varray ( int  size  ) 

Create new VARRAY and allocate space for given number of items.

Space allocated is 'size + 1' so that lines are accessed by line id. Array values are set to 0.

Parameters:
size size of array
Returns:
pointer to new VARRAY
NULL if failed

Definition at line 44 of file array.c.

int Vect_set_varray_from_cat_list ( struct Map_info *  Map,
int  field,
struct cat_list *  clist,
int  type,
int  value,
VARRAY *  varray 
)

Set values in 'varray' to 'value'.

If category of object of given type is in 'clist' (category list). 'type' may be either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY | GV_CENTROID

Array is not reset to zero before, but old values (if any > 0) are overwritten. Array must be initialised by Vect_new_varray(size) call.

Parameters:
Map vector map
field layer number
clist list of categories
type feature type
value value to set up
[in,out] varray varray structure to modify
Returns:
number of items set
-1 on error

Definition at line 132 of file array.c.

References Vect_cat_get(), Vect_cat_in_cat_list(), Vect_destroy_cats_struct(), Vect_get_area_centroid(), Vect_get_num_areas(), Vect_get_num_lines(), Vect_new_cats_struct(), and Vect_read_line().

Referenced by Vect_set_varray_from_cat_string().

int Vect_set_varray_from_cat_string ( struct Map_info *  Map,
int  field,
const char *  cstring,
int  type,
int  value,
VARRAY *  varray 
)

Set values in 'varray' to 'value'.

If category of object of given type is in 'cstring' (string representing category list like: '1,3,5-7'). 'type' may be either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY | GV_CENTROID

Array is not reset to zero before, but old values (if any > 0) are overwritten. Array must be initialised by Vect_new_varray(size) call.

Parameters:
Map vector map
field layer number
cstring pointer to string with categories
type feature type
value value to set up
[in,out] varray varray structure to modify
Returns:
number of items set
-1 on error

Definition at line 85 of file array.c.

References Vect_destroy_cat_list(), Vect_new_cat_list(), Vect_set_varray_from_cat_list(), and Vect_str_to_cat_list().

int Vect_set_varray_from_db ( struct Map_info *  Map,
int  field,
const char *  where,
int  type,
int  value,
VARRAY *  varray 
)

Set values in 'varray' to 'value'.

if category of object of given type is in categories selected from DB based on where statement (given without where). 'type' may be either: GV_AREA or: GV_POINT | GV_LINE | GV_BOUNDARY | GV_CENTROID

Array is not reset to zero before, but old values (if any > 0) are overwritten. Array must be initialised by Vect_new_varray(size) call.

Parameters:
Map vector map
field layer number
where where statement
type feature type
value value to set up
[in,out] varray varray structure to modify
Returns:
number of items set
-1 on error

Definition at line 251 of file array.c.

References Vect_destroy_cats_struct(), Vect_get_area_centroid(), Vect_get_field(), Vect_get_num_areas(), Vect_get_num_lines(), Vect_new_cats_struct(), and Vect_read_line().