[GRASS-SVN] r53769 - grass/trunk/lib/vector/rtree
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Nov 11 10:43:43 PST 2012
Author: mmetz
Date: 2012-11-11 10:43:43 -0800 (Sun, 11 Nov 2012)
New Revision: 53769
Modified:
grass/trunk/lib/vector/rtree/index.c
grass/trunk/lib/vector/rtree/indexf.c
grass/trunk/lib/vector/rtree/indexm.c
grass/trunk/lib/vector/rtree/rtree.h
Log:
rtree: add option to fine-tune rtree creation
Modified: grass/trunk/lib/vector/rtree/index.c
===================================================================
--- grass/trunk/lib/vector/rtree/index.c 2012-11-10 23:35:30 UTC (rev 53768)
+++ grass/trunk/lib/vector/rtree/index.c 2012-11-11 18:43:43 UTC (rev 53769)
@@ -95,6 +95,9 @@
n = RTreeAllocNode(new_rtree, 0);
new_rtree->rootlevel = n->level = 0; /* leaf */
new_rtree->root = NULL;
+
+ /* use overflow by default */
+ new_rtree->overflow = 1;
if (fd > -1) { /* file based */
/* nodecard and leafcard can be adjusted, must NOT be larger than MAXCARD */
@@ -182,6 +185,24 @@
}
/*!
+ \brief Enable/disable R*-tree forced reinsertion (overflow)
+
+ For dynamic R*-trees with runtime insertion and deletion,
+ forced reinsertion results in a more compact tree, searches are a bit
+ faster. For static R*-trees (no insertion/deletion after creation)
+ forced reinsertion can be disabled at the cost of slower searches.
+
+ \param t pointer to RTree structure
+ \param overflow binary flag
+
+ \return nothing
+*/
+void RTreeSetOverflow(struct RTree *t, char overflow)
+{
+ t->overflow = overflow != 0;
+}
+
+/*!
\brief Destroy an R*-Tree
This method releases all memory allocated to a RTree. It deletes all
Modified: grass/trunk/lib/vector/rtree/indexf.c
===================================================================
--- grass/trunk/lib/vector/rtree/indexf.c 2012-11-10 23:35:30 UTC (rev 53768)
+++ grass/trunk/lib/vector/rtree/indexf.c 2012-11-11 18:43:43 UTC (rev 53769)
@@ -248,7 +248,7 @@
}
/* R*-tree forced reinsertion: for each level only once */
- memset(overflow, 1, MAXLEVEL);
+ memset(overflow, t->overflow, MAXLEVEL);
result =
RTreeInsertRect2F(r, child, level, &newnode, &newnode_pos, t,
Modified: grass/trunk/lib/vector/rtree/indexm.c
===================================================================
--- grass/trunk/lib/vector/rtree/indexm.c 2012-11-10 23:35:30 UTC (rev 53768)
+++ grass/trunk/lib/vector/rtree/indexm.c 2012-11-11 18:43:43 UTC (rev 53769)
@@ -195,7 +195,7 @@
struct RTree_Branch *b = &(t->tmpb1);
/* R*-tree forced reinsertion: for each level only once */
- memset(overflow, 1, MAXLEVEL);
+ memset(overflow, t->overflow, MAXLEVEL);
result =
RTreeInsertRect2M(r, child, level, &newnode, t, &reInsertList,
Modified: grass/trunk/lib/vector/rtree/rtree.h
===================================================================
--- grass/trunk/lib/vector/rtree/rtree.h 2012-11-10 23:35:30 UTC (rev 53768)
+++ grass/trunk/lib/vector/rtree/rtree.h 2012-11-11 18:43:43 UTC (rev 53769)
@@ -145,6 +145,7 @@
int min_leaf_fill; /* balance criteria for leaf removal */
int minfill_node_split; /* balance criteria for splitting */
int minfill_leaf_split; /* balance criteria for splitting */
+ char overflow; /* enable/disable overflow */
/* free node positions for recycling */
struct _recycle {
@@ -211,6 +212,7 @@
int RTreeDeleteRect(struct RTree_Rect *, int, struct RTree *);
void RTreePrintRect(struct RTree_Rect *, int, struct RTree *);
struct RTree *RTreeCreateTree(int, off_t, int);
+void RTreeSetOverflow(struct RTree *, char);
void RTreeDestroyTree(struct RTree *);
int RTreeOverlap(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
int RTreeContained(struct RTree_Rect *, struct RTree_Rect *, struct RTree *);
More information about the grass-commit
mailing list