/** * Tests separation of a concatenated transform. * * @throws FactoryException if an error occurred while creating a new transform. */ @Test @DependsOnMethod("testLinearTransform") public void testConcatenatedTransform() throws FactoryException { final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class); final TransformSeparator s = new TransformSeparator(EllipsoidToCentricTransform.createGeodeticConversion( factory, HardCodedDatum.WGS84.getEllipsoid(), false), factory); s.addSourceDimensions(0, 1); s.addTargetDimensions(0, 1); final Iterator<MathTransform> it = MathTransforms.getSteps(s.separate()).iterator(); assertInstanceOf("normalize", LinearTransform.class, it.next()); assertInstanceOf("transform", EllipsoidToCentricTransform.class, it.next()); assertInstanceOf("denormalize", LinearTransform.class, it.next()); assertFalse(it.hasNext()); }
assertArrayEquals("targetDimensions", new int[] {0, 3, 4}, s.getTargetDimensions()); try { s.addSourceDimensions(3, 4, 5); fail("Shall not accept non-increasing value."); } catch (IllegalArgumentException e) { s.addSourceDimensions(4, 6); s.addTargetDimensionRange(6, 8); assertArrayEquals("sourceDimensions", new int[] {1, 2, 3, 4, 6}, s.getSourceDimensions()); assertArrayEquals("targetDimensions", new int[] {0, 3, 4, 6, 7}, s.getTargetDimensions()); try { s.addSourceDimensions(8); fail("Shall not accept value out of range."); } catch (IllegalArgumentException e) {
/** * Tests separation of a linear transform containing {@link Double#NaN} values. * * @throws FactoryException if an error occurred while creating a new transform. */ @Test public void testIncompleteTransform() throws FactoryException { Matrix matrix = new Matrix4( 1, 0, 0, 7, 0, 0, 1, 8, 0, NaN, 0, 6, 0, 0, 0, 1 ); TransformSeparator s = new TransformSeparator(MathTransforms.linear(matrix)); s.addSourceDimensions(1); assertMatrixEquals("transform", new Matrix2( NaN, 6, 0, 1 ), ((LinearTransform) s.separate()).getMatrix(), STRICT); assertArrayEquals(new int[] {2}, s.getTargetDimensions()); }
}); s.clear(); s.addSourceDimensions(1, 2); assertMatrixEquals("transform", matrix, ((LinearTransform) s.separate()).getMatrix(), STRICT); assertArrayEquals("sourceDimensions", new int[] {1, 2}, s.getSourceDimensions()); }); s.clear(); s.addSourceDimensions(0, 2); s.addTargetDimensions(0); assertMatrixEquals("transform", matrix, ((LinearTransform) s.separate()).getMatrix(), STRICT);
); s.clear(); s.addSourceDimensions(0, 6); result = s.separate(); assertArrayEquals ("sourceDimensions", new int[] {0, 6}, s.getSourceDimensions()); s.addSourceDimensions(1, 2, 3, 4, 5); result = s.separate(); assertArrayEquals("sourceDimensions", new int[] {1, 2, 3, 4, 5}, s.getSourceDimensions());