50 int nfield,
int tfield,
int tucfield,
51 const char *afcol,
const char *abcol,
52 const char *ncol,
int geo,
int algorithm
UNUSED)
55 int i, j, from, to, line, nlines, nnodes, ret, type, cat, skipped, cfound;
58 double dcost, bdcost, ll;
61 dglInt32_t opaqueset[16] = {360000, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0, 0};
70 int fctype = 0, bctype = 0, nrec, nturns;
72 int ln_cat, nnode_lns, i_line, line_id, i_virt_edge;
81 const char *tcols[] = {
"cat",
"ln_from",
"ln_to",
"cost",
"isec",
NULL};
87 int node_pt_id, turn_cat, tucfound;
92 "Vect_net_ttb_build_graph(): "
93 "ltype = %d, afield = %d, nfield = %d, tfield = %d, tucfield = %d ",
94 ltype, afield, nfield, tfield, tucfield);
95 G_debug(1,
" afcol = %s, abcol = %s, ncol = %s", afcol, abcol, ncol);
108 if (afcol ==
NULL && ll && !geo)
125 for (i = 1; i <= nlines; i++) {
129 for (i = 1; i <= nnodes; i++) {
158 if (ttbdriver ==
NULL)
167 tcols[i], Fi->
table);
172 !strcmp(tcols[i],
"cost"))
178 _(
"Data type of column <%s> not supported (must be numeric)"),
187 G_debug(1,
"forward costs: nrec = %d", nturns);
193 G_debug(2,
"Set nodes' costs");
218 _(
"Data type of column <%s> not supported (must be numeric)"),
225 G_debug(1,
"node costs: nrec = %d", nrec);
236 for (i = 1; i <= nnodes; i++) {
252 for (j = 0; j < List->
n_values; j++) {
254 G_debug(2,
" line (%d) = %d", j, line);
259 if (ncol !=
NULL && !cfound &&
272 _(
"Database record for node %d (cat = %d) not found "
299 if (!tucfound && ret) {
303 for (i_line = 0; i_line < nnode_lns; i_line++) {
320 "Add arc %d for virtual node from %d to %d cost = %d",
321 i_virt_edge, f,
t, 0);
328 "node connection."));
340 "Add arc %d for virtual node from %d to %d cost = %d",
341 i_virt_edge, f,
t, 0);
348 "node connection."));
359 G_warning(
_(
"There exists more than one point of node <%d> with "
360 "unique category field <%d>.\n"
361 "The unique categories layer is not valid therefore "
362 "you will probably get incorrect results."),
365 if (ncol !=
NULL && !cfound)
368 "Category of field %d is not attached to any points in node %d"
375 for (i = 1; i <= nturns; i++) {
390 &node_pt_id) == -1) {
392 _(
"Unable to find point representing intersection <%d> in "
393 "unique categories field <%d>.\n"
394 "Cost for the intersection was set to 0.\n"
395 "The unique categories layer is not valid therefore you "
396 "will probably get incorrect results."),
405 if (node_pt_id == 0) {
407 _(
"Unable to find node for point representing "
408 "intersection <%d> in unique categories field <%d>.\n"
409 "Cost for the intersection was set to 0.\n"
410 "The unique categories layer is not valid therefore "
411 "you will probably get incorrect results."),
415 G_debug(2,
" node = %d", node_pt_id);
421 G_debug(2,
"Set node's cost to %f", dcost);
434 _(
"Database record for turn with cat = %d is not found. "
435 "(The turn was skipped."),
459 G_debug(5,
"Add arc/turn %d for turn from %d to %d cost = %d",
460 turn_cat, f,
t, cost);
467 _(
"Cannot add network arc representing turn."));
510 _(
"Data type of column <%s> not supported (must be numeric)"),
516 G_debug(1,
"forward costs: nrec = %d", nrec);
533 G_debug(1,
"backward costs: nrec = %d", nrec);
541 for (i = 1; i <= nlines; i++) {
557 G_warning(
_(
"Line with id <%d> has more unique categories defined "
559 "The unique categories layer is not valid therefore "
560 "you will probably get incorrect results."),
566 "Category of field %d not attached to the line %d -> "
580 G_warning(
_(
"Database record for line %d (cat = %d, "
581 "forward/both direction(s)) not found "
582 "(cost was set to 0)"),
596 G_warning(
_(
"Database record for line %d (cat = %d, "
597 "backword direction) not found"
598 "(cost was set to 0)"),
626 G_debug(5,
"Setinng node %d cost: %d", cat, cost);
636 G_debug(5,
"Setinng node %d cost: %d", cat, cost);
642 if (afcol !=
NULL && skipped > 0)
643 G_debug(2,
"%d lines missing category of field %d skipped", skipped,
696 int nfield,
const char *afcol,
const char *abcol,
697 const char *ncol,
int geo,
int version)
700 int i, j, from, to, line, nlines, nnodes, ret, type, cat, skipped, cfound;
704 double dcost, bdcost, ll;
708 dglInt32_t opaqueset[16] = {360000, 0, 0, 0, 0, 0, 0, 0,
709 0, 0, 0, 0, 0, 0, 0, 0};
716 int fctype = 0, bctype = 0, nrec;
719 G_debug(1,
"Vect_net_build_graph(): ltype = %d, afield = %d, nfield = %d",
720 ltype, afield, nfield);
721 G_debug(1,
" afcol = %s, abcol = %s, ncol = %s", afcol, abcol, ncol);
734 if (afcol ==
NULL && ll && !geo)
750 for (i = 1; i <= nlines; i++) {
754 for (i = 1; i <= nnodes; i++) {
758 if (version < 1 || version > 3)
803 _(
"Data type of column <%s> not supported (must be numeric)"),
809 G_debug(1,
"forward costs: nrec = %d", nrec);
826 G_debug(1,
"backward costs: nrec = %d", nrec);
834 for (i = 1; i <= nlines; i++) {
846 "Category of field %d not attached to the line %d -> "
861 G_warning(
_(
"Database record for line %d (cat = %d, "
862 "forward/both direction(s)) not found "
863 "(forward/both direction(s) of line skipped)"),
878 G_warning(
_(
"Database record for line %d (cat = %d, "
879 "backword direction) not found"
880 "(direction of line skipped)"),
905 if (dofw && dcost != -1) {
907 G_debug(5,
"Add arc %d from %d to %d cost = %d", i, from, to, cost);
915 G_debug(5,
"bdcost = %f edge_bcosts = %f", bdcost,
917 if (dobw && bdcost != -1) {
919 G_debug(5,
"Add arc %d from %d to %d bcost = %d", -i, to, from,
929 if (afcol !=
NULL && skipped > 0)
930 G_debug(2,
"%d lines missing category of field %d skipped", skipped,
951 G_debug(2,
"Set nodes' costs");
976 _(
"Data type of column <%s> not supported (must be numeric)"),
982 G_debug(1,
"node costs: nrec = %d", nrec);
984 for (i = 1; i <= nnodes; i++) {
999 for (j = 0; j < List->
n_values; j++) {
1001 G_debug(2,
" line (%d) = %d", j, line);
1018 G_warning(
_(
"Database record for node %d (cat = %d) "
1030 "Category of field %d not attached to any points in node %d"
1042 G_debug(3,
"Set node's cost to %d", cost);
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.
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_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_init_handle(dbHandle *)
Initialize handle (i.e database/schema)
void db_init_string(dbString *)
Initialize dbString.
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.
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)
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
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_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats 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 UNUSED)
Build network graph with turntable.
dglSPCache_s spCache
Shortest path cache.
int line_type
Line type used to build the graph.
int cost_multip
Edge and node costs multiplicator.
double * edge_fcosts
Forward costs used for graph.
double * node_costs
Node costs used for graph.
dglGraph_s graph_s
Graph structure.
double * edge_bcosts
backward costs used for graph
struct Graph_info dgraph
Graph info (built for network analysis)
List of bounding boxes with id.
struct bound_box * box
Array of bounding boxes.
int n_values
Number of items in the list.
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')
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
double * z
Array of Z coordinates.
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)
dglInt32_t * dglGetNode(dglGraph_s *pGraph, dglInt32_t nNodeId)