GRASS 8 Programmer's Manual 8.6.0dev(2026)-8843f13794
Loading...
Searching...
No Matches
index.h
Go to the documentation of this file.
1/****************************************************************************
2 * MODULE: R-Tree library
3 *
4 * AUTHOR(S): Antonin Guttman - original code
5 * Daniel Green (green@superliminal.com) - major clean-up
6 * and implementation of bounding spheres
7 * Markus Metz - file-based and memory-based R*-tree
8 *
9 * PURPOSE: Multidimensional index
10 *
11 * SPDX-FileCopyrightText: 2010 GRASS Development Team
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 *****************************************************************************/
14
15#ifndef _R_TREE_INDEX_H_
16#define _R_TREE_INDEX_H_
17
18#include "rtree.h"
19
20/* internal definitions and functions */
21
22/* PGSIZE is normally the natural page size of the machine */
23#define PGSIZE 512
24
25/* R*-tree: number of branches to be force-reinserted when adding a branch */
26#define FORCECARD 3
27
28#define NODETYPE(l, fd) ((l) == 0 ? 0 : ((fd) < 0 ? 1 : 2))
29
33};
34
39
45
46/* functions */
47
48/* index.c */
51void RTreeReInsertNode(struct RTree_Node *, struct RTree_ListNode **);
53
54/* indexm.c */
55int RTreeSearchM(struct RTree *, struct RTree_Rect *, SearchHitCallback *,
56 void *);
57int RTreeInsertRectM(struct RTree_Rect *, union RTree_Child, int,
58 struct RTree *);
59int RTreeDeleteRectM(struct RTree_Rect *, union RTree_Child, struct RTree *);
60int RTreeValidChildM(union RTree_Child *child);
61
62/* indexf.c */
63int RTreeSearchF(struct RTree *, struct RTree_Rect *, SearchHitCallback *,
64 void *);
65int RTreeInsertRectF(struct RTree_Rect *, union RTree_Child, int,
66 struct RTree *);
67int RTreeDeleteRectF(struct RTree_Rect *, union RTree_Child, struct RTree *);
68int RTreeValidChildF(union RTree_Child *);
69
70/* node.c */
71void RTreeNodeCover(struct RTree_Node *, struct RTree_Rect *, struct RTree *);
72int RTreeAddBranch(struct RTree_Branch *, struct RTree_Node *,
73 struct RTree_Node **, struct RTree_ListBranch **,
74 struct RTree_Rect *, char *, struct RTree *);
75int RTreePickBranch(struct RTree_Rect *, struct RTree_Node *, struct RTree *);
76void RTreeDisconnectBranch(struct RTree_Node *, int, struct RTree *);
77void RTreePrintNode(struct RTree_Node *, int, struct RTree *);
78void RTreeTabIn(int);
79void RTreeCopyBranch(struct RTree_Branch *, struct RTree_Branch *,
80 struct RTree *);
81
82/* rect.c */
83void RTreeInitRect(struct RTree_Rect *, struct RTree *);
84void RTreeNullRect(struct RTree_Rect *, struct RTree *);
87RectReal RTreeRectVolume(struct RTree_Rect *, struct RTree *);
88RectReal RTreeRectMargin(struct RTree_Rect *, struct RTree *);
89void RTreeCombineRect(struct RTree_Rect *, struct RTree_Rect *,
90 struct RTree_Rect *, struct RTree *);
91int RTreeExpandRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
92int RTreeCompareRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
93
94/*-----------------------------------------------------------------------------
95| Copy second rectangle to first rectangle.
96-----------------------------------------------------------------------------*/
97#define RTreeCopyRect(r1, r2, t) \
98 memcpy((r1)->boundary, (r2)->boundary, (t)->rectsize)
99
100/* split.c */
101void RTreeSplitNode(struct RTree_Node *, struct RTree_Branch *,
102 struct RTree_Node *, struct RTree *);
103
104/* card.c */
105int RTreeSetNodeMax(int, struct RTree *);
106int RTreeSetLeafMax(int, struct RTree *);
107int RTreeGetNodeMax(struct RTree *);
108int RTreeGetLeafMax(struct RTree *);
109
110/* io.c */
111struct RTree_Node *RTreeGetNode(off_t, int, struct RTree *);
112void RTreeNodeChanged(struct RTree_Node *, off_t, struct RTree *);
113size_t RTreeRewriteNode(struct RTree_Node *, off_t, struct RTree *);
114void RTreeAddNodePos(off_t, int, struct RTree *);
115
116#endif /* _INDEX_ */
int RTreeAddBranch(struct RTree_Branch *, struct RTree_Node *, struct RTree_Node **, struct RTree_ListBranch **, struct RTree_Rect *, char *, struct RTree *)
Definition node.c:540
void RTreePrintNode(struct RTree_Node *, int, struct RTree *)
Definition node.c:614
void RTreeDisconnectBranch(struct RTree_Node *, int, struct RTree *)
Definition node.c:266
int RTreeSearchM(struct RTree *, struct RTree_Rect *, SearchHitCallback *, void *)
Definition indexm.c:30
int RTreeInsertRectF(struct RTree_Rect *, union RTree_Child, int, struct RTree *)
Definition indexf.c:210
void RTreeNodeCover(struct RTree_Node *, struct RTree_Rect *, struct RTree *)
Definition node.c:132
void RTreeFreeListNode(struct RTree_ListNode *)
RectReal RTreeRectSphericalVolume(struct RTree_Rect *, struct RTree *)
Definition rect.c:429
int RTreeGetLeafMax(struct RTree *)
Definition card.c:41
void RTreeTabIn(int)
Definition node.c:599
RectReal RTreeRectArea(struct RTree_Rect *, struct RTree *)
int RTreeDeleteRectM(struct RTree_Rect *, union RTree_Child, struct RTree *)
Definition indexm.c:349
void RTreeReInsertNode(struct RTree_Node *, struct RTree_ListNode **)
int RTreeSearchF(struct RTree *, struct RTree_Rect *, SearchHitCallback *, void *)
Definition indexf.c:33
size_t RTreeRewriteNode(struct RTree_Node *, off_t, struct RTree *)
Definition io.c:197
void RTreeNullRect(struct RTree_Rect *, struct RTree *)
Definition rect.c:222
void RTreeAddNodePos(off_t, int, struct RTree *)
Definition io.c:31
struct RTree_Node * RTreeGetNode(off_t, int, struct RTree *)
Definition io.c:115
void RTreeCopyBranch(struct RTree_Branch *, struct RTree_Branch *, struct RTree *)
Definition node.c:121
int RTreeInsertRectM(struct RTree_Rect *, union RTree_Child, int, struct RTree *)
Definition indexm.c:182
RectReal RTreeRectVolume(struct RTree_Rect *, struct RTree *)
Definition rect.c:320
struct RTree_ListNode * RTreeNewListNode(void)
int RTreeDeleteRectF(struct RTree_Rect *, union RTree_Child, struct RTree *)
Definition indexf.c:405
int RTreePickBranch(struct RTree_Rect *, struct RTree_Node *, struct RTree *)
Definition node.c:232
RectReal RTreeRectMargin(struct RTree_Rect *, struct RTree *)
Definition rect.c:480
void RTreeSplitNode(struct RTree_Node *, struct RTree_Branch *, struct RTree_Node *, struct RTree *)
Definition split.c:610
void RTreeCombineRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
Definition rect.c:497
void RTreeNodeChanged(struct RTree_Node *, off_t, struct RTree *)
Definition io.c:209
int RTreeSetNodeMax(int, struct RTree *)
Definition card.c:26
int RTreeExpandRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
Definition rect.c:533
int RTreeValidChildM(union RTree_Child *child)
Definition indexm.c:20
void RTreeInitRect(struct RTree_Rect *, struct RTree *)
Initialize a rectangle to have all 0 coordinates.
Definition rect.c:106
int RTreeGetNodeMax(struct RTree *)
Definition card.c:36
void RTreeFreeListBranch(struct RTree_ListBranch *)
int RTreeSetLeafMax(int, struct RTree *)
Definition card.c:31
int RTreeCompareRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
Definition rect.c:567
int RTreeValidChildF(union RTree_Child *)
Definition indexf.c:23
int SearchHitCallback(int id, const struct RTree_Rect *rect, void *arg)
Definition rtree.h:83
struct RTree_ListBranch * next
Definition index.h:41
struct RTree_Branch b
Definition index.h:42
off_t node_pos
Definition index.h:37
struct RTree_ListFNode * next
Definition index.h:36
struct RTree_ListNode * next
Definition index.h:31
struct RTree_Node * node
Definition index.h:32
Definition rtree.h:120