Class ImmutableDirectPosition

All Implemented Interfaces:
Serializable, Printable, Position, Direct­Position

public final class ImmutableDirectPosition extends AbstractDirectPosition implements Serializable
An immutable Direct­Position (the coordinates of a position) of arbitrary dimension. This final class is immutable and thus inherently thread-safe if the Coordinate­Reference­System instance given to the constructor is immutable. This is usually the case in Apache SIS.
Since:
1.6
See Also:
  • 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, or null.
      coordinates - the coordinate values for each dimension.
      Throws:
      Mismatched­Dimension­Exception - if the CRS dimension is not equal to the number of coordinates.
  • Method Details

    • castOrCopy

      public static ImmutableDirectPosition castOrCopy(DirectPosition position)
      Returns the given position as an Immutable­Direct­Position instance. If the given position is already an instance of Immutable­Direct­Position, 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, or null.
      Returns:
      the values of the given position as an Immutable­Direct­Position instance.
    • getDimension

      public int getDimension()
      The length of coordinate sequence (the number of entries).
      Specified by:
      get­Dimension in interface Direct­Position
      Returns:
      the dimensionality of this position.
    • getCoordinateReferenceSystem

      public CoordinateReferenceSystem getCoordinateReferenceSystem()
      Returns the coordinate reference system in which the coordinates are given. May be null if this particular Direct­Position is included in a larger object with such a reference to a CRS.
      Specified by:
      get­Coordinate­Reference­System in interface Direct­Position
      Overrides:
      get­Coordinate­Reference­System in class Abstract­Direct­Position
      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:
      get­Coordinates in class Abstract­Direct­Position
      Returns:
      a copy of the coordinates array.
    • getCoordinate

      public double getCoordinate(int dimension) throws IndexOutOfBoundsException
      Returns the coordinate at the specified dimension.
      Specified by:
      get­Coordinate in class Abstract­Direct­Position
      Parameters:
      dimension - the dimension in the range 0 to dimension-1.
      Returns:
      the coordinate at the specified dimension.
      Throws:
      Index­Out­Of­Bounds­Exception - if the specified dimension is out of bounds.