21 #include <sys/types.h>
28 return (child->
pos > -1);
40 int hitCount = 0, notfound, currlevel;
49 currlevel =
t->rootlevel;
50 s[top].
pos =
t->rootpos;
58 currlevel = s[top].
sn->
level - 1;
59 for (i = s[top].
branch_id; i <
t->nodecard; i++) {
78 for (i = 0; i <
t->leafcard; i++) {
109 off_t *newnode_pos,
struct RTree *
t,
115 int top = 0, down = 0;
125 currlevel =
t->rootlevel;
126 s[top].
pos =
t->rootpos;
130 while (s[top].sn->level > level) {
132 currlevel = s[top].
sn->
level - 1;
167 else if (result == 2) {
176 else if (result == 1) {
181 b->child.pos = *newnode_pos;
221 off_t newnode_pos = -1;
234 result = RTreeInsertRect2F(
r, child,
level, newnode, &newnode_pos,
t,
235 &reInsertList, overflow);
242 newroot->
level =
t->rootlevel;
245 b->child.pos =
t->rootpos;
249 b->child.pos = newnode_pos;
261 while (reInsertList) {
266 reInsertList = reInsertList->
next;
270 RTreeInsertRect2F(&(
b->rect),
b->child,
level, newnode,
271 &newnode_pos,
t, &reInsertList, overflow);
278 newroot->
level =
t->rootlevel;
281 b->child.pos =
t->rootpos;
285 b->child.pos = newnode_pos;
307 int i, notfound = 1, currlevel;
309 int top = 0, down = 0;
316 currlevel =
t->rootlevel;
317 s[top].
pos =
t->rootpos;
321 while (notfound && top >= 0) {
323 if (s[top].sn->level > 0) {
325 currlevel = s[top].
sn->
level - 1;
326 for (i = s[top].branch_id; i <
t->nodecard; i++) {
348 for (i = 0; i <
t->leafcard; i++) {
349 if (s[top].sn->branch[i].child.id &&
350 s[top].sn->branch[i].child.id ==
374 minfill = (s[down].
sn->
level ?
t->min_node_fill :
t->min_leaf_fill);
375 if (s[down].sn->count >= minfill) {
415 if (!RTreeDeleteRect2F(
r, child,
t, &reInsertList)) {
419 while (reInsertList) {
421 n = reInsertList->
node;
423 for (i = 0; i <
t->nodecard; i++) {
431 for (i = 0; i <
t->leafcard; i++) {
439 reInsertList = reInsertList->
next;
448 for (i = 0; i <
t->nodecard; i++) {
int RTreeAddBranch(struct RTree_Branch *, struct RTree_Node *, struct RTree_Node **, struct RTree_ListBranch **, struct RTree_Rect *, char *, struct RTree *)
void RTreeDisconnectBranch(struct RTree_Node *, int, struct RTree *)
void RTreeNodeCover(struct RTree_Node *, struct RTree_Rect *, struct RTree *)
void RTreeAddNodePos(off_t, int, struct RTree *)
void RTreeCopyBranch(struct RTree_Branch *, struct RTree_Branch *, struct RTree *)
struct RTree_Node * RTreeGetNode(off_t, int, struct RTree *)
int RTreePickBranch(struct RTree_Rect *, struct RTree_Node *, struct RTree *)
void RTreeNodeChanged(struct RTree_Node *, off_t, struct RTree *)
int RTreeExpandRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
#define RTreeCopyRect(r1, r2, t)
int RTreeCompareRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
int RTreeSearchF(struct RTree *t, struct RTree_Rect *r, SearchHitCallback *shcb, void *cbarg)
int RTreeValidChildF(union RTree_Child *child)
int RTreeDeleteRectF(struct RTree_Rect *r, union RTree_Child child, struct RTree *t)
int RTreeInsertRectF(struct RTree_Rect *r, union RTree_Child child, int level, struct RTree *t)
off_t RTreeGetNodePos(struct RTree *t)
size_t RTreeWriteNode(struct RTree_Node *n, struct RTree *t)
void RTreeCopyNode(struct RTree_Node *n1, struct RTree_Node *n2, struct RTree *t)
void RTreeFreeNode(struct RTree_Node *n)
struct RTree_Node * RTreeAllocNode(struct RTree *t, int level)
void RTreeInitNode(struct RTree *t, struct RTree_Node *n, int type)
int RTreeOverlap(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
int SearchHitCallback(int id, const struct RTree_Rect *rect, void *arg)
struct RTree_ListBranch * next
struct RTree_ListNode * next
struct RTree_Branch * branch
void RTreeFreeListNode(struct RTree_ListNode *p)
void RTreeReInsertNode(struct RTree_Node *n, struct RTree_ListNode **ee)
void RTreeFreeListBranch(struct RTree_ListBranch *p)
#define MAXLEVEL
Maximum verbosity level.