org.geotools.referencing.operation.builder
Class AdvancedAffineBuilder

java.lang.Object
  extended by org.geotools.referencing.operation.builder.MathTransformBuilder
      extended by org.geotools.referencing.operation.builder.AdvancedAffineBuilder

public class AdvancedAffineBuilder
extends MathTransformBuilder

Builder for affine transformation with possibility to set several constrains for affine parameters that will be respected during calculation. This is convenient for example to use when you want affine transformation with skew parameter equal to zero. Development carried out thanks to R&D grant DC08P02OUK006 - Old Maps Online (www.oldmapsonline.org) from Ministry of Culture of the Czech Republic

Since:
Version:
$Id: AdvancedAffineBuilder.java 31099 2008-07-29 09:31:53Z desruisseaux $
Author:
jezekjan

Field Summary
static java.lang.String PHIX
          mark for key to specify phix - rotation constrain
static java.lang.String PHIY
          mark for key to specify phix - rotation constrain
static java.lang.String SX
          mark for key to specify sx - scale in x constrain
static java.lang.String SXY
          mark for key to specify sxy - skew constrain
static java.lang.String SY
          mark for key to specify sy - scale in y constrain
static java.lang.String TX
          mark for key to specify tx - translation in x constrain
static java.lang.String TY
          mark for key to specify ty - translation in y constrain
 
Fields inherited from class org.geotools.referencing.operation.builder.MathTransformBuilder
mtFactory
 
Constructor Summary
AdvancedAffineBuilder(java.util.List<MappedPosition> vectors)
          Constructs builder from set of GCPs
AdvancedAffineBuilder(java.util.List<MappedPosition> vectors, AffineTransform2D affineTrans)
          Constructs affine transform from GCPs and approximate values for calculation.
 
Method Summary
 void clearConstrains()
          Clears all constrains
protected  org.opengis.referencing.operation.MathTransform computeMathTransform()
          Calculates the math transform immediately.
protected  GeneralMatrix getA()
          Generates A matrix (Matrix of derivation of affine equation).
protected  GeneralMatrix getB()
          Fill matrix of derivations of constrains by affine parameters.
protected  GeneralMatrix getL()
          Fill L matrix.
 double getMaxIterationDifference()
          Returns difference that is required between steps in iteration
 int getMinimumPointCount()
          Returns the minimum number of points required by this builder.
 int getNumberOfIterationSteps()
          Return max number of iteration steps.
protected  GeneralMatrix getProjectiveMatrix()
          Calculates coefficients of Projective transformation matrix from geometric parameters.
