/*
* Geotools 2 - OpenSource mapping toolkit
* (C) 2003, Geotools Project Management Committee (PMC)
* (C) 2001, Institut de Recherche pour le Développement
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* This package contains documentation from OpenGIS specifications.
* OpenGIS consortium's work is fully acknowledged here.
*/
package org.geotools.gp;
// J2SE and JAI dependencies
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.RasterFormatException;
import javax.media.jai.Warp;
import org.geotools.ct.MathTransform2D;
import org.geotools.resources.CTSUtilities;
import org.geotools.resources.i18n.ErrorKeys;
import org.geotools.resources.i18n.Errors;
import org.opengis.referencing.operation.TransformException;
/**
* An image warp using {@link MathTransform2D}.
*
* @source $URL$
* @version $Id$
* @author Martin Desruisseaux
*
* @deprecated Replaced by {@link org.geotools.coverage.operation.WarpTransform}.
*/
final class WarpTransform extends Warp {
/**
* The coverage name. Used for formatting error message.
*/
private final String name;
/**
* The inverse of the transform to apply.
* This transform maps destination pixels to source pixels.
*/
private final MathTransform2D inverse;
/**
* Construct a new WarpTransform
.
*
* @param name The coverage name. Used for formatting error message.
* @param inverse The inverse of the transformation
* to apply from source to target image.
*/
public WarpTransform(final String name, final MathTransform2D inverse) {
this.name = name;
this.inverse = inverse;
}
/**
* Computes the source pixel positions for a given rectangular
* destination region, subsampled with an integral period.
*/
public float[] warpSparseRect(final int xmin, final int ymin,
final int width, final int height,
final int periodX, final int periodY, float[] destRect)
{
if (periodX<1) throw new IllegalArgumentException(String.valueOf(periodX));
if (periodY<1) throw new IllegalArgumentException(String.valueOf(periodY));
final int xmax = xmin+width;
final int ymax = ymin+height;
final int count = ((width+(periodX-1))/periodX) * ((height+(periodY-1))/periodY);
if (destRect==null) {
destRect = new float[2*count];
}
int index = 0;
for (int y=ymin; y