use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class DefaultCoordinateOperationFactoryTest method verifyParametersNTF.
/**
* Verifies the datum shift parameters in the <cite>"NTF to WGS 84 (1)"</cite> transformation.
* Those parameters depends on whether an EPSG database have been used or not.
*
* @param steps the list returned by {@link DefaultConcatenatedOperation#getOperations()}.
* @param datumShiftIndex index of the datum shift operations in the {@code steps} list.
* @return the {@link #isUsingEpsgFactory()} value, returned for convenience.
*/
private static boolean verifyParametersNTF(final List<? extends CoordinateOperation> steps, final int datumShiftIndex) throws FactoryException {
if (isUsingEpsgFactory()) {
final SingleOperation step1 = (SingleOperation) steps.get(datumShiftIndex);
final SingleOperation step2 = (SingleOperation) steps.get(datumShiftIndex + 1);
assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (1)", 1763, step1);
assertEpsgNameAndIdentifierEqual("NTF to WGS 84 (1)", 1193, step2);
final ParameterValueGroup p1 = step1.getParameterValues();
final ParameterValueGroup p2 = step2.getParameterValues();
assertEquals("Longitude offset", 2.5969213, p1.parameter("Longitude offset").doubleValue(), STRICT);
assertEquals("X-axis translation", -168, p2.parameter("X-axis translation").doubleValue(), STRICT);
assertEquals("Y-axis translation", -60, p2.parameter("Y-axis translation").doubleValue(), STRICT);
assertEquals("Z-axis translation", 320, p2.parameter("Z-axis translation").doubleValue(), STRICT);
return true;
} else {
assertSame(CoordinateOperationFinder.ELLIPSOID_CHANGE, steps.get(datumShiftIndex).getName());
return false;
}
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class DefaultTransformationTest method verifyProperties.
/**
* Asserts that at least some of the properties of the given {@code op} instance have the expected values
* for an instance created by {@link #createGeocentricTranslation()}.
*/
@SuppressWarnings("SuspiciousToArrayCall")
private static void verifyProperties(final DefaultTransformation op) {
assertEquals("name", "Tokyo to JGD2000 (GSI)", op.getName().getCode());
assertEquals("sourceCRS", "Tokyo 1918", op.getSourceCRS().getName().getCode());
assertEquals("targetCRS", "JGD2000", op.getTargetCRS().getName().getCode());
assertEquals("method", "Geocentric translations", op.getMethod().getName().getCode());
assertEquals("parameters", "Geocentric translations", op.getParameterDescriptors().getName().getCode());
final ParameterValueGroup parameters = op.getParameterValues();
final ParameterValue<?>[] values = parameters.values().toArray(new ParameterValue<?>[3]);
assertEquals("parameters", "Geocentric translations", parameters.getDescriptor().getName().getCode());
assertEquals("parameters[0]", "X-axis translation", values[0].getDescriptor().getName().getCode());
assertEquals("parameters[1]", "Y-axis translation", values[1].getDescriptor().getName().getCode());
assertEquals("parameters[2]", "Z-axis translation", values[2].getDescriptor().getName().getCode());
assertEquals("parameters[0]", -146.414, values[0].doubleValue(), STRICT);
assertEquals("parameters[1]", 507.337, values[1].doubleValue(), STRICT);
assertEquals("parameters[2]", 680.507, values[2].doubleValue(), STRICT);
assertEquals(3, values.length);
final Matrix m = MathTransforms.getMatrix(op.getMathTransform());
assertNotNull("transform", m);
for (int j = m.getNumRow(); --j >= 0; ) {
for (int i = m.getNumCol(); --i >= 0; ) {
double expected = (i == j) ? 1 : 0;
if (i == 2)
switch(j) {
case 0:
expected = -146.414;
break;
case 1:
expected = 507.337;
break;
case 2:
expected = 680.507;
break;
}
assertEquals(expected, m.getElement(j, i), STRICT);
}
}
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class SingleOperationMarshallingTest method testTransformationUnmarshalling.
/**
* Tests unmarshalling of a transformation.
*
* @throws JAXBException if an error occurred during marshalling or unmarshalling.
*/
@Test
@DependsOnMethod("testConversionUnmarshalling")
public void testTransformationUnmarshalling() throws JAXBException {
final DefaultTransformation c = unmarshalFile(DefaultTransformation.class, "Transformation.xml");
assertEquals("name", "NTF (Paris) to NTF (1)", c.getName().getCode());
assertEquals("identifier", "1763", getSingleton(c.getIdentifiers()).getCode());
assertEquals("scope", "Change of prime meridian.", String.valueOf(c.getScope()));
assertEquals("operationVersion", "IGN-Fra", c.getOperationVersion());
final OperationMethod method = c.getMethod();
assertNotNull("method", method);
assertEquals("method.name", "Longitude rotation", method.getName().getCode());
assertEquals("method.identifier", "9601", getSingleton(method.getIdentifiers()).getCode());
assertEquals("method.formula", "Target_longitude = Source_longitude + longitude_offset.", method.getFormula().getFormula().toString());
final ParameterDescriptor<?> descriptor = (ParameterDescriptor<?>) getSingleton(method.getParameters().descriptors());
assertEquals("descriptor.name", "Longitude offset", descriptor.getName().getCode());
assertEquals("descriptor.identifier", "8602", getSingleton(descriptor.getIdentifiers()).getCode());
assertEquals("descriptor.valueClass", Double.class, descriptor.getValueClass());
final ParameterValueGroup parameters = c.getParameterValues();
assertNotNull("parameters", parameters);
assertSame("parameters.descriptors", method.getParameters(), parameters.getDescriptor());
final ParameterValue<?> parameter = (ParameterValue<?>) getSingleton(parameters.values());
assertSame("parameters.descriptor", descriptor, parameter.getDescriptor());
assertEquals("parameters.unit", Units.GRAD, parameter.getUnit());
assertEquals("parameters.value", 2.5969213, parameter.getValue());
final CoordinateReferenceSystem sourceCRS = c.getSourceCRS();
assertInstanceOf("sourceCRS", GeodeticCRS.class, sourceCRS);
assertEquals("sourceCRS.name", "NTF (Paris)", sourceCRS.getName().getCode());
assertEquals("sourceCRS.scope", "Geodetic survey.", sourceCRS.getScope().toString());
assertEquals("sourceCRS.identifier", "4807", getSingleton(sourceCRS.getIdentifiers()).getCode());
final CoordinateReferenceSystem targetCRS = c.getTargetCRS();
assertInstanceOf("targetCRS", GeodeticCRS.class, targetCRS);
assertEquals("targetCRS.name", "NTF", targetCRS.getName().getCode());
assertEquals("targetCRS.scope", "Geodetic survey.", targetCRS.getScope().toString());
assertEquals("targetCRS.identifier", "4275", getSingleton(targetCRS.getIdentifiers()).getCode());
final MathTransform tr = c.getMathTransform();
assertInstanceOf("mathTransform", LinearTransform.class, tr);
assertMatrixEquals("mathTransform.matrix", new Matrix3(1, 0, 0, 0, 1, 2.33722917, 0, 0, 1), ((LinearTransform) tr).getMatrix(), STRICT);
Validators.validate(c);
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class NoOp method parameters.
/**
* Work around for RFE #4093999 in Sun's bug database
* ("Relax constraint on placement of this()/super() call in constructors").
*/
@Workaround(library = "JDK", version = "1.7")
private static Parameters parameters(final double semiMajor, final double semiMinor) {
final ParameterValueGroup group = new ParameterBuilder().addName("No-operation").createGroupForMapProjection().createValue();
group.parameter(Constants.SEMI_MAJOR).setValue(semiMajor);
group.parameter(Constants.SEMI_MINOR).setValue(semiMinor);
return (Parameters) group;
}
use of org.opengis.parameter.ParameterValueGroup in project sis by apache.
the class DefaultMathTransformFactoryTest method testAllMapProjections.
/**
* Tests the creation of all registered map projections.
* Only the semi-axis lengths are specified. For the rest, we rely on default values.
*
* @throws FactoryException if the construction of a map projection failed.
*
* @since 0.7
*/
@Test
public void testAllMapProjections() throws FactoryException {
/*
* Gets all map projections and creates a projection using the WGS84 ellipsoid
* and default parameter values.
*/
final Map<String, ?> dummyName = Collections.singletonMap(DefaultProjectedCRS.NAME_KEY, "Test");
final MathTransformFactory mtFactory = DefaultFactories.forBuildin(MathTransformFactory.class);
final Collection<OperationMethod> methods = mtFactory.getAvailableMethods(Projection.class);
for (final OperationMethod method : methods) {
final String classification = method.getName().getCode();
ParameterValueGroup param = mtFactory.getDefaultParameters(classification);
param.parameter("semi_major").setValue(6377563.396);
param.parameter("semi_minor").setValue(6356256.909237285);
final MathTransform mt;
try {
mt = mtFactory.createParameterizedTransform(param);
} catch (InvalidGeodeticParameterException e) {
/*
* Some map projections have mandatory parameters which we ignore for now
* except for a few well-known projection that we know should not fail.
*/
if (classification.contains("Mercator")) {
throw e;
}
out.print(classification);
out.print(CharSequences.spaces(42 - classification.length()));
out.print(": ");
out.println(e.getLocalizedMessage());
continue;
}
/*
* Verifies that the map projection properties are the ones that we specified.
* Note that the Equirectangular projection has been optimized as an affine transform, which we skip.
*/
if (mt instanceof LinearTransform) {
continue;
}
assertInstanceOf(classification, Parameterized.class, mt);
param = ((Parameterized) mt).getParameterValues();
assertEquals(classification, param.getDescriptor().getName().getCode());
assertEquals(classification, 6377563.396, param.parameter("semi_major").doubleValue(), 1E-4);
assertEquals(classification, 6356256.909237285, param.parameter("semi_minor").doubleValue(), 1E-4);
/*
* Creates a ProjectedCRS from the map projection. This part is more an integration test than
* a DefaultMathTransformFactory test. Again, the intent is to verify that the properties are
* the one that we specified.
*/
final DefaultProjectedCRS crs = new DefaultProjectedCRS(dummyName, CommonCRS.WGS84.normalizedGeographic(), new DefaultConversion(dummyName, method, mt, null), HardCodedCS.PROJECTED);
final Conversion projection = crs.getConversionFromBase();
assertSame(classification, mt, projection.getMathTransform());
assertEquals(classification, projection.getMethod().getName().getCode());
}
}
Aggregations