org.apache.sis.referencing.operation.transform

## Class ContextualParameters

• All Implemented Interfaces:
Serializable, Cloneable, GeneralParameterValue, ParameterValueGroup

```public class ContextualParameters
extends Parameters
implements Serializable```
The parameters that describe a sequence of normalizenon-linear kerneldenormalize transforms as a whole. The normalize and denormalize steps must be affine transforms, while the non-linear kernel is arbitrary.
Note: actually there is nothing in this class which force the kernel to be non-linear. But this class is useless if the kernel is linear, because 3 linear steps can be efficiently concatenated in a single affine transform.

Contextual parameters can be associated to the non-linear kernel step of the above-cited sequence. Since the parameter values of the non-linear kernel contains only normalized parameters (e.g. a map projection on an ellipsoid having a semi-major axis length of 1), Apache SIS needs contextual information for reconstructing the parameters of the complete transforms chain.

Usage in map projections
This object is used mostly for Apache SIS implementation of map projections, where the non-linear kernel is a normalized projection. The complete map projection (ignoring changes of axis order) is a chain of 3 transforms as shown below:
 $MathML capable browser required$ → Map projection on a normalized ellipsoid → $MathML capable browser required$
`Contextual­Parameters` is typically created and used as below:
1. A `Math­Transform­Provider` instantiates a class from the map projection package. Note that different providers may instantiate the same map projection class. For example both "Mercator (variant A)" and "Mercator (variant B)" methods instantiate the same `Mercator` class, but with different ways to represent the parameters.
2. The map projection constructor fetches all parameters that it needs from the user-supplied `Parameters`, initializes the projection, then saves the parameter values that it actually used in a new `Contextual­Parameters` instance.
3. The map projection constructor may keep only the non-linear parameters for itself, and gives the linear parameters to the `normalize­Geographic­Inputs(…)` and `Matrix­SIS​.convert­After(…)` methods, which will create the matrices show above. The projection constructor is free to apply additional operations on the two affine transforms (normalize / denormalize) before or after the above-cited methods have been invoked.
4. After all parameter values have been set and the normalize / denormalize matrices defined, the `complete­Transform(…)` method will mark this `Contextual­Parameters` object as unmodifiable and create the chain of transforms from (λ,φ) in angular degrees to (x,y) in metres. Note that conversions to other units and changes in axis order are not the purpose of this transforms chain – they are separated steps.
Serialization
Serialized instances of this class are not guaranteed to be compatible with future SIS versions. Serialization should be used only for short term storage or RMI between applications running the same SIS version.
Since:
0.6
`Normalized­Projection`, `Abstract­Math­Transform​.get­Contextual­Parameters()`, Serialized Form

Defined in the `sis-referencing` module

• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
`static class ` `Contextual­Parameters​.Matrix­Role`
Whether a matrix is used for normalization or denormalization before or after a non-linear operation.
• ### Constructor Summary

Constructors
Constructor and Description
`Contextual­Parameters(Operation­Method method)`
Creates a new group of parameters for the given non-linear coordinate operation method.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`Parameter­Value­Group` `add­Group(String name)`
Unsupported operation, since `Contextual­Parameters` groups do not contain sub-groups.
`Contextual­Parameters` `clone()`
Returns a modifiable clone of this parameter value group.
`Math­Transform` ```complete­Transform(Math­Transform­Factory factory, Math­Transform kernel)```
Marks this `Contextual­Parameter` as unmodifiable and creates the normalize`kernel`denormalize transforms chain.
`Matrix­SIS` `denormalize­Geographic­Outputs(double λ0)`
Appends a denormalization step after the non-linear kernel, which will convert input ordinates in the two first dimensions from radians to degrees.
`boolean` `equals(Object object)`
Compares the given object with the parameters for equality.
`Parameter­Descriptor­Group` `get­Descriptor()`
Returns the parameters for the normalizenon-linear kerneldenormalize sequence as a whole.
`Matrix­SIS` `get­Matrix(boolean norm)`
Deprecated.
`Matrix­SIS` `get­Matrix(Contextual­Parameters​.Matrix­Role role)`
Returns the affine transforms to be applied before or after the non-linear kernel operation.
`List<Parameter­Value­Group>` `groups(String name)`
Unsupported operation, since `Contextual­Parameters` groups do not contain sub-groups.
`int` `hash­Code()`
Returns a hash code value for this object.
`Matrix­SIS` `normalize­Geographic­Inputs(double λ0)`
Prepends a normalization step converting input ordinates in the two first dimensions from degrees to radians.
`Parameter­Value<?>` `parameter(String name)`
Returns the parameter value of the given name.
`List<General­Parameter­Value>` `values()`
Returns an unmodifiable list containing all parameters in this group.
• ### Methods inherited from class Parameters

