34 G_debug(3,
" Edge = %d NodeFrom = %d NodeTo = %d edge cost = %d",
39 if (from != From_node) {
49 G_debug(3,
" EdgeCost += %d (node)", (
int)cost);
55 G_debug(3,
" don't clip first node");
65static int convert_dgl_shortest_path_result(
struct Map_info *
Map,
76 2,
"From %ld to %ld - cost %ld user %d distance %ld",
79 Map->dgraph.cost_multip,
91static int ttb_convert_dgl_shortest_path_result(
struct Map_info *
Map,
107 &(
Map->dgraph.graph_s),
126 2,
"From %ld to %ld - cost %ld user %d distance %ld",
129 Map->dgraph.cost_multip,
149static int find_shortest_path(
struct Map_info *
Map,
int from,
int to,
158 G_debug(3,
"find_shortest_path(): from = %d, to = %d", from, to);
192 clipper,
pclip, &(
Map->dgraph.spCache));
226 *cost = (
double)nDistance /
Map->dgraph.cost_multip;
296 G_fatal_error(
_(
"Unable to find point with defined unique category "
300 G_warning(
_(
"There exists more than one point on node <%d> with "
301 "unique category in field <%d>.\n"
302 "The unique category layer may not be valid."),
305 G_debug(2,
"from node = %d, unique cat = %d ", from, f);
313 G_debug(2,
"from edge unique cat = %d", from);
337 G_fatal_error(
_(
"Unable to find point with defined unique category "
341 G_warning(
_(
"There exists more than one point on node <%d> with "
342 "unique category in field <%d>.\n"
343 "The unique category layer may not be valid."),
346 G_debug(2,
"to node = %d, unique cat = %d ", to,
t);
354 G_debug(2,
"to edge unique cat = %d", to);
382 return find_shortest_path(
Map, from, to,
List, cost, 0, -1);
398 return &(
Map->dgraph.graph_s);
418 G_debug(5,
"Vect_net_get_line_cost(): line = %d, dir = %d", line,
429 if (
Map->dgraph.edge_fcosts[line] == -1) {
434 *cost =
Map->dgraph.edge_fcosts[line];
443 if (
Map->dgraph.edge_bcosts[line] == -1) {
448 *cost =
Map->dgraph.edge_bcosts[line];
449 G_debug(5,
"Vect_net_get_line_cost(): edge_bcosts = %f",
450 Map->dgraph.edge_bcosts[line]);
453 G_fatal_error(
_(
"Wrong line direction in Vect_net_get_line_cost()"));
469 G_debug(3,
"Vect_net_get_node_cost(): node = %d", node);
471 *cost =
Map->dgraph.node_costs[node];
473 G_debug(3,
" -> cost = %f", *cost);
517 G_debug(3,
"Vect_net_nearest_nodes() x = %f y = %f",
x,
y);
553 G_debug(4,
"line = %d n1 = %d n2 = %d segment = %d", line, n1, n2, segment);
556 G_debug(4,
"cx = %f cy = %f first = %f %f last = %f %f",
cx,
cy,
557 Points->
x[0], Points->
y[0], Points->
x[npoints - 1],
558 Points->
y[npoints - 1]);
560 if (Points->
x[0] ==
cx && Points->
y[0] ==
cy) {
571 G_debug(3,
"first node nearest");
574 if (Points->
x[npoints - 1] ==
cx && Points->
y[npoints - 1] ==
cy) {
585 G_debug(3,
"last node nearest");
620 *
costs1 =
c2 * (length - along) / length;
629 for (i = segment; i < npoints; i++)
634 for (i = npoints - 1; i >= segment; i--)
654 *
costs2 =
c2 * (length - along) / length;
663 for (i = segment - 1; i >= 0; i--)
668 for (i = 0; i < segment; i++)
683 for (i = segment; i < npoints; i++)
688 for (i = npoints - 1; i >= segment; i--)
725 double tx,
double ty,
double tz,
double fmax,
738 static int first = 1;
740 int i,
j,
fn = 0,
tn = 0;
747 G_debug(3,
"Vect_net_shortest_path_coor()");
834 else if (
flen < tlen) {
871 for (i = 0; i <
nfnodes; i++) {
876 G_debug(3,
"i = %d fnode = %d j = %d tnode = %d", i,
fnode[i],
j,
942 for (i = 0; i <
LList->n_values; i++) {
945 line =
LList->value[i];
946 G_debug(3,
"i = %d line = %d", i, line);
1021 double fz,
double tx,
double ty,
double tz,
1029 return find_shortest_path_coor(
Map,
fx,
fy,
fz,
tx,
ty, tz,
fmax,
tmax, 0,
1057 double fz,
double tx,
double ty,
double tz,
1065 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 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)