org.geotoolkit.geometry
Class AbstractEnvelope

Object
  extended by AbstractEnvelope
All Implemented Interfaces:
Envelope
Direct Known Subclasses:
GeneralEnvelope, ImmutableEnvelope

public abstract class AbstractEnvelope
extends Object
implements Envelope

Base class for envelope implementations. This base class provides default implementations for toString(), equals(Object) and hashCode() methods.

This class do not holds any state. The decision to implement Serializable or Cloneable interfaces is left to implementors.

Since:
2.4
Version:
3.10
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
referencing/geotk-referencing (download)    View source code for this class

Constructor Summary
protected AbstractEnvelope()
          Constructs an envelope.
 
Method Summary
 boolean equals(Envelope envelope, double eps, boolean epsIsRelative)
          Compares to the specified envelope for equality up to the specified tolerance value.
 boolean equals(Object object)
          Returns true if the specified object is an envelope of the same class with equals coordinates and CRS.
 DirectPosition getLowerCorner()
          A coordinate position consisting of all the minimal ordinates.
 DirectPosition getUpperCorner()
          A coordinate position consisting of all the maximal ordinates.
 int hashCode()
          Returns a hash value for this envelope.
static String toPolygonString(Envelope envelope)
          Deprecated. Moved to Envelopes.toPolygonWKT(Envelope).
 String toString()
          Formats this envelope in the Well Known Text (WKT) format.
static String toString(Envelope envelope)
          Deprecated. Moved to Envelopes.toWKT(Envelope).
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Envelope
getCoordinateReferenceSystem, getDimension, getMaximum, getMedian, getMinimum, getSpan
 

Constructor Detail

AbstractEnvelope

protected AbstractEnvelope()
Constructs an envelope.

Method Detail

getLowerCorner

public DirectPosition getLowerCorner()
A coordinate position consisting of all the minimal ordinates. The default implementation returns a direct position backed by this envelope, so changes in this envelope will be immediately reflected in the direct position.

Specified by:
getLowerCorner in interface Envelope
Returns:
The lower corner.

getUpperCorner

public DirectPosition getUpperCorner()
A coordinate position consisting of all the maximal ordinates. The default implementation returns a direct position backed by this envelope, so changes in this envelope will be immediately reflected in the direct position.

Specified by:
getUpperCorner in interface Envelope
Returns:
The upper corner.

toString

public String toString()
Formats this envelope in the Well Known Text (WKT) format. The output is like below, where n is the number of dimensions:
BOXnD(lower corner, upper corner)
The output of this method can be parsed by the GeneralEnvelope constructor.

Overrides:
toString in class Object

toString

@Deprecated
public static String toString(Envelope envelope)
Deprecated. Moved to Envelopes.toWKT(Envelope).

Formats a BOX element from an envelope. This method formats the given envelope in the Well Known Text (WKT) format. The output is like below, where n is the number of dimensions:
BOXnD(lower corner, upper corner)
The output of this method can be parsed by the GeneralEnvelope constructor.

Parameters:
envelope - The envelope to format.
Returns:
The envelope as a BOX2D or BOX3D in WKT format.
Since:
3.09
See Also:
GeneralEnvelope.GeneralEnvelope(String), CoordinateFormat, org.geotoolkit.io.wkt

toPolygonString

@Deprecated
public static String toPolygonString(Envelope envelope)
Deprecated. Moved to Envelopes.toPolygonWKT(Envelope).

Formats a POLYGON element from an envelope. This method formats the given envelope as a geometry in the Well Known Text (WKT) format. This is provided as an alternative to the BOX element formatted by toString(Envelope), because the BOX element is usually not considered a geometry while POLYGON is.

The output of this method can be parsed by the GeneralEnvelope constructor.

Parameters:
envelope - The envelope to format.
Returns:
The envelope as a POLYGON in WKT format.
Since:
3.09
See Also:
org.geotoolkit.io.wkt

hashCode

public int hashCode()
Returns a hash value for this envelope.

Overrides:
hashCode in class Object

equals

public boolean equals(Object object)
Returns true if the specified object is an envelope of the same class with equals coordinates and CRS.
Note: This implementation requires that the provided object argument is of the same class than this envelope. We do not relax this rule since not every implementations in the Geotk code base follow the same contract.

Overrides:
equals in class Object
Parameters:
object - The object to compare with this envelope.
Returns:
true if the given object is equal to this envelope.

equals

public boolean equals(Envelope envelope,
                      double eps,
                      boolean epsIsRelative)
Compares to the specified envelope for equality up to the specified tolerance value. The tolerance value eps can be either relative to the envelope span along each dimension or can be an absolute value (as for example some ground resolution of a grid coverage).

If epsIsRelative is set to true, the actual tolerance value for a given dimension i is eps×span where span is the maximum of this envelope span and the specified envelope length along dimension i.

If epsIsRelative is set to false, the actual tolerance value for a given dimension i is eps.

Relative tolerance value (as opposed to absolute tolerance value) help to workaround the fact that tolerance value are CRS dependent. For example the tolerance value need to be smaller for geographic CRS than for UTM projections, because the former typically has a range of -180 to 180° while the later can have a range of thousands of meters.

Note: This method assumes that the specified envelope uses the same CRS than this envelope. For performance reason, it will no be verified unless Java assertions are enabled.

Parameters:
envelope - The envelope to compare with.
eps - The tolerance value to use for numerical comparisons.
epsIsRelative - true if the tolerance value should be relative to axis length, or false if it is an absolute value.
Returns:
true if the given object is equal to this envelope up to the given tolerance value.
Since:
2.4
See Also:
GeneralEnvelope.contains(Envelope, boolean), GeneralEnvelope.intersects(Envelope, boolean)


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.