Classes | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
RStarTree< LeafType, dimensions, min_child_items, max_child_items > Class Template Reference

Implementation of an RTree with an R* index. More...

#include <RStarTree.h>

Classes

struct  QueryFunctor
 
struct  RemoveFunctor
 
struct  RemoveLeafFunctor
 
struct  VisitFunctor
 

Public Types

typedef RStarBoundedItem< dimensions > BoundedItem
 
typedef BoundedItem::BoundingBox BoundingBox
 
typedef RStarNode< BoundedItemNode
 
typedef RStarLeaf< BoundedItem, LeafType > Leaf
 
typedef RStarAcceptOverlapping< Node, LeafAcceptOverlapping
 
typedef RStarAcceptEnclosing< Node, LeafAcceptEnclosing
 
typedef RStarAcceptAny< Node, LeafAcceptAny
 
typedef RStarRemoveLeaf< LeafRemoveLeaf
 
typedef RStarRemoveSpecificLeaf< LeafRemoveSpecificLeaf
 

Public Member Functions

 RStarTree ()
 
 ~RStarTree ()
 
void Insert (LeafType leaf, const BoundingBox &bound)
 
template<typename Acceptor , typename Visitor >
Visitor Query (const Acceptor &accept, Visitor visitor)
 Touches each node using the visitor pattern. More...
 
template<typename Acceptor , typename LeafRemover >
void Remove (const Acceptor &accept, LeafRemover leafRemover)
 Removes item(s) from the tree. More...
 
void RemoveBoundedArea (const BoundingBox &bound)
 
void RemoveItem (const LeafType &item, bool removeDuplicates=true)
 
std::size_t GetSize () const
 
std::size_t GetDimensions () const
 

Protected Member Functions

NodeChooseSubtree (Node *node, const BoundingBox *bound)
 
NodeInsertInternal (Leaf *leaf, Node *node, bool firstInsert=true)
 
NodeOverflowTreatment (Node *level, bool firstInsert)
 
NodeSplit (Node *node)
 
void Reinsert (Node *node)
 

Private Attributes

Nodem_root
 
std::size_t m_size
 

Detailed Description

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
class RStarTree< LeafType, dimensions, min_child_items, max_child_items >

Implementation of an RTree with an R* index.

Template Parameters
LeafTypetype of leaves stored in the tree
dimensionsnumber of dimensions the bounding boxes are described in
min_child_itemsm, in the range 2 <= m < M
max_child_itemsM, in the range 2 <= m < M
RemoveLeafA functor used to remove leaves from the tree

Definition at line 87 of file RStarTree.h.

Member Typedef Documentation

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarAcceptAny<Node, Leaf> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::AcceptAny

Definition at line 100 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarAcceptEnclosing<Node, Leaf> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::AcceptEnclosing

Definition at line 99 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarAcceptOverlapping<Node, Leaf> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::AcceptOverlapping

Definition at line 98 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarBoundedItem<dimensions> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::BoundedItem

Definition at line 91 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef BoundedItem::BoundingBox RStarTree< LeafType, dimensions, min_child_items, max_child_items >::BoundingBox

Definition at line 92 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarLeaf<BoundedItem, LeafType> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Leaf

Definition at line 95 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarNode<BoundedItem> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Node

Definition at line 94 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarRemoveLeaf<Leaf> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::RemoveLeaf

Definition at line 103 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
typedef RStarRemoveSpecificLeaf<Leaf> RStarTree< LeafType, dimensions, min_child_items, max_child_items >::RemoveSpecificLeaf

Definition at line 104 of file RStarTree.h.

Constructor & Destructor Documentation

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
RStarTree< LeafType, dimensions, min_child_items, max_child_items >::RStarTree ( )
inline

Definition at line 110 of file RStarTree.h.

110  : m_root(NULL), m_size(0)
111  {
112  }
Node * m_root
Definition: RStarTree.h:759
std::size_t m_size
Definition: RStarTree.h:761
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
RStarTree< LeafType, dimensions, min_child_items, max_child_items >::~RStarTree ( )
inline

