GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
spindex.c File Reference

Vector library - spatial index (lower level functions) More...

#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/Vect.h>
#include <grass/glocale.h>
Include dependency graph for spindex.c:

Go to the source code of this file.

Functions

int dig_spidx_init (struct Plus_head *Plus)
 Initit spatial index (nodes, lines, areas, isles) More...
 
void dig_spidx_free_nodes (struct Plus_head *Plus)
 Free spatial index for nodes. More...
 
void dig_spidx_free_lines (struct Plus_head *Plus)
 Free spatial index for lines. More...
 
void dig_spidx_free_areas (struct Plus_head *Plus)
 Free spatial index for areas. More...
 
void dig_spidx_free_isles (struct Plus_head *Plus)
 Free spatial index for isles. More...
 
void dig_spidx_free (struct Plus_head *Plus)
 Free spatial index (nodes, lines, areas, isles) More...
 
int dig_spidx_add_node (struct Plus_head *Plus, int node, double x, double y, double z)
 Add new node to spatial index. More...
 
int dig_spidx_add_line (struct Plus_head *Plus, int line, BOUND_BOX *box)
 Add new line to spatial index. More...
 
int dig_spidx_add_area (struct Plus_head *Plus, int area, BOUND_BOX *box)
 Add new area to spatial index. More...
 
int dig_spidx_add_isle (struct Plus_head *Plus, int isle, BOUND_BOX *box)
 Add new island to spatial index. More...
 
int dig_spidx_del_node (struct Plus_head *Plus, int node)
 Delete node from spatial index. More...
 
int dig_spidx_del_line (struct Plus_head *Plus, int line)
 Delete line from spatial index. More...
 
int dig_spidx_del_area (struct Plus_head *Plus, int area)
 Delete area from spatial index. More...
 
int dig_spidx_del_isle (struct Plus_head *Plus, int isle)
 Delete isle from spatial index. More...
 
