Top Description Inners Fields Constructors Methods
org.h2.util.geometry

public final Class GeometryUtils

extends Object
Class Inheritance

Utilities for GEOMETRY data type.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
GeometryUtils.DimensionSystemTarget

Converter output target that determines minimal dimension system for a geometry.

public static class
GeometryUtils.EnvelopeTarget

Converter output target that calculates an envelope.

public abstract static class
GeometryUtils.Target

Converter output target.

Field Summary

Modifier and TypeField and Description
public static final int
DIMENSION_SYSTEM_XY

Code of 2D (XY) dimension system.

public static final int
DIMENSION_SYSTEM_XYM

Code of M (XYM) dimension system.

public static final int
DIMENSION_SYSTEM_XYZ

Code of Z (XYZ) dimension system.

public static final int
DIMENSION_SYSTEM_XYZM

Code of ZM (XYZM) dimension system.

public static final int
GEOMETRY_COLLECTION

GEOMETRYCOLLECTION geometry type.

public static final int
LINE_STRING

LINESTRING geometry type.

public static final int
M

Number of M coordinate.

public static final int
MAX_X

Maximum X coordinate index.

public static final int
MAX_Y

Maximum Y coordinate index.

public static final int
MIN_X

Minimum X coordinate index.

public static final int
MIN_Y

Minimum Y coordinate index.

public static final int
MULTI_LINE_STRING

MULTILINESTRING geometry type.

public static final int
MULTI_POINT

MULTIPOINT geometry type.

public static final int
MULTI_POLYGON

MULTIPOLYGON geometry type.

public static final int
POINT

POINT geometry type.

public static final int
POLYGON

POLYGON geometry type.

public static final int
X

Number of X coordinate.

public static final int
Y

Number of Y coordinate.

public static final int
Z

Number of Z coordinate.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static double

Returns:

the same double value
checkFinite
(double
a double value
d
)

