01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: *
05: * (C) 2003-2006, Geotools Project Managment Committee (PMC)
06: * (C) 2001, Institut de Recherche pour le Développement
07: *
08: * This library is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU Lesser General Public
10: * License as published by the Free Software Foundation; either
11: * version 2.1 of the License, or (at your option) any later version.
12: *
13: * This library is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16: * Lesser General Public License for more details.
17: */
18: package org.geotools.referencing.operation.transform;
19:
20: // OpenGIS dependencies
21: import org.opengis.referencing.operation.MathTransform1D;
22: import org.opengis.referencing.operation.TransformException;
23:
24: /**
25: * Concatenated transform where both transforms are one-dimensional.
26: *
27: * @since 2.0
28: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/ConcatenatedTransformDirect1D.java $
29: * @version $Id: ConcatenatedTransformDirect1D.java 20874 2006-08-07 10:00:01Z jgarnett $
30: * @author Martin Desruisseaux
31: */
32: final class ConcatenatedTransformDirect1D extends
33: ConcatenatedTransformDirect implements MathTransform1D {
34: /**
35: * Serial number for interoperability with different versions.
36: */
37: private static final long serialVersionUID = 1064398659892864966L;
38:
39: /**
40: * The first math transform. This field is identical
41: * to {@link ConcatenatedTransform#transform1}. Only
42: * the type is different.
43: */
44: private final MathTransform1D transform1;
45:
46: /**
47: * The second math transform. This field is identical
48: * to {@link ConcatenatedTransform#transform1}. Only
49: * the type is different.
50: */
51: private final MathTransform1D transform2;
52:
53: /**
54: * Constructs a concatenated transform.
55: */
56: public ConcatenatedTransformDirect1D(
57: final MathTransform1D transform1,
58: final MathTransform1D transform2) {
59: super (transform1, transform2);
60: this .transform1 = transform1;
61: this .transform2 = transform2;
62: }
63:
64: /**
65: * Check if transforms are compatibles with this implementation.
66: */
67: boolean isValid() {
68: return super .isValid() && getSourceDimensions() == 1
69: && getTargetDimensions() == 1;
70: }
71:
72: /**
73: * Transforms the specified value.
74: */
75: public double transform(final double value)
76: throws TransformException {
77: return transform2.transform(transform1.transform(value));
78: }
79:
80: /**
81: * Gets the derivative of this function at a value.
82: */
83: public double derivative(final double value)
84: throws TransformException {
85: final double value1 = transform1.derivative(value);
86: final double value2 = transform2.derivative(transform1
87: .transform(value));
88: return value2 * value1;
89: }
90: }
|