Search in sources :

Example 16 with Parameters

use of org.apache.sis.parameter.Parameters in project sis by apache.

the class StoreProvider method open.

/**
 * Returns a CSV {@link Store} implementation from the given parameters.
 *
 * @return a data store implementation associated with this provider for the given parameters.
 * @throws DataStoreException if an error occurred while creating the data store instance.
 */
@Override
public DataStore open(final ParameterValueGroup parameters) throws DataStoreException {
    ArgumentChecks.ensureNonNull("parameter", parameters);
    final StorageConnector connector = connector(this, parameters);
    final Parameters pg = Parameters.castOrWrap(parameters);
    connector.setOption(DataOptionKey.ENCODING, pg.getValue(ENCODING));
    connector.setOption(DataOptionKey.FOLIATION_REPRESENTATION, pg.getValue(FOLIATION));
    return new Store(this, connector);
}
Also used : StorageConnector(org.apache.sis.storage.StorageConnector) Parameters(org.apache.sis.parameter.Parameters) DataStore(org.apache.sis.storage.DataStore) URIDataStore(org.apache.sis.internal.storage.URIDataStore)

Example 17 with Parameters

use of org.apache.sis.parameter.Parameters in project sis by apache.

the class VerticalOffset method createMathTransform.

/**
 * Creates a transform from the specified group of parameter values.
 * The parameter value is unconditionally converted to metres.
 *
 * @param  factory  ignored (can be null).
 * @param  values   the group of parameter values.
 * @return the created math transform.
 * @throws ParameterNotFoundException if a required parameter was not found.
 */
@Override
public MathTransform createMathTransform(final MathTransformFactory factory, final ParameterValueGroup values) throws ParameterNotFoundException {
    final Parameters pv = Parameters.castOrWrap(values);
    final Matrix2 t = new Matrix2();
    t.m01 = pv.doubleValue(TZ);
    return MathTransforms.linear(t);
}
Also used : Parameters(org.apache.sis.parameter.Parameters) Matrix2(org.apache.sis.referencing.operation.matrix.Matrix2)

Example 18 with Parameters

use of org.apache.sis.parameter.Parameters in project sis by apache.

the class GeocentricAffine method createParameters.

/**
 * Creates parameter values for a Molodensky, Geocentric Translation or Position Vector transformation.
 *
 * @param  descriptor     the {@code PARAMETERS} constant of the subclass describing the operation to create.
 * @param  parameters     Bursa-Wolf parameters from which to get the values.
 * @param  isTranslation  {@code true} if the operation contains only translation terms.
 * @return the operation parameters with their values initialized.
 */
private static Parameters createParameters(final ParameterDescriptorGroup descriptor, final BursaWolfParameters parameters, final boolean isTranslation) {
    final Parameters values = Parameters.castOrWrap(descriptor.createValue());
    values.getOrCreate(TX).setValue(parameters.tX);
    values.getOrCreate(TY).setValue(parameters.tY);
    values.getOrCreate(TZ).setValue(parameters.tZ);
    if (!isTranslation) {
        values.getOrCreate(RX).setValue(parameters.rX);
        values.getOrCreate(RY).setValue(parameters.rY);
        values.getOrCreate(RZ).setValue(parameters.rZ);
        values.getOrCreate(DS).setValue(parameters.dS);
    }
    return values;
}
Also used : Parameters(org.apache.sis.parameter.Parameters) BursaWolfParameters(org.apache.sis.referencing.datum.BursaWolfParameters)

Example 19 with Parameters

use of org.apache.sis.parameter.Parameters in project sis by apache.

the class GeographicOffsets method createMathTransform.

/**
 * Creates a transform from the specified group of parameter values.
 * The parameter values are unconditionally converted to degrees and metres.
 *
 * @param  factory  ignored (can be null).
 * @param  values   the group of parameter values.
 * @return the created math transform.
 * @throws ParameterNotFoundException if a required parameter was not found.
 */
@Override
public MathTransform createMathTransform(MathTransformFactory factory, ParameterValueGroup values) throws ParameterNotFoundException {
    final Parameters pv = Parameters.castOrWrap(values);
    final Matrix4 t = new Matrix4();
    t.m03 = pv.doubleValue(TX);
    t.m13 = pv.doubleValue(TY);
    t.m23 = pv.doubleValue(vertical());
    return MathTransforms.linear(t);
}
Also used : Parameters(org.apache.sis.parameter.Parameters) Matrix4(org.apache.sis.referencing.operation.matrix.Matrix4)

Example 20 with Parameters

use of org.apache.sis.parameter.Parameters in project sis by apache.

the class Geographic3Dto2DTest method createDatumShiftForGeographic2D.

