14 #include <grass/glocale.h>
15 #include <grass/vedit.h>
17 static int select_by_query(
struct Map_info *,
int,
int,
double,
18 int,
struct line_pnts *,
struct line_cats *);
20 static int merge_lists(
struct ilist *alist,
struct ilist *blist);
42 int type,
int layer,
double thresh,
int query,
47 struct line_pnts *Points;
48 struct line_cats *Cats;
49 struct ilist *List_query;
54 if (List->n_values == 0) {
63 if (List->n_values == 0) {
66 for (line = 1; line <= num; line++) {
67 if (select_by_query(Map, line, type, thresh,
73 for (i = 0; i < List->n_values; i++) {
74 line = List->value[i];
75 if (select_by_query(Map, line, type, thresh,
76 query, Points, Cats)) {
84 struct ilist *List_dangle;
87 thresh_tmp = fabs(thresh);
93 for (i = 0; i < List_dangle->n_values; i++) {
111 if (List != List_query) {
112 merge_lists(List, List_query);
116 G_debug(3,
"Vedit_select_by_query(): %d lines selected (by query %d)",
117 List->n_values, query);
122 return List->n_values;
132 int select_by_query(
struct Map_info *Map,
int line,
int type,
double thresh,
133 int query,
struct line_pnts *Points,
134 struct line_cats *Cats)
139 int node1, node2, node;
142 struct ilist *exclude, *found;
143 struct line_cats *Cats_curr;
153 if (query == QUERY_LENGTH) {
156 if (length <= fabs(thresh))
164 else if (query == QUERY_DANGLE) {
183 if ((nnode1 == 4 && nnode2 == 1) || (nnode1 == 1 && nnode2 == 4)) {
196 if (length > fabs(thresh))
200 if (length <= thresh)
212 GV_LINES, 0.0, WITHOUT_Z, exclude, found);
216 for (i = 0; i < found->n_values; i++) {
230 G_fatal_error(
"Vedit_select_by_query(): %s", _(
"Unknown query tool"));
244 int merge_lists(
struct ilist *alist,
struct ilist *blist)
248 struct ilist *list_del;
252 for (i = 0; i < alist->n_values; i++) {
261 return alist->n_values;