24 static int cmp(
const void *pa,
const void *pb);
25 static int in_array(
int *cats,
size_t ncats,
int cat);
80 const char *cstring,
int type,
int value,
86 G_debug(4,
"Vect_set_varray_from_cat_string(): cstring = '%s'", cstring);
93 G_warning(
_(
"%d errors in category string"), ret);
125 struct cat_list *clist,
int type,
int value,
128 int i, n, centr, cat;
133 G_debug(4,
"Vect_set_varray_from_cat_list(): field = %d",
field);
137 G_warning(
_(
"Mixed area and other type requested for vector array"));
147 G_warning(
_(
"Not enough space in vector array"));
151 for (i = 1; i <= n; i++) {
170 G_warning(
_(
"Not enough space in vector array"));
174 for (i = 1; i <= n; i++) {
196 static int cmp(
const void *pa,
const void *pb)
209 static int in_array(
int *cats,
size_t ncats,
int cat)
213 p = (
int *)bsearch((
void *)&
cat, cats, ncats,
sizeof(int), cmp);
245 int i, n, c, centr, *cats;
253 G_debug(4,
"Vect_set_varray_from_db(): field = %d where = '%s'", field,
260 G_warning(
_(
"Mixed area and other type requested for vector array"));
269 G_warning(
_(
"Database connection not defined for layer %d"), field);
275 G_warning(
_(
"Unable to open database <%s> by driver <%s>"),
286 _(
"Unable to select record from table <%s> (key %s, where %s)"),
299 G_warning(
_(
"Not enough space in vector array"));
303 for (i = 1; i <= n; i++) {
310 for (c = 0; c < Cats->
n_cats; c++) {
311 if (Cats->
field[c] == field &&
312 in_array(cats, ncats, Cats->
cat[c])) {
331 G_warning(
_(
"Not enough space in vector array"));
335 for (i = 1; i <= n; i++) {
343 for (c = 0; c < Cats->
n_cats; c++) {
344 if (Cats->
field[c] == field &&
345 in_array(cats, ncats, Cats->
cat[c])) {
struct varray * Vect_new_varray(int size)
Create new struct 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, struct varray *varray)
Set values in 'varray' to 'value' from category string.
int Vect_set_varray_from_cat_list(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.
int Vect_set_varray_from_db(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)
dbDriver * db_start_driver_open_database(const char *, const char *)
Open driver/database connection.
int db_close_database_shutdown_driver(dbDriver *)
Close driver/database connection.
int db_select_int(dbDriver *, const char *, const char *, const char *, int **)
Select array of ordered integers from table/column.
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
plus_t Vect_get_num_lines(struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
plus_t Vect_get_num_areas(struct Map_info *)
Get number of areas in vector map.
int Vect_cat_in_cat_list(int, const struct cat_list *)
Check if category number is in list.
struct cat_list * Vect_new_cat_list(void)
Allocate memory for cat_list structure.
int Vect_str_to_cat_list(const char *, struct cat_list *)
Converts string of categories and cat ranges separated by commas to cat_list.
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
struct field_info * Vect_get_field(struct Map_info *, int)
Get information about link to database (by layer number)
void Vect_destroy_cat_list(struct cat_list *)
Frees allocated cat_list memory.
int Vect_get_area_centroid(struct Map_info *, int)
Returns centroid id for given area.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
const struct driver * driver
int n_ranges
Number of ranges.
int field
Category layer (field)
Layer (old: field) information.
char * table
Name of DB table.
char * driver
Name of DB driver ('sqlite', 'dbf', ...)
char * key
Name of key column (usually 'cat')
int * field
Array of layers (fields)
int * cat
Array of categories.
int n_cats
Number of categories attached to element.