Package org.geotools.referencing.operation.matrix

Examples of org.geotools.referencing.operation.matrix.GeneralMatrix


       
    return WarpGridParameters;
  }

  private static AffineTransform2D getIdntityTransform() {
    GeneralMatrix M = new GeneralMatrix(3, 3);
    double[] m0 = { 1, 0, 0 };
    double[] m1 = { 0, 1, 0 };
    double[] m2 = { 0, 0, 1 };
    M.setRow(0, m0);
    M.setRow(1, m1);
    M.setRow(2, m2);
    return (AffineTransform2D)ProjectiveTransform.create(M);
  }
View Full Code Here


            Envelope env = new Envelope2D(crs, 0, 0, 2000, 3000 );

            // Generates 15 MappedPositions of approximately 2 m differences
            List<MappedPosition> mp = generateMappedPositions(env, 10, 1, crs);

            GeneralMatrix M = new GeneralMatrix(3, 3);
            double[] m0 = { 1, 0, 0 };
            double[] m1 = { 0, 1, 0 };
            double[] m2 = { 0, 0, 1 };
            M.setRow(0, m0);
            M.setRow(1, m1);
            M.setRow(2, m2);

            WarpGridBuilder builder = new TPSGridBuilder(mp, 10, 10, env,ProjectiveTransform.create(M));
           
            //builder.getDeltaFile(0, "/home/jezekjan/gridfile.txt");
View Full Code Here

            Envelope env = new Envelope2D(crs, 0, 0, 1000, 1000);

            // Generates 15 MappedPositions of approximately 2 m differences
            List<MappedPosition> mp = generateMappedPositions(env, 15, 1, crs);

            GeneralMatrix M = new GeneralMatrix(3, 3);
            double[] m0 = { 1, 0, 0 };
            double[] m1 = { 0, 1, 0 };
            double[] m2 = { 0, 0, 1 };
            M.setRow(0, m0);
            M.setRow(1, m1);
            M.setRow(2, m2);

            WarpGridBuilder builder = new RSGridBuilder(mp, 3, 3, env,
                    ProjectiveTransform.create(M));

                     
View Full Code Here

   
    public void testFileProvider(){
         try {
               // Envelope 20*20 km
               Envelope env = new Envelope2D(crs, 10, 10, 500, 500);
               GeneralMatrix M = new GeneralMatrix(3, 3);
                      

             //  WarpGridBuilder builder = new RSGridBuilder(mp, 3, 3, env,
             //          ProjectiveTransform.create(M));

View Full Code Here

     */
    static GeneralMatrix toGMatrix(final Matrix matrix) {
        if (matrix instanceof GeneralMatrix) {
            return (GeneralMatrix) matrix;
        } else {
            return new GeneralMatrix(matrix);
        }
    }
View Full Code Here

            throw new IllegalArgumentException(Errors.format(
                      ErrorKeys.INCOMPATIBLE_COORDINATE_SYSTEM_TYPE));
        }
        final AxisDirection[] sourceAxis = getAxisDirections(sourceCS);
        final AxisDirection[] targetAxis = getAxisDirections(targetCS);
        final GeneralMatrix matrix = new GeneralMatrix(sourceAxis, targetAxis);
        assert Arrays.equals(sourceAxis, targetAxis) == matrix.isIdentity() : matrix;
        /*
         * The previous code computed a matrix for swapping axis. Usually, this
         * matrix contains only 0 and 1 values with only one "1" value by row.
         * For example, the matrix operation for swapping x and y axis is:
         *
         *          [y]   [ 0  1  0 ] [x]
         *          [x] = [ 1  0  0 ] [y]
         *          [1]   [ 0  0  1 ] [1]
         *
         * Now, take in account units conversions. Each matrix's element (j,i)
         * is multiplied by the conversion factor from sourceCS.getUnit(i) to
         * targetCS.getUnit(j). This is an element-by-element multiplication,
         * not a matrix multiplication. The last column is processed in a special
         * way, since it contains the offset values.
         */
        final int sourceDim = matrix.getNumCol()-1;
        final int targetDim = matrix.getNumRow()-1;
        assert sourceDim == sourceCS.getDimension() : sourceCS;
        assert targetDim == targetCS.getDimension() : targetCS;
        for (int j=0; j<targetDim; j++) {
            final Unit<?> targetUnit = targetCS.getAxis(j).getUnit();
            for (int i=0; i<sourceDim; i++) {
                final double element = matrix.getElement(j,i);
                if (element == 0) {
                    // There is no dependency between source[i] and target[j]
                    // (i.e. axis are orthogonal).
                    continue;
                }
                final Unit<?> sourceUnit = sourceCS.getAxis(i).getUnit();
                if (Utilities.equals(sourceUnit, targetUnit)) {
                    // There is no units conversion to apply
                    // between source[i] and target[j].
                    continue;
                }
                final UnitConverter converter = sourceUnit.getConverterTo(targetUnit);
                if (!converter.isLinear()) {
                    throw new ConversionException(Errors.format(
                              ErrorKeys.NON_LINEAR_UNIT_CONVERSION_$2, sourceUnit, targetUnit));
                }
                final double offset = converter.convert(0);
// JSR-275      final double scale  = converter.derivative(0);
                final double scale  = converter.convert(1) - offset;
                matrix.setElement(j,i, element*scale);
                matrix.setElement(j,sourceDim, matrix.getElement(j,sourceDim) + element*offset);
            }
        }
        return matrix;
    }
