Search in sources :

Example 76 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class GeographicOffsetsTest method testCreateMathTransform.

/**
 * Tests the {@code createMathTransform(…)} method of the given provider.
 * This test uses the two-dimensional sample point given in §2.4.4.3 of EPSG guide (April 2015),
 * leaving the height (if any) to zero.
 */
private void testCreateMathTransform(final GeographicOffsets provider) throws FactoryException, TransformException {
    final ParameterValueGroup pv = provider.getParameters().createValue();
    pv.parameter("Latitude offset").setValue(-5.86 / 3600);
    pv.parameter("Longitude offset").setValue(+0.28 / 3600);
    transform = provider.createMathTransform(null, pv);
    tolerance = Formulas.ANGULAR_TOLERANCE;
    final double[] source = new double[transform.getSourceDimensions()];
    final double[] target = new double[transform.getTargetDimensions()];
    // 38°08′36.565″N
    source[1] = 38 + (8 + 36.565 / 60) / 60;
    // 38°08′30.705″N
    target[1] = 38 + (8 + 30.705 / 60) / 60;
    // 23°48′16.235″E
    source[0] = 23 + (48 + 16.235 / 60) / 60;
    // 23°48′16.515″E
    target[0] = 23 + (48 + 16.515 / 60) / 60;
    verifyTransform(source, target);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup)

Example 77 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class LongitudeRotationTest method testCreateMathTransform.

/**
 * Tests {@code LongitudeRotation.createMathTransform(…)}.
 */
@Test
public void testCreateMathTransform() {
    final LongitudeRotation provider = new LongitudeRotation();
    ParameterValueGroup p = provider.getParameters().createValue();
    // Paris meridian
    p.parameter("Longitude offset").setValue(2.5969213, Units.GRAD);
    final MathTransform mt = provider.createMathTransform(null, p);
    /*
         * Verify the full matrix. Note that the longitude offset is expected to be in degrees.
         * This conversion from grad to degrees is specific to Apache SIS and may be revised in
         * future version. See org.apache.sis.referencing.operation package javadoc.
         */
    assertInstanceOf("Shall be an affine transform.", LinearTransform.class, mt);
    assertMatrixEquals("Expected a longitude rotation", new Matrix3(1, 0, 2.33722917, 0, 1, 0, 0, 0, 1), ((LinearTransform) mt).getMatrix(), 1E-16);
}
Also used : MathTransform(org.opengis.referencing.operation.MathTransform) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Matrix3(org.apache.sis.referencing.operation.matrix.Matrix3) Test(org.junit.Test)

Example 78 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class GeocentricTranslationTest method create.

/**
 * Creates a transformation for the given method.
 *
 * @param method  the method to test.
 */
private void create(final GeocentricAffine method) throws FactoryException {
    final ParameterValueGroup values = method.getParameters().createValue();
    setTranslation(values);
    if (method instanceof GeocentricAffineBetweenGeographic) {
        setEllipsoids(values, CommonCRS.WGS84.ellipsoid(), CommonCRS.ED50.ellipsoid());
    }
    transform = method.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class), values);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup)

Example 79 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class MapProjectionParametersTest method testEarthRadius.

/**
 * Tests the {@code "earth_radius"} dynamic parameter.
 */
@Test
public void testEarthRadius() {
    final MapProjectionDescriptor descriptor = createDescriptor(0);
    final ParameterValueGroup parameters = descriptor.createValue();
    // WGS84
    parameters.parameter(SEMI_MAJOR).setValue(6378137.000);
    parameters.parameter(SEMI_MINOR).setValue(6356752.314);
    // Authalic radius.
    assertEquals(6371007, parameters.parameter(EARTH_RADIUS).doubleValue(), 0.5);
    assertEquals(6378137, parameters.parameter(SEMI_MAJOR).doubleValue(), 0.5);
    assertEquals(6356752, parameters.parameter(SEMI_MINOR).doubleValue(), 0.5);
    parameters.parameter(EARTH_RADIUS).setValue(6371000);
    assertEquals(6371000, parameters.parameter(EARTH_RADIUS).doubleValue(), 0.0);
    assertEquals(6371000, parameters.parameter(SEMI_MAJOR).doubleValue(), 0.0);
    assertEquals(6371000, parameters.parameter(SEMI_MINOR).doubleValue(), 0.0);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test)

Example 80 with ParameterValueGroup

