/** * Returns this operation method with different dimensions, if we are allowed to change dimensionality. * See {@link #redimension(OperationMethod, int, int)} for more information. * * <p>The default implementation performs the following choice: * for each dimension (<var>source</var> and <var>target</var>):</p> * <ul> * <li>If the corresponding dimension of the given method is {@code null}, then * set that dimension to the given value in a new {@code OperationMethod}.</li> * <li>Otherwise if the given value is not equal to the corresponding dimension * in the given method, throw an {@link IllegalArgumentException}.</li> * </ul> * * Subclasses should override this method if they can work with different number of dimensions. * For example a <cite>Molodensky</cite> transform usually works in a three-dimensional space, * but can also work in a two-dimensional space by assuming that the ellipsoidal height is zero * everywhere. * * @param sourceDimensions the desired number of input dimensions. * @param targetDimensions the desired number of output dimensions. * @return the redimensioned operation method, or {@code this} if no change is needed. * @throws IllegalArgumentException if the given dimensions are illegal for this operation method. * * @since 0.6 */ public OperationMethod redimension(final int sourceDimensions, final int targetDimensions) { return redimension(this, sourceDimensions, this.sourceDimensions, targetDimensions, this.targetDimensions); }
/** * Returns this operation method with different dimensions, if we are allowed to change dimensionality. * See {@link #redimension(OperationMethod, int, int)} for more information. * * <p>The default implementation performs the following choice: * for each dimension (<var>source</var> and <var>target</var>):</p> * <ul> * <li>If the corresponding dimension of the given method is {@code null}, then * set that dimension to the given value in a new {@code OperationMethod}.</li> * <li>Otherwise if the given value is not equal to the corresponding dimension * in the given method, throw an {@link IllegalArgumentException}.</li> * </ul> * * Subclasses should override this method if they can work with different number of dimensions. * For example a <cite>Molodensky</cite> transform usually works in a three-dimensional space, * but can also work in a two-dimensional space by assuming that the ellipsoidal height is zero * everywhere. * * @param sourceDimensions the desired number of input dimensions. * @param targetDimensions the desired number of output dimensions. * @return the redimensioned operation method, or {@code this} if no change is needed. * @throws IllegalArgumentException if the given dimensions are illegal for this operation method. * * @since 0.6 */ public OperationMethod redimension(final int sourceDimensions, final int targetDimensions) { return redimension(this, sourceDimensions, this.sourceDimensions, targetDimensions, this.targetDimensions); }
return ((DefaultOperationMethod) method).redimension(sourceDimensions, targetDimensions); } else { method = redimension(method, sourceDimensions, method.getSourceDimensions(), targetDimensions, method.getTargetDimensions());
return ((DefaultOperationMethod) method).redimension(sourceDimensions, targetDimensions); } else { method = redimension(method, sourceDimensions, method.getSourceDimensions(), targetDimensions, method.getTargetDimensions());
public void testRedimension() { final OperationMethod method = create("Affine geometric transformation", "9623", "EPSG guidance note #7-2", null); OperationMethod other = DefaultOperationMethod.redimension(method, 2, 2); assertSame(other, DefaultOperationMethod.redimension(other, 2, 2)); assertNotSame(method, other); assertFalse(method.equals(other)); assertEquals("targetDimensions", Integer.valueOf(2), other.getTargetDimensions()); other = DefaultOperationMethod.redimension(method, 2, 3); assertSame(other, DefaultOperationMethod.redimension(other, 2, 3)); assertNotSame(method, other); assertFalse(method.equals(other)); assertEquals("targetDimensions", Integer.valueOf(3), other.getTargetDimensions()); other = DefaultOperationMethod.redimension(method, 3, 2); assertSame(other, DefaultOperationMethod.redimension(other, 3, 2)); assertNotSame(method, other); assertFalse(method.equals(other)); DefaultOperationMethod.redimension(other, 3, 3); fail("Should not have accepted to change non-null dimensions."); } catch (IllegalArgumentException e) {
method = single.getMethod(); try { method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions); } catch (IllegalArgumentException ex) { try { method = factorySIS.getOperationMethod(method.getName().getCode()); method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions); } catch (NoSuchIdentifierException | IllegalArgumentException se) { ex.addSuppressed(se);
method = single.getMethod(); try { method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions); } catch (IllegalArgumentException ex) { try { method = factorySIS.getOperationMethod(method.getName().getCode()); method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions); } catch (NoSuchIdentifierException | IllegalArgumentException se) { ex.addSuppressed(se);
for (int newSource = 2; newSource <= 3; newSource++) { for (int newTarget = 2; newTarget <= 3; newTarget++) { final OperationMethod redim = ((DefaultOperationMethod) method).redimension(newSource, newTarget); assertEquals("sourceDimensions", newSource, redim.getSourceDimensions().intValue()); assertEquals("targetDimensions", newTarget, redim.getTargetDimensions().intValue()); method, ((DefaultOperationMethod) redim).redimension(sourceDimensions, targetDimensions)); assertNotSame("redimension(3,3) should return a new method.", method, proj3D); assertSame("redimension(2,2) should give back the original method.", method, ((DefaultOperationMethod) proj3D).redimension(sourceDimensions, targetDimensions)); assertSame("Value of redimension(3,3) should have been cached.", proj3D, ((MapProjection) method).redimension(sourceDimensions ^ 1, targetDimensions ^ 1)); } else try { ((DefaultOperationMethod) method).redimension(sourceDimensions ^ 1, targetDimensions ^ 1); fail("Type " + method.getClass().getName() + " is not in our list of redimensionable methods."); } catch (IllegalArgumentException e) {
method = owner.createOperationMethod(methodCode.toString()); if (isDimensionKnown) { method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions);
method = owner.createOperationMethod(methodCode.toString()); if (isDimensionKnown) { method = DefaultOperationMethod.redimension(method, sourceDimensions, targetDimensions);
final Integer targetDim = (targetCS != null) ? targetCS.getDimension() : method.getTargetDimensions(); if (sourceDim != null && targetDim != null) { method = ((DefaultOperationMethod) method).redimension(sourceDim, targetDim); if (method instanceof MathTransformProvider) { provider = method;
final Integer targetDim = (targetCS != null) ? targetCS.getDimension() : method.getTargetDimensions(); if (sourceDim != null && targetDim != null) { method = ((DefaultOperationMethod) method).redimension(sourceDim, targetDim); if (method instanceof MathTransformProvider) { provider = method;
method = DefaultOperationMethod.redimension(method, transform.getSourceDimensions(), transform.getTargetDimensions()); if (context != null) {
method = DefaultOperationMethod.redimension(method, transform.getSourceDimensions(), transform.getTargetDimensions()); if (context != null) {