Package org.h2.mvstore.rtree

# Class SpatialDataType

java.lang.Object
org.h2.mvstore.type.BasicDataType<Spatial>
org.h2.mvstore.rtree.SpatialDataType

All Implemented Interfaces:
  `Comparator<Spatial>`, `DataType<Spatial>`

public class SpatialDataType extends BasicDataType<Spatial>
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
Description
`SpatialDataType(int dimensions)`

## Method Summary

Modifier and Type
Method
Description
`int`
`compare(Spatial a, Spatial b)`
Compare two keys.
`boolean`
`contains(Spatial bounds, Spatial object)`
Check whether bounds contains object.
`protected Spatial`
`create(long id, float... minMax)`
Creates spatial object with specified parameters.
`Spatial[]`
`createStorage(int size)`
Create storage object of array type to hold values
`boolean`
`equals(Spatial a, Spatial b)`
Check whether two spatial values are equal.
`float`
`getAreaIncrease(Spatial bounds, Spatial add)`
Get the area increase by extending a to contain b.
`int[]`
`getExtremes(ArrayList<Spatial> list)`
Get the most extreme pair (elements that are as far apart as possible).
`int`
`getMemory(Spatial obj)`
Calculates the amount of used memory in bytes.
`void`
`increaseBounds(Spatial bounds, Spatial add)`
Increase the bounds in the given spatial object.
`boolean`
`isInside(Spatial object, Spatial bounds)`
Check whether object is completely inside bounds and does not touch them.
`boolean`
`isOverlap(Spatial a, Spatial b)`
Check whether the two objects overlap.
`Spatial`
`read(ByteBuffer buff)`
Read an object.
`void`
`write(WriteBuffer buff, Spatial k)`
Write an object.

### Methods inherited from class org.h2.mvstore.type.BasicDataType

`binarySearch, cast, equals, hashCode, isMemoryEstimationAllowed, read, write`

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

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

### Methods inherited from interface java.util.Comparator

`reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### SpatialDataType

public SpatialDataType(int dimensions)

## Method Details

### create

protected Spatial create(long id, float... minMax)
Creates spatial object with specified parameters.

Parameters:
  `id` - the ID
  `minMax` - min x, max x, min y, max y, and so on
Returns:
  the spatial object

### createStorage

public Spatial[] createStorage(int size)
Description copied from interface: `DataType`
Create storage object of array type to hold values

Parameters:
  `size` - number of values to hold
Returns:
  storage object

### compare

public int compare(Spatial a, Spatial b)
Description copied from interface: `DataType`
Compare two keys.

Specified by:
  `compare` in interface `Comparator<Spatial>`
Specified by:
  `compare` in interface `DataType<Spatial>`
Overrides:
  `compare` in class `BasicDataType<Spatial>`
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(Spatial a, Spatial 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(Spatial obj)
Description copied from interface: `DataType`
Calculates the amount of used memory in bytes.

Specified by:
  `getMemory` in interface `DataType<Spatial>`
Specified by:
  `getMemory` in class `BasicDataType<Spatial>`
Parameters:
  `obj` - the object
Returns:
  the used memory

### write

public void write(WriteBuffer buff, Spatial k)
Description copied from interface: `DataType`
Write an object.

Specified by:
  `write` in interface `DataType<Spatial>`
Specified by:
  `write` in class `BasicDataType<Spatial>`
Parameters:
  `buff` - the target buffer
  `k` - the value

### read

public Spatial read(ByteBuffer buff)
Description copied from interface: `DataType`
Read an object.

Specified by:
  `read` in interface `DataType<Spatial>`
Specified by:
  `read` in class `BasicDataType<Spatial>`
Parameters:
  `buff` - the source buffer
Returns:
  the object

### isOverlap

public boolean isOverlap(Spatial a, Spatial b)
Check whether the two objects overlap.

Parameters:
  `a` - the first object
  `b` - the second object
Returns:
  true if they overlap

### increaseBounds

public void increaseBounds(Spatial bounds, Spatial add)
Increase the bounds in the given spatial object.

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

### getAreaIncrease

public float getAreaIncrease(Spatial bounds, Spatial add)
Get the area increase by extending a to contain b.

Parameters:
  `bounds` - the bounding box
  `add` - the object
Returns:
  the area

### contains

public boolean contains(Spatial bounds, Spatial object)
Check whether bounds contains object.

Parameters:
  `bounds` - the bounding box
  `object` - the object
Returns:
  the area

### isInside

public boolean isInside(Spatial object, Spatial bounds)
Check whether object is completely inside bounds and does not touch them.

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

### getExtremes

public int[] getExtremes(ArrayList<Spatial> 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