Package org.h2.mvstore.rtree
Class SpatialDataType
- java.lang.Object
-
- org.h2.mvstore.type.BasicDataType<Spatial>
-
- org.h2.mvstore.rtree.SpatialDataType
-
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.
-
-
Field Summary
Fields Modifier and Type Field Description private int
dimensions
-
Constructor Summary
Constructors Constructor Description SpatialDataType(int dimensions)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(Spatial a, Spatial b)
Compare two keys.boolean
contains(java.lang.Object objA, java.lang.Object objB)
Check whether a contains b.protected Spatial
create(long id, float... minMax)
Creates spatial object with specified parameters.(package private) Spatial
createBoundingBox(java.lang.Object objA)
Create a bounding box starting with the given object.Spatial[]
createStorage(int size)
Create storage object of array type to hold valuesboolean
equals(java.lang.Object a, java.lang.Object b)
Check whether two spatial values are equal.private float
getArea(Spatial a)
float
getAreaIncrease(java.lang.Object objA, java.lang.Object objB)
Get the area increase by extending a to contain b.(package private) float
getCombinedArea(java.lang.Object objA, java.lang.Object objB)
Get the combined area of both objects.int[]
getExtremes(java.util.ArrayList<java.lang.Object> 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.private static java.util.ArrayList<java.lang.Object>
getNotNull(java.util.ArrayList<java.lang.Object> list)
void
increaseBounds(java.lang.Object bounds, java.lang.Object add)
Increase the bounds in the given spatial object.private void
increaseMaxInnerBounds(java.lang.Object bounds, java.lang.Object add)
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(Spatial a, Spatial b)
Check whether the two objects overlap.Spatial
read(java.nio.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
-
-
-
-
Method Detail
-
create
protected Spatial create(long id, float... minMax)
Creates spatial object with specified parameters.- Parameters:
id
- the IDminMax
- 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.
-
equals
public boolean equals(java.lang.Object a, java.lang.Object b)
Check whether two spatial values are equal.- Parameters:
a
- the first valueb
- 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.
-
write
public void write(WriteBuffer buff, Spatial k)
Description copied from interface:DataType
Write an object.
-
read
public Spatial read(java.nio.ByteBuffer buff)
Description copied from interface:DataType
Read an object.
-
isOverlap
public boolean isOverlap(Spatial a, Spatial b)
Check whether the two objects overlap.- Parameters:
a
- the first objectb
- 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 boxobjB
- the object- Returns:
- the area
-
getCombinedArea
float getCombinedArea(java.lang.Object objA, java.lang.Object objB)
Get the combined area of both objects.- Parameters:
objA
- the first objectobjB
- the second object- Returns:
- the area
-
getArea
private float getArea(Spatial a)
-
contains
public boolean contains(java.lang.Object objA, java.lang.Object objB)
Check whether a contains b.- Parameters:
objA
- the bounding boxobjB
- 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 checkobjB
- the bounds- Returns:
- true if a is completely inside b
-
createBoundingBox
Spatial createBoundingBox(java.lang.Object objA)
Create a bounding box starting with the given object.- Parameters:
objA
- the object- Returns:
- the bounding box
-
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
-
getNotNull
private static java.util.ArrayList<java.lang.Object> getNotNull(java.util.ArrayList<java.lang.Object> list)
-
increaseMaxInnerBounds
private void increaseMaxInnerBounds(java.lang.Object bounds, java.lang.Object add)
-
-