Class ImmutableDirectPosition
Object
FormattableObject
AbstractDirectPosition
ImmutableDirectPosition
- All Implemented Interfaces:
Serializable, Printable, Position, DirectPosition
An immutable
DirectPosition (the coordinates of a position) of arbitrary dimension.
This final class is immutable and thus inherently thread-safe if the CoordinateReferenceSystem
instance given to the constructor is immutable. This is usually the case in Apache SIS.- Since:
- 1.6
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionImmutableDirectPosition(CoordinateReferenceSystem crs, double... coordinates) Constructs a position defined by a sequence of coordinate values. -
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableDirectPositioncastOrCopy(DirectPosition position) Returns the given position as anImmutableDirectPositioninstance.doublegetCoordinate(int dimension) Returns the coordinate at the specified dimension.Returns the coordinate reference system in which the coordinates are given.double[]Returns a sequence of numbers that hold the coordinates of this position in its reference system.intThe length of coordinate sequence (the number of entries).Methods inherited from class AbstractDirectPosition
formatTo, getCoordinate, getDirectPosition, getOrdinate, normalize, setCoordinate, setLocation, setOrdinateMethods inherited from class FormattableObject
print, toString, toWKT
-
Constructor Details
-
ImmutableDirectPosition
public ImmutableDirectPosition(CoordinateReferenceSystem crs, double... coordinates) throws MismatchedDimensionException Constructs a position defined by a sequence of coordinate values.- Parameters:
crs- the CRS to assign to this direct position, ornull.coordinates- the coordinate values for each dimension.- Throws:
MismatchedDimensionException- if the CRS dimension is not equal to the number of coordinates.
-
-
Method Details
-
castOrCopy
Returns the given position as anImmutableDirectPositioninstance. If the given position is already an instance ofImmutableDirectPosition, then it is returned unchanged. Otherwise, the coordinate values and the CRS of the given position are copied in a new position.- Parameters:
position- the position to cast or copy, ornull.- Returns:
- the values of the given position as an
ImmutableDirectPositioninstance.
-
getDimension
public int getDimension()The length of coordinate sequence (the number of entries).- Specified by:
getDimensionin interfaceDirectPosition- Returns:
- the dimensionality of this position.
-
getCoordinateReferenceSystem
Returns the coordinate reference system in which the coordinates are given. May benullif this particularDirectPositionis included in a larger object with such a reference to a CRS.- Specified by:
getCoordinateReferenceSystemin interfaceDirectPosition- Overrides:
getCoordinateReferenceSystemin classAbstractDirectPosition- Returns:
- the coordinate reference system, or
null.
-
getCoordinates
public double[] getCoordinates()Returns a sequence of numbers that hold the coordinates of this position in its reference system.- Overrides:
getCoordinatesin classAbstractDirectPosition- Returns:
- a copy of the coordinates array.
-
getCoordinate
Returns the coordinate at the specified dimension.- Specified by:
getCoordinatein classAbstractDirectPosition- Parameters:
dimension- the dimension in the range 0 to dimension-1.- Returns:
- the coordinate at the specified dimension.
- Throws:
IndexOutOfBoundsException- if the specified dimension is out of bounds.
-