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: // J2SE dependencies
21: import java.util.Arrays;
22:
23: /**
24: * A one dimensional, constant transform. Output values are set to a constant value regardless
25: * of input values. This class is really a special case of {@link LinearTransform1D} in which
26: * <code>{@link #scale} = 0</code> and <code>{@link #offset} = constant</code>. However, this
27: * specialized {@code ConstantTransform1D} class is faster.
28: *
29: * @since 2.0
30: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/ConstantTransform1D.java $
31: * @version $Id: ConstantTransform1D.java 20874 2006-08-07 10:00:01Z jgarnett $
32: * @author Martin Desruisseaux
33: */
34: final class ConstantTransform1D extends LinearTransform1D {
35: /**
36: * Serial number for interoperability with different versions.
37: */
38: private static final long serialVersionUID = -1583675681650985947L;
39:
40: /**
41: * Constructs a new constant transform.
42: *
43: * @param offset The {@code offset} term in the linear equation.
44: */
45: protected ConstantTransform1D(final double offset) {
46: super (0, offset);
47: }
48:
49: /**
50: * Transforms the specified value.
51: */
52: public double transform(double value) {
53: return offset;
54: }
55:
56: /**
57: * Transforms a list of coordinate point ordinal values.
58: */
59: public void transform(final float[] srcPts, int srcOff,
60: final float[] dstPts, int dstOff, int numPts) {
61: Arrays.fill(dstPts, dstOff, dstOff + numPts, (float) offset);
62: }
63:
64: /**
65: * Transforms a list of coordinate point ordinal values.
66: */
67: public void transform(final double[] srcPts, int srcOff,
68: final double[] dstPts, int dstOff, int numPts) {
69: Arrays.fill(dstPts, dstOff, dstOff + numPts, offset);
70: }
71: }
|