org.geotoolkit.geometry
Class DirectPosition1D

Object
  extended by AbstractDirectPosition
      extended by DirectPosition1D
All Implemented Interfaces:
Serializable, Cloneable, Position, DirectPosition

public class DirectPosition1D
extends AbstractDirectPosition
implements Serializable, Cloneable

Holds the coordinates for a one-dimensional position within some coordinate reference system.

Since:
2.0
Version:
3.09
Author:
Martin Desruisseaux (IRD, Geomatys)
See Also:
DirectPosition2D, GeneralDirectPosition, Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
 double ordinate
          The ordinate value.
 
Constructor Summary
DirectPosition1D()
          Constructs a position initialized to (0) with a null coordinate reference system.
DirectPosition1D(CoordinateReferenceSystem crs)
          Constructs a position with the specified coordinate reference system.
DirectPosition1D(DirectPosition point)
          Constructs a position initialized to the same values than the specified point.
DirectPosition1D(double ordinate)
          Constructs a 1D position from the specified ordinate.
DirectPosition1D(String wkt)
          Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format.
 
Method Summary
 DirectPosition1D clone()
          Returns a copy of this position.
 double[] getCoordinate()
          Returns a sequence of numbers that hold the coordinate of this position in its reference system.
 CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the coordinate reference system in which the coordinate is given.
 int getDimension()
          The length of coordinate sequence (the number of entries).
 double getOrdinate(int dimension)
          Returns the ordinate at the specified dimension.
 int hashCode()
          Returns a hash value for this coordinate.
 void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
          Sets the coordinate reference system in which the coordinate is given.
 void setLocation(DirectPosition position)
          Sets this coordinate to the specified direct position.
 void setOrdinate(int dimension, double value)
          Sets the ordinate value along the specified dimension.
 
Methods inherited from class AbstractDirectPosition
equals, getDirectPosition, toString, toString
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ordinate

public double ordinate
The ordinate value.

Constructor Detail

DirectPosition1D

public DirectPosition1D()
Constructs a position initialized to (0) with a null coordinate reference system.


DirectPosition1D

public DirectPosition1D(CoordinateReferenceSystem crs)
Constructs a position with the specified coordinate reference system.

Parameters:
crs - The coordinate reference system.

DirectPosition1D

public DirectPosition1D(double ordinate)
Constructs a 1D position from the specified ordinate.

Parameters:
ordinate - The ordinate value.

DirectPosition1D

public DirectPosition1D(DirectPosition point)
Constructs a position initialized to the same values than the specified point.

Parameters:
point - The position to copy.

DirectPosition1D

public DirectPosition1D(String wkt)
                 throws NumberFormatException,
                        IllegalArgumentException
Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format. The given string is typically a POINT element like below:
POINT(6)

Parameters:
wkt - The POINT or other kind of element to parse.
Throws:
NumberFormatException - If a number can not be parsed.
IllegalArgumentException - If the parenthesis are not balanced.
MismatchedDimensionException - If the given point is not one-dimensional.
Since:
3.09
See Also:
AbstractDirectPosition.toString(DirectPosition), CoordinateFormat
Method Detail

getCoordinateReferenceSystem

public final CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the coordinate reference system in which the coordinate is given. May be null if this particular DirectPosition is included in a larger object with such a reference to a CRS.

Specified by:
getCoordinateReferenceSystem in interface DirectPosition
Returns:
The coordinate reference system, or null.

setCoordinateReferenceSystem

public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Sets the coordinate reference system in which the coordinate is given.

Parameters:
crs - The new coordinate reference system, or null.

getDimension

public final int getDimension()
The length of coordinate sequence (the number of entries). This is always 1 for DirectPosition1D objects.

Specified by:
getDimension in interface DirectPosition
Returns:
The dimensionality of this position.

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
Overrides:
getCoordinate in class AbstractDirectPosition
Returns:
The coordinates.

getOrdinate

public final double getOrdinate(int dimension)
                         throws IndexOutOfBoundsException
Returns the ordinate at the specified dimension.

Specified by:
getOrdinate in interface DirectPosition
Parameters:
dimension - The dimension, which must be 0.
Returns:
The ordinate.
Throws:
IndexOutOfBoundsException - if the specified dimension is out of bounds.

setOrdinate

public final void setOrdinate(int dimension,
                              double value)
                       throws IndexOutOfBoundsException
Sets the ordinate value along the specified dimension.

Specified by:
setOrdinate in interface DirectPosition
Parameters:
dimension - The dimension, which must be 0.
value - the ordinate value.
Throws:
IndexOutOfBoundsException - if the specified dimension is out of bounds.

setLocation

public void setLocation(DirectPosition position)
                 throws MismatchedDimensionException
Sets this coordinate to the specified direct position. If the specified position contains a coordinate reference system, then the CRS for this position will be set to the CRS of the specified position.

Overrides:
setLocation in class AbstractDirectPosition
Parameters:
position - The new position for this point.
Throws:
MismatchedDimensionException - if this point doesn't have the expected dimension.

hashCode

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

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

clone

public DirectPosition1D clone()
Returns a copy of this position.

Overrides:
clone in class Object


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