`boolean­Value, cast, cast, cast­Or­Wrap, copy, double­Value, double­Value­List, get­Descriptors, get­Mandatory­Value, get­Member­Name, get­Or­Create, get­Value, get­Value­Domain, int­Value, int­Value­List, print, string­Value, to­String, unmodifiable`
• ### Methods inherited from class Object

`finalize, get­Class, notify, notify­All, wait, wait, wait`
• ### Constructor Detail

• #### ContextualParameters

`public ContextualParameters(OperationMethod method)`
Creates a new group of parameters for the given non-linear coordinate operation method. The method parameters shall describe the normalizenon-linear kerneldenormalize sequence as a whole. After construction, callers shall: See class javadoc for more information.
Parameters:
`method` - The non-linear operation method for which to define the parameter values.
• ### Method Detail

• #### getDescriptor

`public final ParameterDescriptorGroup getDescriptor()`
Returns the parameters for the normalizenon-linear kerneldenormalize sequence as a whole. This is the parameter descriptor of the operation method given to the constructor.

The values for those parameters is given by the `values()` method. Those values may be used in the normalization / denormalization transforms, in the kernel, or both.

Note: The definition of "kernel" is left to implementors. In the particular case of Apache SIS implementation of map projections, kernels are instances of `Normalized­Projection`. Other "kernels" in SIS are `Ellipsoid­To­Centric­Transform` and `Molodensky­Transform`.
Specified by:
`get­Descriptor` in interface `General­Parameter­Value`
Specified by:
`get­Descriptor` in interface `Parameter­Value­Group`
Returns:
The description of the parameters.
• #### getMatrix

`public final MatrixSIS getMatrix(ContextualParameters.MatrixRole role)`
Returns the affine transforms to be applied before or after the non-linear kernel operation. Immediately after construction, those matrices are modifiable identity matrices. Callers can modify the matrix element values, typically by calls to the `Matrix­SIS​.convert­Before(…)` method. Alternatively, the following methods can be invoked for applying some frequently used configurations: After the `complete­Transform(…)` method has been invoked, the matrices returned by this method are unmodifiable.
Application to map projections: after `Normalized­Projection` construction, the matrices returned by `projection​.get­Contextual­Parameters()​.get­Matrix(…)` are initialized to the values shown below. Note that some `Normalized­Projection` subclasses apply further modifications to those matrices.
Initial matrix coefficients after `Normalized­Projection` construction
`get­Matrix(NORMALIZATION)` `get­Matrix(DENORMALIZATION)`
$MathML capable browser required$ $MathML capable browser required$
Parameters:
`role` - `NORMALIZATION` for fetching the normalization transform to apply before the kernel, `DENORMALIZATION` for the denormalization transform to apply after the kernel, or `INVERSE_*` for the inverse of the above-cited matrices.
Returns:
The matrix for the requested normalization or denormalization affine transform.
Since:
0.7
• #### getMatrix

```@Deprecated
public final MatrixSIS getMatrix(boolean norm)```
Deprecated. Replaced by `get­Matrix(Matrix­Role)`.
Parameters:
`norm` - `true` for fetching the normalization transform to apply before the kernel, or `false` for the denormalization transform to apply after the kernel.
Returns:
The matrix for the requested normalization (`true`) or denormalization (`false`) affine transform.
• #### normalizeGeographicInputs

`public MatrixSIS normalizeGeographicInputs(double λ0)`
Prepends a normalization step converting input ordinates in the two first dimensions from degrees to radians. The normalization can optionally subtract the given λ₀ value (in degrees) from the longitude.

Invoking this method is equivalent to concatenating the normalization matrix with the following matrix. This will have the effect of applying the conversion described above before any other operation:

