org.geotools.referencing.operation
Class AbstractCoordinateOperationFactory

Object
  extended by AbstractFactory
      extended by ReferencingFactory
          extended by AbstractCoordinateOperationFactory
All Implemented Interfaces:
RegisterableService, Factory, ObjectFactory, CoordinateOperationFactory
Direct Known Subclasses:
BufferedCoordinateOperationFactory, DefaultCoordinateOperationFactory

public abstract class AbstractCoordinateOperationFactory
extends ReferencingFactory
implements CoordinateOperationFactory

Base class for coordinate operation factories. This class provides helper methods for the construction of building blocks. It doesn't figure out any operation path by itself. This more "intelligent" job is left to subclasses.

Since:
2.1
Author:
Martin Desruisseaux (IRD)

Field Summary
protected static ReferenceIdentifier AXIS_CHANGES
          The identifier for conversion using an affine transform for axis swapping and/or unit conversions.
protected static ReferenceIdentifier DATUM_SHIFT
          The identifier for a transformation which is a datum shift.
protected static ReferenceIdentifier ELLIPSOID_SHIFT
          The identifier for a transformation which is a datum shift without Bursa Wolf parameters.
protected static ReferenceIdentifier GEOCENTRIC_CONVERSION
          The identifier for a geocentric conversion.
protected static ReferenceIdentifier IDENTITY
          The identifier for an identity operation.
protected static ReferenceIdentifier INVERSE_OPERATION
          The identifier for an inverse operation.
 
Fields inherited from class ReferencingFactory
LOGGER
 
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
 
Constructor Summary
AbstractCoordinateOperationFactory(Hints userHints)
          Constructs a coordinate operation factory using the specified hints.
AbstractCoordinateOperationFactory(Hints userHints, int priority)
          Constructs a coordinate operation factory using the specified hints and priority.
 
Method Summary
protected  CoordinateOperation concatenate(CoordinateOperation step1, CoordinateOperation step2)
          Concatenate two operation steps.
protected  CoordinateOperation concatenate(CoordinateOperation step1, CoordinateOperation step2, CoordinateOperation step3)
          Concatenate three transformation steps.
 CoordinateOperation createConcatenatedOperation(Map<String,?> properties, CoordinateOperation[] operations)
          Creates a concatenated operation from a sequence of operations.
 Conversion createDefiningConversion(Map<String,?> properties, OperationMethod method, ParameterValueGroup parameters)
          Constructs a defining conversion from a set of properties.
protected  CoordinateOperation createFromAffineTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, Matrix matrix)
          Creates a coordinate operation from a matrix, which usually describes an affine tranform.
protected  CoordinateOperation createFromMathTransform(Map<String,?> properties, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform, OperationMethod method, Class<? extends CoordinateOperation> type)
          Creates a coordinate operation from a math transform.
protected  CoordinateOperation createFromMathTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform)
          Creates a coordinate operation from a math transform.
protected  CoordinateOperation createFromParameters(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, ParameterValueGroup parameters)
          Creates a coordinate operation from a set of parameters.
protected static void ensureNonNull(String name, Object object)
          Makes sure an argument is non-null.
protected static String getErrorMessage(IdentifiedObject source, IdentifiedObject target)
          Returns an error message for "No path found from sourceCRS to targetCRS".
 Map<RenderingHints.Key,?> getImplementationHints()
          Returns the implementation hints for this factory.
 MathTransformFactory getMathTransformFactory()
          Returns the underlying math transform factory.
protected  CoordinateOperation inverse(CoordinateOperation operation)
          Returns the inverse of the specified operation.
protected  Matrix swapAndScaleAxis(CoordinateSystem sourceCS, CoordinateSystem targetCS)
          Returns an affine transform between two coordinate systems.
 
Methods inherited from class ReferencingFactory
getVendor
 
Methods inherited from class AbstractFactory
addImplementationHints, equals, getPriority, hashCode, onDeregistration, onRegistration, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface CoordinateOperationFactory
createOperation, createOperation
 
Methods inherited from interface Factory
getVendor
 

Field Detail

IDENTITY

protected static final ReferenceIdentifier IDENTITY
The identifier for an identity operation.


AXIS_CHANGES

protected static final ReferenceIdentifier AXIS_CHANGES
The identifier for conversion using an affine transform for axis swapping and/or unit conversions.


DATUM_SHIFT

protected static final ReferenceIdentifier DATUM_SHIFT
The identifier for a transformation which is a datum shift.

See Also:
PositionalAccuracyImpl.DATUM_SHIFT_APPLIED

ELLIPSOID_SHIFT

