org.h2.mvstore.rtree

## Class SpatialDataType

- java.lang.Object
- - org.h2.mvstore.rtree.SpatialDataType

All Implemented Interfaces:
  DataType

    public class SpatialDataType
    extends java.lang.Object
    implements DataType

A spatial data type. This class supports up to 31 dimensions. Each dimension can have a minimum and a maximum value of type float. For each dimension, the maximum value is only stored when it is not the same as the minimum.

### Constructor Summary

Constructors
Constructor and Description
`SpatialDataType(int dimensions)`

### Method Summary

Methods
`int` `compare(java.lang.Object a, java.lang.Object b)` Compare two keys.
`boolean` `contains(java.lang.Object objA, java.lang.Object objB)` Check whether a contains b.
`boolean` `equals(java.lang.Object a, java.lang.Object b)` Check whether two spatial values are equal.
`float` `getAreaIncrease(java.lang.Object objA, java.lang.Object objB)` Get the area increase by extending a to contain b.
`int[]` `getExtremes(java.util.ArrayList<java.lang.Object> list)` Get the most extreme pair (elements that are as far apart as possible).
`int` `getMemory(java.lang.Object obj)` Estimate the used memory in bytes.
`void` `increaseBounds(java.lang.Object bounds, java.lang.Object add)` Increase the bounds in the given spatial object.
`boolean` `isInside(java.lang.Object objA, java.lang.Object objB)` Check whether a is completely inside b and does not touch the given bound.
`boolean` `isOverlap(java.lang.Object objA, java.lang.Object objB)` Check whether the two objects overlap.
`java.lang.Object` `read(java.nio.ByteBuffer buff)` Read an object.
`void` `read(java.nio.ByteBuffer buff, java.lang.Object[] obj, int len, boolean key)` Read a list of objects.
`void` `write(WriteBuffer buff, java.lang.Object obj)` Write an object.
`void` `write(WriteBuffer buff, java.lang.Object[] obj, int len, boolean key)` Write a list of objects.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SpatialDataType

    public SpatialDataType(int dimensions)

### Method Detail

#### compare

    public int compare(java.lang.Object a,
              java.lang.Object b)

Description copied from interface: `DataType`
Compare two keys.

Specified by:
  `compare` in interface `DataType`
Parameters:
  `a` - the first key
  `b` - the second key
Returns:
  -1 if the first key is smaller, 1 if larger, and 0 if equal

#### equals

    public boolean equals(java.lang.Object a,
                 java.lang.Object b)

Check whether two spatial values are equal.

Parameters:
  `a` - the first value
  `b` - the second value
Returns:
  true if they are equal

#### getMemory

    public int getMemory(java.lang.Object obj)

Description copied from interface: `DataType`
Estimate the used memory in bytes.

Specified by:
  `getMemory` in interface `DataType`
Parameters:
  `obj` - the object
Returns:
  the used memory

#### read

    public void read(java.nio.ByteBuffer buff,
            java.lang.Object[] obj,
            int len,
            boolean key)

Description copied from interface: `DataType`
Read a list of objects.

Specified by:
  `read` in interface `DataType`
Parameters:
  `buff` - the target buffer
  `obj` - the objects
  `len` - the number of objects to read
  `key` - whether the objects are keys

#### write

    public void write(WriteBuffer buff,
             java.lang.Object[] obj,
             int len,
             boolean key)

Description copied from interface: `DataType`
Write a list of objects.

Specified by:
  `write` in interface `DataType`
Parameters:
  `buff` - the target buffer
  `obj` - the objects
  `len` - the number of objects to write
  `key` - whether the objects are keys

#### write

    public void write(WriteBuffer buff,
             java.lang.Object obj)

Description copied from interface: `DataType`
Write an object.

Specified by:
  `write` in interface `DataType`
Parameters:
  `buff` - the target buffer
  `obj` - the value

#### read

    public java.lang.Object read(java.nio.ByteBuffer buff)

Description copied from interface: `DataType`
Read an object.

Specified by:
  `read` in interface `DataType`
Parameters:
  `buff` - the source buffer
Returns:
  the object

#### isOverlap

    public boolean isOverlap(java.lang.Object objA,
                    java.lang.Object objB)

Check whether the two objects overlap.

Parameters:
  `objA` - the first object
  `objB` - the second object
Returns:
  true if they overlap

#### increaseBounds

    public void increaseBounds(java.lang.Object bounds,
                      java.lang.Object add)

Increase the bounds in the given spatial object.

Parameters:
  `bounds` - the bounds (may be modified)
  `add` - the value

#### getAreaIncrease

    public float getAreaIncrease(java.lang.Object objA,
                        java.lang.Object objB)

Get the area increase by extending a to contain b.

Parameters:
  `objA` - the bounding box
  `objB` - the object
Returns:
  the area

#### contains

    public boolean contains(java.lang.Object objA,
                   java.lang.Object objB)

Check whether a contains b.

Parameters:
  `objA` - the bounding box
  `objB` - the object
Returns:
  the area

#### isInside

    public boolean isInside(java.lang.Object objA,
                   java.lang.Object objB)

Check whether a is completely inside b and does not touch the given bound.

Parameters:
  `objA` - the object to check
  `objB` - the bounds
Returns:
  true if a is completely inside b

#### getExtremes

    public int[] getExtremes(java.util.ArrayList<java.lang.Object> list)

Get the most extreme pair (elements that are as far apart as possible). This method is used to split a page (linear split). If no extreme objects could be found, this method returns null.

Parameters:
  `list` - the objects
Returns:
  the indexes of the extremes