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

Vector library - update topo for areas (lower level functions) More...

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

Go to the source code of this file.

Functions

int dig_build_area_with_line (struct Plus_head *plus, plus_t first_line, int side, plus_t **lines)
 Build topo for area from lines. More...
 
int dig_add_area (struct Plus_head *plus, int n_lines, plus_t *lines, struct bound_box *box)
 Allocate space for new area and create boundary info from array. More...
 
int dig_area_add_isle (struct Plus_head *plus, int area, int isle)
 Add isle to area if does not exist yet. More...
 
int dig_area_del_isle (struct Plus_head *plus, int area, int isle)
 Delete isle from area. More...
 
int dig_del_area (struct Plus_head *plus, int area)
 Delete area from Plus_head structure. More...
 
int dig_angle_next_line (struct Plus_head *plus, plus_t current_line, int side, int type, float *angle)
 Find line number of next angle to follow a line. More...
 
int dig_node_angle_check (struct Plus_head *plus, plus_t line, int type)
 Check if angles of adjacent lines differ. More...
 
int dig_add_isle (struct Plus_head *plus, int n_lines, plus_t *lines, struct bound_box *box)
 Allocate space for new island and create boundary info from array. More...
 
int dig_del_isle (struct Plus_head *plus, int isle)
 Delete island from Plus_head structure. More...
 

Detailed Description

Vector library - update topo for areas (lower level functions)

Lower level functions for reading/writing/manipulating vectors.

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
CERL (probably Dave Gerdes), Radim Blazek
Date
2001-2006

Definition in file plus_area.c.

Function Documentation

int dig_add_area ( struct Plus_head plus,
int  n_lines,
plus_t lines,
struct bound_box box 
)

Allocate space for new area and create boundary info from array.

Then for each line in area, update line (right,left) info.

Neither islands nor centroids are filled.

Parameters
[in]pluspointer to Plus_head structure
[in]n_linesnumber of lines
[in]linesarray of lines, negative for reverse direction
[in]boxbounding box
Returns
number of new area
-1 on error

Definition at line 184 of file plus_area.c.

References _, Plus_head::alloc_areas, Plus_head::Area, P_area::centroid, dig_alloc_area(), dig_alloc_areas(), dig_area_alloc_line(), dig_spidx_add_area(), G_debug(), G_warning(), if(), P_topo_b::left, Plus_head::Line, P_area::lines, Plus_head::n_areas, P_area::n_lines, NULL, P_topo_b::right, and P_line::topo.

Referenced by Vect_build_line_area().

int dig_add_isle ( struct Plus_head plus,
int  n_lines,
plus_t lines,
struct bound_box box 
)

Allocate space for new island and create boundary info from array.

The order of input lines is expected to be counter clockwise. Then for each line in isle, update line (right,left) info.

Area number the island is within is not filled.

Parameters
[in]pluspointer to Plus_head structure
[in]n_linesnumber of lines
[in]linesarray of lines, negative for reverse direction
[in]boxbounding box
Returns
number of new isle
-1 on error

Definition at line 682 of file plus_area.c.

References _, Plus_head::alloc_isles, P_isle::area, dig_alloc_isle(), dig_alloc_isles(), dig_isle_alloc_line(), dig_spidx_add_isle(), G_debug(), G_warning(), if(), Plus_head::Isle, P_topo_b::left, Plus_head::Line, P_isle::lines, Plus_head::n_isles, P_isle::n_lines, NULL, P_topo_b::right, and P_line::topo.

Referenced by Vect_build_line_area().

int dig_angle_next_line ( struct Plus_head plus,
plus_t  current_line,
int  side,
int  type,
float *  angle 
)

Find line number of next angle to follow a line.

Assume that lines are sorted in increasing angle order and angles of points and degenerated lines are set to -9 (ignored).

Parameters
[in]pluspointer to Plus_head structure
[in]current_linecurrent line id, negative if request for end node
[in]sideside GV_RIGHT or GV_LEFT
[in]typeline type (GV_LINE, GV_BOUNDARY or both)
[in]angle
Returns
line number of next angle to follow a line (negative if connected by end node) (number of current line may be returned if dangle - this is used in build)
0 on error or not found

Definition at line 466 of file plus_area.c.

References P_node::angles, G_debug(), G_fatal_error(), G_getenv_nofatal(), GV_BOUNDARY, GV_LINE, GV_LINES, GV_RIGHT, Plus_head::Line, P_node::lines, P_topo_l::N1, P_topo_b::N1, P_topo_l::N2, P_topo_b::N2, P_node::n_lines, Plus_head::Node, NULL, P_line::topo, and P_line::type.

Referenced by dig_build_area_with_line(), dig_node_angle_check(), V2__add_line_to_topo_nat(), and V2__delete_line_from_topo_nat().

int dig_area_add_isle ( struct Plus_head plus,
int  area,
int  isle 
)

Add isle to area if does not exist yet.

Parameters
[in]pluspointer to Plus_head structure
[in]areaarea id
[in]isleisle id
Returns
0

