GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
net_analyze.c File Reference

Vector library - related fns for vector network analyses. More...

#include <grass/dbmi.h>
#include <grass/vector.h>
#include <grass/glocale.h>
Include dependency graph for net_analyze.c:

Go to the source code of this file.

Functions

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. More...
 
int Vect_net_shortest_path (struct Map_info *Map, int from, int to, struct ilist *List, double *cost)
 Find shortest path. More...
 
dglGraph_sVect_net_get_graph (struct Map_info *Map)
 Get graph structure. More...
 
int Vect_net_get_line_cost (const struct Map_info *Map, int line, int direction, double *cost)
 Returns in cost for given direction in *cost. More...
 
int Vect_net_get_node_cost (const struct Map_info *Map, int node, double *cost)
 Get cost of node. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

Vector library - related fns for vector network analyses.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009, 2014 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Radim Blazek
Stepan Turek stepan.turek seznam.cz (turns support)

Definition in file net_analyze.c.

Function Documentation

◆ Vect_net_get_graph()

dglGraph_s* Vect_net_get_graph ( struct Map_info Map)

Get graph structure.

Graph is built by Vect_net_build_graph().

Returns NULL when graph is not built.

Parameters
Mappointer to Map_info struct
Returns
pointer to dglGraph_s struct or NULL

Definition at line 393 of file net_analyze.c.

References Map_info::dgraph, and Graph_info::graph_s.

◆ Vect_net_get_line_cost()

int Vect_net_get_line_cost ( const struct Map_info Map,
int  line,
int  direction,
double *  cost 
)

Returns in cost for given direction in *cost.

cost is set to -1 if closed.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
lineline id
directiondirection (GV_FORWARD, GV_BACKWARD)
[out]cost
Returns
1 OK
0 does not exist (was not inserted)

Definition at line 412 of file net_analyze.c.

References Map_info::dgraph, Graph_info::edge_fcosts, G_debug(), and GV_FORWARD.

◆ Vect_net_get_node_cost()

int Vect_net_get_node_cost ( const struct Map_info Map,
int  node,
double *  cost 
)

Get cost of node.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
nodenode id
[out]costcosts value
Returns
1

Definition at line 467 of file net_analyze.c.

References Map_info::dgraph, G_debug(), and Graph_info::node_costs.

◆ Vect_net_nearest_nodes()

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.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
x,y,zpoint coordinates (z coordinate NOT USED !)
direction(GV_FORWARD - from point to net, GV_BACKWARD - from net to point)
maxdistmaximum distance to the network
[out]node1pointer where to store the node number (or NULL)
[out]node2pointer where to store the node number (or NULL)
[out]lnpointer where to store the nearest line number (or NULL)
[out]costs1pointer where to store costs on nearest line to node1 (not costs from x,y,z to the line) (or NULL)
[out]costs2pointer where to store costs on nearest line to node2 (not costs from x,y,z to the line) (or NULL)
[out]Points1pointer to structure where to store vertices on nearest line to node1 (or NULL)
[out]Points2pointer to structure where to store vertices on nearest line to node2 (or NULL)
[out]pointerwhere to distance to the line (or NULL)
[out]distance
Returns
number of nodes found (0,1,2)

Definition at line 497 of file net_analyze.c.

◆ Vect_net_shortest_path()

int Vect_net_shortest_path ( struct Map_info Map,
int  from,
int  to,
struct ilist List,
double *  cost 
)

Find shortest path.

Costs for 'from' and 'to' nodes are not considered (SP found even if 'from' or 'to' are 'closed' (costs = -1) and costs of these nodes are not added to SP costs result.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
fromfrom node
toto node
[out]Listlist of line ids (path)
[out]costcosts value
Returns
number of segments
0 is correct for from = to, or List == NULL ? sum of costs is better return value,
-1 : destination unreachable

Definition at line 376 of file net_analyze.c.

◆ Vect_net_shortest_path_coor()

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.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
fx,fy,fzfrom point x coordinate (z ignored)
tx,ty,tzto point x coordinate (z ignored)
fmaxmaximum distance to the network from 'from'
tmaxmaximum distance to the network from 'to'
costspointer where to store costs on the network (or NULL)
Pointspointer to the structure where to store vertices of shortest path (or NULL)
Listpointer to the structure where list of lines on the network is stored (or NULL)
NodesListpointer to the structure where list of nodes on the network is stored (or NULL)
FPointspointer to the structure where to store line from 'from' to first network node (or NULL)
TPointspointer to the structure where to store line from last network node to 'to' (or NULL)
fdistdistance from 'from' to the net (or NULL)
tdistdistance from 'to' to the net (or NULL)
Returns
1 OK, 0 not reachable

Definition at line 1023 of file net_analyze.c.

◆ Vect_net_ttb_shortest_path()

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.

Costs for 'from' and 'to' nodes are not considered (SP found even if 'from' or 'to' are 'closed' (costs = -1) and costs of these nodes are not added to SP costs result.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
fromstart of the path
from_typeif 0 - node id (intersection), if 1 - line unique cat
toend of the path
to_typeif 0 - node id (intersection), if 1 - line unique cat
tucfieldfield with unique categories used in the turntable
[out]Listlist of line ids (path)
[out]costcosts value
Returns
number of segments
0 is correct for from = to, or List == NULL ? sum of costs is better return value,
-1 : destination unreachable

Definition at line 254 of file net_analyze.c.

References t, and x.

◆ Vect_net_ttb_shortest_path_coor()

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.

Parameters
Mapvector map with build graph (see Vect_net_ttb_build_graph and Vect_net_build_graph)
fx,fy,fzfrom point x coordinate (z ignored)
tx,ty,tzto point x coordinate (z ignored)
fmaxmaximum distance to the network from 'from'
tmaxmaximum distance to the network from 'to'
tucfieldfield with unique categories used in the turntable
costspointer where to store costs on the network (or NULL)
Pointspointer to the structure where to store vertices of shortest path (or NULL)
Listpointer to the structure where list of lines on the network is stored (or NULL)
NodesListpointer to the structure where list of nodes on the network is stored (or NULL)
FPointspointer to the structure where to store line from 'from' to first network node (or NULL)
TPointspointer to the structure where to store line from last network node to 'to' (or NULL)
fdistdistance from 'from' to the net (or NULL)
tdistdistance from 'to' to the net (or NULL)
Returns
1 OK, 0 not reachable

Definition at line 1058 of file net_analyze.c.