Search in sources :

Example 41 with ParameterValueGroup

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

the class InterpolatedTransformTest method createNADCON.

/**
 * Creates a transformation from NAD27 to NAD93
 *
 * @throws FactoryException if an error occurred while loading the grid.
 */
private void createNADCON() throws FactoryException {
    final URL latitudeShifts = NADCONTest.getResourceAsConvertibleURL(NADCONTest.TEST_FILE + ".laa");
    final URL longitudeShifts = NADCONTest.getResourceAsConvertibleURL(NADCONTest.TEST_FILE + ".loa");
    final NADCON provider = new NADCON();
    final ParameterValueGroup values = provider.getParameters().createValue();
    values.parameter("Latitude difference file").setValue(latitudeShifts);
    values.parameter("Longitude difference file").setValue(longitudeShifts);
    transform = provider.createMathTransform(DefaultFactories.forBuildin(MathTransformFactory.class), values);
    tolerance = NADCONTest.ANGULAR_TOLERANCE;
    validate();
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) NADCON(org.apache.sis.internal.referencing.provider.NADCON) URL(java.net.URL)

Example 42 with ParameterValueGroup

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

the class MolodenskyTransformTest method testProvider.

/**
 * Tests the creation through the provider.
 *
 * @throws FactoryException if an error occurred while creating a transform step.
 * @throws TransformException if a transformation failed.
 */
@Test
@DependsOnMethod("testRandomPoints")
public void testProvider() throws FactoryException, TransformException {
    final MathTransformFactory factory = new MathTransformFactoryMock(new Molodensky());
    final ParameterValueGroup parameters = factory.getDefaultParameters("Molodenski");
    parameters.parameter("dim").setValue(3);
    parameters.parameter("dx").setValue(-3.0);
    parameters.parameter("dy").setValue(142.0);
    parameters.parameter("dz").setValue(183.0);
    parameters.parameter("src_semi_major").setValue(6378206.4);
    parameters.parameter("src_semi_minor").setValue(6356583.8);
    parameters.parameter("tgt_semi_major").setValue(6378137.0);
    parameters.parameter("tgt_semi_minor").setValue(6356752.31414036);
    transform = factory.createParameterizedTransform(parameters);
    assertEquals(3, transform.getSourceDimensions());
    assertEquals(3, transform.getTargetDimensions());
    tolerance = Formulas.ANGULAR_TOLERANCE * 5;
    zTolerance = Formulas.LINEAR_TOLERANCE * 5;
    verifyInDomain(CoordinateDomain.RANGE_10, ORDINATE_COUNT);
}
Also used : Molodensky(org.apache.sis.internal.referencing.provider.Molodensky) MathTransformFactory(org.opengis.referencing.operation.MathTransformFactory) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) GeocentricTranslationTest(org.apache.sis.internal.referencing.provider.GeocentricTranslationTest) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 43 with ParameterValueGroup

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

the class Store method getOpenParameters.

/**
 * Returns the parameters used to open this data store.
 */
@Override
public ParameterValueGroup getOpenParameters() {
    final String format = StoreUtilities.getFormatName(componentProvider);
    final ParameterValueGroup pg = (provider != null ? provider.getOpenParameters() : FolderStoreProvider.PARAMETERS).createValue();
    pg.parameter(DataStoreProvider.LOCATION).setValue(location);
    if (locale != null)
        pg.parameter("locale").setValue(locale);
    if (timezone != null)
        pg.parameter("timezone").setValue(timezone);
    if (encoding != null)
        pg.parameter("encoding").setValue(encoding);
    if (format != null)
        pg.parameter("format").setValue(format);
    return pg;
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup)

Example 44 with ParameterValueGroup

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

the class URIDataStore method parameters.

/**
 * Creates parameter value group for the current location, if non-null.
 * This convenience method is used for {@link DataStore#getOpenParameters()} implementations in public
 * {@code DataStore} that can not extend {@code URIDataStore} directly, because this class is internal.
 *
 * @param  provider  the provider of the data store for which to get open parameters.
 * @param  location  file opened by the data store.
 * @return parameters to be returned by {@link DataStore#getOpenParameters()}.
 *
 * @todo Verify if non-exported classes in JDK9 are hidden from Javadoc, like package-private classes.
 *       If true, we could remove this hack and extend {@code URIDataStore} even in public classes.
 */
public static ParameterValueGroup parameters(final DataStoreProvider provider, final URI location) {
    if (location == null || provider == null)
        return null;
    final ParameterValueGroup pg = provider.getOpenParameters().createValue();
    pg.parameter(DataStoreProvider.LOCATION).setValue(location);
    return pg;
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup)

Example 45 with ParameterValueGroup

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

the class ServicesForMetadata method toFormattableObject.

/**
 * Converts the given object in a {@code FormattableObject} instance. Callers should verify that the given
 * object is not already an instance of {@code FormattableObject} before to invoke this method. This method
 * returns {@code null} if it can not convert the object.
 *
 * @param  object    the object to wrap.
 * @param  internal  {@code true} if the formatting convention is {@code Convention.INTERNAL}.
 * @return the given object converted to a {@code FormattableObject} instance, or {@code null}.
 *
 * @since 0.6
 */
@Override
public FormattableObject toFormattableObject(final MathTransform object, boolean internal) {
    Matrix matrix;
    final ParameterValueGroup parameters;
    if (internal && (matrix = MathTransforms.getMatrix(object)) != null) {
        parameters = Affine.parameters(matrix);
    } else if (object instanceof Parameterized) {
        parameters = ((Parameterized) object).getParameterValues();
    } else {
        matrix = MathTransforms.getMatrix(object);
        if (matrix == null) {
            return null;
        }
        parameters = Affine.parameters(matrix);
    }
    return new FormattableObject() {

        @Override
        protected String formatTo(final Formatter formatter) {
            WKTUtilities.appendParamMT(parameters, formatter);
            return WKTKeywords.Param_MT;
        }
    };
}
Also used : Parameterized(org.apache.sis.parameter.Parameterized) Matrix(org.opengis.referencing.operation.Matrix) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Formatter(org.apache.sis.io.wkt.Formatter) FormattableObject(org.apache.sis.io.wkt.FormattableObject)

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