net.c File Reference

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/Vect.h>
#include <fcntl.h>

Include dependency graph for net.c:

Go to the source code of this file.

Functions

int Vect_net_build_graph (struct Map_info *Map, int ltype, int afield, int nfield, char *afcol, char *abcol, 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.
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.
int Vect_net_get_line_cost (struct Map_info *Map, int line, int direction, double *cost)
int Vect_net_get_node_cost (struct Map_info *Map, int node, double *cost)
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)
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)


Function Documentation

Vect_net_build_graph ( struct Map_info *  Map,
int  ltype,
int  afield,
int  nfield,
char *  afcol,
char *  abcol,
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.

Returns:
0 on success, 1 on error
Parameters:
Map_info structure, line type for arcs, arc costs field, node costs field, column with forward costs for arc (if NULL use length), column with backward costs for arc (if NULL, back costs = forward costs), column with costs for nodes (if NULL, do not use node costs), use geodesic calculation for length (LL), not used (in future code for algorithm)

Definition at line 89 of file net.c.

References dglAddEdge(), dglFlatten(), dglGetNode(), dglInitialize(), dglNodeSet_Attr(), 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().

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

Definition at line 467 of file net.c.

Referenced by Vect_net_nearest_nodes(), and Vect_net_shortest_path_coor().

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

Definition at line 507 of file net.c.

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 
)

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.

Returns:
number of segments : ( 0 is correct for from = to, or List == NULL ), ? sum of costs is better return value, -1 : destination unreachable
Parameters:
Map_info structure, from?, to?, ilist? cost

Definition at line 389 of file net.c.

References _dglSPReport::cArc, dglEdgeGet_Cost(), dglEdgeGet_Id(), dglFreeSPReport(), dglShortestDistance(), dglShortestPath(), dglStrerror(), _dglSPReport::nDistance, _dglSPArc::nDistance, _dglSPArc::nFrom, _dglSPArc::nTo, _dglSPReport::pArc, _dglSPArc::pnEdge, Vect_list_append(), and Vect_reset_list().

Referenced by 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 line_pnts *  FPoints,
struct line_pnts *  TPoints,
double *  fdist,
double *  tdist 
)


Generated on Sun Apr 6 17:32:50 2008 for GRASS by  doxygen 1.5.5