15 #include <grass/vedit.h>
32 static int merge_lines(
struct line_pnts *Points1,
struct line_cats *Cats1,
33 struct line_pnts *Points2,
struct line_cats *Cats2,
34 double thresh,
struct line_pnts **Points);
49 struct ilist *List_in_box;
51 struct line_pnts *Points1, *Points2, *Points;
52 struct line_cats *Cats1, *
Cats2;
55 int line, line1, type1, line2, type2;
59 int nlines, nlines_selected, nlines_merged;
63 if (List->n_values < 2) {
76 nlines_selected = List->n_values;
79 for (line_i = 0; line_i < List->n_values; line_i++) {
80 line1 = List->value[line_i];
92 for (i = 0; i < Points1->n_points; i += Points1->n_points - 1) {
108 Points1->y[i], Points1->z[i]);
115 GV_LINES, List_in_box)) {
118 for (j = 0; do_merge && j < List->n_values; j++) {
119 if (List->value[j] == line1 ||
131 line2 = List->value[j];
136 if (!do_merge || line2 < 0)
141 merge_lines(Points1, Cats1, Points2, Cats2, -1.0, &Points);
143 G_debug(3,
"Vedit_merge_lines(): lines=%d,%d", line1, line2);
145 if (Points->n_points > 0) {
156 if (Points->n_points > 0) {
178 return nlines_merged;
181 static int merge_lines(
struct line_pnts *Points1,
struct line_cats *Cats1,
182 struct line_pnts *Points2,
struct line_cats *Cats2,
183 double thresh,
struct line_pnts **Points)
185 struct line_pnts *ps = *Points;
186 struct line_cats *cs = Cats1;
195 G_debug(3,
" merge line ? index: %d, mindist: %g, thresh: %g",
196 mindistidx, mindist, thresh);
198 if (thresh > 0 && mindist > thresh) {
203 switch (mindistidx) {
207 if (ps->n_points == Points2->n_points)
212 if (ps->n_points == Points2->n_points)
216 if (ps->n_points == 0)
221 if (ps->n_points == 0)
233 for (i = 0; i < Cats2->n_cats; i++) {