54 int i,
j, from, to, line, nlines,
nnodes,
ret, type, cat,
skipped,
cfound;
61 0, 0, 0, 0, 0, 0, 0, 0};
80 const char *
tcols[] = {
"cat",
"ln_from",
"ln_to",
"cost",
"isec",
NULL};
91 "Vect_net_ttb_build_graph(): "
92 "ltype = %d, afield = %d, nfield = %d, tfield = %d, tucfield = %d ",
108 Map->dgraph.cost_multip = 1000000;
110 Map->dgraph.cost_multip = 1000;
115 gr = &(
Map->dgraph.graph_s);
124 for (i = 1; i <= nlines; i++) {
125 Map->dgraph.edge_fcosts[i] = -1;
126 Map->dgraph.edge_bcosts[i] = -1;
128 for (i = 1; i <=
nnodes; i++) {
129 Map->dgraph.node_costs[i] = 0;
159 Fi->database,
Fi->driver);
178 _(
"Data type of column <%s> not supported (must be numeric)"),
195 G_debug(2,
"Set nodes' costs");
209 Fi->database,
Fi->driver);
221 _(
"Data type of column <%s> not supported (must be numeric)"),
240 for (i = 1; i <=
nnodes; i++) {
251 G_debug(2,
" node = %d nlines = %d", i,
List->n_values);
256 for (
j = 0;
j <
List->n_values;
j++) {
258 G_debug(2,
" line (%d) = %d",
j, line);
276 _(
"Database record for node %d (cat = %d) not found "
324 "Add arc %d for virtual node from %d to %d cost = %d",
332 "node connection."));
344 "Add arc %d for virtual node from %d to %d cost = %d",
352 "node connection."));
363 G_warning(
_(
"There exists more than one point of node <%d> with "
364 "unique category field <%d>.\n"
365 "The unique categories layer is not valid therefore "
366 "you will probably get incorrect results."),
372 "Category of field %d is not attached to any points in node %d"
379 for (i = 1; i <=
nturns; i++) {
396 _(
"Unable to find point representing intersection <%d> in "
397 "unique categories field <%d>.\n"
398 "Cost for the intersection was set to 0.\n"
399 "The unique categories layer is not valid therefore you "
400 "will probably get incorrect results."),
411 _(
"Unable to find node for point representing "
412 "intersection <%d> in unique categories field <%d>.\n"
413 "Cost for the intersection was set to 0.\n"
414 "The unique categories layer is not valid therefore "
415 "you will probably get incorrect results."),
438 _(
"Database record for turn with cat = %d is not found. "
439 "(The turn was skipped."),
463 G_debug(5,
"Add arc/turn %d for turn from %d to %d cost = %d",
471 _(
"Cannot add network arc representing turn."));
503 Fi->database,
Fi->driver);
515 _(
"Data type of column <%s> not supported (must be numeric)"),
548 for (i = 1; i <= nlines; i++) {
564 G_warning(
_(
"Line with id <%d> has more unique categories defined "
566 "The unique categories layer is not valid therefore "
567 "you will probably get incorrect results."),
573 "Category of field %d not attached to the line %d -> "
587 G_warning(
_(
"Database record for line %d (cat = %d, "
588 "forward/both direction(s)) not found "
589 "(cost was set to 0)"),
603 G_warning(
_(
"Database record for line %d (cat = %d, "
604 "backward direction) not found"
605 "(cost was set to 0)"),
633 G_debug(5,
"Setinng node %d cost: %d", cat, cost);
643 G_debug(5,
"Setinng node %d cost: %d", cat, cost);
650 G_debug(2,
"%d lines missing category of field %d skipped",
skipped,
705 const char *
ncol,
int geo,
int version)
708 int i,
j, from, to, line, nlines,
nnodes,
ret, type, cat,
skipped,
cfound;
717 0, 0, 0, 0, 0, 0, 0, 0};
727 G_debug(1,
"Vect_net_build_graph(): ltype = %d, afield = %d, nfield = %d",
743 Map->dgraph.cost_multip = 1000000;
745 Map->dgraph.cost_multip = 1000;
750 gr = &(
Map->dgraph.graph_s);
758 for (i = 1; i <= nlines; i++) {
759 Map->dgraph.edge_fcosts[i] = -1;
760 Map->dgraph.edge_bcosts[i] = -1;
762 for (i = 1; i <=
nnodes; i++) {
763 Map->dgraph.node_costs[i] = 0;
800 Fi->database,
Fi->driver);
812 _(
"Data type of column <%s> not supported (must be numeric)"),
845 for (i = 1; i <= nlines; i++) {
857 "Category of field %d not attached to the line %d -> "
872 G_warning(
_(
"Database record for line %d (cat = %d, "
873 "forward/both direction(s)) not found "
874 "(forward/both direction(s) of line skipped)"),
889 G_warning(
_(
"Database record for line %d (cat = %d, "
890 "backward direction) not found"
891 "(direction of line skipped)"),
918 G_debug(5,
"Add arc %d from %d to %d cost = %d", i, from, to, cost);
927 Map->dgraph.edge_bcosts[i]);
930 G_debug(5,
"Add arc %d from %d to %d bcost = %d", -i, to, from,
941 G_debug(2,
"%d lines missing category of field %d skipped",
skipped,
962 G_debug(2,
"Set nodes' costs");
976 Fi->database,
Fi->driver);
988 _(
"Data type of column <%s> not supported (must be numeric)"),
997 for (i = 1; i <=
nnodes; i++) {
1008 G_debug(2,
" node = %d nlines = %d", i,
List->n_values);
1012 for (
j = 0;
j <
List->n_values;
j++) {
1014 G_debug(2,
" line (%d) = %d",
j, line);
1031 G_warning(
_(
"Database record for node %d (cat = %d) "
1043 "Category of field %d not attached to any points in node %d"
1055 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 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)