GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
utils.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
#include <grass/dbmi.h>
#include <grass/neta.h>
Include dependency graph for utils.c:

Go to the source code of this file.

Functions

void NetA_add_point_on_node (struct Map_info *In, struct Map_info *Out, int node, struct line_cats *Cats)
 Writes point. More...
 
void NetA_points_to_nodes (struct Map_info *In, struct ilist *point_list)
 Finds node. More...
 
int NetA_get_node_costs (struct Map_info *In, int layer, char *column, int *node_costs)
 Get node cost. More...
 
void NetA_varray_to_nodes (struct Map_info *map, struct varray *varray, struct ilist *nodes, int *nodes_to_features)
 Get list of nodes from varray. More...
 
int NetA_initialise_varray (struct Map_info *In, int layer, int mask_type, char *where, char *cat, struct varray **varray)
 Initialize varray. More...
 

Function Documentation

void NetA_add_point_on_node ( struct Map_info *  In,
struct Map_info *  Out,
int  node,
struct line_cats *  Cats 
)

Writes point.

Writes GV_POINT to Out at the position of the node in In.

Parameters
Inpointer to Map_info structure (input vector map)
[in,out]Outpointer to Map_info structure (output vector map)
nodenode id
Catspointer to line_cats structures

Definition at line 35 of file utils.c.

References Vect_append_point(), Vect_destroy_line_struct(), Vect_get_node_coor(), Vect_new_line_struct(), Vect_reset_line(), Vect_write_line(), and y.

int NetA_get_node_costs ( struct Map_info *  In,
int  layer,
char *  column,
int node_costs 
)

Get node cost.

For each node in the map, finds the category of the point on it (if there is any) and stores the value associated with this category in the array node_costs. If there is no point with a category, node_costs=0.

node_costs are multiplied by 1000000 and truncated to integers (as is done in Vect_net_build_graph)

Parameters
Inpointer to Map_info structure
layerlayer number
columnname of column
[out]node_costslist of node costs
Returns
1 on success
0 on failure

Definition at line 102 of file utils.c.

References cat, db_CatValArray_free(), db_CatValArray_get_value_double(), db_CatValArray_init(), db_close_database_shutdown_driver(), db_select_CatValArray(), db_start_driver_open_database(), driver, G_fatal_error(), NULL, dialogs::type, value, Vect_cat_get(), Vect_destroy_cats_struct(), Vect_get_field(), Vect_get_line_nodes(), Vect_get_num_lines(), Vect_get_num_nodes(), Vect_new_cats_struct(), Vect_new_line_struct(), and Vect_read_line().

int NetA_initialise_varray ( struct Map_info *  In,
int  layer,
int  mask_type,
char *  where,
char *  cat,
struct varray **  varray 
)

Initialize varray.

Parameters
Inpointer to Map_info structure
layerlayer number
mask_type?
wherewhere statement
cat?
[out]pointerto varray structure
Returns
number of items set
-1 on error

Definition at line 215 of file utils.c.

References cat, G_fatal_error(), G_warning(), n, NULL, Vect_cat_get(), Vect_destroy_cats_struct(), Vect_get_num_lines(), Vect_new_cats_struct(), Vect_new_varray(), Vect_read_line(), Vect_set_varray_from_cat_string(), and Vect_set_varray_from_db().

void NetA_points_to_nodes ( struct Map_info *  In,
struct ilist *  point_list 
)

Finds node.

Find the node corresponding to each point in the point_list

Parameters
Inpointer to Map_info structure
point_listlist of points (their ids)

Definition at line 73 of file utils.c.

References NULL, and Vect_get_line_nodes().

void NetA_varray_to_nodes ( struct Map_info *  map,
struct varray *  varray,
struct ilist *  nodes,
int nodes_to_features 
)

Get list of nodes from varray.

Returns the list of all nodes on features selected by varray. nodes_to_features conains the index of a feature adjecent to each node or -1 if no such feature specified by varray exists. Nodes_to_features might be NULL, in which case it is left unitialised.

Parameters
mappointer to Map_info structure
varraypointer to varray structure
[out]nodeslist of node ids
node_to_features?

Definition at line 166 of file utils.c.

References NULL, dialogs::type, Vect_get_line_nodes(), Vect_get_num_lines(), Vect_get_num_nodes(), Vect_list_append(), and Vect_read_line().