org.geotoolkit.geometry
Class AbstractDirectPosition

Object
  extended by AbstractDirectPosition
All Implemented Interfaces:
Position, DirectPosition
Direct Known Subclasses:
DirectPosition1D, GeneralDirectPosition

public abstract class AbstractDirectPosition
extends Object
implements DirectPosition

Base class for direct position implementations. This base class provides default implementations for toString(), equals(java.lang.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.16
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
referencing/geotk-referencing (download)    View source code for this class

Constructor Summary
protected AbstractDirectPosition()
          Constructs a direct position.
 
Method Summary
 boolean equals(Object object)
          Returns true if the specified object is also a direct position with equals coordinate and CRS.
 double[] getCoordinate()
          Returns a sequence of numbers that hold the coordinate of this position in its reference system.
 DirectPosition getDirectPosition()
          Returns always this, the direct position for this position.
 int hashCode()
          Returns a hash value for this coordinate.
 void setLocation(DirectPosition position)
          Sets this direct position to the given position.
 String toString()
          Formats this position in the Well Known Text (WKT) format.
static String toString(DirectPosition position)
          Formats a POINT element from a direct position.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface DirectPosition
getCoordinateReferenceSystem, getDimension, getOrdinate, setOrdinate
 

Constructor Detail

AbstractDirectPosition

protected AbstractDirectPosition()
Constructs a direct position.

Method Detail

getDirectPosition

public DirectPosition getDirectPosition()
Returns always this, the direct position for this position.

Specified by:
getDirectPosition in interface Position
Since:
2.5

setLocation

public void setLocation(DirectPosition position)
                 throws MismatchedDimensionException
Sets this direct position to the given position. If the given position is null, then all ordinate values are set to NaN.

If this position and the given position have a non-null CRS, then the default implementation requires the CRS to be equals (ignoring metadata) otherwise a MismatchedReferenceSystemException is thrown. However subclass may choose to assign the CRS of this position to the CRS of the given position.

Parameters:
position - The new position, or null.
Throws:
MismatchedDimensionException - If the given position doesn't have the expected dimension.
MismatchedReferenceSystemException - If the given position doesn't use the expected CRS.
Since:
3.16 (derived from 2.5)

getCoordinate

public double[] getCoordinate()
Returns a sequence of numbers that hold the coordinate of this position in its reference system.

Specified by:
getCoordinate in interface DirectPosition
Returns:
The coordinates.

toString

public String toString()
Formats this position in the Well Known Text (WKT) format. The output is like below:
POINT(ordinates)
The output of this method can be parsed by the GeneralDirectPosition constructor.

Overrides:
toString in class Object

toString

public static String toString(DirectPosition position)
Formats a POINT element from a direct position. This method formats the given position in the Well Known Text (WKT) format. The output is like below:
POINT(ordinates)
The output of this method can be parsed by the GeneralDirectPosition constructor.

Parameters:
position - The position to format.
Returns:
The position as a POINT in WKT format.
Since:
3.09
See Also:
GeneralDirectPosition.GeneralDirectPosition(String), CoordinateFormat, org.geotoolkit.io.wkt

hashCode

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

Specified by:
hashCode in interface DirectPosition
Overrides:
hashCode in class Object
Returns:
A hash code value for this position.

equals

public boolean equals(Object object)
Returns true if the specified object is also a direct position with equals coordinate and CRS.

Specified by:
equals in interface DirectPosition
Overrides:
equals in class Object
Parameters:
object - The object to compare with this position.
Returns:
true if the given object is equal to this position.


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