This commit moves into public API some methods which were used to be package-private. We do not want to make such move. Some code added by this commit are for handling the half-pixel translations, which we do differently in Apache SIS.
Command line:
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r20599:20970 https://svn.osgeo.org/geotools/trunk/modules/library/coverage/src/main/java/org/geotools/coverage/grid/GeneralGridGeometry.java
Revision 20599 | Revision 20970 |
---|---|
/* * 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 |
/* * GeoTools - OpenSource mapping toolkit * http://geotools.org * (C) 2003-2006, Geotools Project Managment Committee (PMC) * (C) 2001, Institut de Recherche pour le Développement * * This library is free software; you can redistribute it and/or |
* 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 */ package org.geotools.coverage.grid; |
* 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. */ package org.geotools.coverage.grid; |
import java.awt.image.BufferedImage; // For javadoc import java.awt.image.RenderedImage; // For javadoc import java.io.Serializable; // OpenGIS dependencies import org.opengis.coverage.grid.GridRange; |
import java.awt.image.BufferedImage; // For javadoc
import java.awt.image.RenderedImage; // For javadoc
import java.io.Serializable;
import java.util.MissingResourceException;
// OpenGIS dependencies
import org.opengis.coverage.grid.GridRange; |
}
/**
* Constructs a new grid geometry from a {@linkplain MathTransform math transform}. This is
* the most general constructor, the one that gives the maximal control on the grid geometry
* to be created.
* |
} /** * Constructs a new grid geometry from a math transform. * * @param gridRange * The valid coordinate range of a grid coverage, or {@code null} * if none. * @param gridToCRS * The math transform which allows for the transformations from * grid coordinates (pixel's <em>center</em>) to real world * earth coordinates. * * @deprecated Replaced by * <code>{@linkplain #GeneralGridGeometry(GridRange, MathTransform, * CoordinateReferenceSystem) GeneralGridGeometry}(gridRange, gridToCRS, null)</code>. */ public GeneralGridGeometry(final GridRange gridRange, final MathTransform gridToCRS) { this(gridRange, gridToCRS, (CoordinateReferenceSystem) null); } /** * Constructs a new grid geometry from a * {@linkplain MathTransform math transform}. This is the most general * the most general constructor, the one that gives the maximal control on the grid geometry * to be created. * |
{ this.gridRange = gridRange; this.gridToCRS = gridToCRS; if (gridRange!=null && gridToCRS!=null) { /* * Checks arguments. |
{ this.gridRange = gridRange; this.gridToCRS = gridToCRS; envelope = getEnvelope(gridRange, gridToCRS, crs, true); } /** * @param gridRange * @param gridToCRS * @param crs * @throws MismatchedDimensionException * @throws IllegalArgumentException * @throws MissingResourceException */ public static GeneralEnvelope getEnvelope(final GridRange gridRange, final MathTransform gridToCRS, final CoordinateReferenceSystem crs, final boolean halfPix) throws MismatchedDimensionException, IllegalArgumentException, MissingResourceException { if (gridRange!=null && gridToCRS!=null) { /* * Checks arguments. |
// TODO: uncomment the exception cause when we will be allowed to target J2SE 1.5. } envelope.setCoordinateReferenceSystem(crs); this.envelope = envelope; } else if (crs != null) { envelope = new GeneralEnvelope(crs); envelope.setToNull(); } else { envelope = null; } } |
// TODO: uncomment the exception cause when we will be allowed to target J2SE 1.5. } envelope.setCoordinateReferenceSystem(crs); return envelope; } else if (crs != null) { GeneralEnvelope retEnvelope = new GeneralEnvelope(crs); retEnvelope.setToNull(); return retEnvelope; } else { return null; } } |
} /** * Constructs a new grid geometry from an {@linkplain Envelope envelope}. An * {@linkplain AffineTransform affine transform} will be computed automatically from the * specified envelope. The two last arguments ({@code swapXY} and {@code reverse}) are hints |
} /** * Constructs a new grid geometry from an envelope. * * @deprecated Replaced by * {@code GeneralGridGeometry(gridRange, userRange, reverse, false)}. * Users just need to append the {@code false} argument value, * so this constructor will be removed in a future version in * order to keep the API lighter. */ public GeneralGridGeometry(final GridRange gridRange, final Envelope userRange, final boolean[] reverse) { this(gridRange, userRange, reverse, false); } /** * Constructs a new grid geometry from an {@linkplain Envelope envelope}. An * {@linkplain AffineTransform affine transform} will be computed automatically from the * specified envelope. The two last arguments ({@code swapXY} and {@code reverse}) are hints |
{ this.gridRange = gridRange; this.envelope = new GeneralEnvelope(userRange); /* * Checks arguments validity. Grid range and envelope dimensions must match. * We are more tolerant for the coordinate system dimension (if any), since |
{ this.gridRange = gridRange; this.envelope = new GeneralEnvelope(userRange); gridToCRS = getTransform(gridRange, userRange, reverse, swapXY, true); } /** * @param gridRange * @param userRange * @param reverse * @param swapXY * @param b * @return * @throws MismatchedDimensionException */ public static MathTransform getTransform(final GridRange gridRange, final Envelope userRange, final boolean[] reverse, final boolean swapXY, boolean halfPix) throws MismatchedDimensionException { /* * Checks arguments validity. Grid range and envelope dimensions must match. * We are more tolerant for the coordinate system dimension (if any), since |
scale = -scale; offset = userRange.getMaximum(j); } offset -= scale * (gridRange.getLower(i)-0.5); matrix.setElement(j, j, 0.0 ); matrix.setElement(j, i, scale ); matrix.setElement(j, dimension, offset); } gridToCRS = ProjectiveTransform.create(matrix); } /** * Returns the coordinate system in use with the specified envelope. This method * is invoked by the {@link #GeneralGridGeometry(GridRange,Envelope)} constructor. |
scale = -scale; offset = userRange.getMaximum(j); } offset -= scale * (gridRange.getLower(i) - (halfPix ? 0.5 : 0)); matrix.setElement(j, j, 0.0 ); matrix.setElement(j, i, scale ); matrix.setElement(j, dimension, offset); } return ProjectiveTransform.create(matrix); } public static MathTransform getTransform(final GridRange gridRange, final Envelope userRange, boolean halfPix) throws MismatchedDimensionException { final CoordinateSystem cs = getCoordinateSystem(userRange); return getTransform(gridRange, userRange, reverse(cs), swapXY(cs), halfPix); } /** * Returns the coordinate system in use with the specified envelope. This method * is invoked by the {@link #GeneralGridGeometry(GridRange,Envelope)} constructor. |
* Applies heuristic rules in order to determine which axis should be reversed. This
* method is invoked by the {@link #GeneralGridGeometry(GridRange,Envelope)} constructor.
*/
static boolean[] reverse(final CoordinateSystem cs) {
if (cs == null) {
return null;
} |
* Applies heuristic rules in order to determine which axis should be reversed. This
* method is invoked by the {@link #GeneralGridGeometry(GridRange,Envelope)} constructor.
*/
static public boolean[] reverse(final CoordinateSystem cs) {
if (cs == null) {
return null;
} |
* Applies heuristic rules in order to determine if the two first axis should be interchanged.
* This method is invoked by the {@link #GeneralGridGeometry(GridRange,Envelope)} constructor.
*/
static boolean swapXY(final CoordinateSystem cs) {
boolean swapXY = false;
if (cs!=null && cs.getDimension() >= 2) {
swapXY = AxisDirection.NORTH.equals(cs.getAxis(0).getDirection().absolute()) && |
* Applies heuristic rules in order to determine if the two first axis should be interchanged.
* This method is invoked by the {@link #GeneralGridGeometry(GridRange,Envelope)} constructor.
*/
static public boolean swapXY(final CoordinateSystem cs) {
boolean swapXY = false;
if (cs!=null && cs.getDimension() >= 2) {
swapXY = AxisDirection.NORTH.equals(cs.getAxis(0).getDirection().absolute()) && |