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.MathTransform;
22: import org.opengis.referencing.operation.TransformException;
23: import org.opengis.geometry.DirectPosition;
24:
25: /**
26: * Concatenated transform where the transfert dimension is the same than source and target
27: * dimension. This fact allows some optimizations, the most important one being the possibility
28: * to avoid the use of an intermediate buffer.
29: *
30: * @since 2.0
31: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/ConcatenatedTransformDirect.java $
32: * @version $Id: ConcatenatedTransformDirect.java 24925 2007-03-27 20:12:08Z jgarnett $
33: * @author Martin Desruisseaux
34: */
35: class ConcatenatedTransformDirect extends ConcatenatedTransform {
36: /**
37: * Serial number for interoperability with different versions.
38: */
39: private static final long serialVersionUID = -3568975979013908920L;
40:
41: /**
42: * Constructs a concatenated transform.
43: */
44: public ConcatenatedTransformDirect(final MathTransform transform1,
45: final MathTransform transform2) {
46: super (transform1, transform2);
47: }
48:
49: /**
50: * Check if transforms are compatibles with this implementation.
51: */
52: boolean isValid() {
53: return super .isValid()
54: && transform1.getSourceDimensions() == transform1
55: .getTargetDimensions()
56: && transform2.getSourceDimensions() == transform2
57: .getTargetDimensions();
58: }
59:
60: /**
61: * Transforms the specified {@code ptSrc} and stores the result in {@code ptDst}.
62: */
63: public DirectPosition transform(final DirectPosition ptSrc,
64: DirectPosition ptDst) throws TransformException {
65: assert isValid();
66: ptDst = transform1.transform(ptSrc, ptDst);
67: return transform2.transform(ptDst, ptDst);
68: }
69:
70: /**
71: * Transforms a list of coordinate point ordinal values.
72: */
73: public void transform(final double[] srcPts, final int srcOff,
74: final double[] dstPts, final int dstOff, final int numPts)
75: throws TransformException {
76: assert isValid();
77: transform1.transform(srcPts, srcOff, dstPts, dstOff, numPts);
78: transform2.transform(dstPts, dstOff, dstPts, dstOff, numPts);
79: }
80:
81: /**
82: * Transforms a list of coordinate point ordinal values.
83: */
84: public void transform(final float[] srcPts, final int srcOff,
85: final float[] dstPts, final int dstOff, final int numPts)
86: throws TransformException {
87: assert isValid();
88: transform1.transform(srcPts, srcOff, dstPts, dstOff, numPts);
89: transform2.transform(dstPts, dstOff, dstPts, dstOff, numPts);
90: }
91: }
|