protected static final ReferenceIdentifier ELLIPSOID_SHIFT
The identifier for a transformation which is a datum shift without Bursa Wolf parameters. Only the changes in ellipsoid axis-length are taken in account. Such ellipsoid shifts are approximative and may have 1 kilometer error. This transformation is allowed only if the factory was created with Hints.LENIENT_DATUM_SHIFT set to Boolean.TRUE.

See Also:
PositionalAccuracyImpl.DATUM_SHIFT_OMITTED

GEOCENTRIC_CONVERSION

protected static final ReferenceIdentifier GEOCENTRIC_CONVERSION
The identifier for a geocentric conversion.


INVERSE_OPERATION

protected static final ReferenceIdentifier INVERSE_OPERATION
The identifier for an inverse operation.

Constructor Detail

AbstractCoordinateOperationFactory

public AbstractCoordinateOperationFactory(Hints userHints)
Constructs a coordinate operation factory using the specified hints. This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM FACTORY hints.

Parameters:
userHints - The hints, or null if none.

AbstractCoordinateOperationFactory

public AbstractCoordinateOperationFactory(Hints userHints,
                                          int priority)
Constructs a coordinate operation factory using the specified hints and priority. This constructor recognizes the CRS, CS, DATUM and MATH_TRANSFORM FACTORY hints.

Parameters:
userHints - The hints, or null if none.
priority - The priority for this factory, as a number between MINIMUM_PRIORITY and MAXIMUM_PRIORITY inclusive.
Since:
2.2
Method Detail

getImplementationHints

public Map<RenderingHints.Key,?> getImplementationHints()
Returns the implementation hints for this factory. The returned map contains values for CRS, CS, DATUM and MATH_TRANSFORM FACTORY hints. Other values may be provided as well, at implementation choice.

Specified by:
getImplementationHints in interface Factory
Overrides:
getImplementationHints in class AbstractFactory
Returns:
The map of hints, or an empty map if none.

getMathTransformFactory

public final MathTransformFactory getMathTransformFactory()
Returns the underlying math transform factory. This factory is used for constructing MathTransform objects for all coordinate operations.

Returns:
The underlying math transform factory.

swapAndScaleAxis

protected Matrix swapAndScaleAxis(CoordinateSystem sourceCS,
                                  CoordinateSystem targetCS)
                           throws OperationNotFoundException
Returns an affine transform between two coordinate systems. Only units and axis order (e.g. transforming from (NORTH,WEST) to (EAST,NORTH)) are taken in account.

Example: If coordinates in sourceCS are (x,y) pairs in metres and coordinates in targetCS are (-y,x) pairs in centimetres, then the transformation can be performed as below:

[-y(cm)] [ 0 -100 0 ] [x(m)] [ x(cm)] = [ 100 0 0 ] [y(m)] [ 1 ] [ 0 0 1 ] [1 ]

Parameters:
sourceCS - The source coordinate system.
targetCS - The target coordinate system.
Returns:
The transformation from sourceCS to targetCS as an affine transform. Only axis orientation and units are taken in account.
Throws:
OperationNotFoundException - If the affine transform can't be constructed.
See Also:
AbstractCS.swapAndScaleAxis(org.opengis.referencing.cs.CoordinateSystem, org.opengis.referencing.cs.CoordinateSystem)

createFromAffineTransform

protected CoordinateOperation createFromAffineTransform(ReferenceIdentifier name,
                                                        CoordinateReferenceSystem sourceCRS,
                                                        CoordinateReferenceSystem targetCRS,
                                                        Matrix matrix)
                                                 throws FactoryException
Creates a coordinate operation from a matrix, which usually describes an affine tranform. A default OperationMethod object is given to this transform. In the special case where the name identifier is DATUM_SHIFT or ELLIPSOID_SHIFT, the operation will be an instance of Transformation instead of the usual Conversion.

Parameters:
name - The identifier for the operation to be created.
sourceCRS - The source coordinate reference system.
targetCRS - The target coordinate reference system.
matrix - The matrix which describe an affine transform operation.
Returns:
The conversion or transformation.
Throws:
FactoryException - if the operation can't be created.

createFromParameters

protected CoordinateOperation createFromParameters(ReferenceIdentifier name,
                                                   CoordinateReferenceSystem sourceCRS,
                                                   CoordinateReferenceSystem targetCRS,
                                                   ParameterValueGroup parameters)
                                            throws FactoryException
Creates a coordinate operation from a set of parameters. The operation method is inferred automatically, if possible.

Parameters:
name - The identifier for the operation to be created.
sourceCRS - The source coordinate reference system.
targetCRS - The target coordinate reference system.
parameters - The parameters.
Returns:
The conversion or transformation.
Throws:
FactoryException - if the operation can't be created.

createFromMathTransform

