org.apache.sis.geometry

## Class DirectPosition1D

- Object
- - AbstractDirectPosition
  - - DirectPosition1D

- All Implemented Interfaces:
    Serializable, Cloneable, Position, DirectPosition

      public class DirectPosition1D
      extends AbstractDirectPosition
      implements Serializable, Cloneable

  A one-dimensional position within some coordinate reference system.
  Since:
    0.3
  See Also:
    `DirectPosition2D`, `GeneralDirectPosition`, `CoordinateFormat`, Serialized Form

  Defined in the `sis-referencing` module

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `double` | `ordinate` The ordinate value.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DirectPosition1D()` Constructs a position initialized to (0) with a `null` coordinate reference system.
    `DirectPosition1D(CharSequence wkt)` Constructs a position initialized to the values parsed from the given string in Well Known Text (WKT) format.
    `DirectPosition1D(CoordinateReferenceSystem crs)` Constructs a position with the specified coordinate reference system.
    `DirectPosition1D(double ordinate)` Constructs a 1D position from the specified ordinate.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DirectPosition1D` | `clone()` Returns a copy of this position.
    `double[]` | `getCoordinate()` Returns a sequence of numbers that hold the coordinate of this position in its reference system.
    `CoordinateReferenceSystem` | `getCoordinateReferenceSystem()` Returns the coordinate reference system in which the coordinate is given.
    `int` | `getDimension()` The length of coordinate sequence (the number of entries).
    `double` | `getOrdinate(int dimension)` Returns the ordinate at the specified dimension.
    `int` | `hashCode()` Returns a hash value for this coordinate.
    `void` | `setCoordinateReferenceSystem(CoordinateReferenceSystem crs)` Sets the coordinate reference system in which the coordinate is given.
    `void` | `setLocation(DirectPosition position)` Sets this coordinate to the specified direct position.
    `void` | `setOrdinate(int dimension, double value)` Sets the ordinate value along the specified dimension.
    `String` | `toString()` Formats this position in the Well Known Text (WKT) format.

    - ### Methods inherited from class AbstractDirectPosition

      `equals, getDirectPosition, normalize`

    - ### Methods inherited from class Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### ordinate

          public double ordinate

      The ordinate value.

  - ### Constructor Detail

    - #### 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 ordinate)

      Constructs a 1D position from the specified ordinate.
      Parameters:
        `ordinate` - the ordinate 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:
        `IllegalArgumentException` - if the given string can not be parsed.
        `MismatchedDimensionException` - if the given point is not one-dimensional.
      See Also:
        `toString()`, `CoordinateFormat`

  - ### Method Detail

    - #### getDimension

          public final int getDimension()

      The length of coordinate sequence (the number of entries). This is always 1 for `DirectPosition1D` objects.
      Specified by:
        `getDimension` in interface `DirectPosition`
      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 `DirectPosition` is included in a larger object with such a reference to a CRS.
      Specified by:
        `getCoordinateReferenceSystem` in interface `DirectPosition`
      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`.

    - #### getCoordinate

          public final double[] getCoordinate()

      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 `ordinate` field, which is public.
      Specified by:
        `getCoordinate` in interface `DirectPosition`
      Overrides:
        `getCoordinate` in class `AbstractDirectPosition`
      Returns:
        the coordinates.

    - #### getOrdinate

          public final double getOrdinate(int dimension)
                                   throws IndexOutOfBoundsException

      Returns the ordinate at the specified dimension.
      API note: This method is final for ensuring consistency with the `ordinate` field, which is public.
      Specified by:
        `getOrdinate` in interface `DirectPosition`
      Parameters:
        `dimension` - the dimension, which must be 0.
      Returns:
        the ordinate.
      Throws:
        `IndexOutOfBoundsException` - if the specified dimension is out of bounds.

    - #### setOrdinate

          public void setOrdinate(int dimension,
                                  double value)
                           throws IndexOutOfBoundsException

      Sets the ordinate value along the specified dimension.
      Specified by:
        `setOrdinate` in interface `DirectPosition`
      Parameters:
        `dimension` - the dimension, which must be 0.
        `value` - the ordinate value.
      Throws:
        `IndexOutOfBoundsException` - if the specified dimension is out of bounds.

    - #### 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:
        `setLocation` in class `AbstractDirectPosition`
      Parameters:
        `position` - the new position for this point.
      Throws:
        `MismatchedDimensionException` - 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(ordinate)

      The string returned by this method can be parsed by the `DirectPosition1D` constructor.
      Overrides:
        `toString` in class `AbstractDirectPosition`
      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.

    - #### hashCode

          public int hashCode()

      Returns a hash value for this coordinate. This method returns a value compliant with the contract documented in the `DirectPosition​.hashCode()` javadoc. Consequently, it should be possible to mix different `DirectPosition` implementations in the same hash map.
      Specified by:
        `hashCode` in interface `DirectPosition`
      Overrides:
        `hashCode` in class `AbstractDirectPosition`
      Returns:
        a hash code value for this position.

Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.