Class DirectPosition1D

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

public class DirectPosition1D extends AbstractDirectPosition implements Serializable, Cloneable
A one-dimensional position within some coordinate reference system.
Since:
0.3
See Also:
  • Field Details

    • coordinate

      public double coordinate
      The coordinate value.
  • Constructor Details

    • DirectPosition1D

      public DirectPosition1D()
      Constructs a position initialized to (0) with a null coordinate reference system.
    • DirectPosition1D

      public DirectPosition1D(CoordinateReferenceSystem crs)
      Constructs a position with the specified coordinate reference system.
      Parameters:
      crs - the coordinate reference system.
    • DirectPosition1D

      public DirectPosition1D(double coordinate)
      Constructs a 1D position from the specified coordinate.
      Parameters:
      coordinate - the coordinate value.
    • DirectPosition1D

      public DirectPosition1D(CharSequence wkt) throws IllegalArgumentException
      Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format. The given string is typically a POINT element like below:
      POINT(6)
      
      Parameters:
      wkt - the POINT or other kind of element to parse.
      Throws:
      Illegal­Argument­Exception - if the given string cannot be parsed.
      Mismatched­Dimension­Exception - if the given point is not one-dimensional.
      See Also:
  • Method Details

    • getDimension

      public final int getDimension()
      The length of coordinate sequence (the number of entries). This is always 1 for Direct­Position1D objects.
      Specified by:
      get­Dimension in interface Direct­Position
      Returns:
      the dimensionality of this position.
    • getCoordinateReferenceSystem

      public final CoordinateReferenceSystem getCoordinateReferenceSystem()
      Returns the coordinate reference system in which the coordinate is 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.
    • setCoordinateReferenceSystem

      public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
      Sets the coordinate reference system in which the coordinate is given.
      Parameters:
      crs - the new coordinate reference system, or null.
    • getCoordinates

      public final double[] getCoordinates()
      Returns a sequence of numbers that hold the coordinate of this position in its reference system.
      API note: This method is final for ensuring consistency with the coordinate field, which is public.
      Overrides:
      get­Coordinates in class Abstract­Direct­Position
      Returns:
      the coordinates.
      Since:
      1.5
    • getCoordinate

      public final double getCoordinate(int dimension) throws IndexOutOfBoundsException
      Returns the coordinate at the specified dimension.
      API note: This method is final for ensuring consistency with the coordinate field, which is public.
      Specified by:
      get­Coordinate in class Abstract­Direct­Position
      Parameters:
      dimension - the dimension, which must be 0.
      Returns:
      the coordinate.
      Throws:
      Index­Out­Of­Bounds­Exception - if the specified dimension is out of bounds.
      Since:
      1.5
    • setCoordinate

      public void setCoordinate(int dimension, double value) throws IndexOutOfBoundsException
      Sets the coordinate value along the specified dimension.
      Overrides:
      set­Coordinate in class Abstract­Direct­Position
      Parameters:
      dimension - the dimension, which must be 0.
      value - the coordinate value.
      Throws:
      Index­Out­Of­Bounds­Exception - if the specified dimension is out of bounds.
      Since:
      1.5
    • setLocation

      public void setLocation(DirectPosition position) throws MismatchedDimensionException
      Sets this coordinate to the specified direct position. If the specified position contains a coordinate reference system (CRS), then the CRS for this position will be set to the CRS of the specified position.
      Overrides:
      set­Location in class Abstract­Direct­Position
      Parameters:
      position - the new position for this point.
      Throws:
      Mismatched­Dimension­Exception - if this point doesn't have the expected dimension.
    • toString

      public String toString()
      Formats this position in the Well Known Text (WKT) format. The output is like below:
      POINT(coordinate)
      
      The string returned by this method can be parsed by the Direct­Position1D constructor.
      Overrides:
      to­String in class Abstract­Direct­Position
      Returns:
      this position as a POINT in Well Known Text (WKT) format.
    • clone

      public DirectPosition1D clone()
      Returns a copy of this position.
      Overrides:
      clone in class Object
      Returns:
      a copy of this position.