52 int i,
j, from, to, line, nlines,
nnodes,
ret, type, cat,
skipped,
cfound;
59 0, 0, 0, 0, 0, 0, 0, 0};
78 const char *
tcols[] = {
"cat",
"ln_from",
"ln_to",
"cost",
"isec",
NULL};
89 "Vect_net_ttb_build_graph(): "
90 "ltype = %d, afield = %d, nfield = %d, tfield = %d, tucfield = %d ",
106 Map->dgraph.cost_multip = 1000000;
108 Map->dgraph.cost_multip = 1000;
113 gr = &(
Map->dgraph.graph_s);
122 for (i = 1; i <= nlines; i++) {
123 Map->dgraph.edge_fcosts[i] = -1;
124 Map->dgraph.edge_bcosts[i] = -1;
126 for (i = 1; i <=
nnodes; i++) {
127 Map->dgraph.node_costs[i] = 0;
157 Fi->database,
Fi->driver);
176 _(
"Data type of column <%s> not supported (must be numeric)"),
193 G_debug(2,
"Set nodes' costs");
207 Fi->database,
Fi->driver);
219 _(
"Data type of column <%s> not supported (must be numeric)"),
238 for (i = 1; i <=
nnodes; i++) {
249 G_debug(2,
" node = %d nlines = %d", i,
List->n_values);
254 for (
j = 0;
j <
List->n_values;
j++) {
256 G_debug(2,
" line (%d) = %d",
j, line);
274 _(
"Database record for node %d (cat = %d) not found "
322 "Add arc %d for virtual node from %d to %d cost = %d",
330 "node connection."));
342 "Add arc %d for virtual node from %d to %d cost = %d",
350 "node connection."));
361 G_warning(
_(
"There exists more than one point of node <%d> with "
362 "unique category field <%d>.\n"
363 "The unique categories layer is not valid therefore "
364 "you will probably get incorrect results."),
370 "Category of field %d is not attached to any points in node %d"
377 for (i = 1; i <=
nturns; i++) {
394 _(
"Unable to find point representing intersection <%d> in "
395 "unique categories field <%d>.\n"
396 "Cost for the intersection was set to 0.\n"
397 "The unique categories layer is not valid therefore you "
398 "will probably get incorrect results."),
409 _(
"Unable to find node for point representing "
410 "intersection <%d> in unique categories field <%d>.\n"
411 "Cost for the intersection was set to 0.\n"
412 "The unique categories layer is not valid therefore "
413 "you will probably get incorrect results."),
436 _(
"Database record for turn with cat = %d is not found. "
437 "(The turn was skipped."),
461 G_debug(5,
"Add arc/turn %d for turn from %d to %d cost = %d",
469 _(
"Cannot add network arc representing turn."));
501 Fi->database,
Fi->driver);
513 _(
"Data type of column <%s> not supported (must be numeric)"),
546 for (i = 1; i <= nlines; i++) {
562 G_warning(
_(
"Line with id <%d> has more unique categories defined "
564 "The unique categories layer is not valid therefore "
565 "you will probably get incorrect results."),
571 "Category of field %d not attached to the line %d -> "
585 G_warning(
_(
"Database record for line %d (cat = %d, "
586 "forward/both direction(s)) not found "
587 "(cost was set to 0)"),
601 G_warning(
_(
"Database record for line %d (cat = %d, "
602 "backward direction) not found"
603 "(cost was set to 0)"),
631 G_debug(5,
"Setinng node %d cost: %d", cat, cost);
641 G_debug(5,
"Setinng node %d cost: %d", cat, cost);
648 G_debug(2,
"%d lines missing category of field %d skipped",
skipped,
703 const char *
ncol,
int geo,
int version)
706 int i,
j, from, to, line, nlines,
nnodes,
ret, type, cat,
skipped,
cfound;
715 0, 0, 0, 0, 0, 0, 0, 0};
725 G_debug(1,
"Vect_net_build_graph(): ltype = %d, afield = %d, nfield = %d",
741 Map->dgraph.cost_multip = 1000000;
743 Map->dgraph.cost_multip = 1000;
748 gr = &(
Map->dgraph.graph_s);
756 for (i = 1; i <= nlines; i++) {
757 Map->dgraph.edge_fcosts[i] = -1;
758 Map->dgraph.edge_bcosts[i] = -1;
760 for (i = 1; i <=
nnodes; i++) {
761 Map->dgraph.node_costs[i] = 0;
798 Fi->database,
Fi->driver);
810 _(
"Data type of column <%s> not supported (must be numeric)"),
843 for (i = 1; i <= nlines; i++) {
855 "Category of field %d not attached to the line %d -> "
870 G_warning(
_(
"Database record for line %d (cat = %d, "
871 "forward/both direction(s)) not found "
872 "(forward/both direction(s) of line skipped)"),
887 G_warning(
_(
"Database record for line %d (cat = %d, "
888 "backward direction) not found"
889 "(direction of line skipped)"),
916 G_debug(5,
"Add arc %d from %d to %d cost = %d", i, from, to, cost);
925 Map->dgraph.edge_bcosts[i]);
928 G_debug(5,
"Add arc %d from %d to %d bcost = %d", -i, to, from,
939 G_debug(2,
"%d lines missing category of field %d skipped",
skipped,
960 G_debug(2,
"Set nodes' costs");
974 Fi->database,
Fi->driver);
986 _(
"Data type of column <%s> not supported (must be numeric)"),
995 for (i = 1; i <=
nnodes; i++) {
1006 G_debug(2,
" node = %d nlines = %d", i,
List->n_values);
1010 for (
j = 0;
j <
List->n_values;
j++) {
1012 G_debug(2,
" line (%d) = %d",
j, line);
1029 G_warning(
_(
"Database record for node %d (cat = %d) "
1041 "Category of field %d not attached to any points in node %d"
1053 G_debug(3,
"Set node's cost to %d", cost);
Main header of GRASS DataBase Management Interface.
void db_CatValArray_free(dbCatValArray *)
Free allocated dbCatValArray.
int db_CatValArray_get_value_int(dbCatValArray *, int, int *)
Find value (integer) by key.
void db_CatValArray_init(dbCatValArray *)
Initialize dbCatValArray.
int db_get_column(dbDriver *, const char *, const char *, dbColumn **)
Get column structure by table and column name.
int db_sqltype_to_Ctype(int)
Get C data type based on given SQL data type.
int db_get_column_sqltype(dbColumn *)
Returns column sqltype for column.
int db_close_database_shutdown_driver(dbDriver *)
Close driver/database connection.
int db_select_CatValArray(dbDriver *, const char *, const char *, const char *, const char *, dbCatValArray *)
Select pairs key/value to array, values are sorted by key (must be integer)
void db_free_column(dbColumn *)
Frees column structure.
void db_init_handle(dbHandle *)
Initialize handle (i.e database/schema)
void db_init_string(dbString *)
Initialize dbString.
dbDriver * db_start_driver_open_database(const char *, const char *)
Open driver/database connection.
int db_CatValArray_get_value_double(dbCatValArray *, int, double *)
Find value (double) by key.
void G_percent(long, long, int)
Print percent complete messages.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
void G_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int G_projection(void)
Query cartographic projection.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_get_line_nodes(struct Map_info *, int, int *, int *)
Get line nodes.
int Vect_get_node_coor(struct Map_info *, int, double *, double *, double *)
Get node coordinates.
plus_t Vect_get_num_lines(struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
double Vect_line_length(const struct line_pnts *)
Calculate line length, 3D-length in case of 3D vector line.
int Vect_cidx_get_field_index(struct Map_info *, int)
Get layer index for given layer number.
double Vect_line_geodesic_length(const struct line_pnts *)
Calculate line length.
int Vect_cidx_find_next(struct Map_info *, int, int, int, int, int *, int *)
Find next line/area id for given category, start_index and type_mask.
struct boxlist * Vect_new_boxlist(int)
Creates and initializes a struct boxlist.
int Vect_cat_get(const struct line_cats *, int, int *)
Get first found category of given field.
void Vect_destroy_boxlist(struct boxlist *)
Frees all memory associated with a struct boxlist, including the struct itself.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
struct field_info * Vect_get_field(struct Map_info *, int)
Get information about link to database (by layer number)
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
void Vect_destroy_field_info(struct field_info *)
Free a struct field_info and all memory associated with it.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
int Vect_get_node_n_lines(struct Map_info *, int)
Get number of lines for node.
plus_t Vect_get_num_nodes(struct Map_info *)
Get number of nodes in vector map.
int Vect_find_node(struct Map_info *, double, double, double, double, int)
Find the nearest node.
int Vect_get_node_line(struct Map_info *, int, int)
Get line id for node line index.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
#define GV_POINT
Feature types used in memory on run time (may change)
#define WITHOUT_Z
2D/3D vector data
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int Vect_net_build_graph(struct Map_info *Map, int ltype, int afield, int nfield, const char *afcol, const char *abcol, const char *ncol, int geo, int version)
Build network graph.
int Vect_net_ttb_build_graph(struct Map_info *Map, int ltype, int afield, int nfield, int tfield, int tucfield, const char *afcol, const char *abcol, const char *ncol, int geo, int algorithm)
Build network graph with turntable.
List of bounding boxes with id.
struct bound_box * box
Array of bounding boxes.
Layer (old: field) information.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
double * z
Array of Z coordinates.
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)
int dglAddEdge(dglGraph_s *pGraph, dglInt32_t nHead, dglInt32_t nTail, dglInt32_t nCost, dglInt32_t nEdge)
void dglNodeSet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode, dglInt32_t *pnAttr)
int dglInitialize(dglGraph_s *pGraph, dglByte_t Version, dglInt32_t NodeAttrSize, dglInt32_t EdgeAttrSize, dglInt32_t *pOpaqueSet)
int dglInitializeSPCache(dglGraph_s *pGraph, dglSPCache_s *pCache)
int dglFlatten(dglGraph_s *pGraph)