/** * Inverse transforms the specified {@code srcPts} and stores the result in {@code dstPts}. * If the derivative has been requested, then this method will delegate the derivative * calculation to the enclosing class and inverts the resulting matrix. */ @Override public Matrix transform(final double[] srcPts, final int srcOff, final double[] dstPts, final int dstOff, final boolean derivate) throws TransformException { double x = srcPts[srcOff ]; double y = srcPts[srcOff+1]; double zone = floor(x / ZONE_SCALE) - 1; x -= (zone + 1) * ZONE_SCALE; dstPts[dstOff ] = x; dstPts[dstOff+1] = y; final Matrix derivative = inverseProjection.transform(dstPts, dstOff, dstPts, dstOff, derivate); dstPts[dstOff] += zone * zoneWidth + initialLongitude; return derivative; } }
/** * Returns a hash value for this transform. This method invokes {@link #computeHashCode()} * when first needed and caches the value for future invocations. Subclasses shall override * {@code computeHashCode()} instead than this method. * * @return the hash code value. This value may change between different execution of the Apache SIS library. */ @Override public final int hashCode() { // No need to synchronize; ok if invoked twice. int hash = hashCode; if (hash == 0) { hash = computeHashCode(); if (hash == 0) { hash = -1; } hashCode = hash; } assert hash == -1 || hash == computeHashCode() : this; return hash; }
@Override public String formatTo(Formatter formatter) { return super.formatTo(formatter); } }
/** * {@inheritDoc} * * @return {@inheritDoc} */ @Override protected int computeHashCode() { return super.computeHashCode() + 31*AbstractMathTransform.this.hashCode(); }
/** * Compares the specified object with this math transform for strict equality. * This method is implemented as below (omitting assertions): * * {@preformat java * return equals(other, ComparisonMode.STRICT); * } * * @param object the object to compare with this transform. * @return {@code true} if the given object is a transform of the same class and using the same parameter values. */ @Override public final boolean equals(final Object object) { final boolean eq = equals(object, ComparisonMode.STRICT); // If objects are equal, then they must have the same hash code value. assert !eq || computeHashCode() == ((AbstractMathTransform) object).computeHashCode() : this; return eq; }
/** * Given a transformation chain, replaces the elements around {@code transforms.get(index)} transform by * alternative objects to use when formatting WKT. The replacement is performed in-place in the given list. * * <p>This method shall replace only the previous element and the few next elements that need * to be changed as a result of the previous change. This method is not expected to continue * the iteration after the changes that are of direct concern to this object.</p> * * <p>This method is invoked only by {@link ConcatenatedTransform#getPseudoSteps()} in order to * get the {@link ParameterValueGroup} of a map projection, or to format a {@code PROJCS} WKT.</p> * * @param transforms the full chain of concatenated transforms. * @param index the index of this transform in the {@code transforms} chain. * @param inverse always {@code false}, except if we are formatting the inverse transform. * @return index of this transform in the {@code transforms} chain after processing. * * @see ConcatenatedTransform#getPseudoSteps() */ int beforeFormat(final List<Object> transforms, final int index, final boolean inverse) { assert unwrap(transforms.get(index), inverse) == this; final ContextualParameters parameters = getContextualParameters(); return (parameters != null) ? parameters.beforeFormat(transforms, index, inverse) : index; }
return; final int dimSource = getSourceDimensions(); final int dimTarget = getTargetDimensions(); if (dimSource == dimTarget) { final int n = numPts * dimSource; dstPts[dstOff + i] = srcPts[srcOff + i]; transform(dstPts, dstOff, dstPts, dstOff, numPts); return; transform(buffer, 0, dstPts, dstOff, numBufferedPts); } catch (TransformException exception) {
final int dimSource = getSourceDimensions(); final double[] coordinate = point.getCoordinate(); if (coordinate.length != dimSource) { throw mismatchedDimension("point", dimSource, coordinate.length); final Matrix derivative = transform(coordinate, 0, null, 0, true); if (derivative == null) { throw new TransformException(Resources.format(Resources.Keys.CanNotComputeDerivative));
/** * Returns an identity transform if this transform is the inverse of the given transform. * If this method is unsure, it conservatively returns {@code null}. */ @Override protected final MathTransform tryConcatenate(boolean applyOtherFirst, MathTransform other, MathTransformFactory factory) throws FactoryException { if (other instanceof LinearTransform) { return super.tryConcatenate(applyOtherFirst, other, factory); } return null; // No need to compute the inverse if the other transform is not linear. }
/** * Compares the specified object with this math transform for equality. * * @return {@inheritDoc} */ @Override public boolean equals(final Object object, final ComparisonMode mode) { return super.equals(object, mode) && Objects.equals(grid, ((DatumShiftTransform) object).grid); } }
/** * Returns the parameter descriptors for this math transform, or {@code null} if unknown. * * <div class="note"><b>Relationship with ISO 19111:</b> * This method is similar to {@link OperationMethod#getParameters()}, except that typical * {@link MathTransform} implementations return parameters in standard units (usually * {@linkplain org.apache.sis.measure.Units#METRE metres} or * {@linkplain org.apache.sis.measure.Units#DEGREE decimal degrees}). * </div> * * @return the parameter descriptors for this math transform, or {@code null} if unspecified. * * @see org.apache.sis.referencing.operation.DefaultOperationMethod#getParameters() */ @Override public ParameterDescriptorGroup getParameterDescriptors() { final ContextualParameters parameters = getContextualParameters(); return (parameters != null) ? parameters.getDescriptor() : null; }
target.getSemiMinorAxis(), target.getAxisUnit(), isTarget3D, EllipsoidToCentricTransform.TargetType.CARTESIAN).inverse(); } else try { ellipsoidToCentric = (AbstractMathTransform) inverse.centricToEllipsoid.inverse(); centricToEllipsoid = (AbstractMathTransform) inverse.ellipsoidToCentric.inverse(); } catch (NoninvertibleTransformException e) { throw new IllegalArgumentException(e); // Should never happen. ellipsoidToCentric.getContextualParameters().getMatrix(ContextualParameters.MatrixRole.NORMALIZATION)); context.getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION).setMatrix( centricToEllipsoid.getContextualParameters().getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION));
/** * Given a transformation chain to format in WKT, inserts a "Geographic 2D to 3D" pseudo-conversion * before this transform (normally {@code transforms.get(index)}) if this conversion expects no height. * * @param transforms the full chain of concatenated transforms. * @param index the index of this transform in the {@code transforms} chain. * @return index of this transform in the {@code transforms} chain after processing. */ @Override final int beforeFormat(final List<Object> transforms, int index, final boolean inverse) { index = super.beforeFormat(transforms, index, inverse); if (!withHeight) { transforms.add(index++, new Geographic3Dto2D.WKT(true)); } return index; }
/** * Gets the derivative of this transform at a point. * The default implementation computes the inverse of the matrix returned by the enclosing math transform. * * @return {@inheritDoc} * @throws NullPointerException if the derivative depends on coordinate and {@code point} is {@code null}. * @throws MismatchedDimensionException if {@code point} does not have the expected dimension. * @throws TransformException if the derivative can not be evaluated at the specified point. */ @Override public Matrix derivative(DirectPosition point) throws TransformException { if (point != null) { point = this.transform(point, null); } return Matrices.inverse(AbstractMathTransform.this.derivative(point)); }
/** * Some tests for the Oblique Mercator Projection. * * @throws FactoryException Should never happen. * @throws TransformException Should never happen. */ @Test public void testObliqueMercator() throws FactoryException, TransformException { MathTransform transform; ParameterValueGroup params; params = mtFactory.getDefaultParameters("Oblique Mercator"); setObliqueMercatorParameter(params); transform = mtFactory.createParameterizedTransform(params); ParameterDescriptorGroup descriptor = ((AbstractMathTransform) transform).getParameterDescriptors(); assertTrue (IdentifiedObjects.isHeuristicMatchForName(descriptor, "Oblique Mercator")); assertFalse(IdentifiedObjects.isHeuristicMatchForName(descriptor, "Hotine Oblique Mercator")); final MathTransform standard = transform; params = mtFactory.getDefaultParameters("Hotine Oblique Mercator"); setObliqueMercatorParameter(params); transform = mtFactory.createParameterizedTransform(params); descriptor = ((AbstractMathTransform) transform).getParameterDescriptors(); assertFalse(IdentifiedObjects.isHeuristicMatchForName(descriptor, "Oblique Mercator")); assertTrue (IdentifiedObjects.isHeuristicMatchForName(descriptor, "Hotine Oblique Mercator")); assertFalse(transform.equals(standard)); }
return; final int dimSource = getSourceDimensions(); final int dimTarget = getTargetDimensions(); if (dimSource == dimTarget) { final int n = numPts * dimSource; dstPts[dstOff + i] = srcPts[srcOff + i]; transform(dstPts, dstOff, dstPts, dstOff, numPts); return; transform(buffer, 0, dstPts, dstOff, numBufferedPts); } catch (TransformException exception) {
final int dimSource = getSourceDimensions(); final double[] coordinate = point.getCoordinate(); if (coordinate.length != dimSource) { throw mismatchedDimension("point", dimSource, coordinate.length); final Matrix derivative = transform(coordinate, 0, null, 0, true); if (derivative == null) { throw new TransformException(Resources.format(Resources.Keys.CanNotComputeDerivative));
/** * If both transforms are {@literal Proj.4} wrappers, returns a single transform without intermediate step. */ @Override protected MathTransform tryConcatenate(final boolean applyOtherFirst, final MathTransform other, final MathTransformFactory factory) throws FactoryException { if (other instanceof Transform) { final Transform tr = (Transform) other; if (applyOtherFirst) { return new Transform(tr.source, tr.source3D, target, target3D); } else { return new Transform(source, source3D, tr.target, tr.target3D); } } return super.tryConcatenate(applyOtherFirst, other, factory); }
/** * Compares the specified object with this math transform for strict equality. * This method is implemented as below (omitting assertions): * * {@preformat java * return equals(other, ComparisonMode.STRICT); * } * * @param object the object to compare with this transform. * @return {@code true} if the given object is a transform of the same class and using the same parameter values. */ @Override public final boolean equals(final Object object) { final boolean eq = equals(object, ComparisonMode.STRICT); // If objects are equal, then they must have the same hash code value. assert !eq || computeHashCode() == ((AbstractMathTransform) object).computeHashCode() : this; return eq; }
/** * Compares the specified object with this math transform for equality. * * @return {@inheritDoc} */ @Override public boolean equals(final Object object, final ComparisonMode mode) { return super.equals(object, mode) && Objects.equals(grid, ((DatumShiftTransform) object).grid); } }