GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
level_two.c File Reference

Vector library - topology level functions. More...

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

Go to the source code of this file.

Functions

plus_t Vect_get_num_nodes (const struct Map_info *Map)
 Get number of nodes in vector map. More...
 
plus_t Vect_get_num_primitives (const struct Map_info *Map, int type)
 Get number of primitives in vector map. More...
 
plus_t Vect_get_num_lines (const struct Map_info *Map)
 Fetch number of features (points, lines, boundaries, centroids) in vector map. More...
 
plus_t Vect_get_num_areas (const struct Map_info *Map)
 Get number of areas in vector map. More...
 
plus_t Vect_get_num_kernels (const struct Map_info *Map)
 Fetch number of kernels in vector map. More...
 
plus_t Vect_get_num_faces (const struct Map_info *Map)
 Get number of faces in vector map. More...
 
plus_t Vect_get_num_volumes (const struct Map_info *Map)
 Fetch number of volumes in vector map. More...
 
plus_t Vect_get_num_islands (const struct Map_info *Map)
 Get number of islands in vector map. More...
 
plus_t Vect_get_num_holes (const struct Map_info *Map)
 Fetch number of holes in vector map. More...
 
int Vect_get_num_dblinks (const struct Map_info *Map)
 Get number of defined dblinks. More...
 
int Vect_get_num_updated_lines (const struct Map_info *Map)
 Get number of updated features. More...
 
int Vect_get_updated_line (const struct Map_info *Map, int idx)
 Get updated line by index. More...
 
off_t Vect_get_updated_line_offset (const struct Map_info *Map, int idx)
 Get updated line offset by index. More...
 
int Vect_get_num_updated_nodes (const struct Map_info *Map)
 Get number of updated nodes. More...
 
int Vect_get_updated_node (const struct Map_info *Map, int idx)
 Get updated (modified) node by index. More...
 
int Vect_get_line_type (const struct Map_info *Map, int line)
 Get line type. More...
 
int Vect_get_node_coor (const struct Map_info *Map, int num, double *x, double *y, double *z)
 Get node coordinates. More...
 
int Vect_get_line_nodes (const struct Map_info *Map, int line, int *n1, int *n2)
 Get line nodes. More...
 
int Vect_get_line_areas (const struct Map_info *Map, int line, int *left, int *right)
 Get area id on the left and right side of the boundary. More...
 
int Vect_get_node_n_lines (const struct Map_info *Map, int node)
 Get number of lines for node. More...
 
int Vect_get_node_line (const struct Map_info *Map, int node, int line)
 Get line id for node line index. More...
 
float Vect_get_node_line_angle (const struct Map_info *Map, int node, int line)
 Angle of segment of the line connected to the node. More...
 
int Vect_get_centroid_area (const struct Map_info *Map, int centroid)
 Get area id the centroid is within. More...
 
void Vect_set_updated (struct Map_info *Map, int enable)
 Enable/disable maintanance of list of updated lines/nodes. More...
 
void Vect_reset_updated (struct Map_info *Map)
 Reset list of updated lines/nodes. More...
 

Detailed Description

Vector library - topology level functions.

(C) 2001-2009, 2011-2012 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
Original author CERL, probably Dave Gerdes or Mike Higgins.
Update to GRASS 5.7 Radim Blazek and David D. Gray.
Update to GRASS 7 by Martin Landa <landa.martin gmail.com>

Definition in file level_two.c.

Function Documentation

int Vect_get_centroid_area ( const struct Map_info Map,
int  centroid 
)

Get area id the centroid is within.

Parameters
Mappointer to Map_info struct
centroidcentroid id
Returns
area id the centroid is within
0 for not in area
negative id if centroid is duplicated in the area

Definition at line 434 of file level_two.c.

References _, P_topo_c::area, G_fatal_error(), GV_CENTROID, Plus_head::Line, Map_info::plus, P_line::topo, and P_line::type.

Referenced by Vedit_delete_area_centroid().

int Vect_get_line_areas ( const struct Map_info Map,
int  line,
int left,
int right 
)

Get area id on the left and right side of the boundary.

Negative area id indicates an isle.

Parameters
Mappointer to Map_info struct
lineline id
[out]left,rightarea id on the left and right side
Returns
1 on success
-1 on failure (topology not available, line is not a boundary)

Definition at line 350 of file level_two.c.

References _, G_warning(), GV_BOUNDARY, if(), P_topo_b::left, Plus_head::Line, NULL, Map_info::plus, P_topo_b::right, P_line::topo, and Vect_get_line_type().

Referenced by Vect_remove_small_areas_ext(), Vect_remove_small_areas_nat(), Vect_select_areas_by_polygon(), Vect_topo_check(), Vect_write_ascii(), and Vedit_delete_area().

int Vect_get_line_nodes ( const struct Map_info Map,
int  line,
int n1,
int n2 
)
int Vect_get_line_type ( const struct Map_info Map,
int  line 
)

Get line type.

Parameters
Mappointer to Map_info struct
lineline id
Returns
line type

Definition at line 258 of file level_two.c.

References Plus_head::Line, Map_info::plus, P_line::type, and Vect_line_alive().

Referenced by Vect_get_line_areas(), Vect_get_line_nodes(), Vect_remove_duplicates(), Vect_topo_check(), Vedit_connect_lines(), and Vedit_extend_lines().

int Vect_get_node_coor ( const struct Map_info Map,
int  num,
double *  x,
double *  y,
double *  z 
)

Get node coordinates.

Parameters
Mappointer to Map_info struct
numnode id (starts at 1)
[out]x,y,zcoordinates values (for 2D coordinates z is NULL)
Returns
0 on success
-1 on error

Definition at line 278 of file level_two.c.

References _, G_warning(), Plus_head::n_nodes, Plus_head::Node, NULL, num, Map_info::plus, P_node::x, P_node::y, and P_node::z.

Referenced by NetA_add_point_on_node(), Vect_clean_small_angles_at_nodes(), Vect_find_node(), Vect_net_build_graph(), Vect_net_ttb_build_graph(), Vect_net_ttb_shortest_path(), Vedit_connect_lines(), and Vedit_extend_lines().

int Vect_get_node_line ( const struct Map_info Map,
int  node,
int  line 
)

Get line id for node line index.

Parameters
Mappointer to Map_info struct
nodenode id
lineline index (range: 0 - Vect_get_node_n_lines())
Returns
line id

Definition at line 401 of file level_two.c.

References P_node::lines, Plus_head::Node, and Map_info::plus.

Referenced by Vect_clean_small_angles_at_nodes(), Vect_merge_lines(), Vect_net_ttb_build_graph(), and Vect_remove_duplicates().

float Vect_get_node_line_angle ( const struct Map_info Map,
int  node,
int  line 
)

Angle of segment of the line connected to the node.

Parameters
Mappointer to Map_info struct
nodenode number
lineline index (range: 0 - Vect_get_node_n_lines())
Returns
angle of segment of the line connected to the node

Definition at line 417 of file level_two.c.

References P_node::angles, Plus_head::Node, and Map_info::plus.

Referenced by Vect_clean_small_angles_at_nodes().

int Vect_get_node_n_lines ( const struct Map_info Map,
int  node 
)

Get number of lines for node.

Parameters
Mappointer to Map_info struct
nodenode id
Returns
numbers of lines

Definition at line 384 of file level_two.c.

References P_node::n_lines, Plus_head::Node, and Map_info::plus.

Referenced by Vect_clean_small_angles_at_nodes(), Vect_merge_lines(), Vect_net_ttb_build_graph(), and Vect_remove_duplicates().

plus_t Vect_get_num_areas ( const struct Map_info Map)
int Vect_get_num_dblinks ( const struct Map_info Map)

Get number of defined dblinks.

Parameters
Mappointer to Map_info struct
Returns
number of dblinks

Definition at line 163 of file level_two.c.

References Map_info::dblnk, and dblinks::n_fields.

Referenced by V1_close_nat(), Vect__delete(), Vect_copy_map_dblinks(), Vect_copy_tables(), Vect_get_column_names(), Vect_get_column_names_types(), Vect_get_column_types(), Vect_get_field2(), Vect_get_field_number(), and Vect_rename().

plus_t Vect_get_num_faces ( const struct Map_info Map)

Get number of faces in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of faces

Definition at line 111 of file level_two.c.

References Plus_head::n_flines, and Map_info::plus.

plus_t Vect_get_num_holes ( const struct Map_info Map)

Fetch number of holes in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of holes

Definition at line 150 of file level_two.c.

