GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
vector/Vlib/select.c File Reference

Vector library - spatial index. More...

#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <string.h>
#include <grass/vector.h>
#include <grass/glocale.h>
Include dependency graph for vector/Vlib/select.c:

Go to the source code of this file.

Functions

void Vect_spatial_index_init (struct spatial_index *si, int with_z)
 Initialize spatial index structure. More...
 
void Vect_spatial_index_destroy (struct spatial_index *si)
 Destroy existing spatial index. More...
 
void Vect_spatial_index_add_item (struct spatial_index *si, int id, const struct bound_box *box)
 Add a new item to spatial index structure. More...
 
void Vect_spatial_index_del_item (struct spatial_index *si, int id, const struct bound_box *box)
 Delete item from spatial index structure. More...
 
int Vect_spatial_index_select (const struct spatial_index *si, const struct bound_box *box, struct ilist *list)
 Select items by bounding box to list. More...
 

Detailed Description

Vector library - spatial index.

Higher level functions for a custom spatial index.

(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
Radim Blazek

Definition in file vector/Vlib/select.c.

Function Documentation

◆ Vect_spatial_index_add_item()

void Vect_spatial_index_add_item ( struct spatial_index si,
int  id,
const struct bound_box box 
)

Add a new item to spatial index structure.

Parameters
[in,out]sipointer to spatial index structure
iditem identifier
boxpointer to item bounding box
Returns
void

Definition at line 62 of file vector/Vlib/select.c.

References bound_box::B, RTree_Rect::boundary, bound_box::E, G_debug(), G_malloc, bound_box::N, RTree::nsides_alloc, RTreeInsertRect(), bound_box::S, spatial_index::si_tree, bound_box::T, and bound_box::W.

◆ Vect_spatial_index_del_item()

void Vect_spatial_index_del_item ( struct spatial_index si,
int  id,
const struct bound_box box 
)

Delete item from spatial index structure.

Parameters
[in,out]sipointer to spatial index structure
iditem identifier
Returns
void

Definition at line 92 of file vector/Vlib/select.c.

References _, bound_box::B, RTree_Rect::boundary, bound_box::E, G_debug(), G_fatal_error(), G_malloc, bound_box::N, RTree::nsides_alloc, RTreeDeleteRect(), bound_box::S, spatial_index::si_tree, bound_box::T, and bound_box::W.

◆ Vect_spatial_index_destroy()

void Vect_spatial_index_destroy ( struct spatial_index si)

Destroy existing spatial index.

Vect_spatial_index_init() must be call before new use.

Parameters
sipointer to spatial index structure
Returns
void

Definition at line 46 of file vector/Vlib/select.c.

References G_debug(), RTreeDestroyTree(), and spatial_index::si_tree.

◆ Vect_spatial_index_init()

void Vect_spatial_index_init ( struct spatial_index si,
int  with_z 
)

Initialize spatial index structure.

Parameters
sipointer to spatial index structure
Returns
void

Definition at line 30 of file vector/Vlib/select.c.

References G_debug(), RTreeCreateTree(), and spatial_index::si_tree.

◆ Vect_spatial_index_select()

int Vect_spatial_index_select ( const struct spatial_index si,
const struct bound_box box,
struct ilist list 
)

Select items by bounding box to list.

Parameters
sipointer to spatial index structure
boxbounding box
[out]listpointer to list where selected items are stored
Returns
number of selected items

Definition at line 136 of file vector/Vlib/select.c.

References bound_box::B, RTree_Rect::boundary, bound_box::E, G_malloc, bound_box::N, RTree::nsides_alloc, RTreeSearch(), bound_box::S, spatial_index::si_tree, bound_box::T, Vect_reset_list(), and bound_box::W.