sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1423053 - in /sis/trunk: ./ sis-referencing/src/main/java/org/apache/sis/geometry/
Date Mon, 17 Dec 2012 17:48:28 GMT
Author: desruisseaux
Date: Mon Dec 17 17:48:27 2012
New Revision: 1423053

URL: http://svn.apache.org/viewvc?rev=1423053&view=rev
Log:
Merge from the JDK6 branch.

Modified:
    sis/trunk/   (props changed)
    sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
    sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
    sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
    sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
    sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
    sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java

Propchange: sis/trunk/
------------------------------------------------------------------------------
  Merged /sis/branches/JDK7:r1422801-1423049
  Merged /sis/branches/JDK6:r1422806-1423051

Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java?rev=1423053&r1=1423052&r2=1423053&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
(original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
Mon Dec 17 17:48:27 2012
@@ -300,11 +300,7 @@ parse:  while (i < length) {
             final long bits = doubleToLongBits(getOrdinate(i));
             code = 31 * code + (((int) bits) ^ (int) (bits >>> 32));
         }
-        final CoordinateReferenceSystem crs = getCoordinateReferenceSystem();
-        if (crs != null) {
-            code += crs.hashCode();
-        }
-        return code;
+        return code + Objects.hashCode(getCoordinateReferenceSystem());
     }
 
     /**

Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1423053&r1=1423052&r2=1423053&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java (original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java Mon
Dec 17 17:48:27 2012
@@ -71,12 +71,12 @@ class ArrayEnvelope extends AbstractEnve
     CoordinateReferenceSystem crs;
 
     /**
-     * Constructs an envelope defined by two direct positions.
+     * Constructs an envelope defined by two corners given as direct positions.
      * If at least one corner is associated to a CRS, then the new envelope will also
      * be associated to that CRS.
      *
-     * @param  lowerCorner The lower corner.
-     * @param  upperCorner The upper corner.
+     * @param  lowerCorner The limits in the direction of decreasing ordinate values for
each dimension.
+     * @param  upperCorner The limits in the direction of increasing ordinate values for
each dimension.
      * @throws MismatchedDimensionException If the two positions do not have the same dimension.
      * @throws MismatchedReferenceSystemException If the CRS of the two position are not
equal.
      */
