Package org.geotools.geometry
Class AbstractPosition
- Object
-
- AbstractPosition
-
- All Implemented Interfaces:
Position
- Direct Known Subclasses:
GeneralPosition
,Position1D
public abstract class AbstractPosition extends Object implements Position
Base class for direct position implementations. This base class provides default implementations fortoString()
,equals(java.lang.Object)
andhashCode()
methods.This class do not holds any state. The decision to implement
Serializable
ororg.geotools.util.Cloneable
interfaces is left to implementors.- Since:
- 2.4
- Author:
- Martin Desruisseaux (IRD)
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPosition()
Constructs a direct position.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
checkCoordinateReferenceSystemDimension(CoordinateReferenceSystem crs, int expected)
Convenience method for checking coordinate reference system validity.boolean
equals(Object object)
double[]
getCoordinate()
Returns a sequence of numbers that hold the coordinate of this position in its reference system.Position
getDirectPosition()
Returns alwaysthis
, the direct position for this position.int
hashCode()
Returns a hash value for this coordinate.void
setPosition(Position position)
Sets this direct position to the given position.String
toString()
Returns a string representation of this coordinate.-
Methods inherited from interface Position
getCoordinateReferenceSystem, getDimension, getOrdinate, setOrdinate
-
-
-
-
Method Detail
-
getDirectPosition
public Position getDirectPosition()
Returns alwaysthis
, the direct position for this position.- Specified by:
getDirectPosition
in interfacePosition
- Returns:
- The direct position (may be
this
). - Since:
- 2.5
-
setPosition
public void setPosition(Position position)
Sets this direct position to the given position. If the given position isnull
, then all ordinate values are set to NaN.- Parameters:
position
- The new position.- Since:
- 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 interfacePosition
- Returns:
- The coordinates.
-
checkCoordinateReferenceSystemDimension
public static void checkCoordinateReferenceSystemDimension(CoordinateReferenceSystem crs, int expected) throws MismatchedDimensionException
Convenience method for checking coordinate reference system validity.- Parameters:
crs
- The coordinate reference system to check.expected
- the dimension expected.- Throws:
MismatchedDimensionException
- if the CRS dimension is not valid.
-
toString
public String toString()
Returns a string representation of this coordinate. The default implementation is okay for occasional formatting (for example for debugging purpose). But if there is a lot of positions to format, users will get more control by using their own instance ofCoordinateFormat
.
-
hashCode
public int hashCode()
Returns a hash value for this coordinate.
-
-