Package org.geotools.geometry
Class Position1D
- Object
-
- AbstractPosition
-
- Position1D
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Position
,Cloneable
public class Position1D extends AbstractPosition implements Serializable, Cloneable
Holds the coordinates for a one-dimensional position within some coordinate reference system.- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
- See Also:
Position2D
,GeneralPosition
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description double
ordinate
The ordinate value.
-
Constructor Summary
Constructors Constructor Description Position1D()
Constructs a position initialized to (0) with anull
coordinate reference system.Position1D(double ordinate)
Constructs a 1D position from the specified ordinate.Position1D(Position point)
Constructs a position initialized to the same values than the specified point.Position1D(CoordinateReferenceSystem crs)
Constructs a position with the specified coordinate reference system.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Position1D
clone()
Returns a copy of this position.boolean
equals(Object o)
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)
Set the coordinate reference system in which the coordinate is given.void
setLocation(Position position)
Set 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 AbstractPosition
checkCoordinateReferenceSystemDimension, getDirectPosition, setPosition, toString
-
-
-
-
Constructor Detail
-
Position1D
public Position1D()
Constructs a position initialized to (0) with anull
coordinate reference system.
-
Position1D
public Position1D(CoordinateReferenceSystem crs)
Constructs a position with the specified coordinate reference system.- Parameters:
crs
- The coordinate reference system.
-
Position1D
public Position1D(double ordinate)
Constructs a 1D position from the specified ordinate.- Parameters:
ordinate
- The ordinate value.
-
Position1D
public Position1D(Position point)
Constructs a position initialized to the same values than the specified point.- Parameters:
point
- The position to copy.
-
-
Method Detail
-
getCoordinateReferenceSystem
public final CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the coordinate reference system in which the coordinate is given. May benull
if this particularDirectPosition
is included in a larger object with such a reference to a coordinate reference system.- Specified by:
getCoordinateReferenceSystem
in interfacePosition
- Returns:
- The coordinate reference system, or
null
.
-
setCoordinateReferenceSystem
public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Set the coordinate reference system in which the coordinate is given.- Parameters:
crs
- The new coordinate reference system, ornull
.
-
getDimension
public final int getDimension()
The length of coordinate sequence (the number of entries). This is always 1 forDirectPosition1D
objects.- Specified by:
getDimension
in interfacePosition
- 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 interfacePosition
- Overrides:
getCoordinate
in classAbstractPosition
- Returns:
- The coordinates.
-
getOrdinate
public final double getOrdinate(int dimension) throws IndexOutOfBoundsException
Returns the ordinate at the specified dimension.- Specified by:
getOrdinate
in interfacePosition
- 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 interfacePosition
- 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(Position position) throws MismatchedDimensionException
Set 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.- 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 interfacePosition
- Overrides:
hashCode
in classAbstractPosition
- Returns:
- A hash code value for this position.
-
equals
public boolean equals(Object o)
Description copied from class:AbstractPosition
- Specified by:
equals
in interfacePosition
- Overrides:
equals
in classAbstractPosition
- Parameters:
o
- The object to compare with this position.- Returns:
true
if the given object is equals to this position.
-
clone
public Position1D clone()
Returns a copy of this position.- Specified by:
clone
in interfaceCloneable
- Overrides:
clone
in classObject
- Returns:
- A copy of this object.
- See Also:
Object.clone()
-
-