Package org.locationtech.proj4j.geoapi
Class PositionWrapper
- java.lang.Object
-
- org.locationtech.proj4j.geoapi.Wrapper
-
- org.locationtech.proj4j.geoapi.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) ProjCoordinateimplThe wrapped PROJ4 implementation.-
Fields inherited from class org.locationtech.proj4j.geoapi.Wrapper
BIDIMENSIONAL, TRIDIMENSIONAL
-
-
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.StringgetCode()Not applicable.double[]getCoordinate(){@return all coordinate values}.org.opengis.referencing.crs.CoordinateReferenceSystemgetCoordinateReferenceSystem()Not specified.intgetDimension(){@return the number of dimensions}, which is 2 or 3 depending on whether the z coordinate value is provided.org.opengis.geometry.DirectPositiongetDirectPosition(){@return the direct position, which is provided directly by this object}.doublegetOrdinate(int dimension){@return the coordinate value in the given dimension}.(package private) java.lang.Objectimplementation(){@return the PROJ4J backing implementation}.private static java.lang.IndexOutOfBoundsExceptionoutOfBounds(int dimension)Returns the exception to throw for a coordinate dimension out of bounds.(package private) static voidsetLocation(ProjCoordinate src, org.opengis.geometry.DirectPosition tgt)Copies the coordinates of the given PROJ4J object into the given GeoAPI object.voidsetOrdinate(int dimension, double value)Sets the coordinate value in the given dimension.private static org.opengis.geometry.MismatchedDimensionExceptionunexpectedDimension(int dimension)Constructs an exception for an unexpected number of dimensions.(package private) static ProjCoordinateunwrapOrCopy(org.opengis.geometry.DirectPosition src){@return the given position as a PROJ4J coordinate tuple}.(package private) static PositionWrapperwrap(ProjCoordinate impl)Wraps the given implementation.-
Methods inherited from class org.locationtech.proj4j.geoapi.Wrapper
equals, getAlias, getAuthority, getCodeSpace, getDomainOfValidity, getIdentifiers, getName, getRemarks, getScope, getVersion, hashCode, toString, toWKT
-
-
-
-
Field Detail
-
impl
final ProjCoordinate impl
The wrapped PROJ4 implementation.
-
-
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, ornull- Returns:
- the wrapper, or
nullif the given implementation was null
-
implementation
final java.lang.Object implementation()
{@return the PROJ4J backing implementation}.- Specified by:
implementationin classWrapper
-
getCode
public java.lang.String getCode()
Not applicable.
-
getDirectPosition
public org.opengis.geometry.DirectPosition getDirectPosition()
{@return the direct position, which is provided directly by this object}.- Specified by:
getDirectPositionin interfaceorg.opengis.geometry.coordinate.Position
-
getCoordinateReferenceSystem
public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Not specified.- Specified by:
getCoordinateReferenceSystemin interfaceorg.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:
getDimensionin interfaceorg.opengis.geometry.DirectPosition
-
getCoordinate
public double[] getCoordinate()
{@return all coordinate values}.- Specified by:
getCoordinatein interfaceorg.opengis.geometry.DirectPosition
-
getOrdinate
public double getOrdinate(int dimension)
{@return the coordinate value in the given dimension}.- Specified by:
getOrdinatein interfaceorg.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:
setOrdinatein interfaceorg.opengis.geometry.DirectPosition- Parameters:
dimension- the dimension of the coordinate to setvalue- 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 copytgt- 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
-
-