[GRASS-SVN] r46939 - grass/trunk/lib/vector/rtree
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jul 3 13:56:34 EDT 2011
Author: mmetz
Date: 2011-07-03 10:56:34 -0700 (Sun, 03 Jul 2011)
New Revision: 46939
Modified:
grass/trunk/lib/vector/rtree/index.c
grass/trunk/lib/vector/rtree/index.h
grass/trunk/lib/vector/rtree/indexf.c
grass/trunk/lib/vector/rtree/indexm.c
grass/trunk/lib/vector/rtree/io.c
grass/trunk/lib/vector/rtree/node.c
grass/trunk/lib/vector/rtree/rect.c
grass/trunk/lib/vector/rtree/split.c
grass/trunk/lib/vector/rtree/split.h
Log:
change struct names to avoid conflicts
Modified: grass/trunk/lib/vector/rtree/index.c
===================================================================
--- grass/trunk/lib/vector/rtree/index.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/index.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -34,7 +34,7 @@
struct RTree *RTreeNewIndex(int fd, off_t rootpos, int ndims)
{
struct RTree *new_rtree;
- struct Node *n;
+ struct RTree_Node *n;
int i;
new_rtree = (struct RTree *)malloc(sizeof(struct RTree));
@@ -44,15 +44,15 @@
new_rtree->ndims = ndims;
new_rtree->nsides = 2 * ndims;
- new_rtree->rectsize = sizeof(struct Rect);
+ new_rtree->rectsize = sizeof(struct RTree_Rect);
/* init free nodes */
new_rtree->free_nodes.avail = 0;
new_rtree->free_nodes.alloc = 0;
new_rtree->free_nodes.pos = NULL;
- new_rtree->nodesize = sizeof(struct Node);
- new_rtree->branchsize = sizeof(struct Branch);
+ new_rtree->nodesize = sizeof(struct RTree_Node);
+ new_rtree->branchsize = sizeof(struct RTree_Branch);
/* create empty root node */
n = RTreeNewNode(new_rtree, 0);
@@ -141,7 +141,7 @@
* overlap the argument rectangle.
* Return the number of qualifying data rects.
*/
-int RTreeSearch(struct RTree *t, struct Rect *r, SearchHitCallback *shcb,
+int RTreeSearch(struct RTree *t, struct RTree_Rect *r, SearchHitCallback *shcb,
void *cbarg)
{
assert(r && t);
@@ -155,9 +155,9 @@
* tid data id stored with rectangle, must be > 0
* t RTree where rectangle should be inserted
*/
-int RTreeInsertRect(struct Rect *r, int tid, struct RTree *t)
+int RTreeInsertRect(struct RTree_Rect *r, int tid, struct RTree *t)
{
- union Child newchild;
+ union RTree_Child newchild;
assert(r && t && tid > 0);
@@ -179,9 +179,9 @@
* compile warnings to rtree lib
* this way it's easier to fix if necessary?
*/
-int RTreeDeleteRect(struct Rect *r, int tid, struct RTree *t)
+int RTreeDeleteRect(struct RTree_Rect *r, int tid, struct RTree *t)
{
- union Child child;
+ union RTree_Child child;
assert(r && t && tid > 0);
@@ -194,12 +194,12 @@
* Allocate space for a node in the list used in DeleteRect to
* store Nodes that are too empty.
*/
-struct ListNode *RTreeNewListNode(void)
+struct RTree_ListNode *RTreeNewListNode(void)
{
- return (struct ListNode *)malloc(sizeof(struct ListNode));
+ return (struct RTree_ListNode *)malloc(sizeof(struct RTree_ListNode));
}
-void RTreeFreeListNode(struct ListNode *p)
+void RTreeFreeListNode(struct RTree_ListNode *p)
{
free(p);
}
@@ -208,9 +208,9 @@
* Add a node to the reinsertion list. All its branches will later
* be reinserted into the index structure.
*/
-void RTreeReInsertNode(struct Node *n, struct ListNode **ee)
+void RTreeReInsertNode(struct RTree_Node *n, struct RTree_ListNode **ee)
{
- struct ListNode *l = RTreeNewListNode();
+ struct RTree_ListNode *l = RTreeNewListNode();
l->node = n;
l->next = *ee;
@@ -220,7 +220,7 @@
/*
* Free ListBranch
*/
-void RTreeFreeListBranch(struct ListBranch *p)
+void RTreeFreeListBranch(struct RTree_ListBranch *p)
{
free(p);
}
Modified: grass/trunk/lib/vector/rtree/index.h
===================================================================
--- grass/trunk/lib/vector/rtree/index.h 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/index.h 2011-07-03 17:56:34 UTC (rev 46939)
@@ -56,31 +56,31 @@
#define NODETYPE(l, fd) ((l) == 0 ? 0 : ((fd) < 0 ? 1 : 2))
-struct Rect
+struct RTree_Rect
{
RectReal boundary[NUMSIDES]; /* xmin,ymin,...,xmax,ymax,... */
};
-struct Node; /* node for spatial index */
+struct RTree_Node; /* node for spatial index */
-union Child
+union RTree_Child
{
int id; /* child id */
- struct Node *ptr; /* pointer to child node */
+ struct RTree_Node *ptr; /* pointer to child node */
off_t pos; /* position of child node in file */
};
-struct Branch /* branch for spatial index */
+struct RTree_Branch /* branch for spatial index */
{
- struct Rect rect;
- union Child child;
+ struct RTree_Rect rect;
+ union RTree_Child child;
};
-struct Node /* node for spatial index */
+struct RTree_Node /* node for spatial index */
{
int count; /* number of branches */
int level; /* 0 is leaf, others positive */
- struct Branch branch[MAXCARD];
+ struct RTree_Branch branch[MAXCARD];
};
/*
@@ -90,15 +90,15 @@
* It can terminate the search early by returning 0 in which case
* the search will return the number of hits found up to that point.
*/
-typedef int SearchHitCallback(int id, struct Rect rect, void *arg);
+typedef int SearchHitCallback(int id, struct RTree_Rect rect, void *arg);
struct RTree;
-typedef int rt_search_fn(struct RTree *, struct Rect *,
+typedef int rt_search_fn(struct RTree *, struct RTree_Rect *,
SearchHitCallback *, void *);
-typedef int rt_insert_fn(struct Rect *, union Child, int, struct RTree *);
-typedef int rt_delete_fn(struct Rect *, union Child, struct RTree *);
-typedef int rt_valid_child_fn(union Child *);
+typedef int rt_insert_fn(struct RTree_Rect *, union RTree_Child, int, struct RTree *);
+typedef int rt_delete_fn(struct RTree_Rect *, union RTree_Child, struct RTree *);
+typedef int rt_valid_child_fn(union RTree_Child *);
struct RTree
{
@@ -134,7 +134,7 @@
* more than three nodes per level would require too complex cache management */
struct NodeBuffer
{
- struct Node n; /* buffered node */
+ struct RTree_Node n; /* buffered node */
off_t pos; /* file position of buffered node */
char dirty; /* node in buffer was modified */
} nb[MAXLEVEL][3];
@@ -150,90 +150,90 @@
rt_search_fn *search_rect;
rt_valid_child_fn *valid_child;
- struct Node *root; /* pointer to root node */
+ struct RTree_Node *root; /* pointer to root node */
off_t rootpos; /* root node position in file */
};
-struct ListNode
+struct RTree_ListNode
{
- struct ListNode *next;
- struct Node *node;
+ struct RTree_ListNode *next;
+ struct RTree_Node *node;
};
-struct ListFNode
+struct RTree_ListFNode
{
- struct ListFNode *next;
+ struct RTree_ListFNode *next;
off_t node_pos;
};
-struct ListBranch
+struct RTree_ListBranch
{
- struct ListBranch *next;
- struct Branch b;
+ struct RTree_ListBranch *next;
+ struct RTree_Branch b;
int level;
};
/* index.c */
-extern int RTreeSearch(struct RTree *, struct Rect *, SearchHitCallback *,
+extern int RTreeSearch(struct RTree *, struct RTree_Rect *, SearchHitCallback *,
void *);
-extern int RTreeInsertRect(struct Rect *, int, struct RTree *);
-extern int RTreeDeleteRect(struct Rect *, int, struct RTree *);
+extern int RTreeInsertRect(struct RTree_Rect *, int, struct RTree *);
+extern int RTreeDeleteRect(struct RTree_Rect *, int, struct RTree *);
extern struct RTree *RTreeNewIndex(int, off_t, int);
extern void RTreeFreeIndex(struct RTree *);
-extern struct ListNode *RTreeNewListNode(void);
-extern void RTreeFreeListNode(struct ListNode *);
-extern void RTreeReInsertNode(struct Node *, struct ListNode **);
-extern void RTreeFreeListBranch(struct ListBranch *);
+extern struct RTree_ListNode *RTreeNewListNode(void);
+extern void RTreeFreeListNode(struct RTree_ListNode *);
+extern void RTreeReInsertNode(struct RTree_Node *, struct RTree_ListNode **);
+extern void RTreeFreeListBranch(struct RTree_ListBranch *);
/* indexm.c */
-extern int RTreeSearchM(struct RTree *, struct Rect *, SearchHitCallback *,
+extern int RTreeSearchM(struct RTree *, struct RTree_Rect *, SearchHitCallback *,
void *);
-extern int RTreeInsertRectM(struct Rect *, union Child, int, struct RTree *);
-extern int RTreeDeleteRectM(struct Rect *, union Child, struct RTree *);
-extern int RTreeValidChildM(union Child *child);
+extern int RTreeInsertRectM(struct RTree_Rect *, union RTree_Child, int, struct RTree *);
+extern int RTreeDeleteRectM(struct RTree_Rect *, union RTree_Child, struct RTree *);
+extern int RTreeValidChildM(union RTree_Child *child);
/* indexf.c */
-extern int RTreeSearchF(struct RTree *, struct Rect *, SearchHitCallback *,
+extern int RTreeSearchF(struct RTree *, struct RTree_Rect *, SearchHitCallback *,
void *);
-extern int RTreeInsertRectF(struct Rect *, union Child, int, struct RTree *);
-extern int RTreeDeleteRectF(struct Rect *, union Child, struct RTree *);
-extern int RTreeValidChildF(union Child *child);
+extern int RTreeInsertRectF(struct RTree_Rect *, union RTree_Child, int, struct RTree *);
+extern int RTreeDeleteRectF(struct RTree_Rect *, union RTree_Child, struct RTree *);
+extern int RTreeValidChildF(union RTree_Child *child);
/* node.c */
-extern struct Node *RTreeNewNode(struct RTree *, int);
-extern void RTreeInitNode(struct Node *, int);
-extern void RTreeFreeNode(struct Node *);
-extern void RTreeDestroyNode(struct Node *, int);
-extern struct Rect RTreeNodeCover(struct Node *, struct RTree *);
-extern int RTreeAddBranch(struct Branch *, struct Node *, struct Node **,
- struct ListBranch **, struct Rect *, int *, struct RTree *);
-extern int RTreePickBranch(struct Rect *, struct Node *, struct RTree *);
-extern void RTreeDisconnectBranch(struct Node *, int, struct RTree *);
-extern void RTreePrintNode(struct Node *, int, struct RTree *);
+extern struct RTree_Node *RTreeNewNode(struct RTree *, int);
+extern void RTreeInitNode(struct RTree_Node *, int);
+extern void RTreeFreeNode(struct RTree_Node *);
+extern void RTreeDestroyNode(struct RTree_Node *, int);
+extern struct RTree_Rect RTreeNodeCover(struct RTree_Node *, struct RTree *);
+extern int RTreeAddBranch(struct RTree_Branch *, struct RTree_Node *, struct RTree_Node **,
+ struct RTree_ListBranch **, struct RTree_Rect *, int *, struct RTree *);
+extern int RTreePickBranch(struct RTree_Rect *, struct RTree_Node *, struct RTree *);
+extern void RTreeDisconnectBranch(struct RTree_Node *, int, struct RTree *);
+extern void RTreePrintNode(struct RTree_Node *, int, struct RTree *);
extern void RTreeTabIn(int);
/* rect.c */
-extern void RTreeInitRect(struct Rect *);
-extern struct Rect RTreeNullRect(void);
-extern RectReal RTreeRectArea(struct Rect *, struct RTree *);
-extern RectReal RTreeRectSphericalVolume(struct Rect *, struct RTree *);
-extern RectReal RTreeRectVolume(struct Rect *, struct RTree *);
-extern RectReal RTreeRectMargin(struct Rect *, struct RTree *);
-extern struct Rect RTreeCombineRect(struct Rect *, struct Rect *, struct RTree *);
-extern int RTreeCompareRect(struct Rect *, struct Rect *, struct RTree *);
-extern int RTreeOverlap(struct Rect *, struct Rect *, struct RTree *);
-extern void RTreePrintRect(struct Rect *, int);
+extern void RTreeInitRect(struct RTree_Rect *);
+extern struct RTree_Rect RTreeNullRect(void);
+extern RectReal RTreeRectArea(struct RTree_Rect *, struct RTree *);
+extern RectReal RTreeRectSphericalVolume(struct RTree_Rect *, struct RTree *);
+extern RectReal RTreeRectVolume(struct RTree_Rect *, struct RTree *);
+extern RectReal RTreeRectMargin(struct RTree_Rect *, struct RTree *);
+extern struct RTree_Rect RTreeCombineRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
+extern int RTreeCompareRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
+extern int RTreeOverlap(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
+extern void RTreePrintRect(struct RTree_Rect *, int);
/* split.c */
-extern void RTreeSplitNode(struct Node *, struct Branch *, struct Node *, struct RTree *);
+extern void RTreeSplitNode(struct RTree_Node *, struct RTree_Branch *, struct RTree_Node *, struct RTree *);
/* card.c */
extern int RTreeSetNodeMax(int, struct RTree *);
extern int RTreeSetLeafMax(int, struct RTree *);
extern int RTreeGetNodeMax(struct RTree *);
extern int RTreeGetLeafMax(struct RTree *);
/* fileio.c */
-extern void RTreeGetNode(struct Node *, off_t, int, struct RTree *);
-extern size_t RTreeReadNode(struct Node *, off_t, struct RTree *);
-extern void RTreePutNode(struct Node *, off_t, struct RTree *);
-extern size_t RTreeWriteNode(struct Node *, struct RTree *);
-extern size_t RTreeRewriteNode(struct Node *, off_t, struct RTree *);
-extern void RTreeUpdateRect(struct Rect *, struct Node *, off_t, int, struct RTree *);
+extern void RTreeGetNode(struct RTree_Node *, off_t, int, struct RTree *);
+extern size_t RTreeReadNode(struct RTree_Node *, off_t, struct RTree *);
+extern void RTreePutNode(struct RTree_Node *, off_t, struct RTree *);
+extern size_t RTreeWriteNode(struct RTree_Node *, struct RTree *);
+extern size_t RTreeRewriteNode(struct RTree_Node *, off_t, struct RTree *);
+extern void RTreeUpdateRect(struct RTree_Rect *, struct RTree_Node *, off_t, int, struct RTree *);
extern void RTreeAddNodePos(off_t, int, struct RTree *);
extern off_t RTreeGetNodePos(struct RTree *);
extern void RTreeFlushBuffer(struct RTree *);
Modified: grass/trunk/lib/vector/rtree/indexf.c
===================================================================
--- grass/trunk/lib/vector/rtree/indexf.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/indexf.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -29,12 +29,12 @@
/* stack used for non-recursive insertion/deletion */
struct fstack
{
- struct Node sn; /* stack node */
+ struct RTree_Node sn; /* stack node */
int branch_id; /* branch no to follow down */
off_t pos; /* file position of stack node */
};
-int RTreeValidChildF(union Child *child)
+int RTreeValidChildF(union RTree_Child *child)
{
return (child->pos > -1);
}
@@ -44,10 +44,10 @@
* overlap the argument rectangle.
* Return the number of qualifying data rects.
*/
-int RTreeSearchF(struct RTree *t, struct Rect *r,
+int RTreeSearchF(struct RTree *t, struct RTree_Rect *r,
SearchHitCallback *shcb, void *cbarg)
{
- struct Node *n;
+ struct RTree_Node *n;
int hitCount = 0, found, currlevel;
int i;
struct fstack s[MAXLEVEL];
@@ -115,15 +115,15 @@
* The level argument specifies the number of steps up from the leaf
* level to insert; e.g. a data rectangle goes in at level = 0.
*/
-static int RTreeInsertRect2F(struct Rect *r, union Child child, int level,
- struct Node *newnode, off_t *newnode_pos,
+static int RTreeInsertRect2F(struct RTree_Rect *r, union RTree_Child child, int level,
+ struct RTree_Node *newnode, off_t *newnode_pos,
struct RTree *t,
- struct ListBranch **ee, int *overflow)
+ struct RTree_ListBranch **ee, int *overflow)
{
int i, currlevel;
- struct Branch b;
- struct Rect nr, *cover;
- struct Node *n, *n2, nn;
+ struct RTree_Branch b;
+ struct RTree_Rect nr, *cover;
+ struct RTree_Node *n, *n2, nn;
struct fstack s[MAXLEVEL];
int top = 0, down = 0;
int result;
@@ -230,12 +230,12 @@
* level to insert; e.g. a data rectangle goes in at level = 0.
* RTreeInsertRect2 does the actual insertion.
*/
-int RTreeInsertRectF(struct Rect *r, union Child child, int level,
+int RTreeInsertRectF(struct RTree_Rect *r, union RTree_Child child, int level,
struct RTree *t)
{
- struct Node oldroot, newroot, newnode;
- struct Branch b;
- struct ListBranch *e, *reInsertList = NULL;
+ struct RTree_Node oldroot, newroot, newnode;
+ struct RTree_Branch b;
+ struct RTree_ListBranch *e, *reInsertList = NULL;
int result;
int i, overflow[MAXLEVEL];
off_t newnode_pos = -1;
@@ -312,12 +312,12 @@
* Returns 1 if record not found, 0 if success.
*/
static int
-RTreeDeleteRect2F(struct Rect *r, union Child child, struct RTree *t,
- struct ListNode **ee)
+RTreeDeleteRect2F(struct RTree_Rect *r, union RTree_Child child, struct RTree *t,
+ struct RTree_ListNode **ee)
{
int i, notfound = 1, currlevel;
- struct Node *n;
- struct Rect nr;
+ struct RTree_Node *n;
+ struct RTree_Rect nr;
struct fstack s[MAXLEVEL];
int top = 0, down = 0;
int minfill;
@@ -414,11 +414,11 @@
* Returns 1 if record not found, 0 if success.
* RTreeDeleteRect1 provides for eliminating the root.
*/
-int RTreeDeleteRectF(struct Rect *r, union Child child, struct RTree *t)
+int RTreeDeleteRectF(struct RTree_Rect *r, union RTree_Child child, struct RTree *t)
{
int i;
- struct Node *n, rn;
- struct ListNode *e, *reInsertList = NULL;
+ struct RTree_Node *n, rn;
+ struct RTree_ListNode *e, *reInsertList = NULL;
if (!RTreeDeleteRect2F(r, child, t, &reInsertList)) {
/* found and deleted a data item */
Modified: grass/trunk/lib/vector/rtree/indexm.c
===================================================================
--- grass/trunk/lib/vector/rtree/indexm.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/indexm.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -25,11 +25,11 @@
/* stack used for non-recursive insertion/deletion */
struct stack
{
- struct Node *sn; /* stack node */
+ struct RTree_Node *sn; /* stack node */
int branch_id; /* branch no to follow down */
};
-int RTreeValidChildM(union Child *child)
+int RTreeValidChildM(union RTree_Child *child)
{
return (child->ptr != NULL);
}
@@ -39,10 +39,10 @@
* overlap the argument rectangle.
* Return the number of qualifying data rects.
*/
-int RTreeSearchM(struct RTree *t, struct Rect *r,
+int RTreeSearchM(struct RTree *t, struct RTree_Rect *r,
SearchHitCallback *shcb, void *cbarg)
{
- struct Node *n;
+ struct RTree_Node *n;
int hitCount = 0, found;
int i;
struct stack s[MAXLEVEL];
@@ -107,15 +107,15 @@
* The level argument specifies the number of steps up from the leaf
* level to insert; e.g. a data rectangle goes in at level = 0.
*/
-static int RTreeInsertRect2M(struct Rect *r, union Child child, int level,
- struct Node **newnode,
+static int RTreeInsertRect2M(struct RTree_Rect *r, union RTree_Child child, int level,
+ struct RTree_Node **newnode,
struct RTree *t,
- struct ListBranch **ee, int *overflow)
+ struct RTree_ListBranch **ee, int *overflow)
{
int i;
- struct Branch b;
- struct Node *n, *n2;
- struct Rect *cover;
+ struct RTree_Branch b;
+ struct RTree_Node *n, *n2;
+ struct RTree_Rect *cover;
struct stack s[MAXLEVEL];
int top = 0, down = 0;
int result;
@@ -201,14 +201,13 @@
* level to insert; e.g. a data rectangle goes in at level = 0.
* RTreeInsertRect2 does the actual insertion.
*/
-int RTreeInsertRectM(struct Rect *r, union Child child, int level,
+int RTreeInsertRectM(struct RTree_Rect *r, union RTree_Child child, int level,
struct RTree *t)
{
- struct Node *newnode;
- struct Node *newroot;
- struct Branch b;
- struct ListBranch *reInsertList = NULL;
- struct ListBranch *e;
+ struct RTree_Node *newnode, *newroot;
+ struct RTree_Branch b;
+ struct RTree_ListBranch *reInsertList = NULL;
+ struct RTree_ListBranch *e;
int result;
int i, overflow[MAXLEVEL];
@@ -280,11 +279,11 @@
* Returns 1 if record not found, 0 if success.
*/
static int
-RTreeDeleteRect2M(struct Rect *r, union Child child, struct RTree *t,
- struct ListNode **ee)
+RTreeDeleteRect2M(struct RTree_Rect *r, union RTree_Child child, struct RTree *t,
+ struct RTree_ListNode **ee)
{
int i, notfound = 1;
- struct Node *n;
+ struct RTree_Node *n;
struct stack s[MAXLEVEL];
int top = 0, down = 0;
int minfill;
@@ -369,12 +368,12 @@
* Returns 1 if record not found, 0 if success.
* RTreeDeleteRect1 provides for eliminating the root.
*/
-int RTreeDeleteRectM(struct Rect *r, union Child child, struct RTree *t)
+int RTreeDeleteRectM(struct RTree_Rect *r, union RTree_Child child, struct RTree *t)
{
int i;
- struct Node *n;
- struct ListNode *reInsertList = NULL;
- struct ListNode *e;
+ struct RTree_Node *n;
+ struct RTree_ListNode *reInsertList = NULL;
+ struct RTree_ListNode *e;
if (!RTreeDeleteRect2M(r, child, t, &reInsertList)) {
/* found and deleted a data item */
Modified: grass/trunk/lib/vector/rtree/io.c
===================================================================
--- grass/trunk/lib/vector/rtree/io.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/io.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -68,14 +68,14 @@
}
/* read node from file */
-size_t RTreeReadNode(struct Node *n, off_t nodepos, struct RTree *t)
+size_t RTreeReadNode(struct RTree_Node *n, off_t nodepos, struct RTree *t)
{
lseek(t->fd, nodepos, SEEK_SET);
return read(t->fd, n, t->nodesize);
}
/* get node from buffer or file */
-void RTreeGetNode(struct Node *n, off_t nodepos, int level, struct RTree *t)
+void RTreeGetNode(struct RTree_Node *n, off_t nodepos, int level, struct RTree *t)
{
int which = (nodepos == t->nb[level][2].pos ? 2 : nodepos == t->nb[level][1].pos);
@@ -104,21 +104,21 @@
}
/* write new node to file */
-size_t RTreeWriteNode(struct Node *n, struct RTree *t)
+size_t RTreeWriteNode(struct RTree_Node *n, struct RTree *t)
{
/* file position must be set first with RTreeGetFNodePos() */
return write(t->fd, n, t->nodesize);
}
/* rewrite updated node to file */
-size_t RTreeRewriteNode(struct Node *n, off_t nodepos, struct RTree *t)
+size_t RTreeRewriteNode(struct RTree_Node *n, off_t nodepos, struct RTree *t)
{
lseek(t->fd, nodepos, SEEK_SET);
return write(t->fd, n, t->nodesize);
}
/* update node in buffer */
-void RTreePutNode(struct Node *n, off_t nodepos, struct RTree *t)
+void RTreePutNode(struct RTree_Node *n, off_t nodepos, struct RTree *t)
{
int which = (nodepos == t->nb[n->level][2].pos ? 2 : nodepos == t->nb[n->level][1].pos);
@@ -138,7 +138,7 @@
}
/* update rectangle */
-void RTreeUpdateRect(struct Rect *r, struct Node *n, off_t nodepos, int b, struct RTree *t)
+void RTreeUpdateRect(struct RTree_Rect *r, struct RTree_Node *n, off_t nodepos, int b, struct RTree *t)
{
int which = (nodepos == t->nb[n->level][2].pos ? 2 : nodepos == t->nb[n->level][1].pos);
Modified: grass/trunk/lib/vector/rtree/node.c
===================================================================
--- grass/trunk/lib/vector/rtree/node.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/node.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -31,21 +31,21 @@
};
/* Initialize one branch cell in an internal node. */
-static void RTreeInitNodeBranchM(struct Branch *b)
+static void RTreeInitNodeBranchM(struct RTree_Branch *b)
{
RTreeInitRect(&(b->rect));
b->child.ptr = NULL;
}
/* Initialize one branch cell in an internal node. */
-static void RTreeInitNodeBranchF(struct Branch *b)
+static void RTreeInitNodeBranchF(struct RTree_Branch *b)
{
RTreeInitRect(&(b->rect));
b->child.pos = -1;
}
/* Initialize one branch cell in a leaf node. */
-static void RTreeInitLeafBranch(struct Branch *b)
+static void RTreeInitLeafBranch(struct RTree_Branch *b)
{
RTreeInitRect(&(b->rect));
b->child.id = 0;
@@ -57,7 +57,7 @@
/* Initialize a Node structure. */
/* type = 1: leaf, type = 2: internal, memory, type = 3: internal, file */
-void RTreeInitNode(struct Node *n, int type)
+void RTreeInitNode(struct RTree_Node *n, int type)
{
int i;
@@ -69,17 +69,17 @@
}
/* Make a new node and initialize to have all branch cells empty. */
-struct Node *RTreeNewNode(struct RTree *t, int level)
+struct RTree_Node *RTreeNewNode(struct RTree *t, int level)
{
- struct Node *n;
+ struct RTree_Node *n;
- n = (struct Node *)malloc((size_t) t->nodesize);
+ n = (struct RTree_Node *)malloc((size_t) t->nodesize);
assert(n);
RTreeInitNode(n, NODETYPE(level, t->fd));
return n;
}
-void RTreeFreeNode(struct Node *n)
+void RTreeFreeNode(struct RTree_Node *n)
{
assert(n);
free(n);
@@ -89,10 +89,10 @@
* Find the smallest rectangle that includes all rectangles in
* branches of a node.
*/
-struct Rect RTreeNodeCover(struct Node *n, struct RTree *t)
+struct RTree_Rect RTreeNodeCover(struct RTree_Node *n, struct RTree *t)
{
int i, first_time = 1;
- struct Rect r;
+ struct RTree_Rect r;
RTreeInitRect(&r);
if ((n)->level > 0) { /* internal node */
@@ -134,13 +134,13 @@
* to get the best resolution when searching.
*/
-static int RTreePickLeafBranch(struct Rect *r, struct Node *n, struct RTree *t)
+static int RTreePickLeafBranch(struct RTree_Rect *r, struct RTree_Node *n, struct RTree *t)
{
- struct Rect *rr;
+ struct RTree_Rect *rr;
int i, j;
RectReal increase, bestIncr = -1, area, bestArea = 0;
int best = 0, bestoverlap;
- struct Rect tmp_rect;
+ struct RTree_Rect tmp_rect;
int overlap;
bestoverlap = t->nodecard + 1;
@@ -193,13 +193,13 @@
* In case of a tie, pick the one which was smaller before, to get
* the best resolution when searching.
*/
-int RTreePickBranch(struct Rect *r, struct Node *n, struct RTree *t)
+int RTreePickBranch(struct RTree_Rect *r, struct RTree_Node *n, struct RTree *t)
{
- struct Rect *rr;
+ struct RTree_Rect *rr;
int i, first_time = 1;
RectReal increase, bestIncr = (RectReal) -1, area, bestArea = 0;
int best = 0;
- struct Rect tmp_rect;
+ struct RTree_Rect tmp_rect;
assert((n)->level > 0); /* must not be called on leaf node */
@@ -228,7 +228,7 @@
}
/* Disconnect a dependent node. */
-void RTreeDisconnectBranch(struct Node *n, int i, struct RTree *t)
+void RTreeDisconnectBranch(struct RTree_Node *n, int i, struct RTree *t)
{
if ((n)->level > 0) {
assert(n && i >= 0 && i < t->nodecard);
@@ -249,7 +249,7 @@
/* Destroy (free) node recursively. */
/* NOTE: only needed for memory based index */
-void RTreeDestroyNode(struct Node *n, int nodes)
+void RTreeDestroyNode(struct RTree_Node *n, int nodes)
{
int i;
@@ -398,19 +398,19 @@
* Allocate space for a branch in the list used in InsertRect to
* store branches of nodes that are too full.
*/
-static struct ListBranch *RTreeNewListBranch(void)
+static struct RTree_ListBranch *RTreeNewListBranch(void)
{
- return (struct ListBranch *)malloc(sizeof(struct ListBranch));
+ return (struct RTree_ListBranch *)malloc(sizeof(struct RTree_ListBranch));
}
/*
* Add a branch to the reinsertion list. It will later
* be reinserted into the index structure.
*/
-static void RTreeReInsertBranch(struct Branch b, int level,
- struct ListBranch **ee)
+static void RTreeReInsertBranch(struct RTree_Branch b, int level,
+ struct RTree_ListBranch **ee)
{
- register struct ListBranch *l;
+ register struct RTree_ListBranch *l;
l = RTreeNewListBranch();
l->b = b;
@@ -424,15 +424,15 @@
* center is farthest away from node cover center.
* Old node updated.
*/
-static void RTreeRemoveBranches(struct Node *n, struct Branch *b,
- struct ListBranch **ee, struct Rect *cover,
+static void RTreeRemoveBranches(struct RTree_Node *n, struct RTree_Branch *b,
+ struct RTree_ListBranch **ee, struct RTree_Rect *cover,
struct RTree *t)
{
int i, j, maxkids, type;
RectReal center_n[NUMDIMS], center_r, delta;
- struct Branch branchbuf[MAXCARD + 1];
+ struct RTree_Branch branchbuf[MAXCARD + 1];
struct dist rdist[MAXCARD + 1];
- struct Rect new_cover;
+ struct RTree_Rect new_cover;
assert(cover);
@@ -497,9 +497,9 @@
* Old node updated, becomes one of two.
* Returns 2 if branches were removed for forced reinsertion
*/
-int RTreeAddBranch(struct Branch *b, struct Node *n,
- struct Node **newnode, struct ListBranch **ee,
- struct Rect *cover, int *overflow, struct RTree *t)
+int RTreeAddBranch(struct RTree_Branch *b, struct RTree_Node *n,
+ struct RTree_Node **newnode, struct RTree_ListBranch **ee,
+ struct RTree_Rect *cover, int *overflow, struct RTree *t)
{
int i, maxkids;
@@ -561,14 +561,14 @@
putchar('\t');
}
-static void RTreePrintBranch(struct Branch *b, int depth, struct RTree *t)
+static void RTreePrintBranch(struct RTree_Branch *b, int depth, struct RTree *t)
{
RTreePrintRect(&(b->rect), depth);
RTreePrintNode(b->child.ptr, depth, t);
}
/* Print out the data in a node. */
-void RTreePrintNode(struct Node *n, int depth, struct RTree *t)
+void RTreePrintNode(struct RTree_Node *n, int depth, struct RTree *t)
{
int i, maxkids;
Modified: grass/trunk/lib/vector/rtree/rect.c
===================================================================
--- grass/trunk/lib/vector/rtree/rect.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/rect.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -35,9 +35,9 @@
/*-----------------------------------------------------------------------------
| Initialize a rectangle to have all 0 coordinates.
-----------------------------------------------------------------------------*/
-void RTreeInitRect(struct Rect *R)
+void RTreeInitRect(struct RTree_Rect *R)
{
- register struct Rect *r = R;
+ register struct RTree_Rect *r = R;
register int i;
for (i = 0; i < NUMSIDES; i++)
@@ -49,9 +49,9 @@
| Return a rect whose first low side is higher than its opposite side -
| interpreted as an undefined rect.
-----------------------------------------------------------------------------*/
-struct Rect RTreeNullRect(void)
+struct RTree_Rect RTreeNullRect(void)
{
- struct Rect r;
+ struct RTree_Rect r;
register int i;
r.boundary[0] = (RectReal) 1;
@@ -68,9 +68,9 @@
| Fills in random coordinates in a rectangle.
| The low side is guaranteed to be less than the high side.
-----------------------------------------------------------------------------*/
-void RTreeRandomRect(struct Rect *R)
+void RTreeRandomRect(struct RTree_Rect *R)
{
- register struct Rect *r = R;
+ register struct RTree_Rect *r = R;
register int i;
register RectReal width;
@@ -95,9 +95,9 @@
| and has size from 0 to the size of the data area in each dimension,
| i.e. search rect can stick out beyond data area.
-----------------------------------------------------------------------------*/
-void RTreeSearchRect(struct Rect *Search, struct Rect *Data)
+void RTreeSearchRect(struct RTree_Rect *Search, struct RTree_Rect *Data)
{
- register struct Rect *search = Search, *data = Data;
+ register struct RTree_Rect *search = Search, *data = Data;
register int i, j;
register RectReal size, center;
@@ -127,9 +127,9 @@
/*-----------------------------------------------------------------------------
| Print out the data for a rectangle.
-----------------------------------------------------------------------------*/
-void RTreePrintRect(struct Rect *R, int depth)
+void RTreePrintRect(struct RTree_Rect *R, int depth)
{
- register struct Rect *r = R;
+ register struct RTree_Rect *r = R;
register int i;
assert(r);
@@ -145,9 +145,9 @@
/*-----------------------------------------------------------------------------
| Calculate the n-dimensional volume of a rectangle
-----------------------------------------------------------------------------*/
-RectReal RTreeRectVolume(struct Rect *R, struct RTree *t)
+RectReal RTreeRectVolume(struct RTree_Rect *R, struct RTree *t)
{
- register struct Rect *r = R;
+ register struct RTree_Rect *r = R;
register int i;
register RectReal volume = (RectReal) 1;
@@ -229,9 +229,9 @@
* A fast approximation to the volume of the bounding sphere for the
* given Rect. By Paul B.
*/
-RectReal RTreeRectSphericalVolume(struct Rect *R, struct RTree *t)
+RectReal RTreeRectSphericalVolume(struct RTree_Rect *R, struct RTree *t)
{
- register struct Rect *r = R;
+ register struct RTree_Rect *r = R;
register int i;
RectReal maxsize = (RectReal) 0, c_size;
@@ -251,7 +251,7 @@
/*
* The exact volume of the bounding sphere for the given Rect.
*/
-RectReal RTreeRectSphericalVolume(struct Rect *r, struct RTree *t)
+RectReal RTreeRectSphericalVolume(struct RTree_Rect *r, struct RTree *t)
{
int i;
double sum_of_squares = 0, radius, half_extent;
@@ -272,7 +272,7 @@
/*-----------------------------------------------------------------------------
| Calculate the n-dimensional surface area of a rectangle
-----------------------------------------------------------------------------*/
-RectReal RTreeRectSurfaceArea(struct Rect *r, struct RTree *t)
+RectReal RTreeRectSurfaceArea(struct RTree_Rect *r, struct RTree *t)
{
int i, j;
RectReal j_extent, sum = (RectReal) 0;
@@ -301,7 +301,7 @@
| Calculate the n-dimensional margin of a rectangle
| the margin is the sum of the lengths of the edges
-----------------------------------------------------------------------------*/
-RectReal RTreeRectMargin(struct Rect *r, struct RTree *t)
+RectReal RTreeRectMargin(struct RTree_Rect *r, struct RTree *t)
{
int i;
RectReal margin = 0.0;
@@ -319,10 +319,10 @@
/*-----------------------------------------------------------------------------
| Combine two rectangles, make one that includes both.
-----------------------------------------------------------------------------*/
-struct Rect RTreeCombineRect(struct Rect *r, struct Rect *rr, struct RTree *t)
+struct RTree_Rect RTreeCombineRect(struct RTree_Rect *r, struct RTree_Rect *rr, struct RTree *t)
{
int i, j;
- struct Rect new_rect;
+ struct RTree_Rect new_rect;
assert(r && rr);
@@ -352,7 +352,7 @@
/*-----------------------------------------------------------------------------
| Decide whether two rectangles are identical.
-----------------------------------------------------------------------------*/
-int RTreeCompareRect(struct Rect *r, struct Rect *s, struct RTree *t)
+int RTreeCompareRect(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
{
register int i, j;
@@ -372,7 +372,7 @@
/*-----------------------------------------------------------------------------
| Decide whether two rectangles overlap.
-----------------------------------------------------------------------------*/
-int RTreeOverlap(struct Rect *r, struct Rect *s, struct RTree *t)
+int RTreeOverlap(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
{
register int i, j;
@@ -392,7 +392,7 @@
/*-----------------------------------------------------------------------------
| Decide whether rectangle r is contained in rectangle s.
-----------------------------------------------------------------------------*/
-int RTreeContained(struct Rect *r, struct Rect *s, struct RTree *t)
+int RTreeContained(struct RTree_Rect *r, struct RTree_Rect *s, struct RTree *t)
{
register int i, j, result;
Modified: grass/trunk/lib/vector/rtree/split.c
===================================================================
--- grass/trunk/lib/vector/rtree/split.c 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/split.c 2011-07-03 17:56:34 UTC (rev 46939)
@@ -28,18 +28,18 @@
#define DBL_MAX 1.797693E308 /* DBL_MAX approximation */
#endif
-struct Branch BranchBuf[MAXCARD + 1];
+struct RTree_Branch BranchBuf[MAXCARD + 1];
int BranchCount;
-struct Rect CoverSplit;
+struct RTree_Rect CoverSplit;
RectReal CoverSplitArea;
/* variables for finding a partition */
-struct PartitionVars Partitions[1];
+struct RTree_PartitionVars Partitions[1];
/*----------------------------------------------------------------------
| Load branch buffer with branches from full node plus the extra branch.
----------------------------------------------------------------------*/
-static void RTreeGetBranches(struct Node *n, struct Branch *b,
+static void RTreeGetBranches(struct RTree_Node *n, struct RTree_Branch *b,
struct RTree *t)
{
int i, maxkids = 0;
@@ -79,7 +79,7 @@
/*----------------------------------------------------------------------
| Put a branch in one of the groups.
----------------------------------------------------------------------*/
-static void RTreeClassify(int i, int group, struct PartitionVars *p,
+static void RTreeClassify(int i, int group, struct RTree_PartitionVars *p,
struct RTree *t)
{
assert(!p->taken[i]);
@@ -109,7 +109,7 @@
| Pick the two that waste the most area if covered by a single
| rectangle.
----------------------------------------------------------------------*/
-static void RTreePickSeeds(struct PartitionVars *p, struct RTree *t)
+static void RTreePickSeeds(struct RTree_PartitionVars *p, struct RTree *t)
{
int i, j, seed0 = 0, seed1 = 0;
RectReal worst, waste, area[MAXCARD + 1];
@@ -120,7 +120,7 @@
worst = -CoverSplitArea - 1;
for (i = 0; i < p->total - 1; i++) {
for (j = i + 1; j < p->total; j++) {
- struct Rect one_rect;
+ struct RTree_Rect one_rect;
one_rect = RTreeCombineRect(&BranchBuf[i].rect,
&BranchBuf[j].rect, t);
@@ -141,8 +141,8 @@
| Copy branches from the buffer into two nodes according to the
| partition.
----------------------------------------------------------------------*/
-static void RTreeLoadNodes(struct Node *n, struct Node *q,
- struct PartitionVars *p, struct RTree *t)
+static void RTreeLoadNodes(struct RTree_Node *n, struct RTree_Node *q,
+ struct RTree_PartitionVars *p, struct RTree *t)
{
int i;
@@ -158,7 +158,7 @@
/*----------------------------------------------------------------------
| Initialize a PartitionVars structure.
----------------------------------------------------------------------*/
-void RTreeInitPVars(struct PartitionVars *p, int maxrects, int minfill)
+void RTreeInitPVars(struct RTree_PartitionVars *p, int maxrects, int minfill)
{
int i;
@@ -177,7 +177,7 @@
| Print out data for a partition from PartitionVars struct.
| Unused, for debugging only
----------------------------------------------------------------------*/
-static void RTreePrintPVars(struct PartitionVars *p)
+static void RTreePrintPVars(struct RTree_PartitionVars *p)
{
int i;
@@ -226,7 +226,7 @@
| group to violate min fill requirement) then other group gets the rest.
| These last are the ones that can go in either group most easily.
----------------------------------------------------------------------*/
-static void RTreeMethodZero(struct PartitionVars *p, int minfill,
+static void RTreeMethodZero(struct RTree_PartitionVars *p, int minfill,
struct RTree *t)
{
int i;
@@ -242,7 +242,7 @@
biggestDiff = (RectReal) - 1.;
for (i = 0; i < p->total; i++) {
if (!p->taken[i]) {
- struct Rect *r, rect_0, rect_1;
+ struct RTree_Rect *r, rect_0, rect_1;
RectReal growth0, growth1, diff;
r = &BranchBuf[i].rect;
@@ -298,9 +298,9 @@
/*----------------------------------------------------------------------
| swap branches
----------------------------------------------------------------------*/
-static void RTreeSwapBranches(struct Branch *a, struct Branch *b)
+static void RTreeSwapBranches(struct RTree_Branch *a, struct RTree_Branch *b)
{
- struct Branch c;
+ struct RTree_Branch c;
c = *a;
*a = *b;
@@ -313,7 +313,7 @@
| return 0 if a == b
| return -1 if a < b
----------------------------------------------------------------------*/
-static int RTreeCompareBranches(struct Branch *a, struct Branch *b, int side)
+static int RTreeCompareBranches(struct RTree_Branch *a, struct RTree_Branch *b, int side)
{
if (a->rect.boundary[side] > b->rect.boundary[side])
return 1;
@@ -450,14 +450,14 @@
| fill requirement) then other group gets the rest.
| These last are the ones that can go in either group most easily.
----------------------------------------------------------------------*/
-static void RTreeMethodOne(struct PartitionVars *p, int minfill,
+static void RTreeMethodOne(struct RTree_PartitionVars *p, int minfill,
int maxkids, struct RTree *t)
{
int i, j, k, l, s;
int axis = 0, best_axis = 0, side = 0, best_side[NUMDIMS];
int best_cut[NUMDIMS];
RectReal margin, smallest_margin = 0;
- struct Rect *r1, *r2, testrect1, testrect2, upperrect, orect;
+ struct RTree_Rect *r1, *r2, testrect1, testrect2, upperrect, orect;
int minfill1 = minfill - 1;
RectReal overlap, vol, smallest_overlap = -1, smallest_vol = -1;
@@ -591,10 +591,10 @@
| Old node is one of the new ones, and one really new one is created.
| May use quadratic split or R*-tree split.
----------------------------------------------------------------------*/
-void RTreeSplitNode(struct Node *n, struct Branch *b, struct Node *nn,
- struct RTree *t)
+void RTreeSplitNode(struct RTree_Node *n, struct RTree_Branch *b,
+ struct RTree_Node *nn, struct RTree *t)
{
- struct PartitionVars *p;
+ struct RTree_PartitionVars *p;
int level;
/* load all the branches into a buffer, initialize old node */
Modified: grass/trunk/lib/vector/rtree/split.h
===================================================================
--- grass/trunk/lib/vector/rtree/split.h 2011-07-03 17:00:20 UTC (rev 46938)
+++ grass/trunk/lib/vector/rtree/split.h 2011-07-03 17:56:34 UTC (rev 46939)
@@ -24,21 +24,21 @@
/* METHOD 1: R*-Tree split */
#define METHOD 1
-struct PartitionVars {
+struct RTree_PartitionVars {
int partition[MAXCARD + 1];
int total, minfill;
int taken[MAXCARD + 1];
int count[2];
- struct Rect cover[2];
+ struct RTree_Rect cover[2];
RectReal area[2];
};
-extern struct Branch BranchBuf[MAXCARD + 1];
+extern struct RTree_Branch BranchBuf[MAXCARD + 1];
extern int BranchCount;
-extern struct Rect CoverSplit;
+extern struct RTree_Rect CoverSplit;
extern RectReal CoverSplitArea;
/* variables for finding a partition */
-extern struct PartitionVars Partitions[1];
+extern struct RTree_PartitionVars Partitions[1];
-extern void RTreeInitPVars(struct PartitionVars *, int, int);
+extern void RTreeInitPVars(struct RTree_PartitionVars *, int, int);
More information about the grass-commit
mailing list