Throw exception if param is not finite value (ie.

public static double[]

Returns:

envelope, or null
getEnvelope
(byte[]
EWKB of a geometry
ewkb
)

Calculates an envelope of a specified geometry.

public static boolean

Returns:

whether the specified envelopes intersects
intersects
(double[]
first envelope, or null
envelope1
,
double[]
second envelope, or null
envelope2
)

Checks whether two envelopes intersect with each other.

pack-priv static double

Returns:

normalized value
toCanonicalDouble
(double
double value
d
)

Normalizes all NaNs into single type on NaN and negative zero to positive zero.

public static double[]

Returns:

union of two envelopes
union
(double[]
first envelope, or null
envelope1
,
double[]
second envelope, or null
envelope2
)

Returns union of two envelopes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DIMENSION_SYSTEM_XYback to summary
public static final int DIMENSION_SYSTEM_XY

Code of 2D (XY) dimension system.

DIMENSION_SYSTEM_XYMback to summary
public static final int DIMENSION_SYSTEM_XYM

Code of M (XYM) dimension system. Can also be used in bit masks to determine presence of dimension M.

DIMENSION_SYSTEM_XYZback to summary
public static final int DIMENSION_SYSTEM_XYZ

Code of Z (XYZ) dimension system. Can also be used in bit masks to determine presence of dimension Z.

DIMENSION_SYSTEM_XYZMback to summary
public static final int DIMENSION_SYSTEM_XYZM

Code of ZM (XYZM) dimension system. Can be also combined from DIMENSION_SYSTEM_XYZ and DIMENSION_SYSTEM_XYM using bitwise OR.

GEOMETRY_COLLECTIONback to summary
public static final int GEOMETRY_COLLECTION

GEOMETRYCOLLECTION geometry type.

LINE_STRINGback to summary
public static final int LINE_STRING

LINESTRING geometry type.

Mback to summary
public static final int M

Number of M coordinate.

MAX_Xback to summary
public static final int MAX_X

Maximum X coordinate index.

MAX_Yback to summary
public static final int MAX_Y

Maximum Y coordinate index.

MIN_Xback to summary
public static final int MIN_X

Minimum X coordinate index.

MIN_Yback to summary
public static final int MIN_Y

Minimum Y coordinate index.

MULTI_LINE_STRINGback to summary
public static final int MULTI_LINE_STRING

MULTILINESTRING geometry type.

MULTI_POINTback to summary
public static final int MULTI_POINT

MULTIPOINT geometry type.

MULTI_POLYGONback to summary
public static final int MULTI_POLYGON

MULTIPOLYGON geometry type.

POINTback to summary
public static final int POINT

POINT geometry type.

POLYGONback to summary
public static final int POLYGON

POLYGON geometry type.

Xback to summary
public static final int X

Number of X coordinate.

Yback to summary
public static final int Y

Number of Y coordinate.

Zback to summary
public static final int Z

Number of Z coordinate.

Constructor Detail

GeometryUtilsback to summary
private GeometryUtils()

Method Detail

checkFiniteback to summary
pack-priv static double checkFinite(double d)

Throw exception if param is not finite value (ie. NaN/inf/etc)

Parameters
d:double

a double value

Returns:double

the same double value

getEnvelopeback to summary
public static double[] getEnvelope(byte[] ewkb)

Calculates an envelope of a specified geometry.

Parameters
ewkb:byte[]

EWKB of a geometry

Returns:double[]

envelope, or null

intersectsback to summary
public static boolean intersects(double[] envelope1, double[] envelope2)

Checks whether two envelopes intersect with each other.

Parameters
envelope1:double[]

first envelope, or null

envelope2:double[]

second envelope, or null

Returns:boolean

whether the specified envelopes intersects

toCanonicalDoubleback to summary
pack-priv static double toCanonicalDouble(double d)

Normalizes all NaNs into single type on NaN and negative zero to positive zero.

Parameters
d:double

double value

Returns:double

normalized value

unionback to summary
public static double[] union(double[] envelope1, double[] envelope2)

Returns union of two envelopes. This method does not modify the specified envelopes, but may return one of them as a result.

Parameters
envelope1:double[]

first envelope, or null

envelope2:double[]

second envelope, or null

Returns:double[]

union of two envelopes

org.h2.util.geometry back to summary

public final Class GeometryUtils.DimensionSystemTarget

extends Target
Class Inheritance

Converter output target that determines minimal dimension system for a geometry.

Field Summary

Modifier and TypeField and Description
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public
DimensionSystemTarget()

Creates a new dimension system determination target.

Method Summary

Modifier and TypeMethod and Description
protected void
addCoordinate(double
X coordinate
x
,
double
Y coordinate
y
,
double
Z coordinate (NaN if not used)
z
,
double
M coordinate (NaN if not used)
m
,
int
0-based index of coordinate in the current sequence
index
,
int
total number of coordinates in the current sequence
total
)

Implements abstract org.h2.util.geometry.GeometryUtils.Target.addCoordinate.

Invoked to add a coordinate to a geometry.

protected void
dimensionSystem(int
dimension system
dimensionSystem
)

Overrides org.h2.util.geometry.GeometryUtils.Target.dimensionSystem.

Invoked to add dimension system requirement.

public int

Returns:

the minimal dimension system
getDimensionSystem
()

Returns the minimal dimension system.

Inherited from org.h2.util.geometry.GeometryUtils.Target:
endCollectionItemendNonEmptyPolygonendObjectinitstartCollectionstartCollectionItemstartLineStringstartPointstartPolygonstartPolygonInner

Field Detail

hasMback to summary
private boolean hasM
hasZback to summary
private boolean hasZ

Constructor Detail

DimensionSystemTargetback to summary
public DimensionSystemTarget()

Creates a new dimension system determination target.

Method Detail

addCoordinateback to summary
protected void addCoordinate(double x, double y, double z, double m, int index, int total)

Implements abstract org.h2.util.geometry.GeometryUtils.Target.addCoordinate.

Doc from org.h2.util.geometry.GeometryUtils.Target.addCoordinate.

Invoked to add a coordinate to a geometry.

Parameters
x:double

X coordinate

y:double

Y coordinate

z:double

Z coordinate (NaN if not used)

m:double

M coordinate (NaN if not used)

index:int

0-based index of coordinate in the current sequence

total:int

total number of coordinates in the current sequence

Annotations
@Override
dimensionSystemback to summary
protected void dimensionSystem(int dimensionSystem)

Overrides org.h2.util.geometry.GeometryUtils.Target.dimensionSystem.

Doc from org.h2.util.geometry.GeometryUtils.Target.dimensionSystem.

Invoked to add dimension system requirement.

Parameters
dimensionSystem:int

dimension system

Annotations
@Override
getDimensionSystemback to summary
public int getDimensionSystem()

Returns the minimal dimension system.

Returns:int

the minimal dimension system

org.h2.util.geometry back to summary

public final Class GeometryUtils.EnvelopeTarget

extends Target
Class Inheritance

Converter output target that calculates an envelope.

Field Summary

Modifier and TypeField and Description
private boolean
enabled

Enables or disables the envelope calculation.

private double
private double
private double
private double
private boolean
set

Whether envelope was set.

Constructor Summary

AccessConstructor and Description
public
EnvelopeTarget()

Creates a new envelope calculation target.

Method Summary

Modifier and TypeMethod and Description
protected void
addCoordinate(double
X coordinate
x
,
double
Y coordinate
y
,
double
Z coordinate (NaN if not used)
z
,
double
M coordinate (NaN if not used)
m
,
int
0-based index of coordinate in the current sequence
index
,
int
total number of coordinates in the current sequence
total
)

Implements abstract org.h2.util.geometry.GeometryUtils.Target.addCoordinate.

Invoked to add a coordinate to a geometry.

public double[]

Returns:

the envelope, or null
getEnvelope
()

Returns the envelope.

protected void
startLineString(int
number of points in line string
numPoints
)

Overrides org.h2.util.geometry.GeometryUtils.Target.startLineString.

Invoked before writing a LINESTRING.

protected void
startPoint()

Overrides org.h2.util.geometry.GeometryUtils.Target.startPoint.

Invoked before writing a POINT.

protected void
startPolygon(int
number of inner polygons
numInner
,
int
number of points in outer polygon
numPoints
)

Overrides org.h2.util.geometry.GeometryUtils.Target.startPolygon.

Invoked before writing a POLYGON.

protected void
startPolygonInner(int
number of points in inner polygon
numInner
)

Overrides org.h2.util.geometry.GeometryUtils.Target.startPolygonInner.

Invoked before writing an inner polygon in POLYGON.

Inherited from org.h2.util.geometry.GeometryUtils.Target:
dimensionSystemendCollectionItemendNonEmptyPolygonendObjectinitstartCollectionstartCollectionItem

Field Detail

enabledback to summary
private boolean enabled

Enables or disables the envelope calculation. Inner rings of polygons are not counted.

maxXback to summary
private double maxX
maxYback to summary
private double maxY
minXback to summary
private double minX
minYback to summary
private double minY
setback to summary
private boolean set

Whether envelope was set.

Constructor Detail

EnvelopeTargetback to summary
public EnvelopeTarget()

Creates a new envelope calculation target.

Method Detail

addCoordinateback to summary
protected void addCoordinate(double x, double y, double z, double m, int index, int total)

Implements abstract org.h2.util.geometry.GeometryUtils.Target.addCoordinate.

Doc from org.h2.util.geometry.GeometryUtils.Target.addCoordinate.

Invoked to add a coordinate to a geometry.

Parameters
x:double

X coordinate

y:double

Y coordinate

z:double

Z coordinate (NaN if not used)

m:double

M coordinate (NaN if not used)

index:int

0-based index of coordinate in the current sequence

total:int

total number of coordinates in the current sequence

Annotations
@Override
getEnvelopeback to summary
public double[] getEnvelope()

Returns the envelope.

Returns:double[]

the envelope, or null

startLineStringback to summary
protected void startLineString(int numPoints)

Overrides org.h2.util.geometry.GeometryUtils.Target.startLineString.

Doc from org.h2.util.geometry.GeometryUtils.Target.startLineString.

Invoked before writing a LINESTRING.

Parameters
numPoints:int

number of points in line string

Annotations
@Override
startPointback to summary
protected void startPoint()

Overrides org.h2.util.geometry.GeometryUtils.Target.startPoint.

Doc from org.h2.util.geometry.GeometryUtils.Target.startPoint.

Invoked before writing a POINT.

Annotations
@Override
startPolygonback to summary
protected void startPolygon(int numInner, int numPoints)

Overrides org.h2.util.geometry.GeometryUtils.Target.startPolygon.

Doc from org.h2.util.geometry.GeometryUtils.Target.startPolygon.

Invoked before writing a POLYGON. If polygon is empty, both parameters are 0.

Parameters
numInner:int

number of inner polygons

numPoints:int

number of points in outer polygon

Annotations
@Override
startPolygonInnerback to summary
protected void startPolygonInner(int numInner)

Overrides org.h2.util.geometry.GeometryUtils.Target.startPolygonInner.

Doc from org.h2.util.geometry.GeometryUtils.Target.startPolygonInner.

Invoked before writing an inner polygon in POLYGON.

Parameters
numInner:int

number of points in inner polygon

Annotations
@Override
org.h2.util.geometry back to summary

public abstract Class GeometryUtils.Target

extends Object
Class Inheritance
Known Direct Subclasses
org.h2.util.geometry.GeometryUtils.EnvelopeTarget, org.h2.util.geometry.GeometryUtils.DimensionSystemTarget, org.h2.util.geometry.JTSUtils.GeometryTarget, org.h2.util.geometry.EWKBUtils.EWKBTarget, org.h2.util.geometry.EWKTUtils.EWKTTarget, org.h2.util.geometry.GeoJsonUtils.GeoJsonTarget

Converter output target.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract void
addCoordinate(double
X coordinate
x
,
double
Y coordinate
y
,
double
Z coordinate (NaN if not used)
z
,
double
M coordinate (NaN if not used)
m
,
int
0-based index of coordinate in the current sequence
index
,
int
total number of coordinates in the current sequence
total
)

Invoked to add a coordinate to a geometry.

protected void
dimensionSystem(int
dimension system
dimensionSystem
)

Invoked to add dimension system requirement.

protected void
endCollectionItem(GeometryUtils.Target target, int
type of collection
type
,
int
0-based index of this item in the collection
index
,
int
total number of items in the collection
total
)

Invoked after writing of a collection item.

protected void
endNonEmptyPolygon()

Invoked after writing of non-empty POLYGON.

protected void
endObject(int
type of the object
type
)

Invoked after writing of the object.

protected void
init(int
SRID
srid
)

Initializes top-level target.

protected void
startCollection(int type, int
number of items in this collection
numItems
)

Invoked before writing of a collection.

protected GeometryUtils.Target

Returns:

output target that should be used for processing of this collection item. May return this target or an custom sub-target.
startCollectionItem
(int
0-based index of this item in the collection
index
,
int
total number of items in the collection
total
)

Invoked before writing of a collection item.

protected void
startLineString(int
number of points in line string
numPoints
)

Invoked before writing a LINESTRING.

protected void
startPoint()

Invoked before writing a POINT.

protected void
startPolygon(int
number of inner polygons
numInner
,
int
number of points in outer polygon
numPoints
)

Invoked before writing a POLYGON.

protected void
startPolygonInner(int
number of points in inner polygon
numInner
)

Invoked before writing an inner polygon in POLYGON.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Targetback to summary
public Target()

Method Detail

addCoordinateback to summary
protected abstract void addCoordinate(double x, double y, double z, double m, int index, int total)

Invoked to add a coordinate to a geometry.

Parameters
x:double

X coordinate

y:double

Y coordinate

z:double

Z coordinate (NaN if not used)

m:double

M coordinate (NaN if not used)

index:int

0-based index of coordinate in the current sequence

total:int

total number of coordinates in the current sequence

dimensionSystemback to summary
protected void dimensionSystem(int dimensionSystem)

Invoked to add dimension system requirement.

Parameters
dimensionSystem:int

dimension system

endCollectionItemback to summary
protected void endCollectionItem(GeometryUtils.Target target, int type, int index, int total)

Invoked after writing of a collection item. This method is invoked on the same target that was used for startCollectionItem(int, int).

Parameters
target:GeometryUtils.Target

the result of startCollectionItem(int, int)

type:int

type of collection

index:int

0-based index of this item in the collection

total:int

total number of items in the collection

endNonEmptyPolygonback to summary
protected void endNonEmptyPolygon()

Invoked after writing of non-empty POLYGON.

endObjectback to summary
protected void endObject(int type)

Invoked after writing of the object.

Parameters
type:int

type of the object

initback to summary
protected void init(int srid)

Initializes top-level target.

Parameters
srid:int

SRID

startCollectionback to summary
protected void startCollection(int type, int numItems)

Invoked before writing of a collection.

Parameters
type:int

type of collection, one of GeometryUtils#MULTI_POINT, GeometryUtils#MULTI_LINE_STRING, GeometryUtils#MULTI_POLYGON, GeometryUtils#GEOMETRY_COLLECTION

numItems:int

number of items in this collection

startCollectionItemback to summary
protected GeometryUtils.Target startCollectionItem(int index, int total)

Invoked before writing of a collection item.

Parameters
index:int

0-based index of this item in the collection

total:int

total number of items in the collection

Returns:GeometryUtils.Target

output target that should be used for processing of this collection item. May return this target or an custom sub-target.

startLineStringback to summary
protected void startLineString(int numPoints)

Invoked before writing a LINESTRING.

Parameters
numPoints:int

number of points in line string

startPointback to summary
protected void startPoint()

Invoked before writing a POINT.

startPolygonback to summary
protected void startPolygon(int numInner, int numPoints)

Invoked before writing a POLYGON. If polygon is empty, both parameters are 0.

Parameters
numInner:int

number of inner polygons

numPoints:int

number of points in outer polygon

startPolygonInnerback to summary
protected void startPolygonInner(int numInner)

Invoked before writing an inner polygon in POLYGON.

Parameters
numInner:int

number of points in inner polygon