/**
 * Creates a "Geographic 2D to 3D → Geocentric → Affine → Geographic → Geographic 3D to 2D" chain.
 * This method is used for integration tests.
 *
 * @param  factory  the math transform factory to use for creating and concatenating the transform.
 * @param  affine   the math transform for the operation in geocentric Cartesian domain.
 * @param  pv       the parameters for the operation in geographic coordinates.
 * @return the chain of transforms.
 * @throws FactoryException if an error occurred while creating a transform.
 *
 * @see GeocentricTranslationTest#createDatumShiftForGeographic2D(MathTransformFactory)
 */
static MathTransform createDatumShiftForGeographic2D(final MathTransformFactory factory, final MathTransform affine, final Parameters pv) throws FactoryException {
    assertEquals("sourceDimensions", 3, affine.getSourceDimensions());
    assertEquals("targetDimensions", 3, affine.getTargetDimensions());
    /*
         * Create a "Geographic to Geocentric" conversion with ellipsoid axis length units converted to metres
         * (the unit implied by SRC_SEMI_MAJOR) because it is the unit of Bursa-Wolf parameters that we created above.
         */
    Parameters step = Parameters.castOrWrap(factory.getDefaultParameters(GeographicToGeocentric.NAME));
    step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MAJOR));
    step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.SRC_SEMI_MINOR));
    MathTransform toGeocentric = factory.createParameterizedTransform(step);
    assertEquals("sourceDimensions", 3, toGeocentric.getSourceDimensions());
    assertEquals("targetDimensions", 3, toGeocentric.getTargetDimensions());
    final MathTransform reduce = factory.createParameterizedTransform(factory.getDefaultParameters("Geographic3D to 2D conversion"));
    assertEquals("sourceDimensions", 3, reduce.getSourceDimensions());
    assertEquals("targetDimensions", 2, reduce.getTargetDimensions());
    try {
        toGeocentric = factory.createConcatenatedTransform(reduce.inverse(), toGeocentric);
    } catch (NoninvertibleTransformException e) {
        throw new FactoryException(e);
    }
    assertEquals("sourceDimensions", 2, toGeocentric.getSourceDimensions());
    assertEquals("targetDimensions", 3, toGeocentric.getTargetDimensions());
    /*
         * Create a "Geocentric to Geographic" conversion with ellipsoid axis length units converted to metres
         * because this is the unit of the Geocentric CRS used above.
         */
    step = Parameters.castOrWrap(factory.getDefaultParameters(GeocentricToGeographic.NAME));
    step.getOrCreate(MapProjection.SEMI_MAJOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MAJOR));
    step.getOrCreate(MapProjection.SEMI_MINOR).setValue(pv.doubleValue(GeocentricAffineBetweenGeographic.TGT_SEMI_MINOR));
    MathTransform toGeographic = factory.createParameterizedTransform(step);
    assertEquals("sourceDimensions", 3, toGeographic.getSourceDimensions());
    assertEquals("targetDimensions", 3, toGeographic.getTargetDimensions());
    toGeographic = factory.createConcatenatedTransform(toGeographic, reduce);
    assertEquals("sourceDimensions", 3, toGeographic.getSourceDimensions());
    assertEquals("targetDimensions", 2, toGeographic.getTargetDimensions());
    /*
         * The  Geocentric → Affine → Geographic  chain.
         */
    return factory.createConcatenatedTransform(toGeocentric, factory.createConcatenatedTransform(affine, toGeographic));
}
Also used : NoninvertibleTransformException(org.opengis.referencing.operation.NoninvertibleTransformException) Parameters(org.apache.sis.parameter.Parameters) MathTransform(org.opengis.referencing.operation.MathTransform) FactoryException(org.opengis.util.FactoryException)

Aggregations

Parameters (org.apache.sis.parameter.Parameters)26 MathTransform (org.opengis.referencing.operation.MathTransform)5 BursaWolfParameters (org.apache.sis.referencing.datum.BursaWolfParameters)4 MathTransformFactoryMock (org.apache.sis.referencing.operation.transform.MathTransformFactoryMock)4 NoninvertibleTransformException (org.opengis.referencing.operation.NoninvertibleTransformException)3 FactoryException (org.opengis.util.FactoryException)3 MatrixSIS (org.apache.sis.referencing.operation.matrix.MatrixSIS)2 ContextualParameters (org.apache.sis.referencing.operation.transform.ContextualParameters)2 StorageConnector (org.apache.sis.storage.StorageConnector)2 Debug (org.apache.sis.util.Debug)2 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)2 AffineTransform (java.awt.geom.AffineTransform)1 Path (java.nio.file.Path)1 StandardOpenOption (java.nio.file.StandardOpenOption)1 Angle (javax.measure.quantity.Angle)1 Length (javax.measure.quantity.Length)1 ParameterizedAffine (org.apache.sis.internal.referencing.j2d.ParameterizedAffine)1 Equirectangular (org.apache.sis.internal.referencing.provider.Equirectangular)1 LambertConformal1SP (org.apache.sis.internal.referencing.provider.LambertConformal1SP)1 PolarStereographicNorth (org.apache.sis.internal.referencing.provider.PolarStereographicNorth)1