spatial
Class SimpleRTreeStrategy

java.lang.Object
  |
  +--spatial.SimpleRTreeStrategy
All Implemented Interfaces:
RTreeStrategy

public class SimpleRTreeStrategy
extends java.lang.Object
implements RTreeStrategy

Class providing the operations which determine the strategy of a simple r-tree.


Field Summary
protected  java.util.BitSet indicator
          Prepared indicator for the distribute operation.
protected  int m
          The minimum number of entries in a node after a split in %.
protected  int reinsertFactor
          Prepared indicator for the distribute operation.
 
Constructor Summary
SimpleRTreeStrategy()
          Constructor.
SimpleRTreeStrategy(int reinsertFactor)
          Constructor.
 
Method Summary
 int chooseSubtree(SpatialSearchTreeNode node, SpatialSearchTreeEntry obj)
          Determines the best subtree for inserting an new object according to the Gutman's original r-tree algorithm 1984.
 java.util.BitSet distribute(SpatialSearchTreeNode node, SpatialSearchTreeEntry entry)
          Distributes the entries of a node to two nodes according to a simple linear algorithm.
 int getMinimum()
          Gets the minimum percentage of entries.
 int getReinsertFactor(int height)
          Returns the percentage of objects which should be reinserted.
 boolean isOrdering()
          Return false because this it not an ordering strategy.
 void readParameters(java.io.DataInputStream in)
          Reads parameters from DataInputStream.
 void setMinimum(int m)
          Sets the minimum percentage of entries.
 void setReinsertFactor(int p)
          Sets the quota of entries to be reinserted.
 void sortAccordingTo(SpatialSearchTreeNode nd, double[] value, int left, int right)
          Performs the sorting of a node between two limits using quicksort and a given array with values.
 void sortAccordingTo(SpatialSearchTreeNode node, double[] value, int leftBorder, int left, int right)
          Performs the sorting of a node between two limits using quicksort and a given array with values.
 void sortForReinsert(SpatialSearchTreeNode node)
          Sorts the entries of the given node according to their distance to the center of the parent entry.
 void writeParameters(java.io.DataOutputStream out)
          Writes parameters to DataOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reinsertFactor

protected int reinsertFactor
Prepared indicator for the distribute operation.


m

protected int m
The minimum number of entries in a node after a split in %.


indicator

protected java.util.BitSet indicator
Prepared indicator for the distribute operation.

Constructor Detail

SimpleRTreeStrategy

public SimpleRTreeStrategy()
Constructor.


SimpleRTreeStrategy

public SimpleRTreeStrategy(int reinsertFactor)
Constructor.

Parameters:
reinsertFactor - percentage of objects which should be reinserted (0 = no reinsert)
Method Detail

chooseSubtree

public int chooseSubtree(SpatialSearchTreeNode node,
                         SpatialSearchTreeEntry obj)
Determines the best subtree for inserting an new object according to the Gutman's original r-tree algorithm 1984.

Specified by:
chooseSubtree in interface RTreeStrategy
Parameters:
node - non-leaf node where the object should to be inserted
obj - the new object or the reinserted entry
Returns:
the index of the subtree

distribute

public java.util.BitSet distribute(SpatialSearchTreeNode node,
                                   SpatialSearchTreeEntry entry)
Distributes the entries of a node to two nodes according to a simple linear algorithm.

Specified by:
distribute in interface RTreeStrategy
Parameters:
node - the node
entry - the entry describing the node
Returns:
Bitset indicating the entries which should leave the node

getMinimum

public int getMinimum()
Gets the minimum percentage of entries.

Specified by:
getMinimum in interface RTreeStrategy
Returns:
the percentage

getReinsertFactor

public int getReinsertFactor(int height)
Returns the percentage of objects which should be reinserted.

Specified by:
getReinsertFactor in interface RTreeStrategy
Returns:
the reinsert factor (0 = no reinsert)

isOrdering

public boolean isOrdering()
Return false because this it not an ordering strategy.

Specified by:
isOrdering in interface RTreeStrategy
Returns:
false

readParameters

public void readParameters(java.io.DataInputStream in)
                    throws java.io.IOException
Reads parameters from DataInputStream.

Specified by:
readParameters in interface RTreeStrategy
Parameters:
in - stream
Throws:
java.io.IOException

setMinimum

public void setMinimum(int m)
Sets the minimum percentage of entries.

Specified by:
setMinimum in interface RTreeStrategy
Parameters:
m - the new value

setReinsertFactor

public void setReinsertFactor(int p)
Sets the quota of entries to be reinserted.

Specified by:
setReinsertFactor in interface RTreeStrategy
Parameters:
p - the new value

sortAccordingTo

public void sortAccordingTo(SpatialSearchTreeNode nd,
                            double[] value,
                            int left,
                            int right)
Performs the sorting of a node between two limits using quicksort and a given array with values.

Parameters:
nd - the node
value - the array with the values
left - left index
right - right index

sortAccordingTo

public void sortAccordingTo(SpatialSearchTreeNode node,
                            double[] value,
                            int leftBorder,
                            int left,
                            int right)
Performs the sorting of a node between two limits using quicksort and a given array with values.

Parameters:
value - the array with the values
leftBorder - the index of the first entry to be sorted
left - left index
right - right index

sortForReinsert

public void sortForReinsert(SpatialSearchTreeNode node)
Sorts the entries of the given node according to their distance to the center of the parent entry. The reinsert factor controls the number of exactly sorted entries. The object that should be reinserted are stored at the end of the node. The last entry should be reinserted first.

Specified by:
sortForReinsert in interface RTreeStrategy
Parameters:
node - the node

writeParameters

public void writeParameters(java.io.DataOutputStream out)
                     throws java.io.IOException
Writes parameters to DataOutputStream.

Specified by:
writeParameters in interface RTreeStrategy
Parameters:
out - stream
Throws:
java.io.IOException