GRASS 8 Programmer's Manual 8.6.0dev(2026)-745b61fbf6
Loading...
Searching...
No Matches
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 (struct Map_info *Map)
 Get number of nodes in vector map.
 
plus_t Vect_get_num_primitives (struct Map_info *Map, int type)
 Get number of primitives in vector map.
 
plus_t Vect_get_num_lines (struct Map_info *Map)
 Fetch number of features (points, lines, boundaries, centroids) in vector map.
 
plus_t Vect_get_num_areas (struct Map_info *Map)
 Get number of areas in vector map.
 
plus_t Vect_get_num_kernels (struct Map_info *Map)
 Fetch number of kernels in vector map.
 
plus_t Vect_get_num_faces (struct Map_info *Map)
 Get number of faces in vector map.
 
plus_t Vect_get_num_volumes (struct Map_info *Map)
 Fetch number of volumes in vector map.
 
plus_t Vect_get_num_islands (struct Map_info *Map)
 Get number of islands in vector map.
 
plus_t Vect_get_num_holes (struct Map_info *Map)
 Fetch number of holes in vector map.
 
int Vect_get_num_dblinks (struct Map_info *Map)
 Get number of defined dblinks.
 
int Vect_get_num_updated_lines (struct Map_info *Map)
 Get number of updated features.
 
int Vect_get_updated_line (struct Map_info *Map, int idx)
 Get updated line by index.
 
off_t Vect_get_updated_line_offset (struct Map_info *Map, int idx)
 Get updated line offset by index.
 
int Vect_get_num_updated_nodes (struct Map_info *Map)
 Get number of updated nodes.
 
int Vect_get_updated_node (struct Map_info *Map, int idx)
 Get updated (modified) node by index.
 
int Vect_get_line_type (struct Map_info *Map, int line)
 Get line type.
 
int Vect_get_node_coor (struct Map_info *Map, int num, double *x, double *y, double *z)
 Get node coordinates.
 
int Vect_get_line_nodes (struct Map_info *Map, int line, int *n1, int *n2)
 Get line nodes.
 
int Vect_get_line_areas (struct Map_info *Map, int line, int *left, int *right)
 Get area id on the left and right side of the boundary.
 
int Vect_get_node_n_lines (struct Map_info *Map, int node)
 Get number of lines for node.
 
int Vect_get_node_line (struct Map_info *Map, int node, int line)
 Get line id for node line index.
 
float Vect_get_node_line_angle (struct Map_info *Map, int node, int line)
 Angle of segment of the line connected to the node.
 
int Vect_get_centroid_area (struct Map_info *Map, int centroid)
 Get area id the centroid is within.
 
void Vect_set_updated (struct Map_info *Map, int enable)
 Enable/disable maintenance of list of updated lines/nodes.
 
void Vect_reset_updated (struct Map_info *Map)
 Reset list of updated lines/nodes.
 

Detailed Description

Vector library - topology level functions.

SPDX-FileCopyrightText: 2001-2009, 2011-2012 GRASS Development Team SPDX-License-Identifier: GPL-2.0-or-later

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

◆ Vect_get_centroid_area()

int Vect_get_centroid_area ( 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 428 of file level_two.c.

References _, P_topo_c::area, G_fatal_error(), and GV_CENTROID.

Referenced by Vedit_delete_area_centroid().

◆ Vect_get_line_areas()

int Vect_get_line_areas ( 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 345 of file level_two.c.

References _, G_warning(), GV_BOUNDARY, P_topo_b::left, NULL, P_topo_b::right, 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().

◆ Vect_get_line_nodes()

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

Get line nodes.

Parameters
Mappointer to Map_info struct
lineline id
n1(start node), ids of line nodes (or NULL)
n2(end node) ids of line nodes (or NULL)
Returns
1

Definition at line 302 of file level_two.c.

References _, G_fatal_error(), GV_BOUNDARY, GV_LINE, GV_LINES, P_topo_l::N1, P_topo_b::N1, P_topo_l::N2, P_topo_b::N2, NULL, and Vect_get_line_type().

Referenced by NetA_get_node_costs(), NetA_varray_to_nodes(), Vect_merge_lines(), Vect_net_build_graph(), Vect_net_nearest_nodes(), Vect_net_ttb_build_graph(), Vect_remove_duplicates(), Vedit_connect_lines(), and Vedit_extend_lines().

◆ Vect_get_line_type()

int Vect_get_line_type ( struct Map_info Map,
int  line 
)

Get line type.

Parameters
Mappointer to Map_info struct
lineline id
Returns
line type

Definition at line 252 of file level_two.c.

References 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().

◆ Vect_get_node_coor()

int Vect_get_node_coor ( 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 272 of file level_two.c.

References _, G_warning(), NULL, 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().

◆ Vect_get_node_line()

int Vect_get_node_line ( 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 395 of file level_two.c.

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

◆ Vect_get_node_line_angle()

float Vect_get_node_line_angle ( 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 411 of file level_two.c.

Referenced by Vect_clean_small_angles_at_nodes().

◆ Vect_get_node_n_lines()

int Vect_get_node_n_lines ( 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 379 of file level_two.c.

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

◆ Vect_get_num_areas()

plus_t Vect_get_num_areas ( struct Map_info Map)

◆ Vect_get_num_dblinks()

int Vect_get_num_dblinks ( struct Map_info Map)

Get number of defined dblinks.

Parameters
Mappointer to Map_info struct
Returns
number of dblinks

Definition at line 157 of file level_two.c.

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().

◆ Vect_get_num_faces()

plus_t Vect_get_num_faces ( struct Map_info Map)

Get number of faces in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of faces

Definition at line 109 of file level_two.c.

◆ Vect_get_num_holes()

plus_t Vect_get_num_holes ( struct Map_info Map)

Fetch number of holes in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of holes

Definition at line 145 of file level_two.c.

◆ Vect_get_num_islands()

plus_t Vect_get_num_islands ( struct Map_info Map)

Get number of islands in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of islands

Definition at line 133 of file level_two.c.

◆ Vect_get_num_kernels()

plus_t Vect_get_num_kernels ( struct Map_info Map)

Fetch number of kernels in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of kernels

Definition at line 97 of file level_two.c.

◆ Vect_get_num_lines()

◆ Vect_get_num_nodes()

plus_t Vect_get_num_nodes ( struct Map_info Map)

Get number of nodes in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of nodes

Definition at line 32 of file level_two.c.

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().

◆ Vect_get_num_primitives()

plus_t Vect_get_num_primitives ( 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 45 of file level_two.c.

References GV_BOUNDARY, GV_CENTROID, GV_FACE, GV_KERNEL, GV_LINE, and GV_POINT.

Referenced by Vect_topo_check().

◆ Vect_get_num_updated_lines()

int Vect_get_num_updated_lines ( 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 173 of file level_two.c.

◆ Vect_get_num_updated_nodes()

int Vect_get_num_updated_nodes ( struct Map_info Map)

Get number of updated nodes.

Parameters
Mappointer to Map_info struct
Returns
number of updated nodes

Definition at line 217 of file level_two.c.

◆ Vect_get_num_volumes()

plus_t Vect_get_num_volumes ( struct Map_info Map)

Fetch number of volumes in vector map.

Parameters
Mappointer to Map_info struct
Returns
number of volumes

Definition at line 121 of file level_two.c.

◆ Vect_get_updated_line()

int Vect_get_updated_line ( 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 189 of file level_two.c.

◆ Vect_get_updated_line_offset()

off_t Vect_get_updated_line_offset ( 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 205 of file level_two.c.

◆ Vect_get_updated_node()

int Vect_get_updated_node ( 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 239 of file level_two.c.

◆ Vect_reset_updated()

void Vect_reset_updated ( struct Map_info Map)

Reset list of updated lines/nodes.

Parameters
Mappointer to Map_info struct

Definition at line 468 of file level_two.c.

References dig_line_reset_updated(), and dig_node_reset_updated().

◆ Vect_set_updated()

void Vect_set_updated ( struct Map_info Map,
int  enable 
)

Enable/disable maintenance 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 453 of file level_two.c.

References FALSE, G_debug(), AMI_STREAM< T >::name(), and TRUE.