-
-
Notifications
You must be signed in to change notification settings - Fork 288
/
rmline.c
68 lines (52 loc) · 1.61 KB
/
rmline.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* ***************************************************************
* *
* * MODULE: v.clean
* *
* * AUTHOR(S): Martin Landa <landa.martin gmail.com>
* *
* * PURPOSE: Clean lines -- remove all lines or boundaries
* * of zero length
* *
* * COPYRIGHT: (C) 2007 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.
* *
* **************************************************************/
#include <stdlib.h>
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/glocale.h>
int remove_zero_line(struct Map_info *Map, int otype, struct Map_info *Err)
{
int count;
int line, type, nlines;
struct line_pnts *Points;
struct line_cats *Cats;
count = 0;
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
nlines = Vect_get_num_lines(Map);
G_debug(1, "nlines = %d", nlines);
for (line = 1; line <= nlines; line++) {
G_percent(line, nlines, 2);
if (!Vect_line_alive(Map, line))
continue;
type = Vect_read_line(Map, Points, Cats, line);
if (!((type & GV_LINES) && (type & otype)))
continue;
if (Vect_line_prune(Points) > 1)
continue;
Vect_delete_line(Map, line);
if (Err) {
Vect_write_line(Err, type, Points, Cats);
}
count++;
}
Vect_destroy_line_struct(Points);
Vect_destroy_cats_struct(Cats);
G_verbose_message(_("Lines / boundaries removed: %d"), count);
return count;
}