18 #include <grass/gis.h>
19 #include <grass/Vect.h>
20 #include <grass/glocale.h>
21 #include <grass/dbmi.h>
22 #include <grass/neta.h>
36 int node,
struct line_cats *Cats)
38 static struct line_pnts *Points;
77 for (i = 0; i < point_list->n_values; i++) {
79 point_list->value[i] = node;
105 int i, nlines, nnodes;
107 struct line_cats *Cats;
108 struct line_pnts *Points;
111 struct field_info *Fi;
116 G_fatal_error(_(
"Unable to open database <%s> by driver <%s>"),
117 Fi->database, Fi->driver);
123 for (i = 1; i <= nnodes; i++)
131 for (i = 1; i <= nlines; i++) {
134 if (type == GV_POINT) {
142 node_costs[node] = value * 1000000.0;
167 struct ilist *nodes,
int *nodes_to_features)
169 int nlines, nnodes, i;
173 if (nodes_to_features)
174 for (i = 1; i <= nnodes; i++)
175 nodes_to_features[i] = -1;
177 for (i = 1; i <= nlines; i++) {
181 if (type == GV_POINT) {
186 if (nodes_to_features)
187 nodes_to_features[node] = i;
195 if (nodes_to_features)
196 nodes_to_features[node1] = nodes_to_features[node2] = i;
216 char *where,
char *
cat,
struct varray **varray)
230 G_warning(_(
"'where' and 'cats' parameters were supplied, cat will be ignored"));
233 G_warning(_(
"Unable to load data from database"));
240 G_warning(_(
"Problem loading category values"));
247 struct line_cats *Cats;
251 for (i = 1; i <=
n; i++) {
254 if (!(ltype & mask_type))
dbDriver * db_start_driver_open_database(const char *drvname, const char *dbname)
Open driver/database connection.
int db_select_CatValArray(dbDriver *driver, const char *tab, const char *key, const char *col, const char *where, dbCatValArray *cvarr)
Select pairs key/value to array, values are sorted by key (must be integer)
struct field_info * Vect_get_field(struct Map_info *Map, int field)
Get information about link to database.
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'.
int Vect_get_line_nodes(struct Map_info *Map, int line, int *n1, int *n2)
Get line nodes.
int db_close_database_shutdown_driver(dbDriver *driver)
Close driver/database connection.
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts.
void db_CatValArray_free(dbCatValArray *arr)
int Vect_reset_line(struct line_pnts *Points)
Reset line.
int Vect_append_point(struct line_pnts *Points, double x, double y, double z)
Appends one point to the end of a line.
int db_CatValArray_get_value_double(dbCatValArray *arr, int key, double *val)
Find value (double) by key.
void NetA_varray_to_nodes(struct Map_info *map, struct varray *varray, struct ilist *nodes, int *nodes_to_features)
Get list of nodes from varray.
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 NetA_initialise_varray(struct Map_info *In, int layer, int mask_type, char *where, char *cat, struct varray **varray)
Initialize varray.
int NetA_get_node_costs(struct Map_info *In, int layer, char *column, int *node_costs)
Get node cost.
VARRAY * Vect_new_varray(int size)
Create new VARRAY and allocate space for given number of items.
int Vect_destroy_cats_struct(struct line_cats *p)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_list_append(struct ilist *list, int val)
Append new item to the end of list if not yet present.
void db_CatValArray_init(dbCatValArray *arr)
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int Vect_get_num_lines(struct Map_info *map)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
void NetA_points_to_nodes(struct Map_info *In, struct ilist *point_list)
Finds node.
void NetA_add_point_on_node(struct Map_info *In, struct Map_info *Out, int node, struct line_cats *Cats)
Writes point.
long Vect_write_line(struct Map_info *Map, int type, struct line_pnts *points, struct line_cats *cats)
Writes new feature to the end of file (table)
int Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, double *z)
Get node coordinates.
int Vect_get_num_nodes(struct Map_info *map)
Get number of nodes in vector map.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int Vect_destroy_line_struct(struct line_pnts *p)
Frees all memory associated with a struct line_pnts, including the struct itself. ...
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.
int Vect_cat_get(struct line_cats *Cats, int field, int *cat)
Get first found category of given field.