Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.Matrix


            start("wcs:GridCRS");
            element("wcs:GridBaseCRS", urnIdentifier(ci.getCRS()));
            element("wcs:GridType", GridType.GT2dGridIn2dCrs.getXmlConstant());
            // TODO: go back to using the metadata once they can be trusted
            final LinearTransform tx = (LinearTransform) ci.getGrid().getGridToCRS();
            final Matrix matrix = tx.getMatrix();
            // origin
            StringBuffer origins = new StringBuffer();
            for (int i = 0; i < matrix.getNumRow() - 1; i++) {
                origins.append(matrix.getElement(i, matrix.getNumCol() - 1));
                if (i < matrix.getNumRow() - 2)
                    origins.append(" ");
            }
            element("wcs:GridOrigin", origins.toString());
            // offsets
            StringBuffer offsets = new StringBuffer();
            for (int i = 0; i < matrix.getNumRow() - 1; i++) {
                for (int j = 0; j < matrix.getNumCol() - 1; j++) {
                    offsets.append(matrix.getElement(i, j));
                    if (j < matrix.getNumCol() - 2)
                        offsets.append(" ");
                }
                if (i < matrix.getNumRow() - 2)
                    offsets.append(" ");

            }
            element("wcs:GridOffsets", offsets.toString());
            element("wcs:GridCS", "urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS");
View Full Code Here


    /**
     * Tests WKT formatting.
     */
    @Test
    public void testWKT() {
        final Matrix matrix = Matrices.createIdentity(4);
        matrix.setElement(0,24);
        matrix.setElement(1,0, -2);
        matrix.setElement(2,37);
        final ParameterValueGroup group = WKT1.createValueGroup(singletonMap(TensorValues.NAME_KEY, "Affine"), matrix);
        validate(group);
        assertWktEquals(
                "ParameterGroup[“Affine”,\n"      +
                "  Parameter[“num_row”, 4],\n"    +
View Full Code Here

     */
    @Test
    @DependsOnMethod("testGetPositionVectorTransformation")
    public void testSetPositionVectorTransformation() {
        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
        final Matrix matrix = bursaWolf.getPositionVectorTransformation(null);
        final BursaWolfParameters actual = new BursaWolfParameters(
                bursaWolf.getTargetDatum(), bursaWolf.getDomainOfValidity());
        actual.setPositionVectorTransformation(matrix, 1E-10);
        assertEquals(bursaWolf, actual);
    }
View Full Code Here

     */
    @Test
    @DependsOnMethod("testProductOfInverse")
    public void testInvert() throws NoninvertibleMatrixException {
        final BursaWolfParameters bursaWolf = createED87_to_WGS84();
        final Matrix original = getPositionVectorTransformation(bursaWolf).inverse();
        bursaWolf.invert();
        final Matrix inverse = getPositionVectorTransformation(bursaWolf);
        assertMatrixEquals("invert", original, inverse, 0.001);
    }
View Full Code Here

        /*
         * Search for BursaWolfParameters around the North Sea area.
         */
        final DefaultGeographicBoundingBox areaOfInterest = new DefaultGeographicBoundingBox(-2, 8, 55, 60);
        final DefaultExtent extent = new DefaultExtent("Around the North Sea", areaOfInterest, null, null);
        Matrix matrix = datum.getPositionVectorTransformation(NAD83, extent);
        assertNull("No BursaWolfParameters for NAD83", matrix);
        matrix = datum.getPositionVectorTransformation(WGS84, extent);
        assertNotNull("BursaWolfParameters for WGS84", matrix);
        checkTransformationSignature(local, matrix, 0);
        /*
 
View Full Code Here

    /**
     * Tests {@link Matrices#copy(Matrix)}
     */
    @Test
    public void testCopy() {
        final Matrix matrix = new Matrix3(10, 20, 30, 40, 50, 60, 70, 80, 90);
        final Matrix copy = Matrices.copy(matrix);
        assertNotSame("copy", matrix, copy);
        assertEquals ("copy", matrix, copy);
    }
View Full Code Here

    public void testMatrixConversion() {
        final int size = 8;
        final Random random = TestUtilities.createRandomNumberGenerator();
        for (int numRow = 2; numRow <= size; numRow++) {
            for (int numCol = 2; numCol <= size; numCol++) {
                final Matrix matrix = Matrices.createZero(numRow, numCol);
                for (int j=0; j<numRow; j++) {
                    for (int i=0; i<numCol; i++) {
                        matrix.setElement(j, i, 200*random.nextDouble() - 100);
                    }
                }
                final ParameterValueGroup group = WKT1.createValueGroup(singletonMap(NAME_KEY, "Test"), matrix);
                assertEquals("num_row",  numRow, group.parameter("num_row").intValue());
                assertEquals("num_col",  numCol, group.parameter("num_col").intValue());
View Full Code Here

    public void append(final MathTransform transform) {
        if (transform != null) {
            if (transform instanceof FormattableObject) {
                append((FormattableObject) transform);
            } else {
                final Matrix matrix = ReferencingServices.getInstance().getMatrix(transform);
                if (matrix != null) {
                    openElement(true, "Param_MT");
                    quote("Affine");
                    indent(+1);
                    append(matrix);
View Full Code Here

     * @return A matrix created from this group of parameters.
     */
    final Matrix toMatrix() {
        final int numRow = dimensions[0].intValue();
        final int numCol = dimensions[1].intValue();
        final Matrix matrix = Matrices.createDiagonal(numRow, numCol);
        if (values != null) {
            for (int j=0; j<numRow; j++) {
                final ParameterValue<?>[] row = (ParameterValue<?>[]) values[j];
                if (row != null) {
                    for (int i=0; i<numCol; i++) {
                        final ParameterValue<?> element = row[i];
                        if (element != null) {
                            matrix.setElement(j, i, element.doubleValue());
                        }
                    }
                }
            }
        }
View Full Code Here

            return ((TensorValues) parameters).toMatrix(); // More efficient implementation
        }
        // Fallback on the general case (others implementations)
        final ParameterValue<?> numRow = parameters.parameter(dimensions[0].getName().getCode());
        final ParameterValue<?> numCol = parameters.parameter(dimensions[1].getName().getCode());
        final Matrix matrix = Matrices.createDiagonal(numRow.intValue(), numCol.intValue());
        final List<GeneralParameterValue> values = parameters.values();
        if (values != null) {
            for (final GeneralParameterValue param : values) {
                if (param == numRow || param == numCol) {
                    continue;
                }
                final String name = param.getDescriptor().getName().getCode();
                IllegalArgumentException cause = null;
                int[] indices = null;
                try {
                    indices = nameToIndices(name);
                } catch (IllegalArgumentException e) {
                    cause = e;
                }
                if (indices == null) {
                    throw (InvalidParameterNameException) new InvalidParameterNameException(Errors.format(
                                Errors.Keys.UnexpectedParameter_1, name), name).initCause(cause);
                }
                matrix.setElement(indices[0], indices[1], ((ParameterValue<?>) param).doubleValue());
            }
        }
        return matrix;
    }
View Full Code Here

TOP

Related Classes of org.opengis.referencing.operation.Matrix

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.