use of org.opengis.parameter.ParameterValueGroup in project sis by apache.

the class ParametersTest method testCopy.

/**
 * Tests {@link Parameters#copy(ParameterValueGroup, ParameterValueGroup)}.
 *
 * @see <a href="https://issues.apache.org/jira/browse/SIS-202">SIS-202</a>
 */
@Test
public void testCopy() {
    /*
         * The descriptor to be used for this test. This descriptor contain at least
         * one subgroup, for testing the Parameters.copy(...) method recursivity.
         */
    final String subgroupName = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.getName().getCode();
    final DefaultParameterDescriptorGroup descriptor = new DefaultParameterDescriptorGroup(Collections.singletonMap(DefaultParameterDescriptorGroup.NAME_KEY, "parent"), 1, 1, DefaultParameterDescriptorTest.createSimpleOptional("A parent parameter", String.class), DefaultParameterDescriptorGroupTest.M1_M1_O1_O2);
    /*
         * Create the parameter value to copy. We set some values, but intentionally not all of them.
         * The unset values will be used for verifying that they do not overwrite destination values.
         */
    final ParameterValueGroup source = descriptor.createValue();
    final ParameterValueGroup sourceSubgroup = source.addGroup(subgroupName);
    final ParameterValue<?> o1 = sourceSubgroup.parameter("Optional 4");
    // See ParameterFormatTest.testMultiOccurrence()
    final ParameterValue<?> o2 = o1.getDescriptor().createValue();
    sourceSubgroup.parameter("Mandatory 2").setValue(20);
    sourceSubgroup.values().add(o2);
    o1.setValue(40);
    o2.setValue(50);
    source.parameter("A parent parameter").setValue("A value from the source");
    /*
         * Create the parameter to use as the destination. We put some value in those parameters in order to
         * verify that those values are overwritten (only those for which the value is set in the source).
         */
    final ParameterValueGroup target = descriptor.createValue();
    final ParameterValueGroup targetSubgroup = target.addGroup(subgroupName);
    // We expect this value to be overwritten.
    targetSubgroup.parameter("Mandatory 1").setValue(-10);
    // We expect this value to be preserved.
    targetSubgroup.parameter("Optional 3").setValue(30);
    target.parameter("A parent parameter").setValue("A value to be overwritten");
    /*
         * The actual test.
         */
    Parameters.copy(source, target);
    assertSame(sourceSubgroup, TestUtilities.getSingleton(source.groups(subgroupName)));
    assertSame(targetSubgroup, TestUtilities.getSingleton(target.groups(subgroupName)));
    assertEquals("A value from the source", target.parameter("A parent parameter").getValue());
    assertEquals("Mandatory 1", 10, targetSubgroup.parameter("Mandatory 1").intValue());
    assertEquals("Mandatory 2", 20, targetSubgroup.parameter("Mandatory 2").intValue());
    assertEquals("Optional 3", 30, targetSubgroup.parameter("Optional 3").intValue());
    assertEquals("Optional 4", 40, ((ParameterValue<?>) targetSubgroup.values().get(3)).intValue());
    assertEquals("Optional 4 bis", 50, ((ParameterValue<?>) targetSubgroup.values().get(4)).intValue());
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) InternationalString(org.opengis.util.InternationalString) Test(org.junit.Test)

Aggregations

ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)98 Test (org.junit.Test)54 DependsOnMethod (org.apache.sis.test.DependsOnMethod)27 GeneralParameterValue (org.opengis.parameter.GeneralParameterValue)12 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)11 OperationMethod (org.opengis.referencing.operation.OperationMethod)11 ParameterValue (org.opengis.parameter.ParameterValue)8 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7 ParameterNotFoundException (org.opengis.parameter.ParameterNotFoundException)7 SingleOperation (org.opengis.referencing.operation.SingleOperation)6 FactoryException (org.opengis.util.FactoryException)6 DefaultGeodeticDatum (org.apache.sis.referencing.datum.DefaultGeodeticDatum)5 IdentifiedObject (org.opengis.referencing.IdentifiedObject)5 Matrix (org.opengis.referencing.operation.Matrix)5 ArrayList (java.util.ArrayList)4 DefaultConversion (org.apache.sis.referencing.operation.DefaultConversion)4 ParameterDescriptorGroup (org.opengis.parameter.ParameterDescriptorGroup)4 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)4 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)4 URL (java.net.URL)3