32 G_debug(3,
" Edge = %d NodeFrom = %d NodeTo = %d edge cost = %d",
37 if (from != From_node) {
47 G_debug(3,
" EdgeCost += %d (node)", (
int)cost);
53 G_debug(3,
" don't clip first node");
63static int convert_dgl_shortest_path_result(
struct Map_info *
Map,
74 2,
"From %ld to %ld - cost %ld user %d distance %ld",
77 Map->dgraph.cost_multip,
89static int ttb_convert_dgl_shortest_path_result(
struct Map_info *
Map,
105 &(
Map->dgraph.graph_s),
124 2,
"From %ld to %ld - cost %ld user %d distance %ld",
127 Map->dgraph.cost_multip,
147static int find_shortest_path(
struct Map_info *
Map,
int from,
int to,
156 G_debug(3,
"find_shortest_path(): from = %d, to = %d", from, to);
190 clipper,
pclip, &(
Map->dgraph.spCache));
224 *cost = (
double)nDistance /
Map->dgraph.cost_multip;
294 G_fatal_error(
_(
"Unable to find point with defined unique category "
298 G_warning(
_(
"There exists more than one point on node <%d> with "
299 "unique category in field <%d>.\n"
300 "The unique category layer may not be valid."),
303 G_debug(2,
"from node = %d, unique cat = %d ", from, f);
311 G_debug(2,
"from edge unique cat = %d", from);
335 G_fatal_error(
_(
"Unable to find point with defined unique category "
339 G_warning(
_(
"There exists more than one point on node <%d> with "
340 "unique category in field <%d>.\n"
341 "The unique category layer may not be valid."),
344 G_debug(2,
"to node = %d, unique cat = %d ", to,
t);
352 G_debug(2,
"to edge unique cat = %d", to);
380 return find_shortest_path(
Map, from, to,
List, cost, 0, -1);
396 return &(
Map->dgraph.graph_s);
416 G_debug(5,
"Vect_net_get_line_cost(): line = %d, dir = %d", line,
427 if (
Map->dgraph.edge_fcosts[line] == -1) {
432 *cost =
Map->dgraph.edge_fcosts[line];
441 if (
Map->dgraph.edge_bcosts[line] == -1) {
446 *cost =
Map->dgraph.edge_bcosts[line];
447 G_debug(5,
"Vect_net_get_line_cost(): edge_bcosts = %f",
448 Map->dgraph.edge_bcosts[line]);
451 G_fatal_error(
_(
"Wrong line direction in Vect_net_get_line_cost()"));
467 G_debug(3,
"Vect_net_get_node_cost(): node = %d", node);
469 *cost =
Map->dgraph.node_costs[node];
471 G_debug(3,
" -> cost = %f", *cost);
515 G_debug(3,
"Vect_net_nearest_nodes() x = %f y = %f",
x,
y);
551 G_debug(4,
"line = %d n1 = %d n2 = %d segment = %d", line, n1, n2, segment);
554 G_debug(4,
"cx = %f cy = %f first = %f %f last = %f %f",
cx,
cy,
555 Points->
x[0], Points->
y[0], Points->
x[npoints - 1],
556 Points->
y[npoints - 1]);
558 if (Points->
x[0] ==
cx && Points->
y[0] ==
cy) {
569 G_debug(3,
"first node nearest");
572 if (Points->
x[npoints - 1] ==
cx && Points->
y[npoints - 1] ==
cy) {
583 G_debug(3,
"last node nearest");
618 *
costs1 =
c2 * (length - along) / length;
627 for (i = segment; i < npoints; i++)
632 for (i = npoints - 1; i >= segment; i--)
652 *
costs2 =
c2 * (length - along) / length;
661 for (i = segment - 1; i >= 0; i--)
666 for (i = 0; i < segment; i++)
681 for (i = segment; i < npoints; i++)
686 for (i = npoints - 1; i >= segment; i--)
723 double tx,
double ty,
double tz,
double fmax,
736 static int first = 1;
738 int i,
j,
fn = 0,
tn = 0;
745 G_debug(3,
"Vect_net_shortest_path_coor()");
832 else if (
flen < tlen) {
869 for (i = 0; i <
nfnodes; i++) {
874 G_debug(3,
"i = %d fnode = %d j = %d tnode = %d", i,
fnode[i],
j,
940 for (i = 0; i <
LList->n_values; i++) {
943 line =
LList->value[i];
944 G_debug(3,
"i = %d line = %d", i, line);
1019 double fz,
double tx,
double ty,
double tz,
1027 return find_shortest_path_coor(
Map,
fx,
fy,
fz,
tx,
ty, tz,
fmax,
tmax, 0,
1055 double fz,
double tx,
double ty,
double tz,
1063 return find_shortest_path_coor(
Map,
fx,
fy,
fz,
tx,
ty, tz,
fmax,
tmax, 1,
Main header of GRASS DataBase Management Interface.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
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.
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.
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_list_append(struct ilist *, int)
Append new item to the end of list if not yet present.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_line_distance(const struct line_pnts *, double, double, double, int, double *, double *, double *, double *, double *, double *)
Calculate distance of point to line.
int Vect_find_line(struct Map_info *, double, double, double, int, double, int, int)
Find the nearest line.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist.
int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int, struct boxlist *)
Select lines with bounding boxes by box.
void Vect_reset_line(struct line_pnts *)
Reset line.
int Vect_line_prune(struct line_pnts *)
Remove duplicate points, i.e. zero length segments.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_reset_list(struct ilist *)
Reset ilist structure.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
int Vect_append_points(struct line_pnts *, const struct line_pnts *, int)
Appends points to the end of a line.
#define GV_POINT
Feature types used in memory on run time (may change)
#define PORT_DOUBLE_MAX
Limits for portable types.
#define GV_FORWARD
Line direction indicator forward/backward.
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
int Vect_net_shortest_path(struct Map_info *Map, int from, int to, struct ilist *List, double *cost)
Find shortest path.
int Vect_net_ttb_shortest_path_coor(struct Map_info *Map, double fx, double fy, double fz, double tx, double ty, double tz, double fmax, double tmax, int tucfield, double *costs, struct line_pnts *Points, struct ilist *List, struct ilist *NodesList, struct line_pnts *FPoints, struct line_pnts *TPoints, double *fdist, double *tdist)
Find shortest path on network with turntable between 2 points given by coordinates.
int Vect_net_shortest_path_coor(struct Map_info *Map, double fx, double fy, double fz, double tx, double ty, double tz, double fmax, double tmax, double *costs, struct line_pnts *Points, struct ilist *List, struct ilist *NodesList, struct line_pnts *FPoints, struct line_pnts *TPoints, double *fdist, double *tdist)
Find shortest path on network between 2 points given by coordinates.
dglGraph_s * Vect_net_get_graph(struct Map_info *Map)
Get graph structure.
int Vect_net_get_line_cost(struct Map_info *Map, int line, int direction, double *cost)
Returns in cost for given direction in *cost.
int Vect_net_ttb_shortest_path(struct Map_info *Map, int from, int from_type, int to, int to_type, int tucfield, struct ilist *List, double *cost)
Find shortest path on network.
int Vect_net_nearest_nodes(struct Map_info *Map, double x, double y, double z, int direction, double maxdist, int *node1, int *node2, int *ln, double *costs1, double *costs2, struct line_pnts *Points1, struct line_pnts *Points2, double *distance)
Find nearest node(s) on network.
int Vect_net_get_node_cost(struct Map_info *Map, int node, double *cost)
Get cost of node.
List of bounding boxes with id.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.
void dglFreeSPReport(dglGraph_s *pgraph, dglSPReport_s *pSPReport)
int dglGet_NodeAttrSize(dglGraph_s *pgraph)
int dglShortestPath(dglGraph_s *pGraph, dglSPReport_s **ppReport, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
dglInt32_t dglEdgeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnEdge)
char * dglStrerror(dglGraph_s *pgraph)
int dglShortestDistance(dglGraph_s *pGraph, dglInt32_t *pnDistance, dglInt32_t nStart, dglInt32_t nDestination, dglSPClip_fn fnClip, void *pvClipArg, dglSPCache_s *pCache)
dglInt32_t * dglNodeGet_Attr(dglGraph_s *pGraph, dglInt32_t *pnNode)
dglInt32_t dglEdgeGet_Cost(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t * dglEdgeGet_Head(dglGraph_s *pGraph, dglInt32_t *pnEdge)
dglInt32_t dglNodeGet_Id(dglGraph_s *pGraph, dglInt32_t *pnNode)