Definition at line 258 of file plus_area.c.

References _, P_area::alloc_isles, Plus_head::Area, dig_area_alloc_isle(), G_debug(), G_fatal_error(), G_getenv_nofatal(), G_warning(), P_area::isles, P_area::n_isles, and NULL.

Referenced by Vect_attach_isle(), and Vect_remove_small_areas_nat().

int dig_area_del_isle ( struct Plus_head plus,
int  area,
int  isle 
)

Delete isle from area.

Parameters
[in]pluspointer to Plus_head structure
[in]areaarea id
[in]isleisle id
Returns
0

Definition at line 307 of file plus_area.c.

References _, Plus_head::Area, G_debug(), G_fatal_error(), P_area::isles, P_area::n_isles, and NULL.

Referenced by dig_del_isle(), and Vect_attach_isles().

int dig_build_area_with_line ( struct Plus_head plus,
plus_t  first_line,
int  side,
plus_t **  lines 
)

Build topo for area from lines.

Area is built in clockwise order. Take a given line and start off to the RIGHT/LEFT and try to complete an area.

Possible Scenarios:

  • I. path runs into first line. : AREA!
  • II. path runs into a dead end (no other area lines at node) : no area
  • III. path runs into a previous line that is not 1st line or to 1st line but not to start node : no area

After we find an area then we call point_in_area() to see if the specified point is w/in the area

Old returns -1: error 0: no area (1: point in area) -2: island !!

Parameters
[in]pluspointer to Plus_head structure
[in]first_lineline id of first line
[in]sideside of line to build area on (GV_LEFT | GV_RIGHT)
[in]linespointer to array of lines
Returns
-1 on error
0 no area
number of lines

Definition at line 51 of file plus_area.c.

References dig__falloc(), dig__frealloc(), dig_angle_next_line(), dig_node_angle_check(), dig_node_line_angle(), dig_out_of_memory(), G_debug(), G_getenv_nofatal(), GV_BOUNDARY, GV_LEFT, GV_RIGHT, if(), Plus_head::Line, P_topo_b::N1, P_isle::n_lines, NULL, P_line::topo, and P_line::type.

Referenced by Vect_build_line_area().

int dig_del_area ( struct Plus_head plus,
int  area 
)

Delete area from Plus_head structure.

This function deletes area from the topo structure and resets references to this area in boundaries, isles (within), and the centroid (if any) to 0. Possible new area is not created by this function, so that old boundaries participating in this area are left without area information even if form new area. Not enabled now: If area is inside other area, area info for islands within deleted area is reset to that area outside. (currently area info of isles is set to 0)

Parameters
[in]pluspointer to Plus_head structure
[in]areaarea id
Returns
0 on error
1 on success

Definition at line 357 of file plus_area.c.

References _, Plus_head::Area, P_topo_c::area, P_isle::area, P_area::centroid, dig_free_area(), dig_spidx_del_area(), G_debug(), G_fatal_error(), G_warning(), if(), Plus_head::Isle, P_area::isles, P_topo_b::left, Plus_head::Line, P_area::lines, P_area::n_isles, P_area::n_lines, NULL, P_topo_b::right, and P_line::topo.

Referenced by V2__add_line_to_topo_nat(), V2__delete_line_from_topo_nat(), and Vect_remove_small_areas_nat().

int dig_del_isle ( struct Plus_head plus,
int  isle 
)

Delete island from Plus_head structure.

Reset references to it in lines and area outside.

Parameters
[in]pluspointer to Plus_head structure
[in]isleisle id
Returns
1

Definition at line 757 of file plus_area.c.

References _, Plus_head::Area, P_isle::area, dig_area_del_isle(), dig_free_isle(), dig_spidx_del_isle(), G_debug(), G_fatal_error(), if(), Plus_head::Isle, P_topo_b::left, Plus_head::Line, P_isle::lines, P_isle::n_lines, NULL, P_topo_b::right, and P_line::topo.

Referenced by V2__add_line_to_topo_nat(), V2__delete_line_from_topo_nat(), and Vect_remove_small_areas_nat().

int dig_node_angle_check ( struct Plus_head plus,
plus_t  line,
int  type 
)

Check if angles of adjacent lines differ.

Negative line number for end point. Assume that lines are sorted in increasing angle order and angles of points and degenerated lines are set to 9 (ignored).

Parameters
[in]pluspointer to Plus_head structure
[in]linecurrent line id, negative if request for node 2
[in]typeline type (GV_LINE, GV_BOUNDARY or both)
Returns
1 angles differ
0 angle of a line up or down is identical

Definition at line 607 of file plus_area.c.

References dig_angle_next_line(), dig_node_line_angle(), G_debug(), GV_BOUNDARY, GV_LEFT, GV_LINE, GV_LINES, GV_RIGHT, Plus_head::Line, P_topo_l::N1, P_topo_b::N1, P_topo_l::N2, P_topo_b::N2, P_line::topo, and P_line::type.

Referenced by dig_build_area_with_line().