org.garret.perst
Interface SpatialIndexR2

All Superinterfaces:
java.io.Externalizable, IPersistent, IResource, ITable, java.io.Serializable

public interface SpatialIndexR2
extends IPersistent, IResource, ITable

Interface of object spatial index. Spatial index is used to allow fast selection of spatial objects belonging to the specified rectangle. Spatial index is implemented using Guttman R-Tree with quadratic split algorithm.


Method Summary
 void clear()
          Remove all objects from the index
 java.util.Iterator entryIterator()
          Get entry iterator through all members of the index This iterator doesn't support remove() method.
 java.util.Iterator entryIterator(RectangleR2 r)
          Get entry iterator through objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method.
 IPersistent[] get(RectangleR2 r)
          Find all objects located in the selected rectangle
 java.util.ArrayList getList(RectangleR2 r)
          Find all objects located in the selected rectangle
 RectangleR2 getWrappingRectangle()
          Get wrapping rectangle
 java.util.Iterator iterator()
          Get iterator through all members of the index This iterator doesn't support remove() method.
 java.util.Iterator iterator(RectangleR2 r)
          Get objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method.
 void put(RectangleR2 r, IPersistent obj)
          Put new object in the index.
 void remove(RectangleR2 r, IPersistent obj)
          Remove object with specified enveloping rectangle from the tree.
 int size()
          Get number of objects in the index
 IPersistent[] toArray()
          Get array of all members of the index
 IPersistent[] toArray(IPersistent[] arr)
          Get all objects in the index.
 
Methods inherited from interface org.garret.perst.IPersistent
assignOid, deallocate, getOid, getStorage, invalidate, isDeleted, isModified, isPersistent, isRaw, load, loadAndModify, makePersistent, modify, onLoad, onStore, recursiveLoading, store
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface org.garret.perst.IResource
exclusiveLock, exclusiveLock, reset, sharedLock, sharedLock, unlock
 
Methods inherited from interface org.garret.perst.ITable
select
 

Method Detail

clear

public void clear()
Remove all objects from the index


entryIterator

public java.util.Iterator entryIterator()
Get entry iterator through all members of the index This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Returns:
entry iterator which key specifies recrtangle and value - correspondent object

entryIterator

public java.util.Iterator entryIterator(RectangleR2 r)
Get entry iterator through objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Parameters:
r - selected rectangle
Returns:
entry iterator for objects which enveloping rectangle overlaps with specified rectangle

get

public IPersistent[] get(RectangleR2 r)
Find all objects located in the selected rectangle

Parameters:
r - selected rectangle
Returns:
array of objects which enveloping rectangle intersects with specified rectangle

getList

public java.util.ArrayList getList(RectangleR2 r)
Find all objects located in the selected rectangle

Parameters:
r - selected rectangle
Returns:
array list of objects which enveloping rectangle intersects with specified rectangle

getWrappingRectangle

public RectangleR2 getWrappingRectangle()
Get wrapping rectangle

Returns:
minimal rectangle containing all rectangles in the index, null if index is empty

iterator

public java.util.Iterator iterator()
Get iterator through all members of the index This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Specified by:
iterator in interface ITable
Returns:
iterator through all objects in the index

iterator

public java.util.Iterator iterator(RectangleR2 r)
Get objects which rectangle intersects with specified rectangle This iterator doesn't support remove() method. It is not possible to modify spatial index during iteration.

Parameters:
r - selected rectangle
Returns:
iterator for objects which enveloping rectangle overlaps with specified rectangle

put

public void put(RectangleR2 r,
                IPersistent obj)
Put new object in the index.

Parameters:
r - enveloping rectangle for the object
obj - object associated with this rectangle. Object can be not yet persistent, in this case its forced to become persistent by assigning OID to it.

remove

public void remove(RectangleR2 r,
                   IPersistent obj)
Remove object with specified enveloping rectangle from the tree.

Parameters:
r - enveloping rectangle for the object
obj - object removed from the index
Throws:
StorageError(StorageError.KEY_NOT_FOUND) - exception if there is no such key in the index

size

public int size()
Get number of objects in the index

Specified by:
size in interface ITable
Returns:
number of objects in the index

toArray

public IPersistent[] toArray()
Get array of all members of the index

Returns:
array of index members

toArray

public IPersistent[] toArray(IPersistent[] arr)
Get all objects in the index. The runtime type of the returned array is that of the specified array. If the index fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this index.

If this index fits in the specified array with room to spare (i.e., the array has more elements than this index), the element in the array immediately following the end of the index is set to null. This is useful in determining the length of this index only if the caller knows that this index does not contain any null elements.)

Parameters:
arr - specified array
Returns:
array of all objects in the index