GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
array.c File Reference

Vector library - category array. More...

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

Go to the source code of this file.

Functions

struct varrayVect_new_varray (int size)
 Create new struct varray and allocate space for given number of items. More...
 
int Vect_set_varray_from_cat_string (const struct Map_info *Map, int field, const char *cstring, int type, int value, struct varray *varray)
 Set values in 'varray' to 'value' from category string. More...
 
int Vect_set_varray_from_cat_list (const struct Map_info *Map, int field, struct cat_list *clist, int type, int value, struct varray *varray)
 Set values in 'varray' to 'value' from category list. More...
 
int Vect_set_varray_from_db (const struct Map_info *Map, int field, const char *where, int type, int value, struct varray *varray)
 Set values in 'varray' to 'value' from DB (where statement) More...
 

Detailed Description

Vector library - category array.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009 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

Definition in file array.c.

Function Documentation

◆ Vect_new_varray()

struct varray* Vect_new_varray ( int  size)

Create new struct 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
sizesize of array
Returns
pointer to new struct varray
NULL if failed

Definition at line 41 of file array.c.

References varray::c, G_calloc, G_free(), G_malloc, NULL, and varray::size.

Referenced by NetA_initialise_varray().

◆ Vect_set_varray_from_cat_list()

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

Set values in 'varray' to 'value' from category list.

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

Parameters
Mapvector map
fieldlayer number
clistlist of categories
typefeature type
valuevalue to set up
[out]varrayvarray structure to modify
Returns
number of items set
-1 on error

Definition at line 129 of file array.c.

◆ Vect_set_varray_from_cat_string()

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

Set values in 'varray' to 'value' from category string.

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

Parameters
Mapvector map
fieldlayer number
cstringpointer to string with categories
typefeature type
valuevalue to set up
[out]varrayvarray structure to modify
Returns
number of items set
-1 on error

Definition at line 82 of file array.c.

Referenced by NetA_initialise_varray().

◆ Vect_set_varray_from_db()

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

Set values in 'varray' to 'value' from DB (where statement)

I 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() call.

Parameters
Mapvector map
fieldlayer number
wherewhere statement
typefeature type
valuevalue to set up
[out]varrayvarray structure to modify
Returns
number of items set
-1 on error

Definition at line 249 of file array.c.

Referenced by NetA_initialise_varray().