GRASS 8 Programmer's Manual 8.6.0dev(2026)-1878fdfec5
Loading...
Searching...
No Matches
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.
 
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_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).
 
int Vect_find_area (struct Map_info *Map, double x, double y)
 Find the nearest area.
 
int Vect_find_island (struct Map_info *Map, double x, double y)
 Find the nearest island.
 

Detailed Description

Vector library - Find nearest vector feature.

Higher level functions for reading/writing/manipulating vectors.

SPDX-FileCopyrightText: 2001-2009 GRASS Development Team SPDX-License-Identifier: GPL-2.0-or-later

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 21 of file vector/Vlib/find.c.

Function Documentation

◆ Vect_find_area()

◆ Vect_find_island()

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

◆ 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 124 of file vector/Vlib/find.c.

References NULL, Vect_destroy_list(), Vect_find_line_list(), Vect_list_append(), and Vect_new_list().

Referenced by Vect_net_nearest_nodes(), and Vedit_snap_point().

◆ 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 157 of file vector/Vlib/find.c.

References boxlist::box, G_debug(), HUGE_VAL, NULL, PORT_DOUBLE_MAX, Vect_destroy_boxlist(), Vect_line_distance(), Vect_list_append(), Vect_new_boxlist(), Vect_new_line_struct(), Vect_read_line(), Vect_reset_list(), Vect_select_lines_by_box(), and Vect_val_in_list().

Referenced by Vect_find_line(), Vedit_connect_lines(), Vedit_extend_lines(), and Vedit_merge_lines().

◆ 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 54 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, Vect_get_node_coor(), Vect_new_list(), Vect_points_distance(), Vect_select_nodes_by_box(), bound_box::W, and x.

Referenced by NetA_points_to_nodes(), NetA_varray_to_nodes(), and Vect_net_ttb_build_graph().