Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC20211596 for ; Thu, 9 May 2013 12:25:14 +0000 (UTC) Received: (qmail 2132 invoked by uid 500); 9 May 2013 12:25:14 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 2038 invoked by uid 500); 9 May 2013 12:25:12 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 2008 invoked by uid 99); 9 May 2013 12:25:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 May 2013 12:25:11 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 May 2013 12:25:08 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AF95F2388A64; Thu, 9 May 2013 12:24:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1480602 [4/15] - in /sis/branches/Android: ./ ide-project/ ide-project/NetBeans/ ide-project/NetBeans/nbproject/ ide-project/eclipse/ sis-app/src/main/java/org/apache/sis/cli/ sis-build-helper/ sis-build-helper/src/main/java/org/apache/sis... Date: Thu, 09 May 2013 12:24:20 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130509122447.AF95F2388A64@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java [UTF-8] Thu May 9 12:24:13 2013 @@ -30,22 +30,30 @@ import org.opengis.metadata.extent.Geogr import org.opengis.referencing.cs.CoordinateSystemAxis; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.util.FactoryException; -import org.apache.sis.util.resources.Errors; +import org.apache.sis.util.ArraysExt; import org.apache.sis.util.CharSequences; +import org.apache.sis.util.resources.Errors; import org.apache.sis.referencing.CRS; -import static org.apache.sis.util.Arrays.resize; import static org.apache.sis.util.ArgumentChecks.*; import static org.apache.sis.math.MathFunctions.isNegative; import static org.apache.sis.internal.referencing.Utilities.isPoleToPole; // Related to JDK7 -import org.apache.sis.internal.util.Objects; +import org.apache.sis.internal.jdk7.Objects; /** - * Base class of envelopes backed by an array. - * See {@link GeneralEnvelope} javadoc for more information. + * Base class of envelopes backed by an array. The ordinate values are stored in the {@link #ordinates} array. + * The ordinate values of the lower corner are stored in the array portion from index {@link #beginIndex()} + * inclusive to index {@link #endIndex()} exclusive. The ordinate values of the upper corner are stored in + * the array portion from index {@code beginIndex() + d} inclusive to index {@code endIndex() + d} exclusive + * where {@code d = ordinates.length >>> 1}. + * + *

Unless otherwise indicated by a "{@code // Must be overridden in SubEnvelope}" comment, every methods + * in {@code ArrayEnvelope} and subclasses must take in account the {@code beginIndex} and {@code endIndex} + * bounds. A few methods ignore the bounds for performance reason, so they need a dedicated implementation + * in {@link SubEnvelope}.

