19 #include <grass/gis.h>
20 #include <grass/Vect.h>
23 #define HUGE_VAL 9999999999999.0
39 double ux,
double uy,
double uz,
double maxdist,
int with_z)
45 double cur_dist, dist;
47 G_debug(3,
"Vect_find_node() for %f %f %f maxdist = %f", ux, uy, uz,
66 G_debug(3,
" %d nodes in box", nnodes);
72 cur_dist = PORT_DOUBLE_MAX;
74 for (i = 0; i < nnodes; i++) {
77 if (dist < cur_dist) {
82 G_debug(3,
" nearest node %d in distance %f", NList->value[node],
86 if (cur_dist <= maxdist)
87 return (NList->value[node]);
111 double ux,
double uy,
double uz,
112 int type,
double maxdist,
int with_z,
int exclude)
115 struct ilist *exclude_list;
122 type, maxdist, with_z, exclude_list,
NULL);
146 double ux,
double uy,
double uz,
147 int type,
double maxdist,
int with_z,
148 struct ilist *exclude,
struct ilist *found)
155 static struct line_pnts *Points;
156 static int first_time = 1;
157 struct Plus_head *Plus;
161 G_debug(3,
"Vect_find_line_list() for %f %f %f type = %d maxdist = %f",
162 ux, uy, uz, type, maxdist);
174 box.N = uy + maxdist;
175 box.S = uy - maxdist;
176 box.E = ux + maxdist;
177 box.W = ux - maxdist;
179 box.T = uz + maxdist;
180 box.B = uz - maxdist;
183 box.T = PORT_DOUBLE_MAX;
184 box.B = -PORT_DOUBLE_MAX;
193 for (i = 0; i < List->n_values; i++) {
194 line = List->value[i];
196 G_debug(3,
" line = %d exclude", line);
211 G_debug(3,
" line = %d distance = %f", line, new_dist);
213 if (found && new_dist <= maxdist) {
217 if ((++gotone == 1) || (new_dist <= cur_dist)) {
218 if (new_dist == cur_dist) {
229 G_debug(3,
"min distance found = %f", cur_dist);
230 if (cur_dist > maxdist)
251 static int first = 1;
253 static struct ilist *List;
255 G_debug(3,
"Vect_find_area() x = %f y = %f", x, y);
267 box.T = PORT_DOUBLE_MAX;
268 box.B = -PORT_DOUBLE_MAX;
270 G_debug(3,
" %d areas selected by box", List->n_values);
272 for (i = 0; i < List->n_values; i++) {
273 area = List->value[i];
276 G_debug(3,
" area = %d Vect_point_in_area() = %d", area, ret);
297 int i, ret, island, current, current_size, size;
298 static int first = 1;
300 static struct ilist *List;
301 static struct line_pnts *Points;
303 G_debug(3,
"Vect_find_island() x = %f y = %f", x, y);
316 box.T = PORT_DOUBLE_MAX;
317 box.B = -PORT_DOUBLE_MAX;
319 G_debug(3,
" %d islands selected by box", List->n_values);
323 for (i = 0; i < List->n_values; i++) {
324 island = List->value[i];
329 if (current_size == -1) {
341 if (size < current_size) {