Class PositionWrapper

java.lang.Object
org.locationtech.proj4j.geoapi.Wrapper
org.locationtech.proj4j.geoapi.PositionWrapper
All Implemented Interfaces:
Serializable, org.opengis.geometry.coordinate.Position, org.opengis.geometry.DirectPosition, org.opengis.metadata.Identifier, org.opengis.referencing.ReferenceIdentifier

final class PositionWrapper extends Wrapper implements org.opengis.geometry.DirectPosition, Serializable
Wraps a PROJ4J implementation behind the equivalent GeoAPI interface. The CRS is assumed two-dimensional.
  • Field Details

  • Constructor Details

    • PositionWrapper

      PositionWrapper(ProjCoordinate impl)
      Creates a new wrapper for the given PROJ4J implementation.
  • Method Details

    • wrap

      static PositionWrapper wrap(ProjCoordinate impl)
      Wraps the given implementation.
      Parameters:
      impl - the implementation to wrap, or null
      Returns:
      the wrapper, or null if the given implementation was null
    • implementation

      final Object implementation()
      Returns the PROJ4J backing implementation..
      Specified by:
      implementation in class Wrapper
      Returns:
      the PROJ4J backing implementation
    • getCode

      public String getCode()
      Not applicable.
      Specified by:
      getCode in interface org.opengis.metadata.Identifier
      Specified by:
      getCode in class Wrapper
      Returns:
      the primary object name
    • getDirectPosition

      public org.opengis.geometry.DirectPosition getDirectPosition()
      Returns the direct position, which is provided directly by this object..
      Specified by:
      getDirectPosition in interface org.opengis.geometry.coordinate.Position
      Returns:
      the direct position, which is provided directly by this object
    • getCoordinateReferenceSystem

      public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
      Not specified.
      Specified by:
      getCoordinateReferenceSystem in interface org.opengis.geometry.DirectPosition
    • getDimension

      public int getDimension()
      Returns the number of dimensions., which is 2 or 3 depending on whether the z coordinate value is provided.
      Specified by:
      getDimension in interface org.opengis.geometry.DirectPosition
      Returns:
      the number of dimensions
    • getCoordinate

      public double[] getCoordinate()
      Returns all coordinate values..
      Specified by:
      getCoordinate in interface org.opengis.geometry.DirectPosition
      Returns:
      all coordinate values
    • getOrdinate

      public double getOrdinate(int dimension)
      Returns the coordinate value in the given dimension..
      Specified by:
      getOrdinate in interface org.opengis.geometry.DirectPosition
      Parameters:
      dimension - the dimension of the coordinate to get
      Returns:
      the coordinate value in the given dimension
    • setOrdinate

      public void setOrdinate(int dimension, double value)
      Sets the coordinate value in the given dimension.
      Specified by:
      setOrdinate in interface org.opengis.geometry.DirectPosition
      Parameters:
      dimension - the dimension of the coordinate to set
      value - the value to set
    • setLocation

      static void setLocation(ProjCoordinate src, org.opengis.geometry.DirectPosition tgt)
      Copies the coordinates of the given PROJ4J object into the given GeoAPI object.
      Parameters:
      src - the source coordinates to copy
      tgt - where to copy the coordinates
    • unwrapOrCopy

      static ProjCoordinate unwrapOrCopy(org.opengis.geometry.DirectPosition src)
      Returns the given position as a PROJ4J coordinate tuple.. This method tries to return the backing implementation if possible, or otherwise copies the coordinate values in a new coordinate tuple.
      Parameters:
      src - the position to unwrap or copy
      Returns:
      the given position as a PROJ4J coordinate tuple
    • outOfBounds

      private static IndexOutOfBoundsException outOfBounds(int dimension)
      Returns the exception to throw for a coordinate dimension out of bounds.
      Parameters:
      dimension - the dimension which is out of bound
      Returns:
      the exception to throw
    • unexpectedDimension

      private static org.opengis.geometry.MismatchedDimensionException unexpectedDimension(int dimension)
      Constructs an exception for an unexpected number of dimensions.
      Parameters:
      dimension - the number of dimensions of the object provided by the user
      Returns:
      the exception to throw