21 #include <grass/gis.h>
22 #include <grass/Vect.h>
23 #include <grass/glocale.h>
26 remove_bridges(
struct Map_info *
Map,
int chtype,
struct Map_info *Err);
46 remove_bridges(Map, 0, Err);
67 remove_bridges(Map, 1, Err);
84 remove_bridges(
struct Map_info *
Map,
int chtype,
struct Map_info *Err)
86 int i,
type, nlines, line;
87 int left, right, node1, node2, current_line, next_line;
88 int bridges_removed = 0;
89 int lines_removed = 0;
91 struct Plus_head *Plus;
92 struct line_pnts *Points;
93 struct line_cats *Cats;
94 struct ilist *CycleList;
95 struct ilist *BridgeList;
97 int dangle, other_side;
100 lmsg =
"changed lines";
102 lmsg =
"removed lines";
113 G_debug(1,
"nlines = %d", nlines);
115 for (line = 1; line <= nlines; line++) {
121 if (!(type & GV_BOUNDARY))
126 if (left != 0 || right != 0)
129 G_debug(2,
"line %d - bridge candidate", line);
133 if (abs(node1) == abs(node2))
136 current_line = -line;
153 if (abs(next_line) == abs(current_line)) {
154 G_debug(4,
" dangle -> no bridge");
158 if (abs(next_line) == line) {
161 G_debug(5,
" other side reached");
169 current_line = -next_line;
172 if (!dangle && other_side) {
173 G_debug(3,
" line %d is part of bridge chain", line);
175 for (i = 0; i < BridgeList->n_values; i++) {
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/isle ids on the left and right.
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts.
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist.
int dig_angle_next_line(struct Plus_head *plus, plus_t current_line, int side, int type)
Find number line of next angle to follow an line.
int G_percent(long n, long d, int s)
Print percent complete messages.
void G_verbose_message(const char *msg,...)
Print a message to stderr but only if module is in verbose mode.
int Vect_rewrite_line(struct Map_info *Map, int line, int type, struct line_pnts *points, struct line_cats *cats)
Rewrites feature info at the given offset.
int Vect_reset_list(struct ilist *list)
Reset ilist structure.
int Vect_list_append(struct ilist *list, int val)
Append new item to the end of list if not yet present.
int Vect_line_alive(struct Map_info *Map, int line)
Check if feature is alive or dead.
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
int Vect_get_num_lines(struct Map_info *map)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
int G_debug(int level, const char *msg,...)
Print debugging message.
int Vect_delete_line(struct Map_info *Map, int line)
Delete feature.
long Vect_write_line(struct Map_info *Map, int type, struct line_pnts *points, struct line_cats *cats)
Writes new feature to the end of file (table)
int Vect_val_in_list(struct ilist *list, int val)
Find a given item in the list.
void Vect_remove_bridges(struct Map_info *Map, struct Map_info *Err)
Remove bridges from vector map.
void Vect_chtype_bridges(struct Map_info *Map, struct Map_info *Err)
Change type of bridges in vector map.
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.