GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-c17eaff561
vector/Vlib/find.c File Reference

Vector library - Find nearest vector feature. More...

#include <stdlib.h>
#include <math.h>
#include <grass/vector.h>
Include dependency graph for vector/Vlib/find.c:

Go to the source code of this file.

Macros

#define HUGE_VAL   9999999999999.0
 

Functions

int Vect_find_node (struct Map_info *Map, double ux, double uy, double uz, double maxdist, int with_z)
 Find the nearest node. More...
 
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. More...
 
int Vect_find_line_list (struct Map_info *map, double ux, double uy, double uz, int type, double maxdist, int with_z, const struct ilist *exclude, struct ilist *found)
 Find the nearest line(s). More...
 
int Vect_find_area (struct Map_info *Map, double x, double y)
 Find the nearest area. More...
 
int Vect_find_island (struct Map_info *Map, double x, double y)
 Find the nearest island. More...
 

Detailed Description

Vector library - Find nearest vector feature.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL, probably Dave Gerdes or Mike Higgins.
Update to GRASS 5.7 Radim Blazek and David D. Gray.

Definition in file vector/Vlib/find.c.

Macro Definition Documentation

◆ HUGE_VAL

#define HUGE_VAL   9999999999999.0

Definition at line 23 of file vector/Vlib/find.c.

Function Documentation

◆ Vect_find_area()

int Vect_find_area ( struct Map_info Map,
double  x,
double  y 
)

Find the nearest area.

Parameters
Mapvector map
x,ypoint coordinates
Returns
area number
0 if not found

Definition at line 258 of file vector/Vlib/find.c.

References bound_box::B, boxlist::box, bound_box::E, G_debug(), G_malloc, G_realloc, boxlist::id, bound_box::N, boxlist::n_values, NULL, Map_info::plus, PORT_DOUBLE_MAX, bound_box::S, bound_box::T, Vect_new_boxlist(), Vect_select_areas_by_box(), bound_box::W, and x.

◆ Vect_find_island()

int Vect_find_island ( struct Map_info Map,
double  x,
double  y 
)

Find the nearest island.

Parameters
Mapvector map
x,ypoints coordinates
Returns
island number,
0 if not found

Definition at line 362 of file vector/Vlib/find.c.

◆ Vect_find_line()

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.

Parameters
mapvector map
ux,uy,uzpoints coordinates
typefeature type (GV_LINE, GV_POINT, GV_BOUNDARY or GV_CENTROID) if only want to search certain types of lines or -1 if search all lines
maxdistmax distance from the line
with_z3D (WITH_Z, WITHOUT_Z)
excludeif > 0 number of line which should be excluded from selection. May be useful if we need line nearest to other one.
Returns
number of nearest line
0 if not found

Definition at line 126 of file vector/Vlib/find.c.

◆ Vect_find_line_list()

int Vect_find_line_list ( struct Map_info map,
double  ux,
double  uy,
double  uz,
int  type,
double  maxdist,
int  with_z,
const struct ilist exclude,
struct ilist found 
)

Find the nearest line(s).

Parameters
mapvector map
ux,uy,uzpoints coordinates
typefeature type (GV_LINE, GV_POINT, GV_BOUNDARY or GV_CENTROID) if only want to search certain types of lines or -1 if search all lines
maxdistmax distance from the line
with_z3D (WITH_Z, WITHOUT_Z)
excludelist of lines which should be excluded from selection
foundlist of found lines (or NULL)
Returns
number of nearest line
0 if not found

Definition at line 159 of file vector/Vlib/find.c.

◆ Vect_find_node()

int Vect_find_node ( struct Map_info Map,
double  ux,
double  uy,
double  uz,
double  maxdist,
int  with_z 
)

Find the nearest node.

Parameters
Mapvector map
ux,uy,uzpoint coordinates
maxdistmax distance from the line
with_z3D (WITH_Z, WITHOUT_Z)
Returns
number of nearest node
0 if not found

Definition at line 56 of file vector/Vlib/find.c.

References bound_box::B, bound_box::E, G_debug(), HUGE_VAL, bound_box::N, PORT_DOUBLE_MAX, bound_box::S, bound_box::T, ilist::value, Vect_get_node_coor(), Vect_new_list(), Vect_points_distance(), Vect_select_nodes_by_box(), bound_box::W, and x.