GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rtree_search.c
Go to the documentation of this file.
1 /*!
2  \file lib/vector/Vlib/rtree_search.c
3 
4  \brief Vector library - simplified rtree search
5 
6  Higher level functions for reading/writing/manipulating vectors.
7 
8  (C) 2012 by the GRASS Development Team
9 
10  This program is free software under the GNU General Public License
11  (>=v2). Read the file COPYING that comes with GRASS for details.
12 
13  \author Soeren Gebbert
14  */
15 
16 #include <assert.h>
17 #include <grass/vector.h>
18 
19 /* Function to add the ids of overlapping rectangles to an ilist
20  * This function is a callback function used in RTreeSearch2()
21  * */
22 static int add_id_to_list(int id, const struct RTree_Rect *rect, void *list)
23 {
24  struct ilist *l = (struct ilist*)list;
25  G_ilist_add(l, id);
26  return 1;
27 }
28 
29 /**
30  * Search in an index tree for all data retangles that
31  * overlap the argument rectangle.
32  *
33  * \param t: The RTree
34  * \param r: The argument rectangle
35  * \param list: The list to store the ids of overlapping rectangles
36  * \return the number of qualifying data rects.
37  */
38 int RTreeSearch2(struct RTree *t, struct RTree_Rect *r, struct ilist *list)
39 {
40  assert(r && t);
41 
42  G_init_ilist(list);
43 
44  return t->search_rect(t, r, add_id_to_list, (void*)list);
45 }
46 
int RTreeSearch2(struct RTree *t, struct RTree_Rect *r, struct ilist *list)
Definition: rtree_search.c:38
rt_search_fn * search_rect
Definition: rtree.h:172
double l
Definition: r_raster.c:39
double t
Definition: r_raster.c:39
Definition: manage.h:4
void G_init_ilist(struct ilist *list)
Init an integer list and free allocated memory.
Definition: ilist.c:57
List of integers.
Definition: gis.h:650
void G_ilist_add(struct ilist *list, int val)
Add item to ilist.
Definition: ilist.c:77
Definition: rtree.h:128
double r
Definition: r_raster.c:39