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);
}
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);
}
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;
}
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);
}
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));
}
Aggregations