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, setOrdinateModifier and TypeMethodDescriptionprotected StringFormats this position in the Well Known Text (WKT) format.double[]Deprecated.final DirectPositionReturns this direct position.doublegetOrdinate(int dimension) Deprecated.RenamedAbstractDirectPosition.getCoordinate(int)for consistency with ISO 19111 terminology.booleanEnsures that the position is contained in the coordinate system domain.voidsetCoordinate(int dimension, double value) Sets the coordinate value along the specified dimension.voidsetLocation(DirectPosition position) Sets this direct position to the given position.voidsetOrdinate(int dimension, double value) Deprecated.RenamedAbstractDirectPosition.setCoordinate(int, double)for consistency with ISO 19111 terminology.Methods inherited from class FormattableObject
print, toString, toWKTModifier and TypeMethodDescriptionvoidprint()Prints a string representation of this object to the standard output stream.toString(Convention convention) Returns a Well Known Text (WKT) for this object using the specified convention.toWKT()Returns a strictly compliant Well Known Text (WKT) using the default convention, symbols and indentation.
-
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.
-
AbstractDirectPosition.getCoordinates()for consistency with ISO 19111 terminology.