View Full Code Here

         * Special case for transformation backed by a matrix. Is is possible to use a
         * new matrix for such transform, instead of wrapping the sub-transform into a
         * PassThroughTransform object. It is faster and easier to concatenate.
         */
        if (subTransform instanceof LinearTransform) {
            GeneralMatrix matrix = toGMatrix(((LinearTransform)subTransform).getMatrix());
            matrix = PassThroughTransform.expand(matrix, firstAffectedOrdinate, numTrailingOrdinates, 1);
            return ProjectiveTransform.create(matrix);
        }
        /*
         * Constructs the general PassThroughTransform object. An optimisation
View Full Code Here

                                        final int affine)
    {
        final int         nSkipped = firstAffectedOrdinate + numTrailingOrdinates;
        final int           numRow = subMatrix.getNumRow() - affine;
        final int           numCol = subMatrix.getNumCol() - affine;
        final GeneralMatrix matrix = new GeneralMatrix(numRow + nSkipped + affine,
                                                       numCol + nSkipped + affine);
        matrix.setZero();

        //  Set UL part to 1:   [ 1  0             ]
        //                      [ 0  1             ]
        //                      [                  ]
        //                      [                  ]
        //                      [                  ]
        for (int j=0; j<firstAffectedOrdinate; j++) {
            matrix.setElement(j, j, 1);
        }
        //  Set central part:   [ 1  0  0  0  0  0 ]
        //                      [ 0  1  0  0  0  0 ]
        //                      [ 0  0  ?  ?  ?  0 ]
        //                      [ 0  0  ?  ?  ?  0 ]
        //                      [                  ]
        subMatrix.copySubMatrix(0, 0, numRow, numCol,
                                firstAffectedOrdinate, firstAffectedOrdinate, matrix);

        //  Set LR part to 1:   [ 1  0  0  0  0  0 ]
        //                      [ 0  1  0  0  0  0 ]
        //                      [ 0  0  ?  ?  ?  0 ]
        //                      [ 0  0  ?  ?  ?  0 ]
        //                      [ 0  0  0  0  0  1 ]
        final int offset = numCol-numRow;
        final int numRowOut = numRow + nSkipped;
        for (int j=numRowOut-numTrailingOrdinates; j<numRowOut; j++) {
            matrix.setElement(j, j+offset, 1);
        }
        if (affine != 0) {
            // Copy the translation terms in the last column.
            subMatrix.copySubMatrix(0, numCol, numRow, affine,
                                    firstAffectedOrdinate, numCol+nSkipped, matrix);
View Full Code Here

        final int dimension = matrix.getNumRow()-1;
        if (dimension == matrix.getNumCol()-1) {
            if (matrix.isIdentity()) {
                return IdentityTransform.create(dimension);
            }
            final GeneralMatrix m = toGMatrix(matrix);
            if (m.isAffine()) {
                switch (dimension) {
                    case 1: return LinearTransform1D.create(m.getElement(0,0), m.getElement(0,1));
                    case 2: return create(m.toAffineTransform2D());
                }
            }
        }
        switch (dimension) {
            case 2return new ProjectiveTransform2D(matrix);
View Full Code Here

     */
    public static LinearTransform createScale(final int dimension, final double scale) {
        if (scale == 1) {
            return IdentityTransform.create(dimension);
        }
        final Matrix matrix = new GeneralMatrix(dimension + 1);
        for (int i=0; i<dimension; i++) {
            matrix.setElement(i, i, scale);
        }
        return create(matrix);
    }
View Full Code Here

TOP

Related Classes of org.geotools.referencing.operation.matrix.GeneralMatrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.