sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1422606 - /sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/
Date Sun, 16 Dec 2012 16:03:38 GMT
Author: desruisseaux
Date: Sun Dec 16 16:03:37 2012
New Revision: 1422606

URL: http://svn.apache.org/viewvc?rev=1422606&view=rev
Log:
Reordered the constructors in a more consistent way.
The constructor expecting DirectPosition arguments is put first,
because Envelope are defined by those direct positions.

Modified:
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
    sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
Sun Dec 16 16:03:37 2012
@@ -16,6 +16,11 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.geom.Point2D in this class, because not all platforms
+ * support Java2D (e.g. Android), or applications that do not need it may want to avoid to
+ * to force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.util.Arrays;
 import java.util.Objects;
 import org.opengis.geometry.DirectPosition;
@@ -40,7 +45,7 @@ import static org.apache.sis.util.String
  * or {@link Cloneable} interfaces. The internal representation, and the choice to be cloneable
or
  * serializable, is left to subclasses.</p>
  *
- * @author Martin Desruisseaux (IRD, Geomatys)
+ * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.4)
  * @version 0.3
  * @module
@@ -114,6 +119,7 @@ public abstract class AbstractDirectPosi
 
     /**
      * Ensures that the given CRS, if non-null, has the expected number of dimensions.
+     * This method presumes that the argument name is {@code "crs"}.
      *
      * @param  crs The coordinate reference system to check, or {@code null}.
      * @param  expected The expected number of dimensions.
@@ -125,8 +131,8 @@ public abstract class AbstractDirectPosi
         if (crs != null) {
             final int dimension = crs.getCoordinateSystem().getDimension();
             if (dimension != expected) {
-                throw new MismatchedDimensionException(Errors.format(Errors.Keys.MismatchedDimension_3,
-                          crs.getName().getCode(), dimension, expected));
+                throw new MismatchedDimensionException(Errors.format(
+                        Errors.Keys.MismatchedDimension_3, "crs", dimension, expected));
             }
         }
     }

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
Sun Dec 16 16:03:37 2012
@@ -16,6 +16,11 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.Rectangle2D in this class, because not every platforms
+ * support Java2D (e.g. Android),  or applications that do not need it may want to avoid
to
+ * force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.io.Serializable;
 import javax.measure.unit.Unit;
 import javax.measure.converter.ConversionException;
@@ -141,16 +146,17 @@ public abstract class AbstractEnvelope i
     /**
      * Returns the common CRS of specified points.
      *
-     * @param  lower The first position.
-     * @param  upper The second position.
+     * @param  lowerCorner The first position.
+     * @param  upperCorner The second position.
      * @return Their common CRS, or {@code null} if none.
-     * @throws MismatchedReferenceSystemException if the two positions don't use the same
CRS.
+     * @throws MismatchedReferenceSystemException if the two positions don't use equal CRS.
      */