protected  GeneralMatrix getU()
          Fill matrix of constrain values (e.g.
 void setConstrain(java.lang.String param, double value)
          Sets constrain that param is equal to value.
 void setMaxIterationDifference(double dif)
          Sets difference that is required between steps in iteration.
 void setNumberOfIterationSteps(int steps)
          Sets max number of iteration steps.
 
Methods inherited from class org.geotools.referencing.operation.builder.MathTransformBuilder
getCoordinateSystemType, getDimension, getErrorStatistics, getMappedPositions, getMathTransform, getName, getSourceCRS, getSourcePoints, getTargetCRS, getTargetPoints, getTransformation, printPoints, setMappedPositions, setSourcePoints, setTargetPoints, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SX

public static final java.lang.String SX
mark for key to specify sx - scale in x constrain

See Also:
Constant Field Values

SY

public static final java.lang.String SY
mark for key to specify sy - scale in y constrain

See Also:
Constant Field Values

SXY

public static final java.lang.String SXY
mark for key to specify sxy - skew constrain

See Also:
Constant Field Values

PHIX

public static final java.lang.String PHIX
mark for key to specify phix - rotation constrain

See Also:
Constant Field Values

PHIY

public static final java.lang.String PHIY
mark for key to specify phix - rotation constrain

See Also:
Constant Field Values

TX

public static final java.lang.String TX
mark for key to specify tx - translation in x constrain

See Also:
Constant Field Values

TY

public static final java.lang.String TY
mark for key to specify ty - translation in y constrain

See Also:
Constant Field Values
Constructor Detail

AdvancedAffineBuilder

public AdvancedAffineBuilder(java.util.List<MappedPosition> vectors)
                      throws javax.vecmath.MismatchedSizeException,
                             org.opengis.geometry.MismatchedDimensionException,
                             org.opengis.geometry.MismatchedReferenceSystemException,
                             org.opengis.referencing.FactoryException
Constructs builder from set of GCPs

Parameters:
vectors - GCPs
Throws:
javax.vecmath.MismatchedSizeException
org.opengis.geometry.MismatchedDimensionException
org.opengis.geometry.MismatchedReferenceSystemException
org.opengis.referencing.FactoryException

AdvancedAffineBuilder

public AdvancedAffineBuilder(java.util.List<MappedPosition> vectors,
                             AffineTransform2D affineTrans)
                      throws javax.vecmath.MismatchedSizeException,
                             org.opengis.geometry.MismatchedDimensionException,
                             org.opengis.geometry.MismatchedReferenceSystemException,
                             org.opengis.referencing.FactoryException
Constructs affine transform from GCPs and approximate values for calculation. This constructor should be used when the default calculation is divergating.

Parameters:
vectors - GCPs
affineTrans - approximate affine transformation
Throws:
javax.vecmath.MismatchedSizeException
org.opengis.geometry.MismatchedDimensionException
org.opengis.geometry.MismatchedReferenceSystemException
org.opengis.referencing.FactoryException
Method Detail

setConstrain

public void setConstrain(java.lang.String param,
                         double value)
Sets constrain that param is equal to value. Be aware that the calculation may diverge in the case you set some values that are not 'close' to approximate values. I the case of divergence you can set approximate values using proper constructor

Parameters:
param - parameter name - set one of AdvancedAffineBuilder static variables.
value - required value

clearConstrains

public void clearConstrains()
Clears all constrains


getA

protected GeneralMatrix getA()
Generates A matrix (Matrix of derivation of affine equation). Each column is derivation by each transformation parameter (sx, sy, sxy, phi, tx,ty). The rows are derivations of fx and fy.

Returns:
A matrix

getL

protected GeneralMatrix getL()
Fill L matrix. This matrix contains differences between expected value and value calculated from affine parameters

Returns:
l matrix

getMinimumPointCount

public int getMinimumPointCount()
Description copied from class: MathTransformBuilder
Returns the minimum number of points required by this builder. This minimum depends on the algorithm used. For example affine transform builders require at least 3 points, while similar transform builders requires only 2 points.

Specified by:
getMinimumPointCount in class MathTransformBuilder

getB

protected GeneralMatrix getB()
Fill matrix of derivations of constrains by affine parameters.

Returns:
B matrix

getU

protected GeneralMatrix getU()
Fill matrix of constrain values (e.g. for constrain skew = 0 the value is 0)

Returns:
U matrix

getProjectiveMatrix

protected GeneralMatrix getProjectiveMatrix()
                                     throws org.opengis.referencing.FactoryException
Calculates coefficients of Projective transformation matrix from geometric parameters.

Returns:
Projective Matrix
Throws:
org.opengis.referencing.FactoryException

computeMathTransform

protected org.opengis.referencing.operation.MathTransform computeMathTransform()
                                                                        throws org.opengis.referencing.FactoryException
Description copied from class: MathTransformBuilder
Calculates the math transform immediately.

Specified by:
computeMathTransform in class MathTransformBuilder
Returns:
Math transform from MappedPosition.
Throws:
org.opengis.referencing.FactoryException - if the math transform can't be created.

getMaxIterationDifference

public double getMaxIterationDifference()
Returns difference that is required between steps in iteration

Returns:
max difference that is required for iteration steps

setMaxIterationDifference

public void setMaxIterationDifference(double dif)
Sets difference that is required between steps in iteration.

Parameters:
dif -

getNumberOfIterationSteps

public int getNumberOfIterationSteps()
Return max number of iteration steps. If the difference between calculated values in each iteration steps is still bigger than required then Exception is thrown. This is not the number that was really needed for iteration.

Returns:
max number of iteration steps.

setNumberOfIterationSteps

public void setNumberOfIterationSteps(int steps)
Sets max number of iteration steps. If the difference between calculated values in each iteration steps is still bigger than required than Exception is thrown.

Parameters:
steps - max number of iterations.


Copyright © 1996-2010 Geotools. All Rights Reserved.