Envelope2D changes for revisions 22697:22698

This commit constructs an Envelope from its two corners. This is a quite natural commit since the ISO 19107 Envelope is defined that way. This code has been rewritten in a different way in SIS (except the Javadoc which is a copy-and-paste of the Javadoc of an other constructor):

Furthermore this commit contains a bug: the last non-trivial line should access the y field, not x.

Command line:

svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r22697:22698 https://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/geometry/Envelope2D.java
Revision 22697Revision 22698
    super(x, y, width, height);
    setCoordinateReferenceSystem(crs);
}

/**
 * Returns the coordinate reference system in which the coordinates are given.
 *
 * @return The coordinate reference system, or {@code null}.
    super(x, y, width, height);
    setCoordinateReferenceSystem(crs);
}
/**
 * Constructs two-dimensional envelope defined by the specified coordinates. Despite
 * their name, the (<var>x</var>,<var>y</var>) coordinates don't need to be oriented
 * toward ({@linkplain AxisDirection#EAST East}, {@linkplain AxisDirection#NORTH North}).
 * Those parameter names simply match the {@linkplain #x x} and {@linkplain #y y} fields.
 * The actual axis orientations are determined by the specified CRS.
 * See the {@linkplain Envelope2D class javadoc} for details.
 */
public Envelope2D( DirectPosition2D a, DirectPosition2D b )
{
    this( a.getCoordinateReferenceSystem(),
          Math.min( a.x, b.x ),
          Math.min( a.y, b.y ),
          Math.abs( a.x- b.x ),
          Math.abs( a.x- b.x ) );
}
/**
 * Returns the coordinate reference system in which the coordinates are given.
 *
 * @return The coordinate reference system, or {@code null}.

The SIS code is as below:

Apache SIS code
public Envelope2D(final DirectPosition lowerCorner, final DirectPosition upperCorner)
        throws MismatchedReferenceSystemException, MismatchedDimensionException
{
    // The call to getCommonCRS(…) performs a check against null values.
    this(getCommonCRS(lowerCorner, upperCorner), lowerCorner, upperCorner);
}

private Envelope2D(final CoordinateReferenceSystem crs,
                   final DirectPosition lowerCorner,
                   final DirectPosition upperCorner)
{
    /*
     * JDK constraint: The call to ensureDimensionMatch(…) should have been first if Sun/Oracle
     * fixed RFE #4093999 (Relax constraint on placement of this()/super() call in constructors).
     */
    this(lowerCorner.getOrdinate(0), lowerCorner.getOrdinate(1),
         upperCorner.getOrdinate(0), upperCorner.getOrdinate(1));
    AbstractDirectPosition.ensureDimensionMatch(crs, 2);
    this.crs = crs;
}

private Envelope2D(final double xmin, final double ymin, final double xmax, final double ymax) {
    super(xmin, ymin, xmax - xmin, ymax - ymin);
}