org.geotoolkit.referencing.operation
Class MathTransformProvider

Object
  extended by FormattableObject
      extended by AbstractIdentifiedObject
          extended by DefaultOperationMethod
              extended by MathTransformProvider
All Implemented Interfaces:
Serializable, Formattable, LenientComparable, IdentifiedObject, OperationMethod
Direct Known Subclasses:
Affine, EllipsoidToGeocentric, Exponential, GeocentricToEllipsoid, Logarithmic, LongitudeRotation, MapProjection, Molodensky, NADCON, NTv2, PositionVector7Param, RGF93

@Immutable
public abstract class MathTransformProvider
extends DefaultOperationMethod

An operation method capable to create a math transform from set of parameter values. Implementations of this class should be listed in the following file:

META-INF/services/org.geotoolkit.referencing.operation.MathTransformProvider
The default math transform factory will parse this file in order to get all available providers on a system. If this file is bundle in many JAR files, the factory will read all of them.

Since:
1.2
Version:
3.01
Author:
Martin Desruisseaux (IRD)
See Also:
org.geotoolkit.referencing.operation.provider, Serialized Form
Module:
referencing/geotk-referencing (download)    View source code for this class

Field Summary
 
Fields inherited from class DefaultOperationMethod
sourceDimension, targetDimension
 
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
 
Fields inherited from class FormattableObject
EPSG, GEOTIFF, INTERNAL, OGC, SINGLE_LINE
 
Fields inherited from interface OperationMethod
FORMULA_KEY
 
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
 
Constructor Summary
MathTransformProvider(int sourceDimension, int targetDimension, ParameterDescriptorGroup parameters)
          Constructs a math transform provider from a set of parameters.
MathTransformProvider(Map<String,?> properties, int sourceDimension, int targetDimension, ParameterDescriptorGroup parameters)
          Constructs a math transform provider from a set of properties.
 
Method Summary
protected abstract  MathTransform createMathTransform(ParameterValueGroup values)
          Creates a math transform from the specified group of parameter values.
protected  ParameterValueGroup ensureValidValues(ParameterValueGroup values)
          Ensures that the given set of parameters contains only valid values.
 String formatWKT(Formatter formatter)
          Format the inner part of a Well Known Text (WKT) element.
 Class<? extends SingleOperation> getOperationType()
          Returns the operation type.
 
Methods inherited from class DefaultOperationMethod
checkDimensions, computeHashCode, equals, getFormula, getParameters, getSourceDimensions, getTargetDimensions
 
Methods inherited from class AbstractIdentifiedObject
equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, hashCode, nameMatches, nameMatches, nameMatches
 
Methods inherited from class FormattableObject
getDefaultIndentation, print, setDefaultIndentation, toString, toWKT, toWKT, toWKT
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
 

Constructor Detail

MathTransformProvider

public MathTransformProvider(int sourceDimension,
                             int targetDimension,
                             ParameterDescriptorGroup parameters)
Constructs a math transform provider from a set of parameters. The provider identifiers will be the same than the parameter ones.

Parameters:
sourceDimension - Number of dimensions in the source CRS of this operation method.
targetDimension - Number of dimensions in the target CRS of this operation method.
parameters - The set of parameters (never null).

MathTransformProvider

public MathTransformProvider(Map<String,?> properties,
                             int sourceDimension,
                             int targetDimension,
                             ParameterDescriptorGroup parameters)
Constructs a math transform provider from a set of properties. The properties map is given unchanged to the super-class constructor.

Parameters:
properties - Set of properties. Should contains at least "name".
sourceDimension - Number of dimensions in the source CRS of this operation method.
targetDimension - Number of dimensions in the target CRS of this operation method.
parameters - The set of parameters (never null).
Method Detail

getOperationType

public Class<? extends SingleOperation> getOperationType()
Returns the operation type. It may be SingleOperation.class, Conversion.class, Projection.class, etc.

The default implementation returns SingleOperation.class. Subclass should overrides this methods and returns the appropriate OpenGIS interface type (not the implementation type).

Returns:
The GeoAPI interface implemented by this operation.

createMathTransform

protected abstract MathTransform createMathTransform(ParameterValueGroup values)
                                              throws InvalidParameterNameException,
                                                     ParameterNotFoundException,
                                                     InvalidParameterValueException,
                                                     FactoryException
Creates a math transform from the specified group of parameter values. Subclasses can implements this method as in the example below:
double semiMajor = values.parameter("semi_major").doubleValue(SI.METRE);
double semiMinor = values.parameter("semi_minor").doubleValue(SI.METRE);
// etc...
return new MyTransform(semiMajor, semiMinor, ...);

Parameters:
values - The group of parameter values.
Returns:
The created math transform.
Throws:
InvalidParameterNameException - if the values contains an unknown parameter.
ParameterNotFoundException - if a required parameter was not found.
InvalidParameterValueException - if a parameter has an invalid value.
FactoryException - if the math transform can't be created for some other reason (for example a required file was not found).

ensureValidValues

protected ParameterValueGroup ensureValidValues(ParameterValueGroup values)
                                         throws InvalidParameterNameException,
                                                InvalidParameterValueException
Ensures that the given set of parameters contains only valid values. This method compares all parameter names against the names declared in the operation method parameter descriptor. If an unknown parameter name is found, then an InvalidParameterNameException is thrown. This method also ensures that all values are assignable to the expected class, are between the minimum and maximum values and are one of the set of valid values. If the value fails any of those tests, then an InvalidParameterValueException is thrown.

Parameters:
values - The parameters values to check.
Returns:
The parameter values to use for math transform construction. May be different than the supplied values argument if some missing values needed to be filled with default values.
Throws:
InvalidParameterNameException - if a parameter name is unknown.
InvalidParameterValueException - if a parameter has an invalid value.

formatWKT

public String formatWKT(Formatter formatter)
Format the inner part of a Well Known Text (WKT) element.

Specified by:
formatWKT in interface Formattable
Overrides:
formatWKT in class DefaultOperationMethod
Parameters:
formatter - The formatter to use.
Returns:
The WKT element name.
See Also:
FormattableObject.toWKT(), FormattableObject.toString()


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.