protected CoordinateOperation createFromMathTransform(ReferenceIdentifier name,
                                                      CoordinateReferenceSystem sourceCRS,
                                                      CoordinateReferenceSystem targetCRS,
                                                      MathTransform transform)
                                               throws FactoryException
Creates a coordinate operation from a math transform.

Parameters:
name - The identifier for the operation to be created.
sourceCRS - The source coordinate reference system.
targetCRS - The destination coordinate reference system.
transform - The math transform.
Returns:
A coordinate operation using the specified math transform.
Throws:
FactoryException - if the operation can't be constructed.

createFromMathTransform

protected CoordinateOperation createFromMathTransform(Map<String,?> properties,
                                                      CoordinateReferenceSystem sourceCRS,
                                                      CoordinateReferenceSystem targetCRS,
                                                      MathTransform transform,
                                                      OperationMethod method,
                                                      Class<? extends CoordinateOperation> type)
                                               throws FactoryException
Creates a coordinate operation from a math transform. If the specified math transform is already a coordinate operation, and if source and target CRS match, then transform is returned with no change. Otherwise, a new coordinate operation is created.

Parameters:
properties - The properties to give to the operation.
sourceCRS - The source coordinate reference system.
targetCRS - The destination coordinate reference system.
transform - The math transform.
method - The operation method, or null.
type - The required super-class (e.g. Transformation.class).
Returns:
A coordinate operation using the specified math transform.
Throws:
FactoryException - if the operation can't be constructed.

createDefiningConversion

public Conversion createDefiningConversion(Map<String,?> properties,
                                           OperationMethod method,
                                           ParameterValueGroup parameters)
                                    throws FactoryException
Constructs a defining conversion from a set of properties.

Specified by:
createDefiningConversion in interface CoordinateOperationFactory
Parameters:
properties - Set of properties. Should contains at least "name".
method - The operation method.
parameters - The parameter values.
Returns:
The defining conversion.
Throws:
FactoryException - if the object creation failed.
Since:
2.5
See Also:
DefiningConversion

createConcatenatedOperation

public CoordinateOperation createConcatenatedOperation(Map<String,?> properties,
                                                       CoordinateOperation[] operations)
                                                throws FactoryException
Creates a concatenated operation from a sequence of operations.

Specified by:
createConcatenatedOperation in interface CoordinateOperationFactory
Parameters:
properties - Set of properties. Should contains at least "name".
operations - The sequence of operations.
Returns:
The concatenated operation.
Throws:
FactoryException - if the object creation failed.

concatenate

protected CoordinateOperation concatenate(CoordinateOperation step1,
                                          CoordinateOperation step2)
                                   throws FactoryException
Concatenate two operation steps. If an operation is an AXIS_CHANGES, it will be included as part of the second operation instead of creating an ConcatenatedOperation. If a concatenated operation is created, it will get an automatically generated name.

Parameters:
step1 - The first step, or null for the identity operation.
step2 - The second step, or null for the identity operation.
Returns:
A concatenated operation, or null if all arguments was nul.
Throws:
FactoryException - if the operation can't be constructed.

concatenate

protected CoordinateOperation concatenate(CoordinateOperation step1,
                                          CoordinateOperation step2,
                                          CoordinateOperation step3)
                                   throws FactoryException
Concatenate three transformation steps. If the first and/or the last operation is an AXIS_CHANGES, it will be included as part of the second operation instead of creating an ConcatenatedOperation. If a concatenated operation is created, it will get an automatically generated name.

Parameters:
step1 - The first step, or null for the identity operation.
step2 - The second step, or null for the identity operation.
step3 - The third step, or null for the identity operation.
Returns:
A concatenated operation, or null if all arguments were null.
Throws:
FactoryException - if the operation can't be constructed.

inverse

protected CoordinateOperation inverse(CoordinateOperation operation)
                               throws NoninvertibleTransformException,
                                      FactoryException
Returns the inverse of the specified operation.

Parameters:
operation - The operation to invert.
Returns:
The inverse of operation.
Throws:
NoninvertibleTransformException - if the operation is not invertible.
FactoryException - if the operation creation failed for an other reason.
Since:
2.3

getErrorMessage

protected static String getErrorMessage(IdentifiedObject source,
                                        IdentifiedObject target)
Returns an error message for "No path found from sourceCRS to targetCRS". This is used for the construction of OperationNotFoundException.

Parameters:
source - The source CRS.
target - The target CRS.
Returns:
A default error message.

ensureNonNull

protected static void ensureNonNull(String name,
                                    Object object)
                             throws IllegalArgumentException
Makes sure an argument is non-null.

Parameters:
name - Argument name.
object - User argument.
Throws:
IllegalArgumentException - if object is null.


Copyright © 1996-2014 Geotools. All Rights Reserved.