Package org.locationtech.proj4j.geoapi
Class ParameterWrapper
- java.lang.Object
-
- org.locationtech.proj4j.geoapi.Wrapper
-
- org.locationtech.proj4j.geoapi.ParameterWrapper
-
- All Implemented Interfaces:
java.io.Serializable
,org.opengis.metadata.Identifier
,org.opengis.parameter.GeneralParameterValue
,org.opengis.parameter.ParameterValue<java.lang.Double>
,org.opengis.referencing.ReferenceIdentifier
final class ParameterWrapper extends Wrapper implements org.opengis.parameter.ParameterValue<java.lang.Double>, java.io.Serializable
Wraps a PROJ4J implementation behind the equivalent GeoAPI interface. This implementation is restricted to values of thedouble
primitive type.
-
-
Field Summary
Fields Modifier and Type Field Description private ParameterAccessor
descriptor
The parameter name together with the methods for getting or setting values.private Projection
impl
The wrapped PROJ4 implementation.-
Fields inherited from class org.locationtech.proj4j.geoapi.Wrapper
BIDIMENSIONAL, TRIDIMENSIONAL
-
-
Constructor Summary
Constructors Constructor Description ParameterWrapper(Projection impl, ParameterAccessor descriptor)
Creates a new wrapper for the given PROJ4J implementation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
booleanValue()
org.opengis.parameter.ParameterValue<java.lang.Double>
clone()
{@return a modifiable copy of this parameter}.double
doubleValue()
{@return the value in the PROJ4J projection for the parameter described by this object}.double
doubleValue(javax.measure.Unit<?> unit)
{@return the value in the PROJ4J projection for the parameter described by this object}.double[]
doubleValueList()
double[]
doubleValueList(javax.measure.Unit<?> unit)
java.lang.String
getCode()
{@return this parameter name, as specified in the descriptor}.org.opengis.parameter.ParameterDescriptor<java.lang.Double>
getDescriptor()
{@return a description of this parameter}.javax.measure.Unit<?>
getUnit()
{@return the same unit of measurement as declared in the parameter descriptor}.java.lang.Double
getValue()
{@return the value as an arbitrary object}.private java.lang.IllegalArgumentException
illegalUnit(javax.measure.IncommensurableException e)
{@return the exception to throw for an illegal unit of measurement}.(package private) java.lang.Object
implementation()
{@return an arbitrary object for equality and hash code}.int
intValue()
int[]
intValueList()
private org.opengis.parameter.InvalidParameterValueException
invalidParamType(java.lang.Object value)
{@return the exception to throw for all parameter types other than floating-point}.private org.opengis.parameter.InvalidParameterTypeException
invalidReturnType()
{@return the exception to throw for all parameter types other than floating-point}.void
setValue(boolean value)
void
setValue(double value)
Sets the value of this parameter.void
setValue(double[] values, javax.measure.Unit<?> unit)
void
setValue(double value, javax.measure.Unit<?> unit)
Converts the given value to the unit expected by this parameter, then sets the value.void
setValue(int value)
void
setValue(java.lang.Object value)
Sets the value as an arbitrary object.java.lang.String
stringValue()
java.net.URI
valueFile()
-
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
private final Projection impl
The wrapped PROJ4 implementation.
-
descriptor
private final ParameterAccessor descriptor
The parameter name together with the methods for getting or setting values.
-
-
Constructor Detail
-
ParameterWrapper
ParameterWrapper(Projection impl, ParameterAccessor descriptor)
Creates a new wrapper for the given PROJ4J implementation.- Parameters:
impl
- the wrapped PROJ4 implementationdescriptor
- methods for getting or setting values
-
-
Method Detail
-
implementation
java.lang.Object implementation()
{@return an arbitrary object for equality and hash code}.- Specified by:
implementation
in classWrapper
-
getDescriptor
public org.opengis.parameter.ParameterDescriptor<java.lang.Double> getDescriptor()
{@return a description of this parameter}.- Specified by:
getDescriptor
in interfaceorg.opengis.parameter.GeneralParameterValue
- Specified by:
getDescriptor
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
-
getCode
public java.lang.String getCode()
{@return this parameter name, as specified in the descriptor}.
-
getUnit
public javax.measure.Unit<?> getUnit()
{@return the same unit of measurement as declared in the parameter descriptor}.- Specified by:
getUnit
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
-
illegalUnit
private java.lang.IllegalArgumentException illegalUnit(javax.measure.IncommensurableException e)
{@return the exception to throw for an illegal unit of measurement}.
-
invalidReturnType
private org.opengis.parameter.InvalidParameterTypeException invalidReturnType()
{@return the exception to throw for all parameter types other than floating-point}.
-
invalidParamType
private org.opengis.parameter.InvalidParameterValueException invalidParamType(java.lang.Object value)
{@return the exception to throw for all parameter types other than floating-point}.
-
getValue
public java.lang.Double getValue()
{@return the value as an arbitrary object}.- Specified by:
getValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
-
doubleValue
public double doubleValue()
{@return the value in the PROJ4J projection for the parameter described by this object}.- Specified by:
doubleValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
-
doubleValue
public double doubleValue(javax.measure.Unit<?> unit)
{@return the value in the PROJ4J projection for the parameter described by this object}. The value is converted to the given unit of measurement.- Specified by:
doubleValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Parameters:
unit
- the unit of measurement of value to get- Throws:
java.lang.IllegalArgumentException
- if the given unit is incompatible
-
setValue
public void setValue(java.lang.Object value) throws org.opengis.parameter.InvalidParameterValueException
Sets the value as an arbitrary object.- Specified by:
setValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Parameters:
value
- the value to set- Throws:
org.opengis.parameter.InvalidParameterValueException
- if the value type is illegal
-
setValue
public void setValue(double value)
Sets the value of this parameter. Note that invoking this method may modify the PROJ4J object wrapped byOperationMethodWrapper
. This is generally not recommended.- Specified by:
setValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Parameters:
value
- the value to set
-
setValue
public void setValue(double value, javax.measure.Unit<?> unit)
Converts the given value to the unit expected by this parameter, then sets the value.- Specified by:
setValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Parameters:
value
- the value to setunit
- the unit of measurement of the given value- Throws:
java.lang.UnsupportedOperationException
- if this parameter is unmodifiablejava.lang.IllegalArgumentException
- if the given unit is incompatible
-
intValue
public int intValue()
- Specified by:
intValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
-
booleanValue
public boolean booleanValue() throws java.lang.IllegalStateException
- Specified by:
booleanValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
java.lang.IllegalStateException
-
stringValue
public java.lang.String stringValue() throws java.lang.IllegalStateException
- Specified by:
stringValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
java.lang.IllegalStateException
-
valueFile
public java.net.URI valueFile() throws java.lang.IllegalStateException
- Specified by:
valueFile
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
java.lang.IllegalStateException
-
intValueList
public int[] intValueList() throws java.lang.IllegalStateException
- Specified by:
intValueList
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
java.lang.IllegalStateException
-
doubleValueList
public double[] doubleValueList() throws java.lang.IllegalStateException
- Specified by:
doubleValueList
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
java.lang.IllegalStateException
-
doubleValueList
public double[] doubleValueList(javax.measure.Unit<?> unit) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException
- Specified by:
doubleValueList
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
java.lang.IllegalArgumentException
java.lang.IllegalStateException
-
setValue
public void setValue(int value) throws org.opengis.parameter.InvalidParameterValueException
- Specified by:
setValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
org.opengis.parameter.InvalidParameterValueException
-
setValue
public void setValue(boolean value) throws org.opengis.parameter.InvalidParameterValueException
- Specified by:
setValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
org.opengis.parameter.InvalidParameterValueException
-
setValue
public void setValue(double[] values, javax.measure.Unit<?> unit) throws org.opengis.parameter.InvalidParameterValueException
- Specified by:
setValue
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Throws:
org.opengis.parameter.InvalidParameterValueException
-
clone
public org.opengis.parameter.ParameterValue<java.lang.Double> clone()
{@return a modifiable copy of this parameter}. Note that this method is inefficient as it creates a fullProjection
object for each individual parameter value. It is better to invokeOperationMethodWrapper.clone()
instead.- Specified by:
clone
in interfaceorg.opengis.parameter.GeneralParameterValue
- Specified by:
clone
in interfaceorg.opengis.parameter.ParameterValue<java.lang.Double>
- Overrides:
clone
in classjava.lang.Object
-
-