GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r72095
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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_free(), int, NULL, and varray::size.

Referenced by NetA_initialise_varray().

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.

References _, varray::c, cat, G_debug(), G_warning(), GV_AREA, GV_LINES, GV_POINTS, NULL, varray::size, 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 ( 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.

References _, G_debug(), G_warning(), cat_list::n_ranges, Vect_destroy_cat_list(), Vect_new_cat_list(), Vect_set_varray_from_cat_list(), and Vect_str_to_cat_list().

Referenced by NetA_initialise_varray().

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.

References _, varray::c, line_cats::cat, field_info::database, db_close_database_shutdown_driver(), db_select_int(), db_start_driver_open_database(), driver, field_info::driver, line_cats::field, G_debug(), G_free(), G_warning(), GV_AREA, GV_LINES, GV_POINTS, field_info::key, line_cats::n_cats, NULL, varray::size, field_info::table, 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().

Referenced by NetA_initialise_varray().