Class PositionWrapper

  • All Implemented Interfaces:
    java.io.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, java.io.Serializable
    Wraps a PROJ4J implementation behind the equivalent GeoAPI interface. The CRS is assumed two-dimensional.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) ProjCoordinate impl
      The wrapped PROJ4 implementation.
      • Fields inherited from interface org.opengis.metadata.Identifier

        AUTHORITY_KEY, CODE_KEY
      • Fields inherited from interface org.opengis.referencing.ReferenceIdentifier

        CODESPACE_KEY, VERSION_KEY
    • Constructor Summary

      Constructors 
      Constructor Description
      PositionWrapper​(ProjCoordinate impl)
      Creates a new wrapper for the given PROJ4J implementation.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getCode()
      Not applicable.
      double[] getCoordinate()
      {@return all coordinate values}.
      org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
      Not specified.
      int getDimension()
      {@return the number of dimensions}, which is 2 or 3 depending on whether the z coordinate value is provided.
      org.opengis.geometry.DirectPosition getDirectPosition()
      {@return the direct position, which is provided directly by this object}.
      double getOrdinate​(int dimension)
      {@return the coordinate value in the given dimension}.
      (package private) java.lang.Object implementation()
      {@return the PROJ4J backing implementation}.
      private static java.lang.IndexOutOfBoundsException outOfBounds​(int dimension)
      Returns the exception to throw for a coordinate dimension out of bounds.
      (package private) static void setLocation​(ProjCoordinate src, org.opengis.geometry.DirectPosition tgt)
      Copies the coordinates of the given PROJ4J object into the given GeoAPI object.
      void setOrdinate​(int dimension, double value)
      Sets the coordinate value in the given dimension.
      private static org.opengis.geometry.MismatchedDimensionException unexpectedDimension​(int dimension)
      Constructs an exception for an unexpected number of dimensions.
      (package private) static ProjCoordinate unwrapOrCopy​(org.opengis.geometry.DirectPosition src)
      {@return the given position as a PROJ4J coordinate tuple}.
      (package private) static PositionWrapper wrap​(ProjCoordinate impl)
      Wraps the given implementation.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.opengis.geometry.DirectPosition

        equals, hashCode
    • Field Detail

    • Constructor Detail

      • PositionWrapper

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

      • 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 java.lang.Object implementation()
        {@return the PROJ4J backing implementation}.
        Specified by:
        implementation in class Wrapper
      • getCode

        public java.lang.String getCode()
        Not applicable.
        Specified by:
        getCode in interface org.opengis.metadata.Identifier
        Specified by:
        getCode in class Wrapper
      • getDirectPosition

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

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

        public int getDimension()
        {@return 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
      • getCoordinate

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

        public double getOrdinate​(int dimension)
        {@return 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
      • 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)
        {@return 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
      • outOfBounds

        private static java.lang.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