16 #include <grass/glocale.h>
17 #include <grass/vedit.h>
19 static int select_by_query(
struct Map_info *,
int,
int,
double,
20 int,
struct line_pnts *,
struct line_cats *);
22 static int merge_lists(
struct ilist *alist,
struct ilist *blist);
44 int type,
int layer,
double thresh,
int query,
49 struct line_pnts *Points;
50 struct line_cats *Cats;
51 struct ilist *List_query;
56 if (List->n_values == 0) {
65 if (List->n_values == 0) {
68 for (line = 1; line <= num; line++) {
69 if (select_by_query(Map, line, type, thresh,
75 for (i = 0; i < List->n_values; i++) {
76 line = List->value[i];
77 if (select_by_query(Map, line, type, thresh,
78 query, Points, Cats)) {
86 struct ilist *List_dangle;
89 thresh_tmp = fabs(thresh);
95 for (i = 0; i < List_dangle->n_values; i++) {
113 if (List != List_query) {
114 merge_lists(List, List_query);
118 G_debug(3,
"Vedit_select_by_query(): %d lines selected (by query %d)",
119 List->n_values, query);
124 return List->n_values;
134 int select_by_query(
struct Map_info *
Map,
int line,
int type,
double thresh,
135 int query,
struct line_pnts *Points,
136 struct line_cats *Cats)
141 int node1, node2, node;
144 struct ilist *exclude, *found;
145 struct line_cats *Cats_curr;
155 if (query == QUERY_LENGTH) {
158 if (length <= fabs(thresh))
166 else if (query == QUERY_DANGLE) {
185 if ((nnode1 == 4 && nnode2 == 1) || (nnode1 == 1 && nnode2 == 4)) {
198 if (length > fabs(thresh))
202 if (length <= thresh)
214 GV_LINES, 0.0, WITHOUT_Z, exclude, found);
218 for (i = 0; i < found->n_values; i++) {
232 G_fatal_error(
"Vedit_select_by_query(): %s", _(
"Unknown query tool"));
246 int merge_lists(
struct ilist *alist,
struct ilist *blist)
250 struct ilist *list_del;
254 for (i = 0; i < alist->n_values; i++) {
263 return alist->n_values;