References Plus_head::n_holes, and Map_info::plus.

plus_t Vect_get_num_islands ( const struct Map_info Map)

Get number of islands in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of islands

Definition at line 137 of file level_two.c.

References Plus_head::n_isles, and Map_info::plus.

plus_t Vect_get_num_kernels ( const struct Map_info Map)

Fetch number of kernels in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of kernels

Definition at line 98 of file level_two.c.

References Plus_head::n_klines, and Map_info::plus.

plus_t Vect_get_num_nodes ( const struct Map_info Map)

Get number of nodes in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of nodes

Definition at line 34 of file level_two.c.

References Plus_head::n_nodes, and Map_info::plus.

Referenced by NetA_get_node_costs(), NetA_varray_to_nodes(), Vect_clean_small_angles_at_nodes(), Vect_net_build_graph(), and Vect_net_ttb_build_graph().

plus_t Vect_get_num_primitives ( const struct Map_info Map,
int  type 
)

Get number of primitives in vector map.

Parameters
Mappointer to Map_info struct
typefeature type
Returns
number of primitives

Definition at line 47 of file level_two.c.

References GV_BOUNDARY, GV_CENTROID, GV_FACE, GV_KERNEL, GV_LINE, GV_POINT, Plus_head::n_blines, Plus_head::n_clines, Plus_head::n_flines, Plus_head::n_klines, Plus_head::n_llines, Plus_head::n_plines, num, and Map_info::plus.

Referenced by Vect_topo_check().

int Vect_get_num_updated_lines ( const struct Map_info Map)

Get number of updated features.

Note: Vect_set_updated() must be called to maintain list of updated features

Parameters
Mappointer to Map_info struct
Returns
number of updated features

Definition at line 179 of file level_two.c.

References Plus_head::n_uplines, Map_info::plus, and Plus_head::uplist.

int Vect_get_num_updated_nodes ( const struct Map_info Map)

Get number of updated nodes.

Parameters
Mappointer to Map_info struct
Returns
number of updated nodes

Definition at line 223 of file level_two.c.

References Plus_head::n_upnodes, Map_info::plus, and Plus_head::uplist.

plus_t Vect_get_num_volumes ( const struct Map_info Map)

Fetch number of volumes in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of volumes

Definition at line 124 of file level_two.c.

References Plus_head::n_volumes, and Map_info::plus.

int Vect_get_updated_line ( const struct Map_info Map,
int  idx 
)

Get updated line by index.

Note: Vect_set_updated() must be called to maintain list of updated features

Parameters
Mappointer to Map_info struct
idxindex
Returns
updated line

Definition at line 195 of file level_two.c.

References Map_info::plus, Plus_head::uplines, and Plus_head::uplist.

off_t Vect_get_updated_line_offset ( const struct Map_info Map,
int  idx 
)

Get updated line offset by index.

Note: Vect_set_updated() must be called to maintain list of updated features

Parameters
Mappointer to Map_info struct
idxindex
Returns
updated line

Definition at line 211 of file level_two.c.

References Map_info::plus, Plus_head::uplines_offset, and Plus_head::uplist.

int Vect_get_updated_node ( const struct Map_info Map,
int  idx 
)

Get updated (modified) node by index.

Note: Vect_set_updated() must be called to maintain list of updated features

Negative id:

  • if Node[id] is not NULL then the node was added
  • if Node[id] is NULL then the node was deleted Positive id:
  • node was updated
Parameters
Mappointer to Map_info struct
idxindex
Returns
id of modified node

Definition at line 245 of file level_two.c.

References Map_info::plus, Plus_head::uplist, and Plus_head::upnodes.

void Vect_reset_updated ( struct Map_info Map)

Reset list of updated lines/nodes.

Parameters
Mappointer to Map_info struct

Definition at line 472 of file level_two.c.

References dig_line_reset_updated(), dig_node_reset_updated(), and Map_info::plus.

void Vect_set_updated ( struct Map_info Map,
int  enable 
)

Enable/disable maintanance of list of updated lines/nodes.

See Plus_head.uplist for details.

Parameters
Mappointer to Map_info struct
enableTRUE/FALSE to enable/disable

Definition at line 458 of file level_two.c.

References Plus_head::do_uplist, FALSE, G_debug(), Map_info::name, Map_info::plus, TRUE, and Plus_head::uplist.