MapProjection changes for revisions 29680:29681

Apache SIS will not contain those checks for the validity of input coordinates (we let the mathematic do their "natural" behavior for angles greater than 90° of latitude or 180° of longitude - in many cases the result is still okay), so this change does not apply.

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r29680:29681 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/operation/projection/MapProjection.java
Revision 29680Revision 29681
import java.awt.geom.Point2D;
import java.io.Serializable;
import java.util.Collection;
import javax.units.NonSI;
import javax.units.SI;
import javax.units.Unit;
import java.awt.geom.Point2D;
import java.io.Serializable;
import java.util.Collection;
import java.util.logging.Logger;

import javax.units.NonSI;
import javax.units.SI;
import javax.units.Unit;
import org.geotools.resources.XMath;
import org.geotools.resources.i18n.Errors;
import org.geotools.resources.i18n.ErrorKeys;


/**
import org.geotools.resources.XMath;
import org.geotools.resources.i18n.Errors;
import org.geotools.resources.i18n.ErrorKeys;
import org.geotools.util.logging.Logging;


/**
public abstract class MapProjection extends AbstractMathTransform
                implements MathTransform2D, Serializable
{
    /**
     * Maximum difference allowed when comparing real numbers.
     */
    private static final double EPSILON = 1E-6;
public abstract class MapProjection extends AbstractMathTransform
                implements MathTransform2D, Serializable
{

    /**
     * The projection package logger
     */
    protected static final Logger LOGGER = Logging.getLogger("org.geotools.referencing.operation.projection");

    /**
     * Maximum difference allowed when comparing real numbers.
     */
    private static final double EPSILON = 1E-6;
private transient MathTransform2D inverse;

/**
 * Constructs a new map projection from the suplied parameters.
 *
 * @param  values The parameter values in standard units.
private transient MathTransform2D inverse;

/**
 * When true lat/lon coordinate ranges will be checked, and a WARNING log will be issued
 * if they are out of their natural ranges (-180/180 for longitude, -90/90 for latitude).<br>
 * To avoid excessive logging, this flag will be set to false after the first coordinate
 * failing the checks is found.
 */
protected boolean verifyCoordinateRanges = true;

/**
 * Constructs a new map projection from the suplied parameters.
 *
 * @param  values The parameter values in standard units.
public final Point2D transform(final Point2D ptSrc, Point2D ptDst) throws ProjectionException {
    final double x = ptSrc.getX();
    final double y = ptSrc.getY();
    // Note: the following tests should not fails for NaN values.
    if (x < (Longitude.MIN_VALUE - ANGLE_TOLERANCE) || x > (Longitude.MAX_VALUE + ANGLE_TOLERANCE)) {
        throw new PointOutsideEnvelopeException(Errors.format(
                ErrorKeys.LONGITUDE_OUT_OF_RANGE_$1, new Longitude(x)));
    }
    if (y < (Latitude.MIN_VALUE - ANGLE_TOLERANCE) || y > (Latitude.MAX_VALUE + ANGLE_TOLERANCE)) {
        throw new PointOutsideEnvelopeException(Errors.format(
                ErrorKeys.LATITUDE_OUT_OF_RANGE_$1, new Latitude(y)));
    }
    /*
     * Makes sure that the longitude before conversion stay within +/- PI radians. As a
     * special case, we do not check the range if no rotation were applied on the longitude.
public final Point2D transform(final Point2D ptSrc, Point2D ptDst) throws ProjectionException {
    final double x = ptSrc.getX();
    final double y = ptSrc.getY();

    if(verifyCoordinateRanges) {
    // Note: the following tests should not fails for NaN values.
    if (x < (Longitude.MIN_VALUE - ANGLE_TOLERANCE) || x > (Longitude.MAX_VALUE + ANGLE_TOLERANCE)) {
            LOGGER.warning(Errors.format(ErrorKeys.LONGITUDE_OUT_OF_RANGE_$1, new Longitude(x)));
            verifyCoordinateRanges = false;
    }
    if (y < (Latitude.MIN_VALUE - ANGLE_TOLERANCE) || y > (Latitude.MAX_VALUE + ANGLE_TOLERANCE)) {
            LOGGER.warning(Errors.format(ErrorKeys.LATITUDE_OUT_OF_RANGE_$1, new Latitude(y)));
            verifyCoordinateRanges = false;
    }
    }
    /*
     * Makes sure that the longitude before conversion stay within +/- PI radians. As a
     * special case, we do not check the range if no rotation were applied on the longitude.
    ptDst.setLocation(x,y);

    // Note: the following tests should not fails for NaN values.
    if (x < (Longitude.MIN_VALUE - ANGLE_TOLERANCE) || x > (Longitude.MAX_VALUE + ANGLE_TOLERANCE)) {
        throw new PointOutsideEnvelopeException(Errors.format(
                ErrorKeys.LONGITUDE_OUT_OF_RANGE_$1, new Longitude(x)));
    }
    if (y < (Latitude.MIN_VALUE - ANGLE_TOLERANCE) || y > (Latitude.MAX_VALUE + ANGLE_TOLERANCE)) {
        throw new PointOutsideEnvelopeException(Errors.format(
                ErrorKeys.LATITUDE_OUT_OF_RANGE_$1, new Latitude(y)));
    }
    assert checkReciprocal(ptDst, (ptSrc!=ptDst) ? ptSrc : new Point2D.Double(x0, y0), false);
    return ptDst;
}
    ptDst.setLocation(x,y);

    // Note: the following tests should not fails for NaN values.
    if(verifyCoordinateRanges) {
        // Note: the following tests should not fails for NaN values.
    if (x < (Longitude.MIN_VALUE - ANGLE_TOLERANCE) || x > (Longitude.MAX_VALUE + ANGLE_TOLERANCE)) {
            LOGGER.warning(Errors.format(ErrorKeys.LONGITUDE_OUT_OF_RANGE_$1, new Longitude(x)));
            verifyCoordinateRanges = false;
    }
    if (y < (Latitude.MIN_VALUE - ANGLE_TOLERANCE) || y > (Latitude.MAX_VALUE + ANGLE_TOLERANCE)) {
            LOGGER.warning(Errors.format(ErrorKeys.LATITUDE_OUT_OF_RANGE_$1, new Latitude(y)));
            verifyCoordinateRanges = false;
    }
    }
    assert checkReciprocal(ptDst, (ptSrc!=ptDst) ? ptSrc : new Point2D.Double(x0, y0), false);
    return ptDst;
}