Class AbstractPosition

Object
AbstractPosition
All Implemented Interfaces:
Position
Direct Known Subclasses:
GeneralPosition, Position1D

public abstract class AbstractPosition extends Object implements Position
Base class for direct position implementations. This base class provides default implementations for toString(), equals(java.lang.Object) and hashCode() methods.

This class do not holds any state. The decision to implement Serializable or org.geotools.util.Cloneable interfaces is left to implementors.

Since:
2.4
Author:
Martin Desruisseaux (IRD)
  • Constructor Details

    • AbstractPosition

      protected AbstractPosition()
      Constructs a direct position.
  • Method Details

    • getDirectPosition

      public Position getDirectPosition()
      Returns always this, the direct position for this position.
      Specified by:
      getDirectPosition in interface Position
      Returns:
      The direct position (may be this).
      Since:
      2.5
    • setPosition

      public void setPosition(Position position)
      Sets this direct position to the given position. If the given position is null, then all ordinate values are set to NaN.
      Parameters:
      position - The new position.
      Since:
      2.5
    • getCoordinate

      public double[] getCoordinate()
      Returns a sequence of numbers that hold the coordinate of this position in its reference system.
      Specified by:
      getCoordinate in interface Position
      Returns:
      The coordinates.
    • checkCoordinateReferenceSystemDimension

      public static void checkCoordinateReferenceSystemDimension(CoordinateReferenceSystem crs, int expected) throws MismatchedDimensionException
      Convenience method for checking coordinate reference system validity.
      Parameters:
      crs - The coordinate reference system to check.
      expected - the dimension expected.
      Throws:
      MismatchedDimensionException - if the CRS dimension is not valid.
    • toString

      public String toString()
      Returns a string representation of this coordinate. The default implementation is okay for occasional formatting (for example for debugging purpose). But if there is a lot of positions to format, users will get more control by using their own instance of CoordinateFormat.
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Returns a hash value for this coordinate.
      Specified by:
      hashCode in interface Position
      Overrides:
      hashCode in class Object
      Returns:
      A hash code value for this position.
    • equals

      public boolean equals(Object object)
      Returns true if the specified object is also a direct position with equals coordinate and CRS.
      Specified by:
      equals in interface Position
      Overrides:
      equals in class Object
      Parameters:
      object - The object to compare with this position.
      Returns:
      true if the given object is equals to this position.