use of org.opengis.referencing.operation.SingleOperation in project sis by apache.
the class CoordinateOperationFinderTest method testGeographic3D_to_2D.
/**
* Tests the conversion from a three-dimensional geographic CRS to a two-dimensional geographic CRS.
* The vertical dimension is simply dropped.
*
* @throws FactoryException if the operation can not be created.
* @throws TransformException if an error occurred while converting the test points.
*/
@Test
@DependsOnMethod("testIdentityTransform")
public void testGeographic3D_to_2D() throws FactoryException, TransformException {
final GeographicCRS sourceCRS = CommonCRS.WGS84.geographic3D();
final GeographicCRS targetCRS = CommonCRS.WGS84.geographic();
final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);
assertSame("sourceCRS", sourceCRS, operation.getSourceCRS());
assertSame("targetCRS", targetCRS, operation.getTargetCRS());
assertEquals("name", "Axis changes", operation.getName().getCode());
assertInstanceOf("operation", Conversion.class, operation);
final ParameterValueGroup parameters = ((SingleOperation) operation).getParameterValues();
assertEquals("parameters.descriptor", "Geographic3D to 2D conversion", parameters.getDescriptor().getName().getCode());
assertTrue("parameters.isEmpty", parameters.values().isEmpty());
transform = operation.getMathTransform();
assertInstanceOf("transform", LinearTransform.class, transform);
assertEquals("sourceDimensions", 3, transform.getSourceDimensions());
assertEquals("targetDimensions", 2, transform.getTargetDimensions());
Assert.assertMatrixEquals("transform.matrix", Matrices.create(3, 4, new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }), ((LinearTransform) transform).getMatrix(), STRICT);
isInverseTransformSupported = false;
verifyTransform(new double[] { 30, 10, 20, 20, 30, -10 }, new double[] { 30, 10, 20, 30 });
validate();
}
use of org.opengis.referencing.operation.SingleOperation in project sis by apache.
the class CoordinateOperationRegistryTest method verifyNTF.
/**
* Verifies a coordinate operation which is expected to be <cite>"NTF (Paris) to WGS 84 (1)"</cite> (EPSG:8094).
*
* @param domain either {@code "geog2D domain"} or either {@code "geog3D domain"}.
* @param isEPSG {@code true} if the coordinate operation is expected to contain EPSG identifiers.
*/
private static void verifyNTF(final CoordinateOperation operation, final String domain, final boolean isEPSG) {
assertInstanceOf("Operation should have two steps.", ConcatenatedOperation.class, operation);
final List<? extends CoordinateOperation> steps = ((ConcatenatedOperation) operation).getOperations();
assertEquals("Operation should have two steps.", 2, steps.size());
final SingleOperation step1 = (SingleOperation) steps.get(0);
final SingleOperation step2 = (SingleOperation) steps.get(1);
if (isEPSG) {
assertEpsgNameAndIdentifierEqual("NTF (Paris) to WGS 84 (1)", 8094, operation);
assertEpsgNameAndIdentifierEqual("NTF (Paris)", 4807, operation.getSourceCRS());
assertEpsgNameAndIdentifierEqual("WGS 84", 4326, operation.getTargetCRS());
assertEpsgNameAndIdentifierEqual("NTF (Paris) to NTF (1)", 1763, step1);
assertEpsgNameAndIdentifierEqual("NTF to WGS 84 (1)", 1193, step2);
} else {
assertEpsgNameWithoutIdentifierEqual("NTF (Paris) to WGS 84 (1)", operation);
assertEpsgNameWithoutIdentifierEqual("NTF (Paris)", operation.getSourceCRS());
assertEquals("name", "WGS 84", operation.getTargetCRS().getName().getCode());
assertEpsgNameWithoutIdentifierEqual("NTF (Paris) to NTF (1)", step1);
assertEpsgNameWithoutIdentifierEqual("NTF to WGS 84 (1)", step2);
}
assertSame("SourceCRS shall be the targetCRS of previous step.", step1.getTargetCRS(), step2.getSourceCRS());
assertEquals("Method 1", "Longitude rotation", step1.getMethod().getName().getCode());
assertEquals("Method 2", "Geocentric translations (" + domain + ')', step2.getMethod().getName().getCode());
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);
assertEquals("linearAccuracy", 2, CRS.getLinearAccuracy(operation), STRICT);
}
use of org.opengis.referencing.operation.SingleOperation in project sis by apache.
the class CoordinateOperationRegistryTest method testFindDespiteDifferentAxisOrder.
/**
* Tests <cite>"Martinique 1938 to RGAF09 (1)"</cite> operation with a target CRS fixed to EPSG:7086
* instead of EPSG:5489. Both are <cite>"RGAF09"</cite>, but the former use (longitude, latitude) axis
* order instead than the usual (latitude, longitude) order. The source CRS stay fixed to EPSG:4625.
*
* @throws FactoryException if an error occurred while creating a CRS or operation.
*/
@Test
public void testFindDespiteDifferentAxisOrder() throws FactoryException {
CoordinateReferenceSystem sourceCRS = crsFactory.createGeographicCRS("EPSG:4625");
CoordinateReferenceSystem targetCRS = crsFactory.createGeographicCRS("EPSG:5489");
CoordinateOperation operation = createOperation(sourceCRS, targetCRS);
assertEpsgNameAndIdentifierEqual("Martinique 1938 to RGAF09 (1)", 5491, operation);
/*
* Above was only a verification using the source and target CRS expected by EPSG dataset.
* Now the interesting test: use a target CRS with different axis order.
*/
targetCRS = crsFactory.createGeographicCRS("EPSG:7086");
operation = createOperation(sourceCRS, targetCRS);
assertEpsgNameWithoutIdentifierEqual("Martinique 1938 to RGAF09 (1)", operation);
final ParameterValueGroup p = ((SingleOperation) operation).getParameterValues();
/*
* Values below are copied from EPSG geodetic dataset 9.1. They may need
* to be adjusted if a future version of EPSG dataset modify those values.
*/
assertEquals("X-axis translation", 127.744, p.parameter("X-axis translation").doubleValue(), STRICT);
assertEquals("Y-axis translation", 547.069, p.parameter("Y-axis translation").doubleValue(), STRICT);
assertEquals("Z-axis translation", 118.359, p.parameter("Z-axis translation").doubleValue(), STRICT);
assertEquals("X-axis rotation", -3.1116, p.parameter("X-axis rotation").doubleValue(), STRICT);
assertEquals("Y-axis rotation", 4.9509, p.parameter("Y-axis rotation").doubleValue(), STRICT);
assertEquals("Z-axis rotation", -0.8837, p.parameter("Z-axis rotation").doubleValue(), STRICT);
assertEquals("Scale difference", 14.1012, p.parameter("Scale difference").doubleValue(), STRICT);
assertEquals("linearAccuracy", 0.1, CRS.getLinearAccuracy(operation), STRICT);
}
use of org.opengis.referencing.operation.SingleOperation 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.referencing.operation.SingleOperation in project sis by apache.
the class TransformCommand method printOperations.
/**
* Prints a summary of the given coordinate operation as a sequence of steps.
* If the operations is specified by EPSG, prints the EPSG name and code.
* Otherwise prints only the operation method names, since the coordinate operation names
* generated by SIS are not very meaningful.
*
* @param step the coordinate operation to print as a sequence of steps.
*/
private void printOperations(final CoordinateOperation step, boolean isNext) {
if (isNext) {
isNext = false;
if (colors) {
outHeader.append(X364.FOREGROUND_GREEN.sequence());
}
outHeader.append(" → ");
if (colors) {
outHeader.append(X364.FOREGROUND_DEFAULT.sequence());
}
}
if (!printNameAndIdentifier(step, true)) {
if (step instanceof ConcatenatedOperation) {
for (final CoordinateOperation op : ((ConcatenatedOperation) step).getOperations()) {
printOperations(op, isNext);
isNext = true;
}
} else if (step instanceof PassThroughOperation) {
printOperations(((PassThroughOperation) step).getOperation(), false);
} else if (step instanceof SingleOperation) {
outHeader.append(((SingleOperation) step).getMethod().getName().getCode());
}
}
}
Aggregations