40 #include <sys/types.h> 63 struct RTree *new_rtree;
88 sizeof(struct RTree_Rect) +
90 new_rtree->nodesize =
sizeof(
struct RTree_Node) -
91 sizeof(struct RTree_Branch *) +
92 MAXCARD * new_rtree->branchsize;
96 new_rtree->rootlevel = n->
level = 0;
99 new_rtree->overflow = 1;
113 new_rtree->used =
malloc(MAXLEVEL *
sizeof(
int *));
114 new_rtree->used[0] =
malloc(MAXLEVEL * NODE_BUFFER_SIZE *
sizeof(
int));
119 new_rtree->nb[i][j].dirty = 0;
120 new_rtree->nb[i][j].pos = -1;
122 new_rtree->used[i][j] = j;
124 new_rtree->nb[i][j].n.branch =
malloc(
MAXCARD *
sizeof(
struct RTree_Branch));
127 for (k = 0; k <
MAXCARD; k++) {
134 lseek(new_rtree->fd, rootpos, SEEK_SET);
137 new_rtree->root =
NULL;
158 new_rtree->min_node_fill = (new_rtree->nodecard - 2) / 2;
159 new_rtree->min_leaf_fill = (new_rtree->leafcard - 2) / 2;
162 new_rtree->minfill_node_split = (new_rtree->nodecard - 1) / 2;
163 new_rtree->minfill_leaf_split = (new_rtree->leafcard - 1) / 2;
165 new_rtree->n_nodes = 1;
166 new_rtree->n_leafs = 0;
178 new_rtree->BranchBuf =
malloc((
MAXCARD + 1) *
sizeof(
struct RTree_Branch));
179 for (i = 0; i <=
MAXCARD; i++) {
233 for (k = 0; k <
MAXCARD; k++) {
259 for (i = 0; i <=
MAXCARD; i++) {
319 assert(r && t && tid > 0);
346 assert(r && t && tid > 0);
struct RTree_Rect rect_0 rect_1 upperrect orect
int RTreeInsertRect(struct RTree_Rect *r, int tid, struct RTree *t)
Insert an item into a R*-Tree.
int RTreeDeleteRectM(struct RTree_Rect *, union RTree_Child, struct RTree *)
void RTreeFreeNode(struct RTree_Node *n)
int SearchHitCallback(int id, const struct RTree_Rect *rect, void *arg)
struct RTree::_recycle free_nodes
void RTreeDestroyTree(struct RTree *t)
Destroy an R*-Tree.
rt_search_fn * search_rect
#define MAXLEVEL
Maximum verbosity level.
rt_delete_fn * delete_rect
int RTreeSearch(struct RTree *t, struct RTree_Rect *r, SearchHitCallback *shcb, void *cbarg)
Search an R*-Tree.
struct RTree_ListNode * RTreeNewListNode(void)
int RTreeValidChildM(union RTree_Child *child)
struct RTree_ListNode * next
int RTreeDeleteRect(struct RTree_Rect *r, int tid, struct RTree *t)
Delete an item from a R*-Tree.
void RTreeDestroyNode(struct RTree_Node *n, int nodes)
unsigned char ndims_alloc
int RTreeDeleteRectF(struct RTree_Rect *, union RTree_Child, struct RTree *)
#define assert(condition)
int RTreeSearchF(struct RTree *, struct RTree_Rect *, SearchHitCallback *, void *)
void RTreeFreeListNode(struct RTree_ListNode *p)
void RTreeFreeBoundary(struct RTree_Rect *r)
Delete the boundary of a rectangle.
struct RTree_Branch tmpb1 tmpb2 c
struct RTree_Branch * BranchBuf
struct RTree_Branch * branch
void RTreeSetOverflow(struct RTree *t, char overflow)
Enable/disable R*-tree forced reinsertion (overflow)
void RTreeFreeListBranch(struct RTree_ListBranch *p)
struct RTree_Node * RTreeAllocNode(struct RTree *t, int level)
unsigned char nsides_alloc
int RTreeInsertRectF(struct RTree_Rect *, union RTree_Child, int, struct RTree *)
int RTreeInsertRectM(struct RTree_Rect *, union RTree_Child, int, struct RTree *)
RectReal * RTreeAllocBoundary(struct RTree *t)
Allocate the boundary array of a rectangle for a given tree.
int RTreeValidChildF(union RTree_Child *)
rt_insert_fn * insert_rect
size_t RTreeWriteNode(struct RTree_Node *n, struct RTree *t)
void RTreeReInsertNode(struct RTree_Node *n, struct RTree_ListNode **ee)
int RTreeSearchM(struct RTree *, struct RTree_Rect *, SearchHitCallback *, void *)
struct RTree_Rect cover[2]
struct RTree * RTreeCreateTree(int fd, off_t rootpos, int ndims)
Create new empty R*-Tree.
struct RTree_PartitionVars p