$MathML capable browser required$
Parameters:
`λ0` - Longitude of the central meridian, in degrees.
Returns:
The normalization affine transform as a matrix. Callers can change that matrix directly if they want to apply additional normalization operations.
Throws:
`Illegal­State­Exception` - if this `Contextual­Parameter` has been made unmodifiable.
• #### denormalizeGeographicOutputs

`public MatrixSIS denormalizeGeographicOutputs(double λ0)`
Appends a denormalization step after the non-linear kernel, which will convert input ordinates in the two first dimensions from radians to degrees. After this conversion, the denormalization can optionally add the given λ₀ value (in degrees) to the longitude.

Invoking this method is equivalent to concatenating the denormalization matrix with the following matrix. This will have the effect of applying the conversion described above after the non-linear kernel operation:

$MathML capable browser required$
Parameters:
`λ0` - Longitude of the central meridian, in degrees.
Returns:
The denormalization affine transform as a matrix. Callers can change that matrix directly if they want to apply additional denormalization operations.
Throws:
`Illegal­State­Exception` - if this `Contextual­Parameter` has been made unmodifiable.
• #### completeTransform

```public MathTransform completeTransform(MathTransformFactory factory,
MathTransform kernel)
throws FactoryException```
Marks this `Contextual­Parameter` as unmodifiable and creates the normalize`kernel`denormalize transforms chain. This method shall be invoked only after the (de)normalization matrices have been set to their final values.

The transforms chain created by this method does not include any step for changing axis order or for converting to units other than degrees or metres. Such steps, if desired, should be defined outside `Contextual­Parameters`. Efficient concatenation of those steps will happen "under the hood".

Parameters:
`factory` - The factory to use for creating math transform instances.
`kernel` - The (usually non-linear) kernel. This is often a `Normalized­Projection`.
Returns:
The concatenation of normalizethe given kerneldenormalize transforms.
Throws:
`Factory­Exception` - if an error occurred while creating a math transform instance.
`Normalized­Projection​.create­Map­Projection(Math­Transform­Factory)`
• #### parameter

```public ParameterValue<?> parameter(String name)
throws ParameterNotFoundException```
Returns the parameter value of the given name. Before the call to `complete­Transform(…)`, this method can be used for setting parameter values like below:
`parameter("Scale factor").setValue(0.9996);   // Scale factor of Universal Transverse Mercator (UTM) projections.`
After the call to `complete­Transform(…)`, the returned parameters are read-only.
Specified by:
`parameter` in interface `Parameter­Value­Group`
Parameters:
`name` - The name of the parameter to search.
Returns:
The parameter value for the given name.
Throws:
`Parameter­Not­Found­Exception` - if there is no parameter of the given name.
• #### values

`public List<GeneralParameterValue> values()`
Returns an unmodifiable list containing all parameters in this group. Callers should not attempt to modify the parameter values in this list.
Specified by:
`values` in interface `Parameter­Value­Group`
Returns:
All parameter values.
• #### groups

`public List<ParameterValueGroup> groups(String name)`
Unsupported operation, since `Contextual­Parameters` groups do not contain sub-groups.
Specified by:
`groups` in interface `Parameter­Value­Group`
Parameters:
`name` - Ignored.
Returns:
Never returned.

`public ParameterValueGroup addGroup(String name)`
Unsupported operation, since `Contextual­Parameters` groups do not contain sub-groups.
Specified by:
`add­Group` in interface `Parameter­Value­Group`
Parameters:
`name` - Ignored.
Returns:
Never returned.
• #### clone

`public ContextualParameters clone()`
Returns a modifiable clone of this parameter value group.
Specified by:
`clone` in interface `General­Parameter­Value`
Specified by:
`clone` in interface `Parameter­Value­Group`
Overrides:
`clone` in class `Parameters`
Returns:
A clone of this parameter value group.
`Parameters​.copy(Parameter­Value­Group, Parameter­Value­Group)`
• #### hashCode

`public int hashCode()`
Returns a hash code value for this object. This value is implementation-dependent and may change in any future version.
Overrides:
`hash­Code` in class `Object`
• #### equals

`public boolean equals(Object object)`
Compares the given object with the parameters for equality.
Overrides:
`equals` in class `Object`
Parameters:
`object` - The object to compare with the parameters.
Returns:
`true` if the given object is equal to this one.