* * @author Martin Desruisseaux (IRD, Geomatys) * @since 0.3 (derived from geotk-2.4) @@ -56,12 +64,12 @@ class ArrayEnvelope extends AbstractEnve /** * Serial number for inter-operability with different versions. */ - private static final long serialVersionUID = 7284917239693486738L; + private static final long serialVersionUID = 1657970968782634545L; /** - * Ordinate values of lower and upper corners. The length of this array is twice the - * number of dimensions. The first half contains the lower corner, while the second - * half contains the upper corner. + * Ordinate values of lower and upper corners. Except for {@link SubEnvelope}, the length of + * this array is twice the number of dimensions. The first half contains the lower corner, + * while the second half contains the upper corner. */ final double[] ordinates; @@ -71,6 +79,17 @@ class ArrayEnvelope extends AbstractEnve CoordinateReferenceSystem crs; /** + * Creates a new envelope using the given array of ordinate values. This constructor stores + * the given reference directly; it does not clone the given array. This is + * the desired behavior for proper working of {@link SubEnvelope}. + * + * @param ordinates The array of ordinate values to store directly (not cloned). + */ + ArrayEnvelope(final double[] ordinates) { + this.ordinates = ordinates; + } + + /** * 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. @@ -139,20 +158,14 @@ class ArrayEnvelope extends AbstractEnve */ public ArrayEnvelope(final Envelope envelope) { ensureNonNull("envelope", envelope); - if (envelope instanceof ArrayEnvelope) { - final ArrayEnvelope e = (ArrayEnvelope) envelope; - ordinates = e.ordinates.clone(); - crs = e.crs; - } else { - crs = envelope.getCoordinateReferenceSystem(); - final int dimension = envelope.getDimension(); - ordinates = new double[dimension * 2]; - final DirectPosition lowerCorner = envelope.getLowerCorner(); - final DirectPosition upperCorner = envelope.getUpperCorner(); - for (int i=0; iWell Known Text (WKT) format. The given string is typically a {@code BOX} - * element like below: + * {@code BOX} or Well Known Text (WKT) format. The given string is typically + * a {@code BOX} element like below: * * {@preformat wkt * BOX(-180 -90, 180 90) * } * * However this constructor is lenient to other geometry types like {@code POLYGON}. - * See the javadoc of the {@link GeneralEnvelope#GeneralEnvelope(String) GeneralEnvelope} + * See the javadoc of the {@link GeneralEnvelope#GeneralEnvelope(CharSequence) GeneralEnvelope} * constructor for more information. * * @param wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse. @@ -279,7 +292,7 @@ scanNumber: while ((i += Character.charC } if (levelParenth != 0) fail(wkt, ')'); if (levelBracket != 0) fail(wkt, ']'); - ordinates = resize(minimum, maxDimension << 1); + ordinates = ArraysExt.resize(minimum, maxDimension << 1); System.arraycopy(maximum, 0, ordinates, maxDimension, maxDimension); } @@ -312,14 +325,47 @@ scanNumber: while ((i += Character.charC } /** + * Returns the index of the first valid ordinate value of the lower corner in the {@link #ordinates} array. + * This is always 0, unless this envelope is a {@link SubEnvelope}. + * + *

See {@link #endIndex()} for the list of methods that need to be also overridden + * if this {@code beginIndex()} method is overridden.

+ */ + int beginIndex() { + return 0; + } + + /** + * Returns the index after the last valid ordinate value of the lower corner in the {@link #ordinates} array. + * This is always {@code ordinates.length >>> 1}, unless this envelope is a {@link SubEnvelope}. + * + *

Unless otherwise indicated by a "{@code // Must be overridden in SubEnvelope}" comment, every methods + * in {@code ArrayEnvelope} and subclasses must take in account the {@code beginIndex} and {@code endIndex} + * bounds. The methods listed below ignore the bounds for performance reason, so they need to be overridden + * in {@link SubEnvelope}:

+ * + *
    + *
  • {@link #getDimension()}
  • + *
  • {@link #getLower(int)}
  • + *
  • {@link #getUpper(int)}
  • + *
  • {@link #isAllNaN()}
  • + *
  • {@link #hashCode()}
  • + *
  • {@link #equals(Object)}
  • + *
+ */ + int endIndex() { + return ordinates.length >>> 1; + } + + /** * Returns the length of coordinate sequence (the number of entries) in this envelope. * This information is available even when the {@linkplain #getCoordinateReferenceSystem() * coordinate reference system} is unknown. * * @return The dimensionality of this envelope. */ - @Override - public final int getDimension() { + @Override // Must also be overridden in SubEnvelope + public int getDimension() { return ordinates.length >>> 1; } @@ -331,7 +377,7 @@ scanNumber: while ((i += Character.charC * @return The envelope CRS, or {@code null} if unknown. */ @Override - public final CoordinateReferenceSystem getCoordinateReferenceSystem() { + public CoordinateReferenceSystem getCoordinateReferenceSystem() { assert crs == null || crs.getCoordinateSystem().getDimension() == getDimension(); return crs; } @@ -339,7 +385,7 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override + @Override // Must also be overridden in SubEnvelope public double getLower(final int dimension) throws IndexOutOfBoundsException { ensureValidIndex(ordinates.length >>> 1, dimension); return ordinates[dimension]; @@ -348,11 +394,11 @@ scanNumber: while ((i += Character.charC /** * {@inheritDoc} */ - @Override + @Override // Must also be overridden in SubEnvelope public double getUpper(final int dimension) throws IndexOutOfBoundsException { - final int dim = ordinates.length >>> 1; - ensureValidIndex(dim, dimension); - return ordinates[dimension + dim]; + final int d = ordinates.length >>> 1; + ensureValidIndex(d, dimension); + return ordinates[dimension + d]; } /** @@ -360,10 +406,10 @@ scanNumber: while ((i += Character.charC */ @Override public double getMinimum(final int dimension) throws IndexOutOfBoundsException { - final int dim = ordinates.length >>> 1; - ensureValidIndex(dim, dimension); - double lower = ordinates[dimension]; - if (isNegative(ordinates[dimension + dim] - lower)) { // Special handling for -0.0 + ensureValidIndex(endIndex(), dimension); + final int i = dimension + beginIndex(); + double lower = ordinates[i]; + if (isNegative(ordinates[i + (ordinates.length >>> 1)] - lower)) { // Special handling for -0.0 final CoordinateSystemAxis axis = getAxis(crs, dimension); lower = (axis != null) ? axis.getMinimumValue() : Double.NEGATIVE_INFINITY; } @@ -375,10 +421,10 @@ scanNumber: while ((i += Character.charC */ @Override public double getMaximum(final int dimension) throws IndexOutOfBoundsException { - final int dim = ordinates.length >>> 1; - ensureValidIndex(dim, dimension); - double upper = ordinates[dimension + dim]; - if (isNegative(upper - ordinates[dimension])) { // Special handling for -0.0 + ensureValidIndex(endIndex(), dimension); + final int i = dimension + beginIndex(); + double upper = ordinates[i + (ordinates.length >>> 1)]; + if (isNegative(upper - ordinates[i])) { // Special handling for -0.0 final CoordinateSystemAxis axis = getAxis(crs, dimension); upper = (axis != null) ? axis.getMaximumValue() : Double.POSITIVE_INFINITY; } @@ -390,9 +436,10 @@ scanNumber: while ((i += Character.charC */ @Override public double getMedian(final int dimension) throws IndexOutOfBoundsException { - ensureValidIndex(ordinates.length >>> 1, dimension); - final double minimum = ordinates[dimension]; - final double maximum = ordinates[dimension + (ordinates.length >>> 1)]; + ensureValidIndex(endIndex(), dimension); + final int i = dimension + beginIndex(); + final double minimum = ordinates[i]; + final double maximum = ordinates[i + (ordinates.length >>> 1)]; double median = 0.5 * (minimum + maximum); if (isNegative(maximum - minimum)) { // Special handling for -0.0 median = fixMedian(getAxis(crs, dimension), median); @@ -405,8 +452,9 @@ scanNumber: while ((i += Character.charC */ @Override public double getSpan(final int dimension) throws IndexOutOfBoundsException { - ensureValidIndex(ordinates.length >>> 1, dimension); - double span = ordinates[dimension + (ordinates.length >>> 1)] - ordinates[dimension]; + ensureValidIndex(endIndex(), dimension); + final int i = dimension + beginIndex(); + double span = ordinates[i + (ordinates.length >>> 1)] - ordinates[i]; if (isNegative(span)) { // Special handling for -0.0 span = fixSpan(getAxis(crs, dimension), span); } @@ -418,27 +466,29 @@ scanNumber: while ((i += Character.charC */ @Override public boolean isEmpty() { - final int dimension = ordinates.length >>> 1; - if (dimension == 0) { + final int beginIndex = beginIndex(); + final int endIndex = endIndex(); + if (beginIndex == endIndex) { return true; } - for (int i=0; i>> 1; + for (int i=beginIndex; i 0)) { // Use '!' in order to catch NaN - if (!(isNegative(span) && isWrapAround(crs, i))) { + if (!(isNegative(span) && isWrapAround(crs, i - beginIndex))) { return true; } } } - assert !isNull() : this; + assert !isAllNaN() : this; return false; } /** * {@inheritDoc} */ - @Override - public boolean isNull() { + @Override // Must also be overridden in SubEnvelope + public boolean isAllNaN() { for (int i=0; iclass javadoc for details. * + * @param crs The coordinate reference system, or {@code null}. * @param x The first ordinate value (not necessarily horizontal). * @param y The second ordinate value (not necessarily vertical). - * @param crs The coordinate reference system, or {@code null}. */ - public DirectPosition2D(final double x, final double y, final CoordinateReferenceSystem crs) { + public DirectPosition2D(final CoordinateReferenceSystem crs, final double x, final double y) { super(x, y); this.crs = crs; ensureDimensionMatches("crs", 2, crs); Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] Thu May 9 12:24:13 2013 @@ -49,7 +49,7 @@ import static org.apache.sis.geometry.Ab import static org.apache.sis.geometry.AbstractEnvelope.isNegativeUnsafe; // Related to JDK7 -import org.apache.sis.internal.util.Objects; +import org.apache.sis.internal.jdk7.Objects; /** @@ -108,7 +108,7 @@ public class Envelope2D extends Rectangl /** * Serial number for inter-operability with different versions. */ - private static final long serialVersionUID = -3319231220761419350L; + private static final long serialVersionUID = 761232175464415062L; /** * The coordinate reference system, or {@code null}. @@ -147,7 +147,7 @@ public class Envelope2D extends Rectangl final DirectPosition upperCorner) { /* - * JDK constraint: The call to ensureDimensionMatch(…) should have been first if Sun/Oracle + * 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), @@ -170,7 +170,7 @@ public class Envelope2D extends Rectangl public Envelope2D(final DirectPosition lowerCorner, final DirectPosition upperCorner) throws MismatchedReferenceSystemException, MismatchedDimensionException { - // The call to getCommonCRS(…) performs a check against null values. + // The call to getCommonCRS(…) performs a check against null values. this(getCommonCRS(lowerCorner, upperCorner), lowerCorner, upperCorner); } @@ -216,11 +216,11 @@ public class Envelope2D extends Rectangl * If the given rectangle has negative width or height, they will be interpreted * as an envelope spanning the anti-meridian. * - * @param rect The rectangle to copy (can not be {@code null}). * @param crs The coordinate reference system, or {@code null}. + * @param rect The rectangle to copy (can not be {@code null}). * @throws MismatchedDimensionException If the given CRS is not two-dimensional. */ - public Envelope2D(final Rectangle2D rect, final CoordinateReferenceSystem crs) + public Envelope2D(final CoordinateReferenceSystem crs, final Rectangle2D rect) throws MismatchedDimensionException { super(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); // Really 'super', not 'this'. @@ -243,8 +243,8 @@ public class Envelope2D extends Rectangl * @param height The envelope height. May be negative for envelope spanning the anti-meridian. * @throws MismatchedDimensionException If the given CRS is not two-dimensional. */ - public Envelope2D(final double x, final double y, final double width, final double height, - final CoordinateReferenceSystem crs) throws MismatchedDimensionException + public Envelope2D(final CoordinateReferenceSystem crs, final double x, final double y, + final double width, final double height) throws MismatchedDimensionException { super(x, y, width, height); // Really 'super', not 'this'. ensureDimensionMatches("crs", 2, crs); @@ -302,7 +302,7 @@ public class Envelope2D extends Rectangl */ @Override public DirectPosition2D getLowerCorner() { - return new DirectPosition2D(x, y, crs); + return new DirectPosition2D(crs, x, y); } /** @@ -325,7 +325,7 @@ public class Envelope2D extends Rectangl */ @Override public DirectPosition2D getUpperCorner() { - return new DirectPosition2D(x+width, y+height, crs); + return new DirectPosition2D(crs, x+width, y+height); } /** @@ -691,7 +691,7 @@ public class Envelope2D extends Rectangl @Override public Envelope2D createIntersection(final Rectangle2D rect) { final Envelope2D env = (rect instanceof Envelope2D) ? (Envelope2D) rect : null; - final Envelope2D inter = new Envelope2D(NaN, NaN, NaN, NaN, crs); + final Envelope2D inter = new Envelope2D(crs, NaN, NaN, NaN, NaN); for (int i=0; i!=2; i++) { final double min0, min1, span0, span1; if (i == 0) { @@ -965,16 +965,16 @@ public class Envelope2D extends Rectangl } /** - * Formats this envelope in the Well Known Text (WKT) format. - * The output is of the form "{@code BOX2D(}{@linkplain #getLowerCorner() + * Formats this envelope as a "{@code BOX}" element. + * The output is of the form "{@code BOX(}{@linkplain #getLowerCorner() * lower corner}{@code ,}{@linkplain #getUpperCorner() upper corner}{@code )}". * Example: * * {@preformat wkt - * BOX3D(-90 -180, 90 180) + * BOX(-90 -180, 90 180) * } * - * @see Envelopes#toWKT(Envelope) + * @see Envelopes#toString(Envelope) */ @Override public String toString() { Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java [UTF-8] Thu May 9 12:24:13 2013 @@ -32,7 +32,7 @@ import org.apache.sis.util.resources.Err import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches; // JDK7 related -import org.apache.sis.internal.util.Objects; +import org.apache.sis.internal.jdk7.Objects; /** @@ -61,7 +61,7 @@ public class GeneralDirectPosition exten /** * Serial number for inter-operability with different versions. */ - private static final long serialVersionUID = 9071833698385715524L; + private static final long serialVersionUID = -5524426558018300122L; /** * The ordinates of the direct position. The length of this array is the @@ -201,7 +201,7 @@ public class GeneralDirectPosition exten /** * Sets the ordinate values along all dimensions. * - * @param ordinates The new ordinates values, or a {@code null} array + * @param ordinates The new ordinates values, or a {@code null} array * for setting all ordinate values to {@link Double#NaN NaN}. * @throws MismatchedDimensionException If the length of the specified array is not * equals to the {@linkplain #getDimension() dimension} of this position. @@ -247,7 +247,7 @@ public class GeneralDirectPosition exten * contains a coordinate reference system (CRS), then the CRS for this position will * be set to the CRS of the specified position. * - * @param position The new position for this point, or {@code null} for setting all ordinate + * @param position The new position for this point, or {@code null} for setting all ordinate * values to {@link Double#NaN NaN}. * @throws MismatchedDimensionException if the given position doesn't have the expected dimension. */ Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralDirectPosition.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] Thu May 9 12:24:13 2013 @@ -54,14 +54,14 @@ import static org.apache.sis.math.MathFu * coordinates of an arbitrary number of dimensions. This is in contrast with * {@link Envelope2D}, which can use only two-dimensional coordinates. * - *

A {@code GeneralEnvelope} can be created in various ways:

+ *

A {@code GeneralEnvelope} can be created in various ways:

*
    *
  • {@linkplain #GeneralEnvelope(int) From a given number of dimension}, with all ordinates initialized to 0.
  • *
  • {@linkplain #GeneralEnvelope(double[], double[]) From two coordinate points}.
  • *
  • {@linkplain #GeneralEnvelope(Envelope) From a an other envelope} (copy constructor).
  • *
  • {@linkplain #GeneralEnvelope(GeographicBoundingBox) From a geographic bounding box}.
  • *
  • {@linkplain #GeneralEnvelope(CharSequence) From a character sequence} - * representing a {@code BBOX} in Well Known Text (WKT) format.
  • + * representing a {@code BBOX} or a Well Known Text (WKT) format. *
* * {@section Spanning the anti-meridian of a Geographic CRS} @@ -102,7 +102,7 @@ public class GeneralEnvelope extends Arr /** * Serial number for inter-operability with different versions. */ - private static final long serialVersionUID = 1752330560227688940L; + private static final long serialVersionUID = 3796799507279068254L; /** * Used for setting the {@link #ordinates} field during a {@link #clone()} operation only. @@ -111,6 +111,17 @@ public class GeneralEnvelope extends Arr private static volatile Field ordinatesField; /** + * Creates a new envelope using the given array of ordinate values. This constructor stores + * the given reference directly; it does not clone the given array. This is + * the desired behavior for proper working of {@link SubEnvelope}. + * + * @param ordinates The array of ordinate values to store directly (not cloned). + */ + GeneralEnvelope(final double[] ordinates) { + super(ordinates); + } + + /** * 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. @@ -181,8 +192,8 @@ public class GeneralEnvelope extends Arr /** * Constructs a new envelope initialized to the values parsed from the given string in - * Well Known Text (WKT) format. The given string is typically a {@code BOX} - * element like below: + * {@code BOX} or Well Known Text (WKT) format. The given string is typically + * a {@code BOX} element like below: * * {@preformat wkt * BOX(-180 -90, 180 90) @@ -200,11 +211,11 @@ public class GeneralEnvelope extends Arr *
  • The coordinate having the highest dimension determines the dimension of this envelope.
  • * * - * This constructor does not check the consistency of the provided WKT. For example it doesn't + * This constructor does not check the consistency of the provided text. For example it does not * check that every points in a {@code LINESTRING} have the same dimension. However this * constructor ensures that the parenthesis are balanced, in order to catch some malformed WKT. * - *

    The following examples can be parsed by this constructor in addition of the standard + *

    The following examples can be parsed by this constructor in addition of the usual * {@code BOX} element. This constructor creates the bounding box of those geometries:

    * *
      @@ -216,8 +227,8 @@ public class GeneralEnvelope extends Arr * @param wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse. * @throws IllegalArgumentException If the given string can not be parsed. * - * @see Envelopes#parseWKT(String) - * @see Envelopes#toWKT(Envelope) + * @see Envelopes#fromWKT(CharSequence) + * @see Envelopes#toString(Envelope) */ public GeneralEnvelope(final CharSequence wkt) throws IllegalArgumentException { super(wkt); @@ -269,7 +280,7 @@ public class GeneralEnvelope extends Arr * @param upper The limit in the direction of increasing ordinate values. * @throws IndexOutOfBoundsException If the given index is out of bounds. */ - @Override + @Override // Must also be overridden in SubEnvelope public void setRange(final int dimension, final double lower, final double upper) throws IndexOutOfBoundsException { @@ -282,27 +293,37 @@ public class GeneralEnvelope extends Arr /** * Sets the envelope to the specified values, which must be the lower corner coordinates * followed by upper corner coordinates. The number of arguments provided shall be twice - * this {@linkplain #getDimension envelope dimension}, and minimum shall not be greater + * this {@linkplain #getDimension() envelope dimension}, and minimum shall not be greater * than maximum. * *

      Example:

      * (xmin, ymin, zmin, * xmax, ymax, zmax) * - * @param ordinates The new ordinate values. + * @param corners Ordinates of the new lower corner followed by the new upper corner. + */ + public void setEnvelope(final double... corners) { + verifyArrayLength(ordinates.length >>> 1, corners); + System.arraycopy(corners, 0, ordinates, 0, ordinates.length); + } + + /** + * Verifies that the given array of ordinate values has the expected length + * for the given number of dimensions. + * + * @param dimension The dimension of the envelope. + * @param corners The user-provided array of ordinate values. */ - public void setEnvelope(final double... ordinates) { - if ((ordinates.length & 1) != 0) { + static void verifyArrayLength(final int dimension, final double[] corners) { + if ((corners.length & 1) != 0) { throw new IllegalArgumentException(Errors.format( - Errors.Keys.OddArrayLength_1, ordinates.length)); + Errors.Keys.OddArrayLength_1, corners.length)); } - final int dimension = ordinates.length >>> 1; - final int expected = this.ordinates.length >>> 1; - if (dimension != expected) { + final int d = corners.length >>> 1; + if (d != dimension) { throw new MismatchedDimensionException(Errors.format( - Errors.Keys.MismatchedDimension_3, "ordinates", expected, dimension)); + Errors.Keys.MismatchedDimension_3, "ordinates", dimension, d)); } - System.arraycopy(ordinates, 0, this.ordinates, 0, ordinates.length); } /** @@ -316,17 +337,17 @@ public class GeneralEnvelope extends Arr */ public void setEnvelope(final Envelope envelope) throws MismatchedDimensionException { ensureNonNull("envelope", envelope); - final int dimension = ordinates.length >>> 1; + final int beginIndex = beginIndex(); + final int dimension = endIndex() - beginIndex; ensureDimensionMatches("envelope", dimension, envelope); - if (envelope instanceof ArrayEnvelope) { - System.arraycopy(((ArrayEnvelope) envelope).ordinates, 0, ordinates, 0, ordinates.length); - } else { - final DirectPosition lower = envelope.getLowerCorner(); - final DirectPosition upper = envelope.getUpperCorner(); - for (int i=0; i>> 1; + for (int i=0; i>> 1; - Arrays.fill(ordinates, 0, mid, Double.NEGATIVE_INFINITY); - Arrays.fill(ordinates, mid, ordinates.length, Double.POSITIVE_INFINITY); + final int beginIndex = beginIndex(); + final int endIndex = endIndex(); + final int d = ordinates.length >>> 1; + Arrays.fill(ordinates, beginIndex, endIndex, Double.NEGATIVE_INFINITY); + Arrays.fill(ordinates, beginIndex+d, endIndex+d, Double.POSITIVE_INFINITY); } /** @@ -353,11 +376,12 @@ public class GeneralEnvelope extends Arr * The {@linkplain #getCoordinateReferenceSystem() coordinate reference system} * (if any) stay unchanged. * - * @see #isNull() + * @see #isAllNaN() */ - public void setToNull() { + // Must be overridden in SubEnvelope + public void setToNaN() { Arrays.fill(ordinates, Double.NaN); - assert isNull() : this; + assert isAllNaN() : this; } /** @@ -368,12 +392,12 @@ public class GeneralEnvelope extends Arr * @param array The array which contains the ordinate values. * @param offset Index of the first valid ordinate value in the given array. */ - final void add(final double[] array, final int offset) { - final int dim = ordinates.length >>> 1; - for (int i=0; i>> 1; + for (int i=0; i ordinates[i+dim]) ordinates[i+dim] = value; + if (value < ordinates[i ]) ordinates[i ] = value; + if (value > ordinates[i+d]) ordinates[i+d] = value; } } @@ -394,8 +418,8 @@ public class GeneralEnvelope extends Arr * new point is represented by the {@code +} symbol): * * {@preformat text - * ─────┐ + ┌───── - * ─────┘ └───── + * ─────┐ + ┌───── + * ─────┘ └───── * } * * The default implementation moves only the border which is closest to the given point. @@ -406,23 +430,27 @@ public class GeneralEnvelope extends Arr */ public void add(final DirectPosition position) throws MismatchedDimensionException { ensureNonNull("position", position); - final int dim = ordinates.length >>> 1; - ensureDimensionMatches("position", dim, position); + final int beginIndex = beginIndex(); + final int dimension = endIndex() - beginIndex; + ensureDimensionMatches("position", dimension, position); assert equalsIgnoreMetadata(crs, position.getCoordinateReferenceSystem(), true) : position; - for (int i=0; i>> 1; + for (int i=0; i max) ordinates[i+dim] = value; + if (value < min) ordinates[iLower] = value; + if (value > max) ordinates[iUpper] = value; } else { /* - * Spanning the anti-meridian. The [max…min] range (not that min/max are + * Spanning the anti-meridian. The [max…min] range (not that min/max are * interchanged) is actually an exclusion area. Changes only the closest * side. */ - addToClosest(i, value, max, min); + addToClosest(iLower, value, max, min); } } assert contains(position) || isEmpty() || hasNaN(position) : position; @@ -434,8 +462,8 @@ public class GeneralEnvelope extends Arr * symbol. The point is added only on the closest side. * * {@preformat text - * ─────┐ + ┌───── - * ─────┘ └───── + * ─────┐ + ┌───── + * ─────┘ └───── * } * * @param i The dimension of the ordinate @@ -466,7 +494,7 @@ public class GeneralEnvelope extends Arr * {@section Spanning the anti-meridian of a Geographic CRS} * This method supports envelopes spanning the anti-meridian. If one or both envelopes span * the anti-meridian, then the result of the {@code add} operation may be an envelope expanding - * to infinities. In such case, the ordinate range will be either [-∞…∞] or [0…-0] depending on + * to infinities. In such case, the ordinate range will be either [-∞…∞] or [0…-0] depending on * whatever the original range span the anti-meridian or not. * * @param envelope the {@code Envelope} to add to this envelope. @@ -476,14 +504,18 @@ public class GeneralEnvelope extends Arr */ public void add(final Envelope envelope) throws MismatchedDimensionException { ensureNonNull("envelope", envelope); - final int dim = ordinates.length >>> 1; - ensureDimensionMatches("envelope", dim, envelope); + final int beginIndex = beginIndex(); + final int dimension = endIndex() - beginIndex; + ensureDimensionMatches("envelope", dimension, envelope); assert equalsIgnoreMetadata(crs, envelope.getCoordinateReferenceSystem(), true) : envelope; final DirectPosition lower = envelope.getLowerCorner(); final DirectPosition upper = envelope.getUpperCorner(); - for (int i=0; i>> 1; + for (int i=0; i max0) ordinates[i+dim] = max1; - if (!sp0 || isNegativeUnsafe(ordinates[i+dim] - ordinates[i])) { + if (min1 < min0) ordinates[iLower] = min1; + if (max1 > max0) ordinates[iUpper] = max1; + if (!sp0 || isNegativeUnsafe(ordinates[iUpper] - ordinates[iLower])) { continue; // We are done, go to the next dimension. } // If we were spanning the anti-meridian before the union but @@ -517,10 +549,10 @@ public class GeneralEnvelope extends Arr * Only this envelope spans the anti-meridian; the given envelope is normal or * has NaN values. First we need to exclude the cases were the given envelope * is fully included in this envelope: - * ──────────┐ ┌───── - * ┌────┐ │ │ - * └────┘ │ │ - * ──────────┘ └───── + * ──────────┐ ┌───── + * ┌────┐ │ │ + * └────┘ │ │ + * ──────────┘ └───── */ if (max1 <= max0) continue; // This is the case of above picture. if (min1 >= min0) continue; // Like above picture, but on the right side. @@ -528,18 +560,18 @@ public class GeneralEnvelope extends Arr * At this point, the given envelope partially overlaps the "exclusion area" * of this envelope or has NaN values. We will move at most one edge of this * envelope, in order to leave as much free space as possible. - * ─────┐ ┌───── - * ┌─┼────┐ │ - * └─┼────┘ │ - * ─────┘ └───── + * ─────┐ ┌───── + * ┌─┼────┐ │ + * └─┼────┘ │ + * ─────┘ └───── */ final double left = min1 - max0; final double right = min0 - max1; if (left > 0 || right > 0) { // The < and > checks below are not completly redundant. // The difference is when a value is NaN. - if (left > right) ordinates[i ] = min1; - if (right > left) ordinates[i+dim] = max1; // This is the case illustrated above. + if (left > right) ordinates[iLower] = min1; + if (right > left) ordinates[iUpper] = max1; // This is the case illustrated above. continue; // We are done, go to the next dimension. } // If we reach this point, the given envelope fills completly the "exclusion area" @@ -551,15 +583,15 @@ public class GeneralEnvelope extends Arr * given envelope spans to infinities. */ if (max0 <= max1 || min0 >= min1) { - ordinates[i] = min1; - ordinates[i+dim] = max1; + ordinates[iLower] = min1; + ordinates[iUpper] = max1; continue; } final double left = min0 - max1; final double right = min1 - max0; if (left > 0 || right > 0) { - if (left > right) ordinates[i+dim] = max1; - if (right > left) ordinates[i ] = min1; + if (left > right) ordinates[iUpper] = max1; + if (right > left) ordinates[iLower] = min1; continue; } } @@ -569,11 +601,11 @@ public class GeneralEnvelope extends Arr * the "normal" / "anti-meridian spanning" state. */ if (sp0) { - ordinates[i ] = +0.0; - ordinates[i+dim] = -0.0; + ordinates[iLower] = +0.0; + ordinates[iUpper] = -0.0; } else { - ordinates[i ] = Double.NEGATIVE_INFINITY; - ordinates[i+dim] = Double.POSITIVE_INFINITY; + ordinates[iLower] = Double.NEGATIVE_INFINITY; + ordinates[iUpper] = Double.POSITIVE_INFINITY; } } assert contains(envelope, true) || isEmpty() || hasNaN(envelope) : this; @@ -595,14 +627,18 @@ public class GeneralEnvelope extends Arr */ public void intersect(final Envelope envelope) throws MismatchedDimensionException { ensureNonNull("envelope", envelope); - final int dim = ordinates.length >>> 1; - ensureDimensionMatches("envelope", dim, envelope); + final int beginIndex = beginIndex(); + final int dimension = endIndex() - beginIndex; + ensureDimensionMatches("envelope", dimension, envelope); assert equalsIgnoreMetadata(crs, envelope.getCoordinateReferenceSystem(), true) : envelope; final DirectPosition lower = envelope.getLowerCorner(); final DirectPosition upper = envelope.getUpperCorner(); - for (int i=0; i>> 1; + for (int i=beginIndex; i max0 || max1 < min0) && !isNegativeUnsafe(span0)) { /* * The check for !isNegative(span0) is because if both envelopes span the * anti-merdian, then there is always an intersection on both side no matter * what envelope ordinates are because both envelopes extend toward infinities: - * ────┐ ┌──── ────┐ ┌──── - * ──┐ │ │ ┌── or ────┼──┼─┐┌─ - * ──┘ │ │ └── ────┼──┼─┘└─ - * ────┘ └──── ────┘ └──── + * ────┐ ┌──── ────┐ ┌──── + * ──┐ │ │ ┌── or ────┼──┼─┐┌─ + * ──┘ │ │ └── ────┼──┼─┘└─ + * ────┘ └──── ────┘ └──── * Since we excluded the above case, entering in this block means that the * envelopes are "normal" and do not intersect, so we set ordinates to NaN. - * ┌────┐ - * │ │ ┌────┐ - * │ │ └────┘ - * └────┘ + * ┌────┐ + * │ │ ┌────┐ + * │ │ └────┘ + * └────┘ */ - ordinates[i] = ordinates[i+dim] = Double.NaN; + ordinates[iLower] = ordinates[iUpper] = Double.NaN; continue; } } else { @@ -641,13 +677,13 @@ public class GeneralEnvelope extends Arr /* * The first line below checks for the case illustrated below. The second * line does the same check, but with the small rectangle on the right side. - * ─────┐ ┌───── ──────────┐ ┌───── - * ┌─┼────┐ │ or ┌────┐ │ │ - * └─┼────┘ │ └────┘ │ │ - * ─────┘ └───── ──────────┘ └───── + * ─────┐ ┌───── ──────────┐ ┌───── + * ┌─┼────┐ │ or ┌────┐ │ │ + * └─┼────┘ │ └────┘ │ │ + * ─────┘ └───── ──────────┘ └───── */ - if (min1 <= max0) {intersect = 1; ordinates[i ] = min1;} - if (max1 >= min0) {intersect |= 2; ordinates[i+dim] = max1;} + if (min1 <= max0) {intersect = 1; ordinates[iLower] = min1;} + if (max1 >= min0) {intersect |= 2; ordinates[iUpper] = max1;} } else { // Same than above, but with indices 0 and 1 interchanged. // No need to set ordinate values since they would be the same. @@ -660,20 +696,20 @@ public class GeneralEnvelope extends Arr * only the ordinate value which has not been set by the above code. * * [intersect=0] [intersect=3] - * ─────┐ ┌───── ─────┐ ┌───── - * negative: max0│ ┌─┐ │min0 ┌─┼─────┼─┐ - * │ └─┘ │ └─┼─────┼─┘ - * ─────┘ └───── ─────┘ └───── + * ─────┐ ┌───── ─────┐ ┌───── + * negative: max0│ ┌─┐ │min0 ┌─┼─────┼─┐ + * │ └─┘ │ └─┼─────┼─┘ + * ─────┘ └───── ─────┘ └───── * - * max1 ┌─┐ min1 ┌─────────┐ - * positive: ─────┐ │ │ ┌───── ───┼─┐ ┌─┼─── - * ─────┘ │ │ └───── ───┼─┘ └─┼─── - * └─┘ └─────────┘ + * max1 ┌─┐ min1 ┌─────────┐ + * positive: ─────┐ │ │ ┌───── ───┼─┐ ┌─┼─── + * ─────┘ │ │ └───── ───┼─┘ └─┼─── + * └─┘ └─────────┘ */ switch (intersect) { default: throw new AssertionError(intersect); - case 1: if (max1 < max0) ordinates[i+dim] = max1; break; - case 2: if (min1 > min0) ordinates[i ] = min1; break; + case 1: if (max1 < max0) ordinates[iUpper] = max1; break; + case 2: if (min1 > min0) ordinates[iLower] = min1; break; case 3: // Fall through case 0: { // Before to declare the intersection as invalid, verify if the envelope @@ -691,15 +727,15 @@ public class GeneralEnvelope extends Arr min = Double.NaN; max = Double.NaN; } - ordinates[i] = min; - ordinates[i+dim] = max; + ordinates[iLower] = min; + ordinates[iUpper] = max; break; } } continue; } - if (min1 > min0) ordinates[i ] = min1; - if (max1 < max0) ordinates[i+dim] = max1; + if (min1 > min0) ordinates[iLower] = min1; + if (max1 < max0) ordinates[iUpper] = max1; } // Tests only if the interection result is non-empty. assert isEmpty() || AbstractEnvelope.castOrCopy(envelope).contains(this, true) : this; @@ -720,11 +756,11 @@ public class GeneralEnvelope extends Arr * are replaced by the axis minimum. * *
    • If {@link RangeMeaning#WRAPAROUND} (typically longitudes ordinates), then - * a multiple of the axis range (e.g. 360° for longitudes) is added or subtracted. + * a multiple of the axis range (e.g. 360° for longitudes) is added or subtracted. * Example: *
        - *
      • the [190 … 200]° longitude range is converted to [-170 … -160]°,
      • - *
      • the [170 … 200]° longitude range is converted to [+170 … -160]°.
      • + *
      • the [190 … 200]° longitude range is converted to [-170 … -160]°,
      • + *
      • the [170 … 200]° longitude range is converted to [+170 … -160]°.
      • *
      * See Spanning the anti-meridian of a Geographic CRS in the * class javadoc for more information about the meaning of such range.
    • @@ -743,7 +779,7 @@ public class GeneralEnvelope extends Arr * } * * {@section Choosing the range of longitude values} - * Geographic CRS typically have longitude values in the [-180 … +180]° range, but the [0 … 360]° + * Geographic CRS typically have longitude values in the [-180 … +180]° range, but the [0 … 360]° * range is also occasionally used. Callers need to ensure that this envelope CRS is associated * to axes having the desired {@linkplain CoordinateSystemAxis#getMinimumValue() minimum} and * {@linkplain CoordinateSystemAxis#getMaximumValue() maximum value}. @@ -761,47 +797,50 @@ public class GeneralEnvelope extends Arr public boolean normalize() { boolean changed = false; if (crs != null) { - final int dimension = ordinates.length >>> 1; + final int d = ordinates.length >>> 1; + final int beginIndex = beginIndex(); + final int dimension = endIndex() - beginIndex; final CoordinateSystem cs = crs.getCoordinateSystem(); for (int i=0; i maximum) {ordinates[j] = maximum; changed = true;} + if (ordinates[iLower] < minimum) {ordinates[iLower] = minimum; changed = true;} + if (ordinates[iUpper] > maximum) {ordinates[iUpper] = maximum; changed = true;} } else if (RangeMeaning.WRAPAROUND.equals(rm)) { final double csSpan = maximum - minimum; if (csSpan > 0 && csSpan < Double.POSITIVE_INFINITY) { - double o1 = ordinates[i]; - double o2 = ordinates[j]; + double o1 = ordinates[iLower]; + double o2 = ordinates[iUpper]; if (Math.abs(o2-o1) >= csSpan) { /* * If the range exceed the CS span, then we have to replace it by the * full span, otherwise the range computed by the "else" block is too - * small. The full range will typically be [-180 … 180]°. However we + * small. The full range will typically be [-180 … 180]°. However we * make a special case if the two bounds are multiple of the CS span, - * typically [0 … 360]°. In this case the [0 … -0]° range matches the + * typically [0 … 360]°. In this case the [0 … -0]° range matches the * original values and is understood by GeneralEnvelope as a range * spanning all the world. */ if (o1 != minimum || o2 != maximum) { if ((o1 % csSpan) == 0 && (o2 % csSpan) == 0) { - ordinates[i] = +0.0; - ordinates[j] = -0.0; + ordinates[iLower] = +0.0; + ordinates[iUpper] = -0.0; } else { - ordinates[i] = minimum; - ordinates[j] = maximum; + ordinates[iLower] = minimum; + ordinates[iUpper] = maximum; } changed = true; } } else { o1 = Math.floor((o1 - minimum) / csSpan) * csSpan; o2 = Math.floor((o2 - minimum) / csSpan) * csSpan; - if (o1 != 0) {ordinates[i] -= o1; changed = true;} - if (o2 != 0) {ordinates[j] -= o2; changed = true;} + if (o1 != 0) {ordinates[iLower] -= o1; changed = true;} + if (o2 != 0) {ordinates[iUpper] -= o2; changed = true;} } } } @@ -835,16 +874,19 @@ public class GeneralEnvelope extends Arr */ public boolean simplify() throws IllegalStateException { boolean changed = false; - final int dimension = ordinates.length >>> 1; + final int d = ordinates.length >>> 1; + final int beginIndex = beginIndex(); + final int dimension = endIndex() - beginIndex; for (int i=0; iThis method is useful for querying and updating only some dimensions. + * For example in order to expand only the horizontal component of a four dimensional + * (x,y,z,t) envelope, one can use:

      + * + * {@preformat java + * envelope.subEnvelope(0, 2).add(myPosition2D); + * } + * + * If the sub-envelope needs to be independent from the original envelope, use the following idiom: + * + * {@preformat java + * GeneralEnvelope copy = envelope.subEnvelope(0, 2).clone(); + * } + * + * The sub-envelope is initialized with a {@code null} {@linkplain #getCoordinateReferenceSystem() CRS}. + * This method does not compute a sub-CRS because it may not be needed, or the sub-CRS may be already + * known by the caller. + * + * @param beginIndex The index of the first valid ordinate value of the corners. + * @param endIndex The index after the last valid ordinate value of the corners. + * @return The sub-envelope of dimension {@code endIndex - beginIndex}. + * @throws IndexOutOfBoundsException If an index is out of bounds. + */ + // Must be overridden in SubEnvelope + public GeneralEnvelope subEnvelope(final int beginIndex, final int endIndex) throws IndexOutOfBoundsException { + ensureValidIndexRange(ordinates.length >>> 1, beginIndex, endIndex); + return new SubEnvelope(ordinates, beginIndex, endIndex); + // Do check if we could return "this" as an optimization, in order to keep the + // method contract simpler (i.e. the returned envelope CRS is always null). + } + + /** * Returns a deep copy of this envelope. * * @return A clone of this envelope. Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java [UTF-8] Thu May 9 12:24:13 2013 @@ -37,7 +37,12 @@ import static org.apache.sis.util.Argume * This class is final in order to ensure that the immutability contract can not be broken * (assuming not using Java Native Interface or reflections). * - * @author Cédric Briançon (Geomatys) + * {@note While ImmutableEnvelope objects are immutable, they contain references to + * CoordinateReferenceSystem objects which are not guaranteed to be immutable. + * For better safety, factory codes are encouraged to pass only immutable instances of + * coordinate reference systems to the constructors.} + * + * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (IRD, Geomatys) * @since 0.3 (derived from geotk-3.00) * @version 0.3 @@ -48,7 +53,7 @@ public final class ImmutableEnvelope ext /** * For cross-version compatibility. */ - private static final long serialVersionUID = 5593936512712449234L; + private static final long serialVersionUID = 8740224085449107870L; /** * Constructs an envelope defined by two corners given as direct positions. @@ -115,12 +120,12 @@ public final class ImmutableEnvelope ext *

      The main purpose of this method is to assign a non-null CRS when the envelope to * copy has a null CRS.

      * - * @param envelope The envelope from which to copy ordinate values. * @param crs The CRS to assign to this envelope, or {@code null}. + * @param envelope The envelope from which to copy ordinate values. * @throws MismatchedDimensionException If the dimension of the given CRS is not equals * to the dimension of the given envelope. */ - public ImmutableEnvelope(final Envelope envelope, final CoordinateReferenceSystem crs) + public ImmutableEnvelope(final CoordinateReferenceSystem crs, final Envelope envelope) throws MismatchedDimensionException { super(envelope); @@ -130,24 +135,24 @@ public final class ImmutableEnvelope ext /** * Constructs a new envelope initialized to the values parsed from the given string in - * Well Known Text (WKT) format. The given string is typically a {@code BOX} - * element like below: + * {@code BOX} or Well Known Text (WKT) format. The given string is typically + * a {@code BOX} element like below: * * {@preformat wkt * BOX(-180 -90, 180 90) * } * * However this constructor is lenient to other geometry types like {@code POLYGON}. - * See the javadoc of the {@link GeneralEnvelope#GeneralEnvelope(String) GeneralEnvelope} + * See the javadoc of the {@link GeneralEnvelope#GeneralEnvelope(CharSequence) GeneralEnvelope} * constructor for more information. * - * @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. + * @param wkt The {@code BOX}, {@code POLYGON} or other kind of element to parse. * @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 CharSequence wkt, final CoordinateReferenceSystem crs) + public ImmutableEnvelope(final CoordinateReferenceSystem crs, final CharSequence wkt) throws IllegalArgumentException, MismatchedDimensionException { super(wkt); Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/ImmutableEnvelope.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java [UTF-8] Thu May 9 12:24:13 2013 @@ -37,6 +37,9 @@ public final class Utilities extends Sta * Default tolerance threshold for comparing ordinate values in a projected CRS, * assuming that the unit of measurement is metre. This is not a tolerance for * testing map projection accuracy. + * + * @see #ANGULAR_TOLERANCE + * @see org.apache.sis.internal.util.Utilities#COMPARISON_THRESHOLD */ public static final double LINEAR_TOLERANCE = 1.0; @@ -44,6 +47,9 @@ public final class Utilities extends Sta * Default tolerance threshold for comparing ordinate values in a geographic CRS, * assuming that the unit of measurement is decimal degrees and using the standard * nautical mile length. + * + * @see #LINEAR_TOLERANCE + * @see org.apache.sis.internal.util.Utilities#COMPARISON_THRESHOLD */ public static final double ANGULAR_TOLERANCE = LINEAR_TOLERANCE / (1852 * 60); Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Utilities.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/internal/referencing/package-info.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Modified: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java URL: http://svn.apache.org/viewvc/sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1480602&r1=1480601&r2=1480602&view=diff ============================================================================== --- sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [iso-8859-1] (original) +++ sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Thu May 9 12:24:13 2013 @@ -54,6 +54,6 @@ public final class CRS extends Static { throws NoSuchAuthorityCodeException, FactoryException { ensureNonNull("code", code); - throw new UnsupportedOperationException("Not yet implemented."); + return null; } } Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/GeoRSSData.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/NodeType.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/QuadTree.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/QuadTreeData.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/QuadTreeNode.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/QuadTreeReader.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/QuadTreeWriter.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/storage/Quadrant.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/main/java/org/apache/sis/util/GeoHashUtils.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/test/java/org/apache/sis/core/TestLatLon.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/test/java/org/apache/sis/core/TestLatLonRect.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8 Propchange: sis/branches/Android/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractDirectPositionTest.java ------------------------------------------------------------------------------ --- svn:mime-type (original) +++ svn:mime-type Thu May 9 12:24:13 2013 @@ -1 +1 @@ -text/plain +text/plain;charset=UTF-8