GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
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 SPDX-FileCopyrightText: 2012 GRASS Development Team
9 SPDX-License-Identifier: GPL-2.0-or-later
10
11 \author Soeren Gebbert
12 */
13
14#include <assert.h>
15#include <grass/vector.h>
16
17/* Function to add the ids of overlapping rectangles to an ilist
18 * This function is a callback function used in RTreeSearch2()
19 * */
20static int add_id_to_list(int id, const struct RTree_Rect *rect G_UNUSED,
21 void *list)
22{
23 struct ilist *l = (struct ilist *)list;
24
25 G_ilist_add(l, id);
26 return 1;
27}
28
29/**
30 * Search in an index tree for all data rectangles 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 */
38int RTreeSearch2(struct RTree *t, struct RTree_Rect *r, struct ilist *list)
39{
40 assert(r && t);
41
43
44 return t->search_rect(t, r, add_id_to_list, (void *)list);
45}
void G_init_ilist(struct ilist *)
Init an integer list and free allocated memory.
Definition ilist.c:55
void G_ilist_add(struct ilist *, int)
Add item to ilist.
Definition ilist.c:75
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Definition gis.h:43
#define assert(condition)
Definition lz4.c:291
double l
Definition r_raster.c:37
double t
Definition r_raster.c:37
double r
Definition r_raster.c:37
int RTreeSearch2(struct RTree *t, struct RTree_Rect *r, struct ilist *list)
Definition rtree.h:120
List of integers.
Definition gis.h:712
Definition manage.h:4