Class AbstractCoordinateOperationFactory
Object
AbstractFactory
ReferencingFactory
AbstractCoordinateOperationFactory
- All Implemented Interfaces:
Factory,ObjectFactory,CoordinateOperationFactory,Factory,RegistrableFactory
- 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
FieldsModifier and TypeFieldDescriptionprotected static final ReferenceIdentifierThe identifier for conversion using an affine transform for axis swapping and/or unit conversions.protected static final ReferenceIdentifierThe identifier for a transformation which is a datum shift.protected static final ReferenceIdentifierThe identifier for a transformation which is a datum shift without Bursa Wolf parameters.protected static final ReferenceIdentifierThe identifier for a geocentric conversion.protected static final ReferenceIdentifierThe identifier for an identity operation.protected static final ReferenceIdentifierThe identifier for an inverse operation.Fields inherited from class ReferencingFactory
LOGGERFields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCoordinateOperationFactory(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
Modifier and TypeMethodDescriptionprotected Set<CoordinateOperation>concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2) Concatenate two operation steps.protected Set<CoordinateOperation>concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2, Set<CoordinateOperation> candidatesStep3) Concatenate two sets of operation steps.protected CoordinateOperationconcatenate(CoordinateOperation step1, CoordinateOperation step2) Concatenate two operation steps.protected CoordinateOperationconcatenate(CoordinateOperation step1, CoordinateOperation step2, CoordinateOperation step3) Concatenate three transformation steps.createConcatenatedOperation(Map<String, ?> properties, CoordinateOperation... operations) Creates a concatenated operation from a sequence of operations.createDefiningConversion(Map<String, ?> properties, OperationMethod method, ParameterValueGroup parameters) Constructs a defining conversion from a set of properties.protected CoordinateOperationcreateFromAffineTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, Matrix matrix) Creates a coordinate operation from a matrix, which usually describes an affine tranform.protected CoordinateOperationcreateFromMathTransform(Map<String, ?> properties, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform, OperationMethod method, Class<? extends CoordinateOperation> type) Creates a coordinate operation from a math transform.protected CoordinateOperationcreateFromMathTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform) Creates a coordinate operation from a math transform.protected CoordinateOperationcreateFromParameters(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, ParameterValueGroup parameters) Creates a coordinate operation from a set of parameters.protected static voidensureNonNull(String name, Object object) Makes sure an argument is non-null.protected static StringgetErrorMessage(IdentifiedObject source, IdentifiedObject target) Returns an error message for "No path found from sourceCRS to targetCRS".Returns the implementation hints for this factory.final MathTransformFactoryReturns the underlying math transform factory.protected CoordinateOperationinverse(CoordinateOperation operation) Returns the inverse of the specified operation.protected MatrixswapAndScaleAxis(CoordinateSystem sourceCS, CoordinateSystem targetCS) Returns an affine transform between two coordinate systems.Methods inherited from class ReferencingFactory
getVendorMethods inherited from class AbstractFactory
addImplementationHints, equals, getPriority, hashCode, onDeregistration, onRegistration, toStringMethods inherited from interface CoordinateOperationFactory
createOperation, createOperation, findOperations
-
Field Details
-
IDENTITY
The identifier for an identity operation. -
AXIS_CHANGES
The identifier for conversion using an affine transform for axis swapping and/or unit conversions. -
DATUM_SHIFT
The identifier for a transformation which is a datum shift. -
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 withHints.LENIENT_DATUM_SHIFTset toBoolean.TRUE. -
GEOCENTRIC_CONVERSION
The identifier for a geocentric conversion. -
INVERSE_OPERATION
The identifier for an inverse operation.
-
-
Constructor Details
-
AbstractCoordinateOperationFactory
Constructs a coordinate operation factory using the specified hints. This constructor recognizes theCRS,CS,DATUMandMATH_TRANSFORMFACTORYhints.- Parameters:
userHints- The hints, ornullif none.
-
AbstractCoordinateOperationFactory
Constructs a coordinate operation factory using the specified hints and priority. This constructor recognizes theCRS,CS,DATUMandMATH_TRANSFORMFACTORYhints.- Parameters:
userHints- The hints, ornullif none.priority- The priority for this factory, as a number betweenMINIMUM_PRIORITYandMAXIMUM_PRIORITYinclusive.- Since:
- 2.2
-
-
Method Details
-
getImplementationHints
Returns the implementation hints for this factory. The returned map contains values forCRS,CS,DATUMandMATH_TRANSFORMFACTORYhints. Other values may be provided as well, at implementation choice.- Specified by:
getImplementationHintsin interfaceFactory- Overrides:
getImplementationHintsin classAbstractFactory- Returns:
- The map of hints, or an empty map if none.
-
getMathTransformFactory
Returns the underlying math transform factory. This factory is used for constructingMathTransformobjects 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
sourceCSare (x,y) pairs in metres and coordinates intargetCSare (-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
sourceCStotargetCSas an affine transform. Only axis orientation and units are taken in account. - Throws:
OperationNotFoundException- If the affine transform can't be constructed.- See Also:
-
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 defaultOperationMethodobject is given to this transform. In the special case where thenameidentifier isDATUM_SHIFTorELLIPSOID_SHIFT, the operation will be an instance ofTransformationinstead of the usualConversion.- 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 FactoryExceptionCreates a coordinate operation from a math transform. If the specified math transform is already a coordinate operation, and if source and target CRS match, thentransformis 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, ornull.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 FactoryExceptionConstructs a defining conversion from a set of properties.- Specified by:
createDefiningConversionin interfaceCoordinateOperationFactory- 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:
-
createConcatenatedOperation
public CoordinateOperation createConcatenatedOperation(Map<String, ?> properties, CoordinateOperation... operations) throws FactoryExceptionCreates a concatenated operation from a sequence of operations.- Specified by:
createConcatenatedOperationin interfaceCoordinateOperationFactory- 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 anAXIS_CHANGES, it will be included as part of the second operation instead of creating anConcatenatedOperation. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
step1- The first step, ornullfor the identity operation.step2- The second step, ornullfor the identity operation.- Returns:
- A concatenated operation, or
nullif all arguments was nul. - Throws:
FactoryException- if the operation can't be constructed.
-
concatenate
protected Set<CoordinateOperation> concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2) throws FactoryException Concatenate two operation steps. If an operation is anAXIS_CHANGES, it will be included as part of the second operation instead of creating anConcatenatedOperation. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
candidatesStep1- The first step, ornullfor the identity operation.candidatesStep2- The second step, ornullfor the identity operation.- Returns:
- A concatenated operation, or
nullif all arguments was nul. - Throws:
FactoryException- if the operation can't be constructed.
-
concatenate
protected Set<CoordinateOperation> concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2, Set<CoordinateOperation> candidatesStep3) throws FactoryException Concatenate two sets of operation steps. The result is the concatenation of all the steps on the firt set with all the steps on the second set (cartesian product), which will be then concatenated with all the steps on the third step.If an operation is an
AXIS_CHANGES, it will be included as part of the second operation instead of creating anConcatenatedOperation. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
candidatesStep1- The first set of candidate stepscandidatesStep2- The second set of candidate stepscandidatesStep3- The third step of candidate steps- Returns:
- A set of operations
- Throws:
FactoryException- if any of the concatenated operations couldn't be constructed.- See Also:
-
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 anAXIS_CHANGES, it will be included as part of the second operation instead of creating anConcatenatedOperation. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
step1- The first step, ornullfor the identity operation.step2- The second step, ornullfor the identity operation.step3- The third step, ornullfor the identity operation.- Returns:
- A concatenated operation, or
nullif 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
Returns an error message for "No path found from sourceCRS to targetCRS". This is used for the construction ofOperationNotFoundException.- Parameters:
source- The source CRS.target- The target CRS.- Returns:
- A default error message.
-
ensureNonNull
Makes sure an argument is non-null.- Parameters:
name- Argument name.object- User argument.- Throws:
IllegalArgumentException- ifobjectis null.
-