int dig_select_nodes (struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
 Select nodes by bbox. More...
 
int dig_find_node (struct Plus_head *Plus, double x, double y, double z)
 Find one node by coordinates. More...
 
int dig_select_lines (struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
 Select lines by box. More...
 
int dig_select_areas (struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
 Select areas by box. More...
 
int dig_select_isles (struct Plus_head *Plus, BOUND_BOX *box, struct ilist *list)
 Select isles by box. More...
 

Detailed Description

Vector library - spatial index (lower level functions)

Lower level functions for reading/writing/manipulating vectors.

(C) 2001 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
CERL (probably Dave Gerdes), Radim Blazek

Definition in file spindex.c.

Function Documentation

int dig_find_node ( struct Plus_head *  Plus,
double  x,
double  y,
double  z 
)

Find one node by coordinates.

Parameters
Pluspointer to Plus_head structure
x,y,zcoordinates
Returns
number of node
0 not found

Definition at line 420 of file spindex.c.

References Rect::boundary, dig_init_list(), G_debug(), RTreeSearch(), and y.

int dig_select_areas ( struct Plus_head *  Plus,
BOUND_BOX *  box,
struct ilist *  list 
)

Select areas by box.

Parameters
Pluspointer to Plus_head structure
boxbounding box
listlist of selected lines
Returns
number of selected areas

Definition at line 482 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeSearch().

Referenced by Vect_select_areas_by_box().

int dig_select_isles ( struct Plus_head *  Plus,
BOUND_BOX *  box,
struct ilist *  list 
)

Select isles by box.

Parameters
Pluspointer to Plus_head structure
boxbounding box
listlist of selected lines
Returns
number of selected isles

Definition at line 511 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeSearch().

Referenced by Vect_select_isles_by_box().

int dig_select_lines ( struct Plus_head *  Plus,
BOUND_BOX *  box,
struct ilist *  list 
)

Select lines by box.

Parameters
Pluspointer to Plus_head structure
boxbounding box
listlist of selected lines
Returns
number of selected lines

Definition at line 453 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeSearch().

Referenced by Vect_select_lines_by_box().

int dig_select_nodes ( struct Plus_head *  Plus,
BOUND_BOX *  box,
struct ilist *  list 
)

Select nodes by bbox.

Parameters
Pluspointer to Plus_head structure
boxbounding box
listlist of selected lines
Returns
number of selected nodes
-1 on error

Definition at line 385 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeSearch().

Referenced by Vect_select_nodes_by_box().

int dig_spidx_add_area ( struct Plus_head *  Plus,
int  area,
BOUND_BOX *  box 
)

Add new area to spatial index.

Parameters
Pluspointer to Plus_head structure
areaarea id
boxbounding box
Returns
0

Definition at line 174 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeInsertRect().

Referenced by dig_add_area(), and Vect_build_sidx_from_topo().

int dig_spidx_add_isle ( struct Plus_head *  Plus,
int  isle,
BOUND_BOX *  box 
)

Add new island to spatial index.

Parameters
Pluspointer to Plus_head structure
isleisle id
boxbounding box
Returns
0

Definition at line 201 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeInsertRect().

Referenced by dig_add_isle(), and Vect_build_sidx_from_topo().

int dig_spidx_add_line ( struct Plus_head *  Plus,
int  line,
BOUND_BOX *  box 
)

Add new line to spatial index.

Parameters
Pluspointer to Plus_head structure
lineline id
boxbounding box
Returns
0

Definition at line 148 of file spindex.c.

References Rect::boundary, G_debug(), and RTreeInsertRect().

Referenced by Vect_build_sidx_from_topo().

int dig_spidx_add_node ( struct Plus_head *  Plus,
int  node,
double  x,
double  y,
double  z 
)

Add new node to spatial index.

Parameters
Pluspointer to Plus_head structure
nodenode id
x,y,znode coordinates
Returns
1 OK
0 on error

Definition at line 120 of file spindex.c.

References Rect::boundary, G_debug(), RTreeInsertRect(), and y.

Referenced by dig_add_node(), and Vect_build_sidx_from_topo().

int dig_spidx_del_area ( struct Plus_head *  Plus,
int  area 
)

Delete area from spatial index.

G_fatal_error() called on error.

Parameters
Pluspointer to Plus_head structure
areaarea id
Returns
0

Definition at line 303 of file spindex.c.

References Rect::boundary, G_debug(), G_fatal_error(), NULL, and RTreeDeleteRect().

Referenced by dig_del_area().

int dig_spidx_del_isle ( struct Plus_head *  Plus,
int  isle 
)

Delete isle from spatial index.

G_fatal_error() called on error.

Parameters
Pluspointer to Plus_head structure
isleisle id
Returns
0

Definition at line 342 of file spindex.c.

References Rect::boundary, G_debug(), G_fatal_error(), and RTreeDeleteRect().

Referenced by dig_del_isle().

int dig_spidx_del_line ( struct Plus_head *  Plus,
int  line 
)

Delete line from spatial index.

G_fatal_error() called on error.

Parameters
Pluspointer to Plus_head structure
lineline id
Returns
0

Definition at line 263 of file spindex.c.

References Rect::boundary, G_debug(), G_fatal_error(), and RTreeDeleteRect().

Referenced by dig_del_line().

int dig_spidx_del_node ( struct Plus_head *  Plus,
int  node 
)

Delete node from spatial index.

G_fatal_error() called on error.

Parameters
Pluspointer to Plus_head structure
nodenode id
Returns
0

Definition at line 228 of file spindex.c.

References Rect::boundary, G_debug(), G_fatal_error(), and RTreeDeleteRect().

Referenced by dig_del_line().

void dig_spidx_free ( struct Plus_head *  Plus)

Free spatial index (nodes, lines, areas, isles)

Parameters
Pluspointer to Plus_head structure

Definition at line 101 of file spindex.c.

References dig_spidx_free_areas(), dig_spidx_free_isles(), dig_spidx_free_lines(), and dig_spidx_free_nodes().

Referenced by Vect__open_old(), and Vect_close().

void dig_spidx_free_areas ( struct Plus_head *  Plus)

Free spatial index for areas.

Parameters
Pluspointer to Plus_head structure

Definition at line 79 of file spindex.c.

References RTreeDestroyNode(), and RTreeNewIndex().

Referenced by dig_spidx_free(), and Vect_build_nat().

void dig_spidx_free_isles ( struct Plus_head *  Plus)

Free spatial index for isles.

Parameters
Pluspointer to Plus_head structure

Definition at line 90 of file spindex.c.

References RTreeDestroyNode(), and RTreeNewIndex().

Referenced by dig_spidx_free(), and Vect_build_nat().

void dig_spidx_free_lines ( struct Plus_head *  Plus)

Free spatial index for lines.

Parameters
Pluspointer to Plus_head structure

Definition at line 68 of file spindex.c.

References RTreeDestroyNode(), and RTreeNewIndex().

Referenced by dig_spidx_free(), and Vect_build_nat().

void dig_spidx_free_nodes ( struct Plus_head *  Plus)

Free spatial index for nodes.

Parameters
Pluspointer to Plus_head structure

Definition at line 57 of file spindex.c.

References RTreeDestroyNode(), and RTreeNewIndex().

Referenced by dig_spidx_free(), and Vect_build_nat().

int dig_spidx_init ( struct Plus_head *  Plus)

Initit spatial index (nodes, lines, areas, isles)

Parameters
Pluspointer to Plus_head structure
Returns
1 OK
0 on error

Definition at line 31 of file spindex.c.

References G_debug(), and RTreeNewIndex().

Referenced by dig_init_plus(), dig_read_spidx(), Vect_build_sidx_from_topo(), and Vect_open_spatial_index().