@@ -95,11 +95,11 @@ class ArrayEnvelope extends AbstractEnve
     }
 
     /**
-     * Constructs an envelope defined by two sequences of ordinate values.
+     * Constructs an envelope defined by two corners given as sequences of ordinate values.
      * The Coordinate Reference System is initially {@code null}.
      *
-     * @param  lowerCorner Lower ordinate values.
-     * @param  upperCorner Upper ordinate values.
+     * @param  lowerCorner The limits in the direction of decreasing ordinate values for
each dimension.
+     * @param  upperCorner The limits in the direction of increasing ordinate values for
each dimension.
      * @throws MismatchedDimensionException If the two sequences do not have the same length.
      */
     public ArrayEnvelope(final double[] lowerCorner, final double[] upperCorner) throws MismatchedDimensionException
{
@@ -340,30 +340,6 @@ scanNumber: while ((i += Character.charC
      * {@inheritDoc}
      */
     @Override
-    public DirectPosition getLowerCorner() {
-        final int dim = ordinates.length >>> 1;
-        final GeneralDirectPosition position = new GeneralDirectPosition(dim);
-        System.arraycopy(ordinates, 0, position.ordinates, 0, dim);
-        position.setCoordinateReferenceSystem(crs);
-        return position;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public DirectPosition getUpperCorner() {
-        final int dim = ordinates.length >>> 1;
-        final GeneralDirectPosition position = new GeneralDirectPosition(dim);
-        System.arraycopy(ordinates, dim, position.ordinates, 0, dim);
-        position.setCoordinateReferenceSystem(crs);
-        return position;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public double getLower(final int dimension) throws IndexOutOfBoundsException {
         ensureValidIndex(ordinates.length >>> 1, dimension);
         return ordinates[dimension];

Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1423053&r1=1423052&r2=1423053&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java (original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java Mon Dec
17 17:48:27 2012
@@ -282,8 +282,9 @@ public class Envelope2D extends Rectangl
     }
 
     /**
-     * A coordinate position consisting of all the starting ordinates for each
-     * dimension for all points within the {@code Envelope}.
+     * The limits in the direction of decreasing ordinate values for the two dimensions.
+     * This is typically a coordinate position consisting of the minimal ordinates for
+     * the two dimensions for all points within the {@code Envelope}.
      *
      * {@note The <cite>Web Coverage Service</cite> (WCS) 1.1 specification uses
an extended
      * interpretation of the bounding box definition. In a WCS 1.1 data structure, the lower
@@ -301,8 +302,9 @@ public class Envelope2D extends Rectangl
     }
 
     /**
-     * A coordinate position consisting of all the ending ordinates for each
-     * dimension for all points within the {@code Envelope}.
+     * The limits in the direction of increasing ordinate values for the two dimensions.
+     * This is typically a coordinate position consisting of the maximal ordinates for
+     * the two dimensions for all points within the {@code Envelope}.
      *
      * {@note The <cite>Web Coverage Service</cite> (WCS) 1.1 specification uses
an extended
      * interpretation of the bounding box definition. In a WCS 1.1 data structure, the upper

Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java?rev=1423053&r1=1423052&r2=1423053&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
(original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
Mon Dec 17 17:48:27 2012
@@ -29,6 +29,9 @@ import org.opengis.geometry.MismatchedDi
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.util.resources.Errors;
 
+// JDK7 related
+import org.apache.sis.internal.util.Objects;
+
 
 /**
  * Holds the coordinates for a position within some coordinate reference system.
@@ -92,16 +95,23 @@ public class GeneralDirectPosition exten
 
     /**
      * Constructs a position with the specified ordinates.
-     * The {@code ordinates} array will be copied.
+     * This constructor assigns the given array directly (without clone) to the {@link #ordinates}
field.
+     * Consequently, callers shall not recycle the same array for creating many instances.
+     *
+     * {@note The array is not cloned because this is usually not needed, especially in the
context
+     *        of variable argument lengths since the array is often created implicitly. Furthermore
+     *        the <code>ordinates</code> field is public, so cloning the array
would not protect
+     *        the state of this object anyway.}
      *
-     * @param ordinates The ordinate values to copy.
+     * @param ordinates The ordinate values. This array is <strong>not</strong>
cloned.
      */
     public GeneralDirectPosition(final double... ordinates) {
-        this.ordinates = ordinates.clone();
+        this.ordinates = ordinates;
     }
 
     /**
      * Constructs a position initialized to the same values than the specified point.
+     * This is a copy constructor.
      *
      * @param point The position to copy.
      */
@@ -276,10 +286,7 @@ public class GeneralDirectPosition exten
      */
     @Override
     public int hashCode() {
-        int code = Arrays.hashCode(ordinates);
-        if (crs != null) {
-            code += crs.hashCode();
-        }
+        final int code = Arrays.hashCode(ordinates) + Objects.hashCode(getCoordinateReferenceSystem());
         assert code == super.hashCode();
         return code;
     }

Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1423053&r1=1423052&r2=1423053&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java (original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java Mon
Dec 17 17:48:27 2012
@@ -108,12 +108,12 @@ public class GeneralEnvelope extends Arr
     private static volatile Field ordinatesField;
 
     /**
-     * Constructs an envelope defined by two direct positions.
+     * Constructs an envelope defined by two corners given as direct positions.
      * If at least one corner is associated to a CRS, then the new envelope will also
      * be associated to that CRS.
      *
-     * @param  lowerCorner The lower corner.
-     * @param  upperCorner The upper corner.
+     * @param  lowerCorner The limits in the direction of decreasing ordinate values for
each dimension.
+     * @param  upperCorner The limits in the direction of increasing ordinate values for
each dimension.
      * @throws MismatchedDimensionException If the two positions do not have the same dimension.
      * @throws MismatchedReferenceSystemException If the CRS of the two position are not
equal.
      */
@@ -124,11 +124,11 @@ public class GeneralEnvelope extends Arr
     }
 
     /**
-     * Constructs an envelope defined by two sequences of ordinate values.
+     * Constructs an envelope defined by two corners given as sequences of ordinate values.
      * The Coordinate Reference System is initially {@code null}.
      *
-     * @param  lowerCorner Lower ordinate values.
-     * @param  upperCorner Upper ordinate values.
+     * @param  lowerCorner The limits in the direction of decreasing ordinate values for
each dimension.
+     * @param  upperCorner The limits in the direction of increasing ordinate values for
each dimension.
      * @throws MismatchedDimensionException If the two sequences do not have the same length.
      */
     public GeneralEnvelope(final double[] lowerCorner, final double[] upperCorner) throws
MismatchedDimensionException {

Modified: sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java?rev=1423053&r1=1423052&r2=1423053&view=diff
==============================================================================
--- sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
(original)
+++ sis/trunk/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
Mon Dec 17 17:48:27 2012
@@ -49,11 +49,11 @@ public final class ImmutableEnvelope ext
     private static final long serialVersionUID = 5593936512712449234L;
 
     /**
-     * Constructs an envelope defined by two direct positions.
+     * Constructs an envelope defined by two corners given as direct positions.
      * The envelope CRS will be the CRS of the given positions.
      *
-     * @param  lowerCorner The lower corner.
-     * @param  upperCorner The upper corner.
+     * @param  lowerCorner The limits in the direction of decreasing ordinate values for
each dimension.
+     * @param  upperCorner The limits in the direction of increasing ordinate values for
each dimension.
      * @throws MismatchedDimensionException If the two positions do not have the same dimension.
      * @throws MismatchedReferenceSystemException If the CRS of the two position are not
equal.
      */
@@ -64,10 +64,10 @@ public final class ImmutableEnvelope ext
     }
 
     /**
-     * Constructs an envelope defined by two sequences of ordinate values.
+     * Constructs an envelope defined by two corners given as sequences of ordinate values.
      *
-     * @param  lowerCorner Lower ordinate values.
-     * @param  upperCorner Upper ordinate values.
+     * @param  lowerCorner The limits in the direction of decreasing ordinate values for
each dimension.
+     * @param  upperCorner The limits in the direction of increasing ordinate values for
each dimension.
      * @param  crs         The CRS to assign to this envelope, or {@code null}.
      * @throws MismatchedDimensionException If the two sequences do not have the same length,
or
      *         if the dimension of the given CRS is not equals to the dimension of the given
corners.



Mime
View raw message