GRASS Programmer's Manual
6.5.svn(2014)-r66266
|
Vector library - net releated fns. More...
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Go to the source code of this file.
Functions | |
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 algorithm) |
Build network graph. More... | |
int | Vect_net_shortest_path (struct Map_info *Map, int from, int to, struct ilist *List, double *cost) |
Find shortest path. More... | |
int | Vect_net_get_line_cost (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 (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 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_shortest_path_coor2 (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... | |
Vector library - net releated fns.
Higher level functions for reading/writing/manipulating vectors.
(C) 2001-2008 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.
Definition in file net.c.
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 | algorithm | ||
) |
Build network graph.
Internal format for edge costs is integer, costs are multiplied before conversion to int by 1000 and for lenghts LL without geo flag by 1000000. The same multiplication factor is used for nodes. Costs in database column may be 'integer' or 'double precision' number >= 0 or -1 for infinity i.e. arc or node is closed and cannot be traversed If record in table is not found for arcs, arc is skip. If record in table is not found for node, costs for node are set to 0.
Map | vector map |
ltype | line type for arcs |
afield | arc costs field (if 0, use length) |
nfield | node costs field (if 0, do not use node costs) |
afcol | column with forward costs for arc |
abcol | column with backward costs for arc (if NULL, back costs = forward costs), |
ncol | column with costs for nodes (if NULL, do not use node costs), |
geo | use geodesic calculation for length (LL), |
algorithm | not used (in future code for algorithm) |
Definition at line 91 of file net.c.
References cat, db_CatValArray_free(), db_CatValArray_get_value_double(), db_CatValArray_get_value_int(), db_CatValArray_init(), db_close_database_shutdown_driver(), db_get_column(), db_get_column_sqltype(), db_init_handle(), db_init_string(), db_select_CatValArray(), db_sqltype_to_Ctype(), db_start_driver_open_database(), dglAddEdge(), dglFlatten(), dglGetNode(), dglInitialize(), dglInitializeSPCache(), dglNodeSet_Attr(), G_debug(), G_fatal_error(), G_message(), G_percent(), G_projection(), G_warning(), NULL, dialogs::type, Vect_cat_get(), Vect_get_field(), Vect_get_line_nodes(), Vect_get_node_line(), Vect_get_node_n_lines(), Vect_get_num_lines(), Vect_get_num_nodes(), Vect_line_geodesic_length(), Vect_line_length(), Vect_new_cats_struct(), Vect_new_line_struct(), and Vect_read_line().
Returns in cost for given direction in *cost.
cost is set to -1 if closed.
Map | vector map |
line | line id |
direction | direction (GV_FORWARD, GV_BACKWARD) |
Definition at line 565 of file net.c.
References G_debug(), and G_fatal_error().
Referenced by Vect_net_nearest_nodes(), and Vect_net_shortest_path_coor2().
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.
Map | vetor map |
x,y,z | point coordinates (z coordinate NOT USED !) |
direction | (GV_FORWARD - from point to net, GV_BACKWARD - from net to point) |
maxdist | maximum distance to the network |
node1 | pointer where to store the node number (or NULL) |
node2 | pointer where to store the node number (or NULL) |
ln | pointer where to store the nearest line number (or NULL) |
costs1 | pointer where to store costs on nearest line to node1 (not costs from x,y,z to the line) (or NULL) |
costs2 | pointer where to store costs on nearest line to node2 (not costs from x,y,z to the line) (or NULL) |
Points1 | pointer to structure where to store vertices on nearest line to node1 (or NULL) |
Points2 | pointer to structure where to store vertices on nearest line to node2 (or NULL) |
pointer | where to distance to the line (or NULL) |
Definition at line 647 of file net.c.
References G_debug(), NULL, Vect_append_point(), Vect_find_line(), Vect_get_line_nodes(), Vect_line_distance(), Vect_line_length(), Vect_net_get_line_cost(), Vect_new_line_struct(), Vect_read_line(), and Vect_reset_line().
Referenced by Vect_net_shortest_path_coor2().
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.
Map | vector map | |
from | from node | |
to | to node | |
[out] | List | list of line ids (path) |
[out] | cost | costs value |
Definition at line 464 of file net.c.
References _dglSPReport::cArc, dglEdgeGet_Cost(), dglEdgeGet_Id(), dglFreeSPReport(), dglShortestDistance(), dglShortestPath(), dglStrerror(), G_debug(), G_warning(), _dglSPArc::nDistance, _dglSPReport::nDistance, _dglSPArc::nFrom, _dglSPArc::nTo, NULL, _dglSPReport::pArc, _dglSPArc::pnEdge, Vect_list_append(), and Vect_reset_list().
Referenced by Vect_net_shortest_path_coor2().
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 line_pnts * | FPoints, | ||
struct line_pnts * | TPoints, | ||
double * | fdist, | ||
double * | tdist | ||
) |
Find shortest path on network between 2 points given by coordinates.
Map | vector map |
fx,fy,fz | from point x coordinate (z ignored) |
tx,ty,tz | to point x coordinate (z ignored) |
fmax | maximum distance to the network from 'from' |
tmax | maximum distance to the network from 'to' |
costs | pointer where to store costs on the network (or NULL) |
Points | pointer to the structure where to store vertices of shortest path (or NULL) |
List | pointer to the structure where list of lines on the network is stored (or NULL) |
FPoints | pointer to the structure where to store line from 'from' to first network node (or NULL) |
TPoints | pointer to the structure where to store line from last network node to 'to' (or NULL) |
fdist | distance from 'from' to the net (or NULL) |
tdist | distance from 'to' to the net (or NULL) |
Definition at line 866 of file net.c.
References NULL, and Vect_net_shortest_path_coor2().
int Vect_net_shortest_path_coor2 | ( | 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.
Map | vector map |
fx,fy,fz | from point x coordinate (z ignored) |
tx,ty,tz | to point x coordinate (z ignored) |
fmax | maximum distance to the network from 'from' |
tmax | maximum distance to the network from 'to' |
costs | pointer where to store costs on the network (or NULL) |
Points | pointer to the structure where to store vertices of shortest path (or NULL) |
List | pointer to the structure where list of lines on the network is stored (or NULL) |
List | pointer to the structure where list of nodes on the network is stored (or NULL) |
FPoints | pointer to the structure where to store line from 'from' to first network node (or NULL) |
TPoints | pointer to the structure where to store line from last network node to 'to' (or NULL) |
fdist | distance from 'from' to the net (or NULL) |
tdist | distance from 'to' to the net (or NULL) |
Definition at line 898 of file net.c.
References first, frame::fn, G_debug(), NULL, Vect_append_point(), Vect_append_points(), Vect_get_line_nodes(), Vect_line_distance(), Vect_line_length(), Vect_list_append(), Vect_net_get_line_cost(), Vect_net_nearest_nodes(), Vect_net_shortest_path(), Vect_new_line_struct(), Vect_new_list(), Vect_read_line(), Vect_reset_line(), and Vect_reset_list().
Referenced by Vect_net_shortest_path_coor().