-    static CoordinateReferenceSystem getCoordinateReferenceSystem(final DirectPosition lower,
-            final DirectPosition upper) throws MismatchedReferenceSystemException
+    static CoordinateReferenceSystem getCommonCRS(final DirectPosition lowerCorner,
+                                                  final DirectPosition upperCorner)
+            throws MismatchedReferenceSystemException
     {
-        final CoordinateReferenceSystem crs1 = lower.getCoordinateReferenceSystem();
-        final CoordinateReferenceSystem crs2 = upper.getCoordinateReferenceSystem();
+        final CoordinateReferenceSystem crs1 = lowerCorner.getCoordinateReferenceSystem();
+        final CoordinateReferenceSystem crs2 = upperCorner.getCoordinateReferenceSystem();
         if (crs1 == null) {
             return crs2;
         } else {
@@ -607,31 +613,31 @@ public abstract class AbstractEnvelope i
         AbstractDirectPosition.ensureDimensionMatch("envelope", envelope.getDimension(),
dimension);
         assert equalsIgnoreMetadata(getCoordinateReferenceSystem(),
                 envelope.getCoordinateReferenceSystem(), true) : envelope;
-        final DirectPosition lower = envelope.getLowerCorner();
-        final DirectPosition upper = envelope.getUpperCorner();
+        final DirectPosition lowerCorner = envelope.getLowerCorner();
+        final DirectPosition upperCorner = envelope.getUpperCorner();
         for (int i=0; i<dimension; i++) {
-            final double min0 = getLower(i);
-            final double max0 = getUpper(i);
-            final double min1 = lower.getOrdinate(i);
-            final double max1 = upper.getOrdinate(i);
-            final boolean minCondition, maxCondition;
+            final double lower0 = getLower(i);
+            final double upper0 = getUpper(i);
+            final double lower1 = lowerCorner.getOrdinate(i);
+            final double upper1 = upperCorner.getOrdinate(i);
+            final boolean lowerCondition, upperCondition;
             if (edgesInclusive) {
-                minCondition = (min1 >= min0);
-                maxCondition = (max1 <= max0);
+                lowerCondition = (lower1 >= lower0);
+                upperCondition = (upper1 <= upper0);
             } else {
-                minCondition = (min1 > min0);
-                maxCondition = (max1 < max0);
+                lowerCondition = (lower1 > lower0);
+                upperCondition = (upper1 < upper0);
             }
-            if (minCondition & maxCondition) {
-                /*           maxCnd          maxCnd
+            if (lowerCondition & upperCondition) {
+                /*         upperCnd          upperCnd
                  *  ┌─────────────┐
         ────┐  ┌────                  
   ┌─┐
                  *  │  ┌───────┐  │
   or    ──┐ │  │ ┌──    excluding    ───┐
│ │ ┌───
                  *  │  └───────┘  │
         ──┘ │  │ └──                 ───┘
│ │ └───
                  *  └─────────────┘
         ────┘  └────                  
   └─┘
-                 *  minCnd                          minCnd
+                 *  lowerCnd                        lowerCnd
                  */
-                // (max1-min1) is negative if the small rectangle in above pictures spans
the anti-meridian.
-                if (!isNegativeUnsafe(max1 - min1) || isNegativeUnsafe(max0 - min0)) {
+                // (upper1-lower1) is negative if the small rectangle in above pictures spans
the anti-meridian.
+                if (!isNegativeUnsafe(upper1 - lower1) || isNegativeUnsafe(upper0 - lower0))
{
                     // Not the excluded case, go to next dimension.
                     continue;
                 }
@@ -639,25 +645,25 @@ public abstract class AbstractEnvelope i
                 // does, we don't contain the given envelope except in the special case
                 // where the envelope spanning is equals or greater than the axis spanning
                 // (including the case where this envelope expands to infinities).
-                if ((min0 == Double.NEGATIVE_INFINITY && max0 == Double.POSITIVE_INFINITY)
||
-                    (max0 - min0 >= getSpan(getAxis(getCoordinateReferenceSystem(), i))))
+                if ((lower0 == Double.NEGATIVE_INFINITY && upper0 == Double.POSITIVE_INFINITY)
||
+                    (upper0 - lower0 >= getSpan(getAxis(getCoordinateReferenceSystem(),
i))))
                 {
                     continue;
                 }
-            } else if (minCondition != maxCondition) {
-                /*       maxCnd                     !maxCnd
+            } else if (lowerCondition != upperCondition) {
+                /*     upperCnd                     !upperCnd
                  *  ──────────┐  ┌─────
             ─────┐  ┌─────────
                  *    ┌────┐  │  │           or 
         │  │  ┌────┐
                  *    └────┘  │  │              
         │  │  └────┘
                  *  ──────────┘  └─────
             ─────┘  └─────────
-                 *               !minCnd                     minCnd */
-                if (isNegative(max0 - min0)) {
-                    if (isPositive(max1 - min1)) {
+                 *               !lowerCnd                   lowerCnd */
+                if (isNegative(upper0 - lower0)) {
+                    if (isPositive(upper1 - lower1)) {
                         continue;
                     }
                     // Special case for the [0…-0] range, if inclusive.
-                    if (edgesInclusive && Double.doubleToRawLongBits(min0) == 0L
&&
-                            Double.doubleToRawLongBits(max0) == SIGN_BIT_MASK)
+                    if (edgesInclusive && Double.doubleToRawLongBits(lower0) == 0L
&&
+                            Double.doubleToRawLongBits(upper0) == SIGN_BIT_MASK)
                     {
                         continue;
                     }
@@ -697,30 +703,30 @@ public abstract class AbstractEnvelope i
         AbstractDirectPosition.ensureDimensionMatch("envelope", envelope.getDimension(),
dimension);
         assert equalsIgnoreMetadata(getCoordinateReferenceSystem(),
                 envelope.getCoordinateReferenceSystem(), true) : envelope;
-        final DirectPosition lower = envelope.getLowerCorner();
-        final DirectPosition upper = envelope.getUpperCorner();
+        final DirectPosition lowerCorner = envelope.getLowerCorner();
+        final DirectPosition upperCorner = envelope.getUpperCorner();
         for (int i=0; i<dimension; i++) {
-            final double min0 = getLower(i);
-            final double max0 = getUpper(i);
-            final double min1 = lower.getOrdinate(i);
-            final double max1 = upper.getOrdinate(i);
-            final boolean minCondition, maxCondition;
+            final double lower0 = getLower(i);
+            final double upper0 = getUpper(i);
+            final double lower1 = lowerCorner.getOrdinate(i);
+            final double upper1 = upperCorner.getOrdinate(i);
+            final boolean lowerCondition, upperCondition;
             if (edgesInclusive) {
-                minCondition = (min1 <= max0);
-                maxCondition = (max1 >= min0);
+                lowerCondition = (lower1 <= upper0);
+                upperCondition = (upper1 >= lower0);
             } else {
-                minCondition = (min1 < max0);
-                maxCondition = (max1 > min0);
+                lowerCondition = (lower1 < upper0);
+                upperCondition = (upper1 > lower0);
             }
-            if (maxCondition & minCondition) {
+            if (upperCondition & lowerCondition) {
                 /*     ┌──────────┐
                  *     │  ┌───────┼──┐
                  *     │  └───────┼──┘
                  *     └──────────┘
(this is the most standard case) */
                 continue;
             }
-            final boolean sp0 = isNegative(max0 - min0);
-            final boolean sp1 = isNegative(max1 - min1);
+            final boolean sp0 = isNegative(upper0 - lower0);
+            final boolean sp1 = isNegative(upper1 - lower1);
             if (sp0 | sp1) {
                 /*
                  * If both envelopes span the anti-meridian (sp0 & sp1), we have an unconditional
@@ -731,7 +737,7 @@ public abstract class AbstractEnvelope i
                  *     ────┼───┐  ┌───┼────
     or          ┌─┼──────┼─┐
                  *     ────┼───┘  └───┼────
                 └─┼──────┼─┘
                  *         └──────────┘
                  ─────┘      └─────
*/
-                if ((sp0 & sp1) | (maxCondition | minCondition)) {
+                if ((sp0 & sp1) | (upperCondition | lowerCondition)) {
                     continue;
                 }
             }
@@ -808,8 +814,8 @@ public abstract class AbstractEnvelope i
         {
             return false;
         }
-        final DirectPosition lower = other.getLowerCorner();
-        final DirectPosition upper = other.getUpperCorner();
+        final DirectPosition lowerCorner = other.getLowerCorner();
+        final DirectPosition upperCorner = other.getUpperCorner();
         for (int i=0; i<dimension; i++) {
             double ε = eps;
             if (epsIsRelative) {
@@ -818,8 +824,8 @@ public abstract class AbstractEnvelope i
                     ε *= span;
                 }
             }
-            if (!epsilonEqual(getLower(i), lower.getOrdinate(i), ε) ||
-                !epsilonEqual(getUpper(i), upper.getOrdinate(i), ε))
+            if (!epsilonEqual(getLower(i), lowerCorner.getOrdinate(i), ε) ||
+                !epsilonEqual(getUpper(i), upperCorner.getOrdinate(i), ε))
             {
                 return false;
             }
@@ -921,19 +927,19 @@ public abstract class AbstractEnvelope i
      * @see org.apache.sis.io.wkt
      */
     static String toString(final Envelope envelope) {
-        final int dimension = envelope.getDimension();
-        final DirectPosition lower = envelope.getLowerCorner();
-        final DirectPosition upper = envelope.getUpperCorner();
-        final StringBuilder buffer = new StringBuilder(64).append("BOX").append(dimension).append("D(");
+        final int            dimension   = envelope.getDimension();
+        final DirectPosition lowerCorner = envelope.getLowerCorner();
+        final DirectPosition upperCorner = envelope.getUpperCorner();
+        final StringBuilder  buffer = new StringBuilder(64).append("BOX").append(dimension).append("D(");
         for (int i=0; i<dimension; i++) {
             if (i != 0) {
                 buffer.append(' ');
             }
-            trimFractionalPart(buffer.append(lower.getOrdinate(i)));
+            trimFractionalPart(buffer.append(lowerCorner.getOrdinate(i)));
         }
         buffer.append(',');
         for (int i=0; i<dimension; i++) {
-            trimFractionalPart(buffer.append(' ').append(upper.getOrdinate(i)));
+            trimFractionalPart(buffer.append(' ').append(upperCorner.getOrdinate(i)));
         }
         return buffer.append(')').toString();
     }

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
Sun Dec 16 16:03:37 2012
@@ -16,12 +16,18 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.Rectangle2D in this class, because not every platforms
+ * support Java2D (e.g. Android),  or applications that do not need it may want to avoid
to
+ * force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.util.Arrays;
 import java.util.Objects;
 import java.io.Serializable;
 import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.geometry.MismatchedReferenceSystemException;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -64,6 +70,48 @@ class ArrayEnvelope extends AbstractEnve
     CoordinateReferenceSystem crs;
 
     /**
+     * Constructs an envelope defined by two 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.
+     * @throws MismatchedDimensionException If the two positions do not have the same dimension.
+     * @throws MismatchedReferenceSystemException If the CRS of the two position are not
equal.
+     */
+    public ArrayEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner)
+            throws MismatchedDimensionException, MismatchedReferenceSystemException
+    {
+        ensureNonNull("lowerCorner", lowerCorner);
+        ensureNonNull("upperCorner", upperCorner);
+        final int dimension = lowerCorner.getDimension();
+        ensureSameDimension(dimension, upperCorner.getDimension());
+        ordinates = new double[dimension * 2];
+        for (int i=0; i<dimension; i++) {
+            ordinates[i            ] = lowerCorner.getOrdinate(i);
+            ordinates[i + dimension] = upperCorner.getOrdinate(i);
+        }
+        crs = getCommonCRS(lowerCorner, upperCorner);
+        AbstractDirectPosition.ensureDimensionMatch(crs, dimension);
+    }
+
+    /**
+     * Constructs an envelope defined by two sequences of ordinate values.
+     * The Coordinate Reference System is initially {@code null}.
+     *
+     * @param  lowerCorner Lower ordinate values.
+     * @param  upperCorner Upper ordinate values.
+     * @throws MismatchedDimensionException If the two sequences do not have the same length.
+     */
+    public ArrayEnvelope(final double[] lowerCorner, final double[] upperCorner) throws MismatchedDimensionException
{
+        ensureNonNull("lowerCorner", lowerCorner);
+        ensureNonNull("upperCorner", upperCorner);
+        ensureSameDimension(lowerCorner.length, upperCorner.length);
+        ordinates = Arrays.copyOf(lowerCorner, lowerCorner.length + upperCorner.length);
+        System.arraycopy(upperCorner, 0, ordinates, lowerCorner.length, upperCorner.length);
+    }
+
+    /**
      * Constructs an empty envelope of the specified dimension. All ordinates
      * are initialized to 0 and the coordinate reference system is undefined.
      *
@@ -86,21 +134,6 @@ class ArrayEnvelope extends AbstractEnve
     }
 
     /**
-     * Constructs a envelope defined by two positions.
-     *
-     * @param  lowerCorner Lower ordinate values.
-     * @param  upperCorner Upper ordinate values.
-     * @throws MismatchedDimensionException if the two positions do not have the same dimension.
-     */
-    public ArrayEnvelope(final double[] lowerCorner, final double[] upperCorner) throws MismatchedDimensionException
{
-        ensureNonNull("lowerCorner", lowerCorner);
-        ensureNonNull("upperCorner", upperCorner);
-        ensureSameDimension(lowerCorner.length, upperCorner.length);
-        ordinates = Arrays.copyOf(lowerCorner, lowerCorner.length + upperCorner.length);
-        System.arraycopy(upperCorner, 0, ordinates, lowerCorner.length, upperCorner.length);
-    }
-
-    /**
      * Constructs a new envelope with the same data than the specified envelope.
      *
      * @param envelope The envelope to copy.

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition1D.java
Sun Dec 16 16:03:37 2012
@@ -16,6 +16,11 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.geom.Point2D in this class, because not all platforms
+ * support Java2D (e.g. Android), or applications that do not need it may want to avoid to
+ * to force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.io.Serializable;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.geometry.DirectPosition;
@@ -26,7 +31,7 @@ import org.apache.sis.util.resources.Err
 /**
  * Holds the coordinates for a one-dimensional position within some coordinate reference
system.
  *
- * @author Martin Desruisseaux (IRD, Geomatys)
+ * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.0)
  * @version 0.3
  * @module

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
Sun Dec 16 16:03:37 2012
@@ -29,13 +29,15 @@ import static org.apache.sis.util.String
 
 
 /**
- * Holds the coordinates for a two-dimensional position within some coordinate reference
system.
- * This class inherits {@linkplain #x x} and {@linkplain #y y} fields. But despite their
names,
- * they don't need to be oriented toward {@linkplain AxisDirection#EAST East} and {@linkplain
- * AxisDirection#NORTH North}. The (<var>x</var>,<var>y</var>) axis
can have any orientation and
- * should be understood as "<cite>ordinate 0</cite>" and "<cite>ordinate
1</cite>" values instead.
+ * Holds the coordinates for a two-dimensional position on top of {@link Point2D}.
+ * This implementation is provided for inter-operability between Java2D and GeoAPI.
+ *
+ * <p>This class inherits {@linkplain #x x} and {@linkplain #y y} fields.
+ * But despite their names, they don't need to be oriented toward {@linkplain AxisDirection#EAST
East} and
+ * {@linkplain AxisDirection#NORTH North} respectively. The (<var>x</var>,<var>y</var>)
axis can have any
+ * direction and should be understood as <cite>ordinate 0</cite> and <cite>ordinate
1</cite> values instead.
  * This is not specific to this implementation; in Java2D too, the visual axis orientation
depend
- * on the {@linkplain java.awt.Graphics2D#getTransform() affine transform in the graphics
context}.
+ * on the {@linkplain java.awt.Graphics2D#getTransform() affine transform in the graphics
context}.</p>
  *
  * {@note The rational for avoiding axis orientation restriction is that other <code>DirectPosition</code>
  *        implementations do not have such restriction, and it would be hard to generalize.
@@ -53,7 +55,7 @@ import static org.apache.sis.util.String
  * {@code HashSet<DirectPosition>}, but it is unsafe to add them in a {@code HashSet<Point2D>}.
  * Collections that do not rely on hash codes, like {@code ArrayList}, are safe in all cases.</p>
  *
- * @author Martin Desruisseaux (IRD, Geomatys)
+ * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-2.0)
  * @version 0.3
  * @module

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java
Sun Dec 16 16:03:37 2012
@@ -16,6 +16,11 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.geom.Point2D in this class, because not all platforms
+ * support Java2D (e.g. Android), or applications that do not need it may want to avoid to
+ * to force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.util.Arrays;
 import java.io.Serializable;
 import java.lang.reflect.Field;
@@ -39,7 +44,7 @@ import org.apache.sis.util.resources.Err
  * position is known to be always two-dimensional, then {@link DirectPosition2D} provides
  * a more efficient implementation.</p>
  *
- * @author Martin Desruisseaux (IRD, Geomatys)
+ * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-1.2)
  * @version 0.3
  * @module

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
Sun Dec 16 16:03:37 2012
@@ -16,6 +16,11 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.Rectangle2D in this class, because not every platforms
+ * support Java2D (e.g. Android),  or applications that do not need it may want to avoid
to
+ * force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.util.Arrays;
 import java.io.Serializable;
 import java.lang.reflect.Field;
@@ -23,6 +28,7 @@ import org.opengis.referencing.crs.Coord
 import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.geometry.MismatchedReferenceSystemException;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.util.resources.Errors;
 
@@ -49,7 +55,7 @@ import static org.apache.sis.math.MathFu
  * <p>A {@code GeneralEnvelope} can be created in various ways:</p>
  * <ul>
  *   <li>{@linkplain #GeneralEnvelope(int) From a given number of dimension}, with
all ordinates initialized to 0.</li>
- *   <li>{@linkplain #GeneralEnvelope(GeneralDirectPosition, GeneralDirectPosition)
From two coordinate points}.</li>
+ *   <li>{@linkplain #GeneralEnvelope(double[], double[]) From two coordinate points}.</li>
  *   <li>{@linkplain #GeneralEnvelope(Envelope) From a an other envelope} (copy constructor).</li>
  *   <li>{@linkplain #GeneralEnvelope(GeographicBoundingBox) From a geographic bounding
box}.</li>
  *   <li>{@linkplain #GeneralEnvelope(String) From a string} representing a {@code
BBOX} in <cite>Well Known Text</cite> (WKT) format.</li>
@@ -61,7 +67,7 @@ import static org.apache.sis.math.MathFu
  * envelopes crossing the anti-meridian, like the red box below (the green box is the usual
case).
  * The default implementation of methods listed in the right column can handle such cases.
  *
- * <center><table><tr><td>
+ * <center><table class="compact"><tr><td>
  *   <img src="doc-files/AntiMeridian.png">
  * </td><td>
  * Supported methods:
@@ -71,9 +77,9 @@ import static org.apache.sis.math.MathFu
  *   <li>{@link #getMedian(int)}</li>
  *   <li>{@link #getSpan(int)}</li>
  *   <li>{@link #isEmpty()}</li>
- *   <li>{@link #contains(DirectPosition)}</li>
- *   <li>{@link #contains(Envelope, boolean)}</li>
- *   <li>{@link #intersects(Envelope, boolean)}</li>
+ *   <li>{@link #contains(DirectPosition) contains(DirectPosition)}</li>
+ *   <li>{@link #contains(Envelope, boolean) contains(Envelope, boolean)}</li>
+ *   <li>{@link #intersects(Envelope, boolean) intersects(Envelope, boolean)}</li>
  *   <li>{@link #intersect(Envelope)}</li>
  *   <li>{@link #add(Envelope)}</li>
  *   <li>{@link #add(DirectPosition)}</li>
@@ -102,6 +108,34 @@ public class GeneralEnvelope extends Arr
     private static volatile Field ordinatesField;
 
     /**
+     * Constructs an envelope defined by two 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.
+     * @throws MismatchedDimensionException If the two positions do not have the same dimension.
+     * @throws MismatchedReferenceSystemException If the CRS of the two position are not
equal.
+     */
+    public GeneralEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner)
+            throws MismatchedDimensionException, MismatchedReferenceSystemException
+    {
+        super(lowerCorner, upperCorner);
+    }
+
+    /**
+     * Constructs an envelope defined by two sequences of ordinate values.
+     * The Coordinate Reference System is initially {@code null}.
+     *
+     * @param  lowerCorner Lower ordinate values.
+     * @param  upperCorner Upper ordinate values.
+     * @throws MismatchedDimensionException If the two sequences do not have the same length.
+     */
+    public GeneralEnvelope(final double[] lowerCorner, final double[] upperCorner) throws
MismatchedDimensionException {
+        super(lowerCorner, upperCorner);
+    }
+
+    /**
      * Constructs an empty envelope of the specified dimension. All ordinates
      * are initialized to 0 and the coordinate reference system is undefined.
      *
@@ -122,22 +156,11 @@ public class GeneralEnvelope extends Arr
     }
 
     /**
-     * Constructs a envelope defined by two positions.
-     *
-     * @param  lowerCorner Lower ordinate values.
-     * @param  upperCorner Upper ordinate values.
-     * @throws MismatchedDimensionException if the two positions do not have the same dimension.
-     */
-    public GeneralEnvelope(final double[] lowerCorner, final double[] upperCorner) throws
MismatchedDimensionException {
-        super(lowerCorner, upperCorner);
-    }
-
-    /**
      * Constructs a new envelope with the same data than the specified envelope.
      *
      * @param envelope The envelope to copy.
      *
-     * @see Envelope2D#Envelope2D(Envelope)
+     * @see #castOrCopy(Envelope)
      */
     public GeneralEnvelope(final Envelope envelope) {
         super(envelope);
@@ -148,8 +171,6 @@ public class GeneralEnvelope extends Arr
      * The coordinate reference system is set to {@code "CRS:84"}.
      *
      * @param box The bounding box to copy.
-     *
-     * @see Envelope2D#Envelope2D(GeographicBoundingBox)
      */
     public GeneralEnvelope(final GeographicBoundingBox box) {
         super(box);
@@ -209,6 +230,7 @@ public class GeneralEnvelope extends Arr
      * @return The values of the given envelope as a {@code GeneralEnvelope} instance.
      *
      * @see AbstractEnvelope#castOrCopy(Envelope)
+     * @see ImmutableEnvelope#castOrCopy(Envelope)
      */
     public static GeneralEnvelope castOrCopy(final Envelope envelope) {
         if (envelope == null || envelope instanceof GeneralEnvelope) {

Modified: sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java?rev=1422606&r1=1422605&r2=1422606&view=diff
==============================================================================
--- sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
(original)
+++ sis/branches/JDK7/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java
Sun Dec 16 16:03:37 2012
@@ -16,11 +16,17 @@
  */
 package org.apache.sis.geometry;
 
+/*
+ * Do not add dependency to java.awt.Rectangle2D in this class, because not every platforms
+ * support Java2D (e.g. Android),  or applications that do not need it may want to avoid
to
+ * force installation of the Java2D module (e.g. JavaFX/SWT).
+ */
 import java.io.Serializable;
 import net.jcip.annotations.Immutable;
-
 import org.opengis.geometry.Envelope;
+import org.opengis.geometry.DirectPosition;
 import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.geometry.MismatchedReferenceSystemException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 
@@ -44,17 +50,18 @@ public final class ImmutableEnvelope ext
     private static final long serialVersionUID = 5593936512712449234L;
 
     /**
-     * Creates an immutable envelope with the values of the given envelope.
-     * This constructor can be used when the given envelope is known to not
-     * be an instance of {@code ImmutableEnvelope}. In case of doubt,
-     * consider using {@link #castOrCopy(Envelope)} instead.
-     *
-     * @param envelope The envelope to copy.
+     * Constructs an envelope defined by two direct positions.
+     * The envelope CRS will be the CRS of the given positions.
      *
-     * @see #castOrCopy(Envelope)
+     * @param  lowerCorner The lower corner.
+     * @param  upperCorner The upper corner.
+     * @throws MismatchedDimensionException If the two positions do not have the same dimension.
+     * @throws MismatchedReferenceSystemException If the CRS of the two position are not
equal.
      */
-    public ImmutableEnvelope(final Envelope envelope) {
-        super(envelope);
+    public ImmutableEnvelope(final DirectPosition lowerCorner, final DirectPosition upperCorner)
+            throws MismatchedDimensionException, MismatchedReferenceSystemException
+    {
+        super(lowerCorner, upperCorner);
     }
 
     /**
@@ -68,6 +75,20 @@ public final class ImmutableEnvelope ext
     }
 
     /**
+     * Creates an immutable envelope with the values of the given envelope.
+     * This constructor can be used when the given envelope is known to not
+     * be an instance of {@code ImmutableEnvelope}. In case of doubt,
+     * consider using {@link #castOrCopy(Envelope)} instead.
+     *
+     * @param envelope The envelope to copy.
+     *
+     * @see #castOrCopy(Envelope)
+     */
+    public ImmutableEnvelope(final Envelope envelope) {
+        super(envelope);
+    }
+
+    /**
      * Creates an immutable envelope with the ordinate values of the given envelope but
      * a different CRS. This method does <strong>not</strong> reproject the given
envelope.
      * It just assign the given CRS to this envelope without any check, except for the CRS
@@ -76,12 +97,12 @@ public final class ImmutableEnvelope ext
      * <p>The main purpose of this method is to assign a non-null CRS when the envelope
to
      * copy has a null CRS.</p>
      *
-     * @param crs      The CRS to assign to this envelope, or {@code null}.
      * @param envelope The envelope from which to copy ordinate values.
+     * @param crs      The CRS to assign to this envelope, or {@code null}.
      * @throws MismatchedDimensionException If the dimension of the given CRS is not equals
      *         to the dimension of the given envelope.
      */
-    public ImmutableEnvelope(final CoordinateReferenceSystem crs, final Envelope envelope)
+    public ImmutableEnvelope(final Envelope envelope, final CoordinateReferenceSystem crs)
             throws MismatchedDimensionException
     {
         super(envelope);
@@ -102,13 +123,13 @@ public final class ImmutableEnvelope ext
      * See the javadoc of the {@link GeneralEnvelope#GeneralEnvelope(String) GeneralEnvelope}
      * constructor for more information.
      *
-     * @param  crs The coordinate reference system, or {@code null} if none.
      * @param  wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse.
+     * @param  crs The coordinate reference system, or {@code null} if none.
      * @throws IllegalArgumentException If the given string can not be parsed.
      * @throws MismatchedDimensionException If the dimension of the given CRS is not equals
      *         to the dimension of the parsed envelope.
      */
-    public ImmutableEnvelope(final CoordinateReferenceSystem crs, final String wkt)
+    public ImmutableEnvelope(final String wkt, final CoordinateReferenceSystem crs)
             throws IllegalArgumentException, MismatchedDimensionException
     {
         super(wkt);
@@ -125,6 +146,7 @@ public final class ImmutableEnvelope ext
      * @param  envelope The envelope to cast, or {@code null}.
      * @return The values of the given envelope as an {@code ImmutableEnvelope} instance.
      *
+     * @see AbstractEnvelope#castOrCopy(Envelope)
      * @see GeneralEnvelope#castOrCopy(Envelope)
      */
     public static ImmutableEnvelope castOrCopy(final Envelope envelope) {



Mime
View raw message