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) {
 
int Vect_destroy_list(struct ilist *list)
Frees all memory associated with a struct ilist, including the struct itself. 
int Vect_select_isles_by_box(struct Map_info *Map, BOUND_BOX *Box, struct ilist *list)
Select isles by box. 
int Vect_get_isle_points(struct Map_info *Map, int isle, struct line_pnts *BPoints)
Returns the polygon array of points in BPoints. 
double G_area_of_polygon(const double *x, const double *y, int n)
Area in square meters of polygon. 
int Vect_select_nodes_by_box(struct Map_info *Map, BOUND_BOX *Box, struct ilist *list)
Select nodes by box. 
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts. 
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist. 
int Vect_point_in_island(double X, double Y, struct Map_info *Map, int isle)
Determines if a point (X,Y) is inside an island. 
int Vect_find_line_list(struct Map_info *map, double ux, double uy, double uz, int type, double maxdist, int with_z, struct ilist *exclude, struct ilist *found)
Find the nearest line(s). 
int Vect_find_area(struct Map_info *Map, double x, double y)
Find the nearest area. 
int G_begin_polygon_area_calculations(void)
Begin polygon area calculations. 
int Vect_point_in_area(struct Map_info *Map, int area, double x, double y)
Returns 1 if point is in area. 
int Vect_reset_list(struct ilist *list)
Reset ilist structure. 
int Vect_list_append(struct ilist *list, int val)
Append new item to the end of list if not yet present. 
int Vect_select_lines_by_box(struct Map_info *Map, BOUND_BOX *Box, int type, struct ilist *list)
Select lines by box. 
int Vect_find_node(struct Map_info *Map, double ux, double uy, double uz, double maxdist, int with_z)
Find the nearest node. 
int Vect_select_areas_by_box(struct Map_info *Map, BOUND_BOX *Box, struct ilist *list)
Select areas by box. 
int Vect_find_island(struct Map_info *Map, double x, double y)
Find the nearest island. 
int G_debug(int level, const char *msg,...)
Print debugging message. 
double Vect_points_distance(double x1, double y1, double z1, double x2, double y2, double z2, int with_z)
Calculate distance of 2 points. 
int Vect_val_in_list(struct ilist *list, int val)
Find a given item in the list. 
int Vect_get_node_coor(struct Map_info *map, int num, double *x, double *y, double *z)
Get node coordinates. 
int Vect_line_distance(struct line_pnts *points, double ux, double uy, double uz, int with_z, double *px, double *py, double *pz, double *dist, double *spdist, double *lpdist)
calculate line distance. 
int Vect_find_line(struct Map_info *map, double ux, double uy, double uz, int type, double maxdist, int with_z, int exclude)
Find the nearest line. 
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.