Definition at line 115 of file RStarTree.h.

115  {
116  Remove(
117  AcceptAny(),
118  RemoveLeaf()
119  );
120  }
void Remove(const Acceptor &accept, LeafRemover leafRemover)
Removes item(s) from the tree.
Definition: RStarTree.h:245
RStarRemoveLeaf< Leaf > RemoveLeaf
Definition: RStarTree.h:103
RStarAcceptAny< Node, Leaf > AcceptAny
Definition: RStarTree.h:100

Member Function Documentation

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
Node* RStarTree< LeafType, dimensions, min_child_items, max_child_items >::ChooseSubtree ( Node node,
const BoundingBox bound 
)
inlineprotected

Definition at line 292 of file RStarTree.h.

293  {
294  // If the child pointers in N point to leaves
295  if (static_cast<Node*>(node->items[0])->hasLeaves)
296  {
297  // determine the minimum overlap cost
298  if (max_child_items > (RTREE_CHOOSE_SUBTREE_P*2)/3 && node->items.size() > RTREE_CHOOSE_SUBTREE_P)
299  {
300  // ** alternative algorithm:
301  // Sort the rectangles in N in increasing order of
302  // then area enlargement needed to include the new
303  // data rectangle
304 
305  // Let A be the group of the first p entrles
306  std::partial_sort( node->items.begin(), node->items.begin() + RTREE_CHOOSE_SUBTREE_P, node->items.end(),
308 
309  // From the items in A, considering all items in
310  // N, choose the leaf whose rectangle needs least
311  // overlap enlargement
312 
313  return static_cast<Node*>(* std::min_element(node->items.begin(), node->items.begin() + RTREE_CHOOSE_SUBTREE_P,
315  }
316 
317  // choose the leaf in N whose rectangle needs least
318  // overlap enlargement to include the new data
319  // rectangle Resolve ties by choosmg the leaf
320  // whose rectangle needs least area enlargement, then
321  // the leaf with the rectangle of smallest area
322 
323  return static_cast<Node*>(* std::min_element(node->items.begin(), node->items.end(),
325  }
326 
327  // if the chlld pointers in N do not point to leaves
328 
329  // [determine the minimum area cost],
330  // choose the leaf in N whose rectangle needs least
331  // area enlargement to include the new data
332  // rectangle. Resolve ties by choosing the leaf
333  // with the rectangle of smallest area
334 
335  return static_cast<Node*>(* std::min_element( node->items.begin(), node->items.end(),
337  }
#define RTREE_CHOOSE_SUBTREE_P
Definition: RStarTree.h:48
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
std::size_t RStarTree< LeafType, dimensions, min_child_items, max_child_items >::GetDimensions ( ) const
inline

Definition at line 284 of file RStarTree.h.

284 { return dimensions; }
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
std::size_t RStarTree< LeafType, dimensions, min_child_items, max_child_items >::GetSize ( ) const
inline

Definition at line 283 of file RStarTree.h.

283 { return m_size; }
std::size_t m_size
Definition: RStarTree.h:761
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
void RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Insert ( LeafType  leaf,
const BoundingBox bound 
)
inline

Definition at line 123 of file RStarTree.h.

124  {
125  // ID1: Invoke Insert starting with the leaf level as a
126  // parameter, to Insert a new data rectangle
127  Leaf * newLeaf = new Leaf();
128  newLeaf->bound = bound;
129  newLeaf->leaf = leaf;
130 
131  // create a new root node if necessary
132  if (!m_root)
133  {
134  m_root = new Node();
135  m_root->hasLeaves = true;
136 
137  // reserve memory
138  m_root->items.reserve(min_child_items);
139  m_root->items.push_back(newLeaf);
140  m_root->bound = bound;
141  }
142  else
143  // start the insertion process
144  InsertInternal(newLeaf, m_root);
145 
146  m_size += 1;
147  }
std::vector< BoundedItem * > items
Definition: RStarTree.h:65
Node * m_root
Definition: RStarTree.h:759
RStarLeaf< BoundedItem, LeafType > Leaf
Definition: RStarTree.h:95
bool hasLeaves
Definition: RStarTree.h:66
std::size_t m_size
Definition: RStarTree.h:761
RStarNode< BoundedItem > Node
Definition: RStarTree.h:94
Node * InsertInternal(Leaf *leaf, Node *node, bool firstInsert=true)
Definition: RStarTree.h:343
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
Node* RStarTree< LeafType, dimensions, min_child_items, max_child_items >::InsertInternal ( Leaf leaf,
Node node,
bool  firstInsert = true 
)
inlineprotected

Definition at line 343 of file RStarTree.h.

344  {
345  // I4: Adjust all covering rectangles in the insertion path
346  // such that they are minimum bounding boxes
347  // enclosing the children rectangles
348  node->bound.stretch(leaf->bound);
349 
350 
351  // CS2: If we're at a leaf, then use that level
352  if (node->hasLeaves)
353  {
354  // I2: If N has less than M items, accommodate E in N
355  node->items.push_back(leaf);
356  }
357  else
358  {
359  // I1: Invoke ChooseSubtree. with the level as a parameter,
360  // to find an appropriate node N, m which to place the
361  // new leaf E
362 
363  // of course, this already does all of that recursively. we just need to
364  // determine whether we need to split the overflow or not
365  Node * tmp_node = InsertInternal( leaf, ChooseSubtree(node, &leaf->bound), firstInsert );
366 
367  if (!tmp_node)
368  return NULL;
369 
370  // this gets joined to the list of items at this level
371  node->items.push_back(tmp_node);
372  }
373 
374 
375  // If N has M+1 items. invoke OverflowTreatment with the
376  // level of N as a parameter [for reinsertion or split]
377  if (node->items.size() > max_child_items )
378  {
379 
380  // I3: If OverflowTreatment was called and a split was
381  // performed, propagate OverflowTreatment upwards
382  // if necessary
383 
384  // This is implicit, the rest of the algorithm takes place in there
385  return OverflowTreatment(node, firstInsert);
386  }
387 
388  return NULL;
389  }
Node * ChooseSubtree(Node *node, const BoundingBox *bound)
Definition: RStarTree.h:292
Node * OverflowTreatment(Node *level, bool firstInsert)
Definition: RStarTree.h:393
Node * InsertInternal(Leaf *leaf, Node *node, bool firstInsert=true)
Definition: RStarTree.h:343
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
Node* RStarTree< LeafType, dimensions, min_child_items, max_child_items >::OverflowTreatment ( Node level,
bool  firstInsert 
)
inlineprotected

Definition at line 393 of file RStarTree.h.

394  {
395  // OT1: If the level is not the root level AND this is the first
396  // call of OverflowTreatment in the given level during the
397  // insertion of one data rectangle, then invoke Reinsert
398  if (level != m_root && firstInsert)
399  {
400  Reinsert(level);
401  return NULL;
402  }
403 
404  Node * splitItem = Split(level);
405 
406  // If OverflowTreatment caused a split of the root, create a new root
407  if (level == m_root)
408  {
409  Node * newRoot = new Node();
410  newRoot->hasLeaves = false;
411 
412  // reserve memory
413  newRoot->items.reserve(min_child_items);
414  newRoot->items.push_back(m_root);
415  newRoot->items.push_back(splitItem);
416 
417  // Do I4 here for the new root item
418  newRoot->bound.reset();
419  for_each(newRoot->items.begin(), newRoot->items.end(), StretchBoundingBox<BoundedItem>(&newRoot->bound));
420 
421  // and we're done
422  m_root = newRoot;
423  return NULL;
424  }
425 
426  // propagate it upwards
427  return splitItem;
428  }
void Reinsert(Node *node)
Definition: RStarTree.h:563
Node * m_root
Definition: RStarTree.h:759
Node * Split(Node *node)
Definition: RStarTree.h:436
RStarNode< BoundedItem > Node
Definition: RStarTree.h:94
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
template<typename Acceptor , typename Visitor >
Visitor RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Query ( const Acceptor &  accept,
Visitor  visitor 
)
inline

Touches each node using the visitor pattern.

You must specify an acceptor functor that takes a BoundingBox and a visitor that takes a BoundingBox and a const LeafType&.

See RStarVisitor.h for more information about the various visitor types available.

Parameters
acceptorAn acceptor functor that returns true if this branch or leaf of the tree should be considered for visitation.
visitorA visitor functor that does the visiting
Returns
This will return the Visitor object, so you can retrieve whatever data it has in it if needed (for example, to get the count of items visited). It returns by value, so ensure that the copy is cheap for decent performance.

Definition at line 215 of file RStarTree.h.

216  {
217  if (m_root)
218  {
219  QueryFunctor<Acceptor, Visitor> query(accept, visitor);
220  query(m_root);
221  }
222 
223  return visitor;
224  }
Node * m_root
Definition: RStarTree.h:759
query_result< Args... > query(sqlite3 *db, std::string const &ddl)
Definition: select.h:75
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
void RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Reinsert ( Node node)
inlineprotected

Definition at line 563 of file RStarTree.h.

564  {
565  std::vector< BoundedItem* > removed_items;
566 
567  const std::size_t n_items = node->items.size();
568  const std::size_t p = (std::size_t)((double)n_items * RTREE_REINSERT_P) > 0 ? (std::size_t)((double)n_items * RTREE_REINSERT_P) : 1;
569 
570  // RI1 For all M+l items of a node N, compute the distance
571  // between the centers of their rectangles and the center
572  // of the bounding rectangle of N
573  assert(n_items == max_child_items + 1);
574 
575  // RI2: Sort the items in increasing order of their distances
576  // computed in RI1
577  std::partial_sort(node->items.begin(), node->items.end() - p, node->items.end(),
579 
580  // RI3.A: Remove the last p items from N
581  removed_items.assign(node->items.end() - p, node->items.end());
582  node->items.erase(node->items.end() - p, node->items.end());
583 
584  // RI3.B: adjust the bounding rectangle of N
585  node->bound.reset();
586  for_each(node->items.begin(), node->items.end(), StretchBoundingBox<BoundedItem>(&node->bound));
587 
588  // RI4: In the sort, defined in RI2, starting with the
589  // minimum distance (= close reinsert), invoke Insert
590  // to reinsert the items
591  for (typename std::vector< BoundedItem* >::iterator it = removed_items.begin(); it != removed_items.end(); it++)
592  InsertInternal( static_cast<Leaf*>(*it), m_root, false);
593  }
intermediate_table::iterator iterator
Node * m_root
Definition: RStarTree.h:759
p
Definition: test.py:223
#define RTREE_REINSERT_P
Definition: RStarTree.h:47
Node * InsertInternal(Leaf *leaf, Node *node, bool firstInsert=true)
Definition: RStarTree.h:343
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
template<typename Acceptor , typename LeafRemover >
void RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Remove ( const Acceptor &  accept,
LeafRemover  leafRemover 
)
inline

Removes item(s) from the tree.

See RStarVisitor.h for more information about the various visitor types available.

Parameters
acceptorA node acceptor functor that returns true if this branch or leaf of the tree should be considered for deletion (it does not delete it, however. That is what the LeafRemover does).
leafRemoverA visitor functor that decides whether that individual item should be removed from the tree. If it returns true, then the node holding that item will be deleted.

See also RemoveBoundedArea, RemoveItem for examples of how this function can be called.

Definition at line 245 of file RStarTree.h.

246  {
247  std::list<Leaf*> itemsToReinsert;
248 
249  if (!m_root)
250  return;
251 
252  RemoveFunctor<Acceptor, LeafRemover> remove(accept, leafRemover, &itemsToReinsert, &m_size);
253  remove(m_root, true);
254 
255  if (!itemsToReinsert.empty())
256  {
257  // reinsert anything that needs to be reinserted
258  typename std::list< Leaf* >::iterator it = itemsToReinsert.begin();
259  typename std::list< Leaf* >::iterator end = itemsToReinsert.end();
260 
261  // TODO: do this whenever that actually works..
262  // BulkInsert(itemsToReinsert, m_root);
263 
264  for(;it != end; it++)
265  InsertInternal(*it, m_root);
266  }
267  }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
intermediate_table::iterator iterator
Node * m_root
Definition: RStarTree.h:759
std::size_t m_size
Definition: RStarTree.h:761
Node * InsertInternal(Leaf *leaf, Node *node, bool firstInsert=true)
Definition: RStarTree.h:343
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
void RStarTree< LeafType, dimensions, min_child_items, max_child_items >::RemoveBoundedArea ( const BoundingBox bound)
inline

Definition at line 270 of file RStarTree.h.

271  {
272  Remove(AcceptEnclosing(bound), RemoveLeaf());
273  }
void Remove(const Acceptor &accept, LeafRemover leafRemover)
Removes item(s) from the tree.
Definition: RStarTree.h:245
RStarRemoveLeaf< Leaf > RemoveLeaf
Definition: RStarTree.h:103
RStarAcceptEnclosing< Node, Leaf > AcceptEnclosing
Definition: RStarTree.h:99
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
void RStarTree< LeafType, dimensions, min_child_items, max_child_items >::RemoveItem ( const LeafType &  item,
bool  removeDuplicates = true 
)
inline

Definition at line 277 of file RStarTree.h.

278  {
279  Remove( AcceptAny(), RemoveSpecificLeaf(item, removeDuplicates));
280  }
void Remove(const Acceptor &accept, LeafRemover leafRemover)
Removes item(s) from the tree.
Definition: RStarTree.h:245
RStarAcceptAny< Node, Leaf > AcceptAny
Definition: RStarTree.h:100
RStarRemoveSpecificLeaf< Leaf > RemoveSpecificLeaf
Definition: RStarTree.h:104
template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
Node* RStarTree< LeafType, dimensions, min_child_items, max_child_items >::Split ( Node node)
inlineprotected

Definition at line 436 of file RStarTree.h.

437  {
438  Node * newNode = new Node();
439  newNode->hasLeaves = node->hasLeaves;
440 
441  const std::size_t n_items = node->items.size();
442  const std::size_t distribution_count = n_items - 2*min_child_items + 1;
443 
444  std::size_t split_axis = dimensions+1, split_edge = 0, split_index = 0;
445  int split_margin = 0;
446 
447  BoundingBox R1, R2;
448 
449  // these should always hold true
450  assert(n_items == max_child_items + 1);
451  assert(distribution_count > 0);
452  assert(min_child_items + distribution_count-1 <= n_items);
453 
454  // S1: Invoke ChooseSplitAxis to determine the axis,
455  // perpendicular to which the split 1s performed
456  // S2: Invoke ChooseSplitIndex to determine the best
457  // distribution into two groups along that axis
458 
459  // NOTE: We don't compare against node->bound, so it gets overwritten
460  // at the end of the loop
461 
462  // CSA1: For each axis
463  for (std::size_t axis = 0; axis < dimensions; axis++)
464  {
465  // initialize per-loop items
466  int margin = 0;
467  double overlap = 0, dist_area, dist_overlap;
468  std::size_t dist_edge = 0, dist_index = 0;
469 
470  dist_area = dist_overlap = std::numeric_limits<double>::max();
471 
472 
473  // Sort the items by the lower then by the upper
474  // edge of their bounding box on this particular axis and
475  // determine all distributions as described . Compute S. the
476  // sum of all margin-values of the different
477  // distributions
478 
479  // lower edge == 0, upper edge = 1
480  for (std::size_t edge = 0; edge < 2; edge++)
481  {
482  // sort the items by the correct key (upper edge, lower edge)
483  if (edge == 0)
484  std::sort(node->items.begin(), node->items.end(), SortBoundedItemsByFirstEdge<BoundedItem>(axis));
485  else
486  std::sort(node->items.begin(), node->items.end(), SortBoundedItemsBySecondEdge<BoundedItem>(axis));
487 
488  // Distributions: pick a point m in the middle of the thing, call the left
489  // R1 and the right R2. Calculate the bounding box of R1 and R2, then
490  // calculate the margins. Then do it again for some more points
491  for (std::size_t k = 0; k < distribution_count; k++)
492  {
493  double area = 0;
494 
495  // calculate bounding box of R1
496  R1.reset();
497  for_each(node->items.begin(), node->items.begin()+(min_child_items+k), StretchBoundingBox<BoundedItem>(&R1));
498 
499  // then do the same for R2
500  R2.reset();
501  for_each(node->items.begin()+(min_child_items+k+1), node->items.end(), StretchBoundingBox<BoundedItem>(&R2));
502 
503 
504  // calculate the three values
505  margin += R1.edgeDeltas() + R2.edgeDeltas();
506  area += R1.area() + R2.area(); // TODO: need to subtract.. overlap?
507  overlap = R1.overlap(R2);
508 
509 
510  // CSI1: Along the split axis, choose the distribution with the
511  // minimum overlap-value. Resolve ties by choosing the distribution
512  // with minimum area-value.
513  if (overlap < dist_overlap || (overlap == dist_overlap && area < dist_area))
514  {
515  // if so, store the parameters that allow us to recreate it at the end
516  dist_edge = edge;
517  dist_index = min_child_items+k;
518  dist_overlap = overlap;
519  dist_area = area;
520  }
521  }
522  }
523 
524  // CSA2: Choose the axis with the minimum S as split axis
525  if (split_axis == dimensions+1 || split_margin > margin )
526  {
527  split_axis = axis;
528  split_margin = margin;
529  split_edge = dist_edge;
530  split_index = dist_index;
531  }
532  }
533 
534  // S3: Distribute the items into two groups
535 
536  // ok, we're done, and the best distribution on the selected split
537  // axis has been recorded, so we just have to recreate it and
538  // return the correct index
539 
540  if (split_edge == 0)
541  std::sort(node->items.begin(), node->items.end(), SortBoundedItemsByFirstEdge<BoundedItem>(split_axis));
542 
543  // only reinsert the sort key if we have to
544  else if (split_axis != dimensions-1)
545  std::sort(node->items.begin(), node->items.end(), SortBoundedItemsBySecondEdge<BoundedItem>(split_axis));
546 
547  // distribute the end of the array to the new node, then erase them from the original node
548  newNode->items.assign(node->items.begin() + split_index, node->items.end());
549  node->items.erase(node->items.begin() + split_index, node->items.end());
550 
551  // adjust the bounding box for each 'new' node
552  node->bound.reset();
553  std::for_each(node->items.begin(), node->items.end(), StretchBoundingBox<BoundedItem>(&node->bound));
554 
555  newNode->bound.reset();
556  std::for_each(newNode->items.begin(), newNode->items.end(), StretchBoundingBox<BoundedItem>(&newNode->bound));
557 
558  return newNode;
559  }
double overlap(const RStarBoundingBox< dimensions > &bb) const
double area() const
int edgeDeltas() const
static int max(int a, int b)
RStarNode< BoundedItem > Node
Definition: RStarTree.h:94

Member Data Documentation

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
Node* RStarTree< LeafType, dimensions, min_child_items, max_child_items >::m_root
private

Definition at line 759 of file RStarTree.h.

template<typename LeafType, std::size_t dimensions, std::size_t min_child_items, std::size_t max_child_items>
std::size_t RStarTree< LeafType, dimensions, min_child_items, max_child_items >::m_size
private

Definition at line 761 of file RStarTree.h.


The documentation for this class was generated from the following file: