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 Summary
FieldsModifier and TypeFieldDescription(package private) final ProjCoordinateThe wrapped PROJ4 implementation.Fields inherited from class Wrapper
BIDIMENSIONAL, TRIDIMENSIONALFields inherited from interface org.opengis.metadata.Identifier
AUTHORITY_KEY, CODE_KEYFields inherited from interface org.opengis.referencing.ReferenceIdentifier
CODESPACE_KEY, VERSION_KEY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new wrapper for the given PROJ4J implementation. -
Method Summary
Modifier and TypeMethodDescriptiongetCode()Not applicable.double[]Returns all coordinate values.org.opengis.referencing.crs.CoordinateReferenceSystemNot specified.intReturns the number of dimensions.org.opengis.geometry.DirectPositionReturns the direct position, which is provided directly by this object.doublegetOrdinate(int dimension) Returns the coordinate value in the given dimension.(package private) final ObjectReturns the PROJ4J backing implementation.private static 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) Returns the given position as a PROJ4J coordinate tuple.(package private) static PositionWrapperwrap(ProjCoordinate impl) Wraps the given implementation.Methods inherited from class Wrapper
equals, getAlias, getAuthority, getCodeSpace, getDomainOfValidity, getIdentifiers, getName, getRemarks, getScope, getVersion, hashCode, toString, toWKTMethods inherited from interface org.opengis.geometry.DirectPosition
equals, hashCode
-
Field Details
-
impl
The wrapped PROJ4 implementation.
-
-
Constructor Details
-
PositionWrapper
PositionWrapper(ProjCoordinate impl) Creates a new wrapper for the given PROJ4J implementation.
-
-
Method Details
-
wrap
Wraps the given implementation.- Parameters:
impl- the implementation to wrap, ornull- Returns:
- the wrapper, or
nullif the given implementation was null
-
implementation
Returns the PROJ4J backing implementation..- Specified by:
implementationin classWrapper- Returns:
- the PROJ4J backing implementation
-
getCode
-
getDirectPosition
public org.opengis.geometry.DirectPosition getDirectPosition()Returns the direct position, which is provided directly by this object..- Specified by:
getDirectPositionin interfaceorg.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:
getCoordinateReferenceSystemin interfaceorg.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:
getDimensionin interfaceorg.opengis.geometry.DirectPosition- Returns:
- the number of dimensions
-
getCoordinate
public double[] getCoordinate()Returns all coordinate values..- Specified by:
getCoordinatein interfaceorg.opengis.geometry.DirectPosition- Returns:
- all coordinate values
-
getOrdinate
public double getOrdinate(int dimension) Returns the coordinate value in the given dimension..- Specified by:
getOrdinatein interfaceorg.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:
setOrdinatein interfaceorg.opengis.geometry.DirectPosition- Parameters:
dimension- the dimension of the coordinate to setvalue- the value to set
-
setLocation
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
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
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
-