18 #include <grass/config.h>
21 #include <grass/gis.h>
22 #include <grass/Vect.h>
23 #include <grass/glocale.h>
47 int line, nlines, i, c,
first, last, next_line, curr_line;
48 int merged = 0, newl = 0;
49 int next_node, direction, node_n_lines, same_type;
50 struct Plus_head *Plus;
52 struct line_pnts *MPoints, *Points;
53 struct line_cats *MCats, *Cats;
56 if ((type & GV_BOUNDARY) && (type & GV_LINE)) {
58 (
"Merging is done only with either lines or boundaries, not both types at the same time");
61 if (!(type & GV_BOUNDARY) && !(type & GV_LINE)) {
63 (
"Merging is done with lines or boundaries only, not with other types");
76 for (line = 1; line <= nlines; line++) {
82 Line = Plus->Line[line];
84 if (!(Line->type & type))
101 for (i = 0; i < node_n_lines; i++) {
103 if ((Plus->Line[abs(curr_line)]->type & type)) {
105 if (abs(curr_line) != abs(first))
106 next_line = curr_line;
109 if (same_type == 2 && abs(next_line) != abs(first) &&
110 abs(next_line) != line) {
114 next_node = Plus->Line[-
first]->N1;
116 next_node = Plus->Line[
first]->N2;
129 next_node = Plus->Line[-last]->N1;
131 next_node = Plus->Line[last]->N2;
139 for (i = 0; i < node_n_lines; i++) {
141 if ((Plus->Line[abs(curr_line)]->type & type)) {
143 if (abs(curr_line) != abs(last))
144 next_line = curr_line;
148 if (same_type == 2 && abs(next_line) != abs(last) &&
149 abs(next_line) != abs(first)) {
153 next_node = Plus->Line[-last]->N1;
155 next_node = Plus->Line[last]->N2;
162 if (List->n_values > 1) {
163 G_debug(3,
"merge %d lines", List->n_values);
167 for (i = 0; i < List->n_values; i++) {
171 direction = (List->value[i] < 0 ? GV_BACKWARD : GV_FORWARD);
174 for (c = 0; c < Cats->n_cats; c++) {
185 merged += List->n_values;