Package org.opengis.parameter

Examples of org.opengis.parameter.ParameterValueGroup


    @Test
    public void testDescriptors() {
        final Double  ZERO  = 0.0;
        final Double  ONE   = 1.0;
        final Integer THREE = 3;
        final ParameterValueGroup group = create();

        group.parameter("num_row").setValue(1);
        group.parameter("num_col").setValue(1);
        List<GeneralParameterDescriptor> descriptors = group.getDescriptor().descriptors();
        assertDescriptorEquals("num_row", THREE, descriptors.get(0));
        assertDescriptorEquals("num_col", THREE, descriptors.get(1));
        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get(2));
        assertEquals("size", 3, descriptors.size());

        group.parameter("num_row").setValue(2);
        group.parameter("num_col").setValue(3);
        descriptors = group.getDescriptor().descriptors();
        assertDescriptorEquals("num_row", THREE, descriptors.get(0));
        assertDescriptorEquals("num_col", THREE, descriptors.get(1));
        assertDescriptorEquals("elt_0_0", ONE,   descriptors.get(2));
        assertDescriptorEquals("elt_0_1", ZERO,  descriptors.get(3));
        assertDescriptorEquals("elt_0_2", ZERO,  descriptors.get(4));
View Full Code Here


     * Tests {@link TensorValues#values()}.
     */
    @Test
    @DependsOnMethod("testParameter")
    public void testValues() {
        final ParameterValueGroup group = create();
        group.parameter("num_row").setValue(2);
        group.parameter("num_col").setValue(3);
        List<GeneralParameterValue> values = group.values();
        assertValueEquals("num_row", 2, values.get(0));
        assertValueEquals("num_col", 3, values.get(1));
        assertEquals("size", 2, values.size());

        group.parameter("elt_0_1").setValue(8);
        group.parameter("elt_1_1").setValue(7);
        group.parameter("elt_1_2").setValue(6);
        values = group.values();
        assertValueEquals("num_row", 2,   values.get(0));
        assertValueEquals("num_col", 3,   values.get(1));
        assertValueEquals("elt_0_1", 8.0, values.get(2));
        assertValueEquals("elt_1_1", 7.0, values.get(3));
        assertValueEquals("elt_1_2", 6.0, values.get(4));
View Full Code Here

    /**
     * Tests {@link TensorValues#descriptor(String)}.
     */
    @Test
    public void testDescriptor() {
        final ParameterValueGroup group = create();
        final ParameterDescriptorGroup d = group.getDescriptor();
        assertDescriptorEquals("num_row", 3,   d.descriptor("num_row"));
        assertDescriptorEquals("num_col", 3,   d.descriptor("num_col"));
        assertDescriptorEquals("elt_0_0", 1.0, d.descriptor("elt_0_0"));
        assertDescriptorEquals("elt_2_2", 1.0, d.descriptor("elt_2_2"));
        /*
         * If we reduce the matrix size, than it shall not be possible
         * anymore to get the descriptor in the row that we removed.
         */
        group.parameter("num_col").setValue(2);
        try {
            d.descriptor("elt_2_2");
            fail("elt_2_2 should not exist.");
        } catch (ParameterNotFoundException e) {
            final String message = e.getMessage();
View Full Code Here

    /**
     * Tests {@link TensorValues#parameter(String)}.
     */
    @Test
    public void testParameter() {
        final ParameterValueGroup group = create();
        assertValueEquals("num_row", 3,   group.parameter("num_row"));
        assertValueEquals("num_col", 3,   group.parameter("num_col"));
        assertValueEquals("elt_0_0", 1.0, group.parameter("elt_0_0"));
        assertValueEquals("elt_2_2", 1.0, group.parameter("elt_2_2"));

        group.parameter("elt_2_2").setValue(8);
        group.parameter("elt_0_1").setValue(6);
        assertValueEquals("elt_2_2", 8.0, group.parameter("elt_2_2"));
        assertValueEquals("elt_0_1", 6.0, group.parameter("elt_0_1"));
        /*
         * If we reduce the matrix size, than it shall not be possible
         * anymore to get the descriptor in the row that we removed.
         */
        group.parameter("num_col").setValue(2);
        try {
            group.parameter("elt_2_2");
            fail("elt_2_2 should not exist.");
        } catch (ParameterNotFoundException e) {
            final String message = e.getMessage();
            assertTrue(message, message.contains("elt_2_2"));
            assertTrue(message, message.contains(GROUP_NAME));
View Full Code Here

     * Tests {@link TensorValues#clone()}.
     */
    @Test
    @DependsOnMethod("testParameter")
    public void testClone() {
        final ParameterValueGroup group = create();
        group.parameter("num_row").setValue(2);
        group.parameter("elt_0_1").setValue(4);
        group.parameter("elt_1_0").setValue(2);
        /*
         * Creates a clone, modify some values, keep other values.
         */
        final ParameterValueGroup clone = group.clone();
        clone.parameter("num_row").setValue(4);
        clone.parameter("elt_0_1").setValue(3);
        /*
         * Verify that changes in cloned values did not affected
         * values in the original object.
         */
        assertEquals(2, group.parameter("num_row").intValue());
        assertEquals(4, clone.parameter("num_row").intValue());
        assertEquals(4, group.parameter("elt_0_1").intValue());
        assertEquals(3, clone.parameter("elt_0_1").intValue());
        assertEquals(2, group.parameter("elt_1_0").intValue());
        assertEquals(2, clone.parameter("elt_1_0").intValue());
    }
View Full Code Here

    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"    +
                "  Parameter[“num_col”, 4],\n"    +
View Full Code Here

        descriptor = new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "theGroup"), 1, 1,
                new DefaultParameterDescriptorGroup(singletonMap(NAME_KEY, "theSubGroup"), 0, 10)
        );
        validate(descriptor);

        final ParameterValueGroup groupValues = descriptor.createValue();
        assertEquals("Size before add.", 0, groupValues.values().size());
        final ParameterValueGroup subGroupValues = groupValues.addGroup("theSubGroup");
        assertEquals("Size after add.", 1, groupValues.values().size());
        assertSame(subGroupValues, groupValues.values().get(0));
        assertArrayEquals(new Object[] {subGroupValues}, groupValues.groups("theSubGroup").toArray());
    }
View Full Code Here

                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());
                assertEquals("elements", matrix, WKT1.toMatrix(group));
                assertEquals("elements", matrix, WKT1.toMatrix(new ParameterValueGroupWrapper(group)));
            }
        }
    }
View Full Code Here

        final GeneralParameterDescriptor child = descriptor.descriptor(name);
        if (!(child instanceof ParameterDescriptorGroup)) {
            throw new ParameterNotFoundException(Errors.format(
                    Errors.Keys.ParameterNotFound_2, descriptor.getName(), name), name);
        }
        final ParameterValueGroup value = ((ParameterDescriptorGroup) child).createValue();
        values.add(value);
        return value;
    }
View Full Code Here

        if (!CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
            /*
             * Operations.DEFAULT.resample( coverage, targetCRS, null,
             * Interpolation.getInstance(Interpolation.INTERP_NEAREST))
             */
            final ParameterValueGroup param = (ParameterValueGroup) resampleParams.clone();
            param.parameter("Source").setValue(coverage);
            param.parameter("CoordinateReferenceSystem").setValue(targetCRS);
            param.parameter("GridGeometry").setValue(null);
            param.parameter("InterpolationType").setValue(interpolation);

            coverage = (GridCoverage2D) resampleFactory.doOperation(param, hints);
        }

        return coverage;
View Full Code Here

TOP

Related Classes of org.opengis.parameter.ParameterValueGroup

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.