PixelTranslation changes for revisions 10795:10867

See GridGeometry (shared history).

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r10795:10867 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/metadata/iso/spatial/PixelTranslation.java
Revision 10795Revision 10867
/*
 * 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
/*
 * 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
package org.geotools.coverage.grid;

// J2SE dependencies
import java.io.Serializable;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.AffineTransform;
import java.awt.image.RenderedImage;  // For Javadoc
import java.awt.image.BufferedImage;  // For Javadoc

// JAI dependencies
import javax.media.jai.IntegerSequence;

// OpenGIS dependencies
import org.opengis.coverage.grid.GridRange;
import org.opengis.coverage.CannotEvaluateException;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.TransformException;
import org.opengis.referencing.operation.MathTransformFactory;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.spatialschema.geometry.MismatchedDimensionException;
import org.opengis.spatialschema.geometry.Envelope;

// Geotools dependencies
import org.geotools.geometry.GeneralEnvelope;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.referencing.FactoryFinder;
import org.geotools.referencing.operation.GeneralMatrix;
import org.geotools.referencing.operation.transform.ProjectiveTransform;

// Resources
import org.geotools.resources.Utilities;
import org.geotools.resources.CRSUtilities;
import org.geotools.resources.gcs.Resources;
import org.geotools.resources.gcs.ResourceKeys;
import org.geotools.resources.image.JAIUtilities;


/**
 * Describes the valid range of grid coordinates and the math
 * transform to transform grid coordinates to real world coordinates.
package org.geotools.coverage.grid;

// J2SE dependencies
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.Serializable;

import org.geotools.geometry.DirectPosition2D;
import org.geotools.geometry.GeneralEnvelope;
import org.geotools.referencing.operation.GeneralMatrix;
import org.geotools.referencing.operation.transform.ProjectiveTransform;
import org.geotools.resources.CRSUtilities;
import org.geotools.resources.Utilities;
import org.geotools.resources.gcs.ResourceKeys;
import org.geotools.resources.gcs.Resources;
import org.opengis.coverage.CannotEvaluateException;
import org.opengis.coverage.grid.GridRange;
import org.opengis.gc.GC_GridGeometry;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransform2D;
import org.opengis.referencing.operation.Matrix;
import org.opengis.referencing.operation.NoninvertibleTransformException;
import org.opengis.referencing.operation.TransformException;
import org.opengis.spatialschema.geometry.Envelope;
import org.opengis.spatialschema.geometry.MismatchedDimensionException;


/**
 * Describes the valid range of grid coordinates and the math
 * transform to transform grid coordinates to real world coordinates.
this.gridFromCoordinateSystem2D = inverse(gridToCoordinateSystem2D);
if (gridRange!=null && gridToCoordinateSystem!=null) {
    final int dimRange  = gridRange.getDimension();
    final int dimSource = gridToCoordinateSystem.getDimSource();
    final int dimTarget = gridToCoordinateSystem.getDimTarget();
    if (dimRange != dimSource) {
        throw new MismatchedDimensionException(format(dimRange, dimSource));
    }
this.gridFromCoordinateSystem2D = inverse(gridToCoordinateSystem2D);
if (gridRange!=null && gridToCoordinateSystem!=null) {
    final int dimRange  = gridRange.getDimension();
    final int dimSource = gridToCoordinateSystem.getSourceDimensions();
    final int dimTarget = gridToCoordinateSystem.getTargetDimensions();
    if (dimRange != dimSource) {
        throw new MismatchedDimensionException(format(dimRange, dimSource));
    }
 */
public int getDimension() {
    if (gridToCoordinateSystem != null) {
        return gridToCoordinateSystem.getDimSource();
    }
    return getGridRange().getDimension();
}
 */
public int getDimension() {
    if (gridToCoordinateSystem != null) {
        return gridToCoordinateSystem.getSourceDimensions();
    }
    return getGridRange().getDimension();
}
public GridRange getGridRange() throws InvalidGridGeometryException {
    if (gridRange != null) {
        return gridRange;
    } else {
        throw new InvalidGridGeometryException(Resources.format(
                  ResourceKeys.ERROR_UNSPECIFIED_IMAGE_SIZE));
    }
}

/**
 * Returns the math transform which allows  for the transformations from grid coordinates to
public GridRange getGridRange() throws InvalidGridGeometryException {
    if (gridRange != null) {
        return gridRange;
    }
        throw new InvalidGridGeometryException(Resources.format(
                  ResourceKeys.ERROR_UNSPECIFIED_IMAGE_SIZE));
    }

/**
 * Returns the math transform which allows  for the transformations from grid coordinates to
public MathTransform getGridToCoordinateSystem() throws InvalidGridGeometryException {
    if (gridToCoordinateSystem != null) {
        return gridToCoordinateSystem;
    } else {
        throw new InvalidGridGeometryException();
    }
}

/**
 * Returns a math transform for the first two dimensions, if such a transform exists.
public MathTransform getGridToCoordinateSystem() throws InvalidGridGeometryException {
    if (gridToCoordinateSystem != null) {
        return gridToCoordinateSystem;
    }
        throw new InvalidGridGeometryException();
    }

/**
 * Returns a math transform for the first two dimensions, if such a transform exists.
        if (transform==null || transform instanceof MathTransform2D) {
            return (MathTransform2D) transform;
        }
        final MathTransformFactory factory = FactoryFinder.getMathTransformFactory();
        final IntegerSequence  inputDimensions = JAIUtilities.createSequence(0, 1);
        final IntegerSequence outputDimensions = new IntegerSequence();
// TODO
//        try {
//            transform = factory.createSubTransform(transform, inputDimensions, outputDimensions);
//        } catch (FactoryException exception) {
//            // A MathTransform2D is not mandatory. Just tell that we have none.
//            return null;
        if (transform==null || transform instanceof MathTransform2D) {
            return (MathTransform2D) transform;
        }
//        final MathTransformFactory factory = FactoryFinder.getMathTransformFactory();
//        final IntegerSequence  inputDimensions = JAIUtilities.createSequence(0, 1);
//        final IntegerSequence outputDimensions = new IntegerSequence();
//// TODO
//        try {
//            transform = factory.(transform, inputDimensions, outputDimensions);
//        } catch (FactoryException exception) {
//            // A MathTransform2D is not mandatory. Just tell that we have none.
//            return null;
}

/**
 * Returns a string représentation of this grid range.
 * The returned string is implementation dependent. It
 * is usually provided for debugging purposes.
 */
}

/**
 * Returns a string repr�sentation of this grid range.
 * The returned string is implementation dependent. It
 * is usually provided for debugging purposes.
 */