Class MortonCode<P extends C2D>
- java.lang.Object
-
- org.geolatte.geom.curve.MortonCode<P>
-
public class MortonCode<P extends C2D> extends Object
Calculates the Morton code (Morton-order or Z-order) of GeometriesMorton codes are labels for the nodes of a QuadTree. A QuadTree is a partition of a spatial extent by recursively decomposing it into four equal quadrants. A QuadTree is determined by a spatial extent and depth of the tree (the number of recursive subdivisions of the extent). Both are specified by the
MortonContextpassed during construction of instances of this class.The Morton code of a
Geometrycan be viewed as a path to the quadrant containing the envelope of thatGeometry. The left-most character of the code contains the label of the quadrant at depth 1, the second at depth 2, etc. If the Morton code is the empty string, then the envelope fits in no single quandrant of the QuadTree.At each level the four quadrants are labeled:
- O : lower-left quadrant
- 1 : upper-left quadrant
- 2 : lower-right quadrant
- 3 : upper-right quadrant
- Author:
- Karel Maesen, Geovise BVBA creation-date: 2/19/13
-
-
Constructor Summary
Constructors Constructor Description MortonCode(MortonContext<P> mortonContext)Constructs an instance with the givenMortoncontext
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Envelope<P>envelopeOf(String mortoncode)Returns the extent that corresponds to the specified morton codeintgetMaxLength()Returns the maximum length of a morton code generated by this instance.StringofEnvelope(Envelope<P> envelope)Returns the Morton code for the specifiedEnvelope.StringofGeometry(Geometry<P> geometry)Returns the Morton code for the specifiedGeometry.StringofPosition(P pos)Returns the Morton code for the specifiedPoint.
-
-
-
Constructor Detail
-
MortonCode
public MortonCode(MortonContext<P> mortonContext)
Constructs an instance with the givenMortoncontextThe specified
MortonCodedetermines a QuadTree for which this instance calculates labels.- Parameters:
mortonContext- the context to use when calculating morton codes.
-
-
Method Detail
-
ofGeometry
public String ofGeometry(Geometry<P> geometry)
Returns the Morton code for the specifiedGeometry.This method is equivalent to
ofEnvelope(geometry.getEnvelope()).- Parameters:
geometry- a {code Geometry} value.- Returns:
- the morton code for the envelope of the specified
Geometry. - Throws:
IllegalArgumentException- if the geometry is null, or has an envelope which is not contained in the spatial extent of this instance'sMortonContext
-
ofEnvelope
public String ofEnvelope(Envelope<P> envelope)
Returns the Morton code for the specifiedEnvelope.- Parameters:
envelope- anEnvelopevalue.- Returns:
- the morton code for the specified
Envelopevalue. - Throws:
IllegalArgumentException- if the value of the envelope parameter is null, or is not contained in the spatial extent of this instance'sMortonContext
-
ofPosition
public String ofPosition(P pos)
Returns the Morton code for the specifiedPoint.- Parameters:
pos- anPointvalue.- Returns:
- the morton code for the specified
Pointvalue. - Throws:
IllegalArgumentException- if the value of the point parameter is null, or is not contained in the spatial extent of this instance'sMortonContext
-
getMaxLength
public int getMaxLength()
Returns the maximum length of a morton code generated by this instance.- Returns:
- the maximum length of a morton code generated by this instance.
-
-