sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1755402 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/ sis-referencing/src/main/...
Date Sat, 06 Aug 2016 15:50:22 GMT
Author: desruisseaux
Date: Sat Aug  6 15:50:22 2016
New Revision: 1755402

URL: http://svn.apache.org/viewvc?rev=1755402&view=rev
Log:
Ported CRS.getDomainOfValidity(CRS) method. This implied a revision of Extents.getGeographicBoundingBox(Extent).
This commit contains opportunist javadoc formatting.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/InvalidMetadataException.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -23,8 +23,6 @@ import org.apache.sis.xml.IdentifiedObje
 import org.apache.sis.util.Static;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.metadata.InvalidMetadataException;
-import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.internal.util.Utilities;
 
@@ -34,7 +32,7 @@ import org.apache.sis.internal.util.Util
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class MetadataUtilities extends Static {
@@ -67,28 +65,6 @@ public final class MetadataUtilities ext
     }
 
     /**
-     * Makes sure that the given inclusion is non-nil, then returns its value.
-     * If the given inclusion is {@code null}, then the default value is {@code true}.
-     *
-     * @param  value The {@link org.opengis.metadata.extent.GeographicBoundingBox#getInclusion()} value.
-     * @return The given value as a primitive type.
-     * @throws InvalidMetadataException if the given value is nil.
-     */
-    @SuppressWarnings("NumberEquality")
-    public static boolean getInclusion(final Boolean value) throws InvalidMetadataException {
-        if (value == null) {
-            return true;
-        }
-        final boolean p = value;
-        // (value == Boolean.FALSE) is an optimization for a common case avoiding PrimitiveTypeProperties check.
-        // DO NOT REPLACE BY 'equals' OR 'booleanValue()' - the exact reference value matter.
-        if (p || (value == Boolean.FALSE) || !(PrimitiveTypeProperties.property(value) instanceof NilReason)) {
-            return p;
-        }
-        throw new InvalidMetadataException(Errors.format(Errors.Keys.MissingValueForProperty_1, "inclusion"));
-    }
-
-    /**
      * Ensures that the given property value is positive. If the user gave a negative value or (in some case) zero,
      * then this method logs a warning if we are in process of (un)marshalling a XML document or throw an exception
      * otherwise.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/InvalidMetadataException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/InvalidMetadataException.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/InvalidMetadataException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/InvalidMetadataException.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -18,11 +18,11 @@ package org.apache.sis.metadata;
 
 
 /**
- * Thrown when a metadata is in a invalid state, usually because a mandatory property is missing.
+ * Thrown when a metadata is in a invalid state or has illegal property values.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.8
  * @module
  */
 public class InvalidMetadataException extends IllegalStateException {
@@ -34,9 +34,33 @@ public class InvalidMetadataException ex
     /**
      * Creates a new exception with the specified detail message.
      *
-     * @param message The detail message.
+     * @param  message  the details message, or {@code null} if none.
      */
     public InvalidMetadataException(final String message) {
         super(message);
     }
+
+    /**
+     * Creates a new exception with the specified cause.
+     * The details message is copied from the cause.
+     *
+     * @param  cause  the cause, or {@code null} if none.
+     *
+     * @since 0.8
+     */
+    public InvalidMetadataException(final Throwable cause) {
+        super(cause.getLocalizedMessage(), cause);
+    }
+
+    /**
+     * Creates a new exception with the specified detail message and cause.
+     *
+     * @param  message  the details message, or {@code null} if none.
+     * @param  cause    the cause, or {@code null} if none.
+     *
+     * @since 0.8
+     */
+    public InvalidMetadataException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
 }

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -30,8 +30,10 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Vocabulary;
-import org.apache.sis.internal.metadata.MetadataUtilities;
 import org.apache.sis.internal.metadata.ReferencingServices;
+import org.apache.sis.internal.jaxb.PrimitiveTypeProperties;
+import org.apache.sis.metadata.InvalidMetadataException;
+import org.apache.sis.xml.NilReason;
 
 import static java.lang.Double.doubleToLongBits;
 
@@ -100,7 +102,7 @@ import java.util.Objects;
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.8
  * @module
  *
  * @see org.apache.sis.geometry.GeneralEnvelope
@@ -162,12 +164,12 @@ public class DefaultGeographicBoundingBo
      * Java2D world, which is rather (<var>x</var><sub>min</sub>, <var>y</var><sub>min</sub>,
      * <var>x</var><sub>max</sub>, <var>y</var><sub>max</sub>).</p>
      *
-     * @param westBoundLongitude The minimal λ value.
-     * @param eastBoundLongitude The maximal λ value.
-     * @param southBoundLatitude The minimal φ value.
-     * @param northBoundLatitude The maximal φ value.
+     * @param  westBoundLongitude  the minimal λ value.
+     * @param  eastBoundLongitude  the maximal λ value.
+     * @param  southBoundLatitude  the minimal φ value.
+     * @param  northBoundLatitude  the maximal φ value.
      *
-     * @throws IllegalArgumentException If (<var>south bound</var> &gt; <var>north bound</var>).
+     * @throws IllegalArgumentException if (<var>south bound</var> &gt; <var>north bound</var>).
      *         Note that {@linkplain Double#NaN NaN} values are allowed.
      *
      * @see #setBounds(double, double, double, double)
@@ -192,7 +194,7 @@ public class DefaultGeographicBoundingBo
      * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the
      * given object are not recursively copied.
      *
-     * @param object The metadata to copy values from, or {@code null} if none.
+     * @param  object  the metadata to copy values from, or {@code null} if none.
      *
      * @see #castOrCopy(GeographicBoundingBox)
      */
@@ -227,8 +229,8 @@ public class DefaultGeographicBoundingBo
      *       metadata contained in the given object are not recursively copied.</li>
      * </ul>
      *
-     * @param  object The object to get as a SIS implementation, or {@code null} if none.
-     * @return A SIS implementation containing the values of the given object (may be the
+     * @param  object  the object to get as a SIS implementation, or {@code null} if none.
+     * @return a SIS implementation containing the values of the given object (may be the
      *         given object itself), or {@code null} if the argument was null.
      */
     public static DefaultGeographicBoundingBox castOrCopy(final GeographicBoundingBox object) {
@@ -239,13 +241,35 @@ public class DefaultGeographicBoundingBo
     }
 
     /**
+     * Makes sure that the given inclusion is non-nil, then returns its value.
+     * If the given inclusion is {@code null}, then the default value is {@code true}.
+     *
+     * @param  value  the {@link org.opengis.metadata.extent.GeographicBoundingBox#getInclusion()} value.
+     * @return the given value as a primitive type.
+     * @throws InvalidMetadataException if the given value is nil.
+     */
+    @SuppressWarnings("NumberEquality")
+    static boolean getInclusion(final Boolean value) throws InvalidMetadataException {
+        if (value == null) {
+            return true;
+        }
+        final boolean p = value;
+        // (value == Boolean.FALSE) is an optimization for a common case avoiding PrimitiveTypeProperties check.
+        // DO NOT REPLACE BY 'equals' OR 'booleanValue()' - the exact reference value matter.
+        if (p || (value == Boolean.FALSE) || !(PrimitiveTypeProperties.property(value) instanceof NilReason)) {
+            return p;
+        }
+        throw new InvalidMetadataException(Errors.format(Errors.Keys.MissingValueForProperty_1, "inclusion"));
+    }
+
+    /**
      * Returns the western-most coordinate of the limit of the dataset extent.
      * The value is expressed in longitude in decimal degrees (positive east).
      *
      * <p>Note that the returned value is greater than the {@linkplain #getEastBoundLongitude()
      * east bound longitude} if this box is spanning over the anti-meridian.</p>
      *
-     * @return The western-most longitude between -180° and +180° inclusive,
+     * @return the western-most longitude between -180° and +180° inclusive,
      *         or {@linkplain Double#NaN NaN} if undefined.
      */
     @Override
@@ -260,8 +284,8 @@ public class DefaultGeographicBoundingBo
      * The value is expressed in longitude in decimal degrees (positive east).
      * Values outside the [-180 … 180]° range are {@linkplain Longitude#normalize(double) normalized}.
      *
-     * @param newValue The western-most longitude between -180° and +180° inclusive,
-     *        or {@linkplain Double#NaN NaN} to undefine.
+     * @param  newValue  the western-most longitude between -180° and +180° inclusive,
+     *         or {@linkplain Double#NaN NaN} to undefine.
      */
     public void setWestBoundLongitude(double newValue) {
         checkWritePermission();
@@ -278,7 +302,7 @@ public class DefaultGeographicBoundingBo
      * <p>Note that the returned value is smaller than the {@linkplain #getWestBoundLongitude()
      * west bound longitude} if this box is spanning over the anti-meridian.</p>
      *
-     * @return The eastern-most longitude between -180° and +180° inclusive,
+     * @return the eastern-most longitude between -180° and +180° inclusive,
      *         or {@linkplain Double#NaN NaN} if undefined.
      */
     @Override
@@ -293,8 +317,8 @@ public class DefaultGeographicBoundingBo
      * The value is expressed in longitude in decimal degrees (positive east).
      * Values outside the [-180 … 180]° range are {@linkplain Longitude#normalize(double) normalized}.
      *
-     * @param newValue The eastern-most longitude between -180° and +180° inclusive,
-     *        or {@linkplain Double#NaN NaN} to undefine.
+     * @param  newValue  the eastern-most longitude between -180° and +180° inclusive,
+     *         or {@linkplain Double#NaN NaN} to undefine.
      */
     public void setEastBoundLongitude(double newValue) {
         checkWritePermission();
@@ -308,7 +332,7 @@ public class DefaultGeographicBoundingBo
      * Returns the southern-most coordinate of the limit of the dataset extent.
      * The value is expressed in latitude in decimal degrees (positive north).
      *
-     * @return The southern-most latitude between -90° and +90° inclusive,
+     * @return the southern-most latitude between -90° and +90° inclusive,
      *         or {@linkplain Double#NaN NaN} if undefined.
      */
     @Override
@@ -325,8 +349,8 @@ public class DefaultGeographicBoundingBo
      * If the result is greater than the {@linkplain #getNorthBoundLatitude() north bound latitude},
      * then the north bound is set to {@link Double#NaN}.
      *
-     * @param newValue The southern-most latitude between -90° and +90° inclusive,
-     *        or {@linkplain Double#NaN NaN} to undefine.
+     * @param  newValue  the southern-most latitude between -90° and +90° inclusive,
+     *         or {@linkplain Double#NaN NaN} to undefine.
      */
     public void setSouthBoundLatitude(final double newValue) {
         checkWritePermission();
@@ -340,7 +364,7 @@ public class DefaultGeographicBoundingBo
      * Returns the northern-most, coordinate of the limit of the dataset extent.
      * The value is expressed in latitude in decimal degrees (positive north).
      *
-     * @return The northern-most latitude between -90° and +90° inclusive,
+     * @return the northern-most latitude between -90° and +90° inclusive,
      *         or {@linkplain Double#NaN NaN} if undefined.
      */
     @Override
@@ -357,8 +381,8 @@ public class DefaultGeographicBoundingBo
      * If the result is smaller than the {@linkplain #getSouthBoundLatitude() south bound latitude},
      * then the south bound is set to {@link Double#NaN}.
      *
-     * @param newValue The northern-most latitude between -90° and +90° inclusive,
-     *        or {@linkplain Double#NaN NaN} to undefine.
+     * @param  newValue  the northern-most latitude between -90° and +90° inclusive,
+     *         or {@linkplain Double#NaN NaN} to undefine.
      */
     public void setNorthBoundLatitude(final double newValue) {
         checkWritePermission();
@@ -375,7 +399,7 @@ public class DefaultGeographicBoundingBo
      *
      * <p>This method should be invoked <strong>before</strong> {@link #normalize()}.</p>
      *
-     * @throws IllegalArgumentException If (<var>south bound</var> &gt; <var>north bound</var>).
+     * @throws IllegalArgumentException if (<var>south bound</var> &gt; <var>north bound</var>).
      *         Note that {@linkplain Double#NaN NaN} values are allowed.
      */
     private static void verifyBounds(final double southBoundLatitude, final double northBoundLatitude)
@@ -440,12 +464,12 @@ public class DefaultGeographicBoundingBo
      * Java2D world, which is rather (<var>x</var><sub>min</sub>, <var>y</var><sub>min</sub>,
      * <var>x</var><sub>max</sub>, <var>y</var><sub>max</sub>).</p>
      *
-     * @param westBoundLongitude The minimal λ value.
-     * @param eastBoundLongitude The maximal λ value.
-     * @param southBoundLatitude The minimal φ value.
-     * @param northBoundLatitude The maximal φ value.
+     * @param  westBoundLongitude  the minimal λ value.
+     * @param  eastBoundLongitude  the maximal λ value.
+     * @param  southBoundLatitude  the minimal φ value.
+     * @param  northBoundLatitude  the maximal φ value.
      *
-     * @throws IllegalArgumentException If (<var>south bound</var> &gt; <var>north bound</var>).
+     * @throws IllegalArgumentException if (<var>south bound</var> &gt; <var>north bound</var>).
      *         Note that {@linkplain Double#NaN NaN} values are allowed.
      */
     public void setBounds(final double westBoundLongitude,
@@ -477,7 +501,7 @@ public class DefaultGeographicBoundingBo
      *
      * <p><b>Note:</b> this method is available only if the referencing module is on the classpath.</p>
      *
-     * @param  envelope The envelope to use for setting this geographic bounding box.
+     * @param  envelope  the envelope to use for setting this geographic bounding box.
      * @throws UnsupportedOperationException if the referencing module is not on the classpath.
      * @throws TransformException if the envelope can not be transformed to a geographic extent.
      *
@@ -495,7 +519,7 @@ public class DefaultGeographicBoundingBo
     /**
      * Sets the bounding box to the same values than the specified box.
      *
-     * @param box The geographic bounding box to use for setting the values of this box.
+     * @param  box  the geographic bounding box to use for setting the values of this box.
      */
     public void setBounds(final GeographicBoundingBox box) {
         ArgumentChecks.ensureNonNull("box", box);
@@ -609,7 +633,7 @@ public class DefaultGeographicBoundingBo
      * structure. Consequently NaN values in {@code GeographicBoundingBox} means <cite>"information is unknown"</cite>
      * more often than <cite>"not yet calculated"</cite>.</div>
      *
-     * @param box The geographic bounding box to add to this box.
+     * @param  box  the geographic bounding box to add to this box.
      *
      * @see org.apache.sis.geometry.GeneralEnvelope#add(Envelope)
      */
@@ -624,8 +648,8 @@ public class DefaultGeographicBoundingBo
          * valid metadata object.  If the metadata object is invalid, it is better to get a
          * an exception than having a code doing silently some inappropriate work.
          */
-        final boolean i1 = MetadataUtilities.getInclusion(this.getInclusion());
-        final boolean i2 = MetadataUtilities.getInclusion(box. getInclusion());
+        final boolean i1 = getInclusion(this.getInclusion());
+        final boolean i2 = getInclusion(box. getInclusion());
         final int status = denormalize(λmin, λmax); // Must be after call to getInclusion().
         switch (status) {
             case -1: λmin -= Longitude.MAX_VALUE - Longitude.MIN_VALUE; break;
@@ -664,17 +688,15 @@ public class DefaultGeographicBoundingBo
      * box or the specified box has NaN bounds, then the corresponding bounds of the
      * intersection result will bet set to NaN.</p>
      *
-     * @param box The geographic bounding box to intersect with this box.
-     * @throws IllegalArgumentException If the inclusion status is not the same for both boxes.
+     * @param  box  the geographic bounding box to intersect with this box.
+     * @throws IllegalArgumentException if the inclusion status is not the same for both boxes.
      *
      * @see Extents#intersection(GeographicBoundingBox, GeographicBoundingBox)
      * @see org.apache.sis.geometry.GeneralEnvelope#intersect(Envelope)
      */
     public void intersect(final GeographicBoundingBox box) throws IllegalArgumentException {
         checkWritePermission();
-        if (MetadataUtilities.getInclusion(    getInclusion()) !=
-            MetadataUtilities.getInclusion(box.getInclusion()))
-        {
+        if (getInclusion(getInclusion()) != getInclusion(box.getInclusion())) {
             throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatiblePropertyValue_1, "inclusion"));
         }
         double λmin = box.getWestBoundLongitude();
@@ -723,7 +745,7 @@ public class DefaultGeographicBoundingBo
     /**
      * Compares this geographic bounding box with the specified object for equality.
      *
-     * @param object The object to compare for equality.
+     * @param  object  the object to compare for equality.
      * @return {@code true} if the given object is equal to this box.
      */
     @Override

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -17,7 +17,10 @@
 package org.apache.sis.metadata.iso.extent;
 
 import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
 import javax.measure.unit.Unit;
+import org.opengis.geometry.Envelope;
 import org.opengis.temporal.TemporalPrimitive;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.extent.VerticalExtent;
@@ -28,19 +31,26 @@ import org.opengis.metadata.extent.Geogr
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.crs.VerticalCRS;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.datum.VerticalDatum;
 import org.opengis.referencing.datum.VerticalDatumType;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.metadata.InvalidMetadataException;
 import org.apache.sis.measure.Longitude;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.measure.Range;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Static;
 
 import static java.lang.Math.*;
-import static org.apache.sis.internal.metadata.MetadataUtilities.getInclusion;
 import static org.apache.sis.internal.metadata.ReferencingServices.AUTHALIC_RADIUS;
 
+// Branch-dependent imports
+import org.opengis.geometry.Geometry;
+
 
 /**
  * Convenience static methods for extracting information from {@link Extent} objects.
@@ -56,7 +66,7 @@ import static org.apache.sis.internal.me
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.6
+ * @version 0.8
  * @module
  *
  * @see org.apache.sis.geometry.Envelopes
@@ -84,53 +94,104 @@ public final class Extents extends Stati
 
     /**
      * Returns a single geographic bounding box from the specified extent.
-     * If no bounding box is found, then this method returns {@code null}.
-     * If a single bounding box is found, then that box is returned directly.
-     * If more than one box is found, then all those boxes are
-     * {@linkplain DefaultGeographicBoundingBox#add added} together.
+     * This method tries to find the bounding box in the cheapest way
+     * before to fallback on more expansive computations:
+     *
+     * <ol>
+     *   <li>First, this method searches geographic elements that are instance of {@link GeographicBoundingBox}.<ul>
+     *     <li>If exactly one such instance is found, then this method returns that instance directly (no copy).</li>
+     *     <li>If more than one instance is found, then this method computes and returns the
+     *         {@linkplain DefaultGeographicBoundingBox#add union} of all bounding boxes.</li>
+     *   </ul></li>
+     *   <li>If above step found no {@code GeographicBoundingBox}, then this method inspects geographic elements
+     *       that are instance of {@link BoundingPolygon}, taking in account only the envelopes associated to a
+     *       coordinate reference system of kind {@link GeographicCRS}. If such envelopes are found, then this
+     *       method computes and returns their union.</li>
+     *   <li>If above step found no polygon's envelope associated to a geographic CRS, then in last resort this
+     *       method uses all polygon's envelopes regardless their coordinate reference system (provided that the
+     *       CRS is not null), applying coordinate transformations if needed.</li>
+     *   <li>If above step found no polygon's envelope, then this method returns {@code null}.</li>
+     * </ol>
      *
-     * @param  extent The extent to convert to a geographic bounding box, or {@code null}.
-     * @return A geographic bounding box extracted from the given extent, or {@code null} in none.
+     * @param  extent  the extent to convert to a geographic bounding box, or {@code null}.
+     * @return a geographic bounding box extracted from the given extent, or {@code null} if none.
      */
     public static GeographicBoundingBox getGeographicBoundingBox(final Extent extent) {
-        GeographicBoundingBox candidate = null;
+        GeographicBoundingBox bounds = null;
         if (extent != null) {
+            boolean useOnlyGeographicEnvelopes = false;
             DefaultGeographicBoundingBox modifiable = null;
+            final List<Envelope> fallbacks = new ArrayList<>();
             for (final GeographicExtent element : extent.getGeographicElements()) {
-                final GeographicBoundingBox bounds;
-                if (element instanceof GeographicBoundingBox) {
-                    bounds = (GeographicBoundingBox) element;
-                } else if (element instanceof BoundingPolygon) {
-                    // TODO: iterates through all polygons and invoke Polygon.getEnvelope();
-                    continue;
-                } else {
-                    continue;
-                }
                 /*
-                 * A single geographic bounding box has been extracted. Now add it to previous
-                 * ones (if any). All exclusion boxes before the first inclusion box are ignored.
+                 * If a geographic bounding box can be obtained, add it to the previous boxes (if any).
+                 * All exclusion boxes before the first inclusion box are ignored.
                  */
-                if (candidate == null) {
+                if (element instanceof GeographicBoundingBox) {
+                    final GeographicBoundingBox item = (GeographicBoundingBox) element;
+                    if (bounds == null) {
+                        // We use DefaultGeographicBoundingBox.getInclusion(Boolean) below because
+                        // add(…) method that we use cares about the case where inclusion is false.
+                        if (DefaultGeographicBoundingBox.getInclusion(item.getInclusion())) {
+                            bounds = item;
+                        }
+                    } else {
+                        if (modifiable == null) {
+                            bounds = modifiable = new DefaultGeographicBoundingBox(bounds);
+                        }
+                        modifiable.add(item);
+                    }
+                } else if (bounds == null && element instanceof BoundingPolygon) {
                     /*
-                     * Reminder: 'inclusion' is a mandatory attribute, so it should never be
-                     * null for a valid metadata object.  If the metadata object is invalid,
-                     * it is better to get an exception than having a code doing silently
-                     * some probably inappropriate work.
+                     * If no GeographicBoundingBox has been found so far but we found a BoundingPolygon, remember
+                     * its Envelope but do not transform it yet. We will transform envelopes later only if needed.
+                     *
+                     * No need for DefaultGeographicBoundingBox.getInclusion(Boolean) below because we do not perform
+                     * any processing (apart just ignoring the element) for cases where the inclusion value is false.
                      */
-                    if (getInclusion(bounds.getInclusion())) {
-                        candidate = bounds;
+                    if (!Boolean.FALSE.equals(element.getInclusion())) {
+                        for (final Geometry geometry : ((BoundingPolygon) extent).getPolygons()) {
+                            final Envelope envelope = geometry.getEnvelope();
+                            if (envelope != null) {
+                                final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem();
+                                if (crs != null) {
+                                    if (crs instanceof GeographicCRS) {
+                                        if (!useOnlyGeographicEnvelopes) {
+                                            useOnlyGeographicEnvelopes = true;
+                                            fallbacks.clear();
+                                        }
+                                    } else if (useOnlyGeographicEnvelopes) {
+                                        continue;
+                                    }
+                                    fallbacks.add(envelope);
+                                }
+                            }
+                        }
                     }
-                } else {
-                    if (modifiable == null) {
-                        modifiable = new DefaultGeographicBoundingBox();
-                        modifiable.setBounds(candidate);
-                        candidate = modifiable;
+                }
+            }
+            /*
+             * If we found not explicit GeographicBoundingBox element, use the information that we
+             * collected in BoundingPolygon elements. This may involve coordinate transformations.
+             */
+            if (bounds == null) try {
+                for (final Envelope envelope : fallbacks) {
+                    final DefaultGeographicBoundingBox item = new DefaultGeographicBoundingBox();
+                    item.setBounds(envelope);
+                    if (bounds == null) {
+                        bounds = item;
+                    } else {
+                        if (modifiable == null) {
+                            bounds = modifiable = new DefaultGeographicBoundingBox(bounds);
+                        }
+                        modifiable.add(item);
                     }
-                    modifiable.add(bounds);
                 }
+            } catch (TransformException e) {
+                throw new InvalidMetadataException(Errors.format(Errors.Keys.CanNotTransformEnvelope), e);
             }
         }
-        return candidate;
+        return bounds;
     }
 
     /**
@@ -188,8 +249,8 @@ public final class Extents extends Stati
      *   were found, this method would compute their union.</div></li>
      * </ul>
      *
-     * @param  extent The extent to convert to a vertical measurement range, or {@code null}.
-     * @return A vertical measurement range created from the given extent, or {@code null} if none.
+     * @param  extent  the extent to convert to a vertical measurement range, or {@code null}.
+     * @return a vertical measurement range created from the given extent, or {@code null} if none.
      *
      * @since 0.4
      */
@@ -262,8 +323,8 @@ public final class Extents extends Stati
     /**
      * Returns the union of all time ranges found in the given extent, or {@code null} if none.
      *
-     * @param  extent The extent to convert to a time range, or {@code null}.
-     * @return A time range created from the given extent, or {@code null} if none.
+     * @param  extent  the extent to convert to a time range, or {@code null}.
+     * @return a time range created from the given extent, or {@code null} if none.
      *
      * @since 0.4
      */
@@ -309,10 +370,10 @@ public final class Extents extends Stati
      *   <li>If {@code location} is outside the [0 … 1] range, then the result will be outside the temporal extent.</li>
      * </ul>
      *
-     * @param  extent   The extent from which to get an instant, or {@code null}.
-     * @param  location 0 for the start time, 1 for the end time, 0.5 for the average time, or the
-     *                  coefficient (usually in the [0 … 1] range) for interpolating an instant.
-     * @return An instant interpolated at the given location, or {@code null} if none.
+     * @param  extent    the extent from which to get an instant, or {@code null}.
+     * @param  location  0 for the start time, 1 for the end time, 0.5 for the average time, or the
+     *                   coefficient (usually in the [0 … 1] range) for interpolating an instant.
+     * @return an instant interpolated at the given location, or {@code null} if none.
      *
      * @since 0.4
      */
@@ -351,11 +412,11 @@ public final class Extents extends Stati
      * <p>This method never modify the given boxes, but may return directly one of the given arguments if it
      * already represents the intersection result.</p>
      *
-     * @param  b1 The first bounding box, or {@code null}.
-     * @param  b2 The second bounding box, or {@code null}.
-     * @return The intersection (may be any of the {@code b1} or {@code b2} argument if unchanged),
+     * @param  b1  the first bounding box, or {@code null}.
+     * @param  b2  the second bounding box, or {@code null}.
+     * @return the intersection (may be any of the {@code b1} or {@code b2} argument if unchanged),
      *         or {@code null} if the two given boxes are null.
-     * @throws IllegalArgumentException If the {@linkplain DefaultGeographicBoundingBox#getInclusion() inclusion status}
+     * @throws IllegalArgumentException if the {@linkplain DefaultGeographicBoundingBox#getInclusion() inclusion status}
      *         is not the same for both boxes.
      *
      * @see DefaultGeographicBoundingBox#intersect(GeographicBoundingBox)
@@ -379,8 +440,8 @@ public final class Extents extends Stati
      * {@linkplain org.apache.sis.referencing.CommonCRS#SPHERE GRS 1980 Authalic Sphere}.
      * However this may change in any future SIS version.</p>
      *
-     * @param  box The geographic bounding box for which to compute the area, or {@code null}.
-     * @return An estimation of the area in the given bounding box (m²),
+     * @param  box  the geographic bounding box for which to compute the area, or {@code null}.
+     * @return an estimation of the area in the given bounding box (m²),
      *         or {@linkplain Double#NaN NaN} if the given box was null.
      *
      * @since 0.4

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import javax.measure.unit.NonSI;
 import org.opengis.util.FactoryException;
+import org.opengis.geometry.Envelope;
 import org.opengis.referencing.NoSuchAuthorityCodeException;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.cs.EllipsoidalCS;
@@ -42,13 +43,19 @@ import org.opengis.referencing.crs.Engin
 import org.opengis.referencing.operation.OperationNotFoundException;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.extent.BoundingPolygon;
 import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.metadata.extent.GeographicExtent;
 import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.geometry.Envelopes;
+import org.apache.sis.geometry.GeneralEnvelope;
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.internal.referencing.PositionalAccuracyConstant;
 import org.apache.sis.internal.referencing.CoordinateOperations;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.internal.system.Loggers;
 import org.apache.sis.referencing.cs.DefaultVerticalCS;
 import org.apache.sis.referencing.cs.DefaultEllipsoidalCS;
 import org.apache.sis.referencing.crs.DefaultGeographicCRS;
@@ -61,12 +68,16 @@ import org.apache.sis.referencing.factor
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
 import org.apache.sis.metadata.iso.extent.Extents;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Static;
 
 import static java.util.Collections.singletonMap;
 
+// Branch-dependent imports
+import org.opengis.geometry.Geometry;
+
 
 /**
  * Static methods working on {@linkplain CoordinateReferenceSystem Coordinate Reference Systems}.
@@ -113,7 +124,7 @@ import static java.util.Collections.sing
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class CRS extends Static {
@@ -166,9 +177,9 @@ public final class CRS extends Static {
      * Note that the {@link IdentifiedObjects#lookupURN(IdentifiedObject, Citation)}
      * method can be seen as a converse of this method.
      *
-     * @param  code The authority code.
-     * @return The Coordinate Reference System for the given authority code.
-     * @throws NoSuchAuthorityCodeException If there is no known CRS associated to the given code.
+     * @param  code  the authority code.
+     * @return the Coordinate Reference System for the given authority code.
+     * @throws NoSuchAuthorityCodeException if there is no known CRS associated to the given code.
      * @throws FactoryException if the CRS creation failed for an other reason.
      *
      * @see #getAuthorityFactory(String)
@@ -228,8 +239,8 @@ public final class CRS extends Static {
      * Applications which need to parse a large amount of WKT strings should consider to use
      * the {@link org.apache.sis.io.wkt.WKTFormat} class instead than this method.
      *
-     * @param  text Coordinate system encoded in Well-Known Text format (version 1 or 2).
-     * @return The parsed Coordinate Reference System.
+     * @param  text  coordinate system encoded in Well-Known Text format (version 1 or 2).
+     * @return the parsed Coordinate Reference System.
      * @throws FactoryException if the given WKT can not be parsed.
      *
      * @see org.apache.sis.io.wkt
@@ -249,8 +260,8 @@ public final class CRS extends Static {
      * For reading XML documents from readers or input streams,
      * see static methods in the {@link org.apache.sis.xml.XML} class.
      *
-     * @param  xml Coordinate reference system encoded in XML format.
-     * @return The unmarshalled Coordinate Reference System.
+     * @param  xml  coordinate reference system encoded in XML format.
+     * @return the unmarshalled Coordinate Reference System.
      * @throws FactoryException if the object creation failed.
      *
      * @see org.apache.sis.xml.XML#unmarshal(String)
@@ -288,9 +299,9 @@ public final class CRS extends Static {
      * transform. If there is no known operation between the given pair of CRS, then this method throws an
      * {@link OperationNotFoundException}.
      *
-     * @param  sourceCRS      the CRS of source coordinates.
-     * @param  targetCRS      the CRS of target coordinates.
-     * @param  areaOfInterest the area of interest, or {@code null} if none.
+     * @param  sourceCRS       the CRS of source coordinates.
+     * @param  targetCRS       the CRS of target coordinates.
+     * @param  areaOfInterest  the area of interest, or {@code null} if none.
      * @return the mathematical operation from {@code sourceCRS} to {@code targetCRS}.
      * @throws OperationNotFoundException if no operation was found between the given pair of CRS.
      * @throws FactoryException if the operation can not be created for another reason.
@@ -338,8 +349,8 @@ public final class CRS extends Static {
      *
      * See {@link AbstractCoordinateOperation#getLinearAccuracy()} for more details on the above heuristic rules.
      *
-     * @param  operation The coordinate operation for which to get the accuracy estimation, or {@code null}.
-     * @return The accuracy estimation (always in meters), or NaN if unknown.
+     * @param  operation  the coordinate operation for which to get the accuracy estimation, or {@code null}.
+     * @return the accuracy estimation (always in meters), or NaN if unknown.
      *
      * @see #findOperation(CoordinateReferenceSystem, CoordinateReferenceSystem, GeographicBoundingBox)
      *
@@ -362,8 +373,8 @@ public final class CRS extends Static {
      * {@linkplain org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#add(GeographicBoundingBox) added}
      * together.
      *
-     * @param  operation The coordinate operation for which to get the domain of validity, or {@code null}.
-     * @return The geographic area where the operation is valid, or {@code null} if unspecified.
+     * @param  operation  the coordinate operation for which to get the domain of validity, or {@code null}.
+     * @return the geographic area where the operation is valid, or {@code null} if unspecified.
      *
      * @see #findOperation(CoordinateReferenceSystem, CoordinateReferenceSystem, GeographicBoundingBox)
      * @see Extents#getGeographicBoundingBox(Extent)
@@ -383,8 +394,8 @@ public final class CRS extends Static {
      * {@linkplain org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox#add(GeographicBoundingBox) added}
      * together.
      *
-     * @param  crs The coordinate reference system for which to get the domain of validity, or {@code null}.
-     * @return The geographic area where the coordinate reference system is valid, or {@code null} if unspecified.
+     * @param  crs  the coordinate reference system for which to get the domain of validity, or {@code null}.
+     * @return the geographic area where the coordinate reference system is valid, or {@code null} if unspecified.
      *
      * @see #getEnvelope(CoordinateReferenceSystem)
      * @see Extents#getGeographicBoundingBox(Extent)
@@ -396,6 +407,95 @@ public final class CRS extends Static {
     }
 
     /**
+     * Returns the domain of validity of the specified coordinate reference system, or {@code null} if unknown.
+     * If non-null, then the returned envelope will use the same coordinate reference system them the given CRS
+     * argument.
+     *
+     * <p>This method looks in two places:</p>
+     * <ul>
+     *   <li>First, it checks the {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getDomainOfValidity()
+     *       domain of validity} associated with the given CRS. Only geographic extents that are instances of
+     *       {@link BoundingPolygon} associated to the given CRS are taken in account for this first step.</li>
+     *   <li>If the above step did not found found any bounding polygon, then the
+     *       {@linkplain #getGeographicBoundingBox(CoordinateReferenceSystem) geographic bounding boxes}
+     *       are used as a fallback and tranformed to the given CRS.</li>
+     * </ul>
+     *
+     * @param  crs  the coordinate reference system, or {@code null}.
+     * @return the envelope with coordinates in the given CRS, or {@code null} if none.
+     *
+     * @see #getGeographicBoundingBox(CoordinateReferenceSystem)
+     *
+     * @category information
+     * @since 0.8
+     */
+    public static Envelope getDomainOfValidity(final CoordinateReferenceSystem crs) {
+        Envelope envelope = null;
+        GeneralEnvelope merged = null;
+        if (crs != null) {
+            final Extent domainOfValidity = crs.getDomainOfValidity();
+            if (domainOfValidity != null) {
+                for (final GeographicExtent extent : domainOfValidity.getGeographicElements()) {
+                    if (extent instanceof BoundingPolygon && !Boolean.FALSE.equals(extent.getInclusion())) {
+                        for (final Geometry geometry : ((BoundingPolygon) extent).getPolygons()) {
+                            final Envelope candidate = geometry.getEnvelope();
+                            if (candidate != null) {
+                                final CoordinateReferenceSystem sourceCRS = candidate.getCoordinateReferenceSystem();
+                                if (sourceCRS == null || Utilities.equalsIgnoreMetadata(sourceCRS, crs)) {
+                                    if (envelope == null) {
+                                        envelope = candidate;
+                                    } else {
+                                        if (merged == null) {
+                                            envelope = merged = new GeneralEnvelope(envelope);
+                                        }
+                                        merged.add(envelope);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        /*
+         * If no envelope was found, uses the geographic bounding box as a fallback. We will
+         * need to transform it from WGS84 to the supplied CRS. This step was not required in
+         * the previous block because the later selected only envelopes in the right CRS.
+         */
+        if (envelope == null) {
+            final GeographicBoundingBox bounds = getGeographicBoundingBox(crs);
+            if (bounds != null && !Boolean.FALSE.equals(bounds.getInclusion())) {
+                /*
+                 * We do not assign WGS84 unconditionally to the geographic bounding box, because
+                 * it is not defined to be on a particular datum; it is only approximative bounds.
+                 * We try to get the GeographicCRS from the user-supplied CRS in order to reduce
+                 * the amount of transformation needed.
+                 */
+                final SingleCRS targetCRS = getHorizontalComponent(crs);
+                final GeographicCRS sourceCRS = ReferencingUtilities.toNormalizedGeographicCRS(targetCRS);
+                if (sourceCRS != null) {
+                    envelope = merged = new GeneralEnvelope(bounds);
+                    merged.translate(-getGreenwichLongitude(sourceCRS), 0);
+                    merged.setCoordinateReferenceSystem(sourceCRS);
+                    try {
+                        envelope = Envelopes.transform(envelope, targetCRS);
+                    } catch (TransformException exception) {
+                        /*
+                         * The envelope is probably outside the range of validity for this CRS.
+                         * It should not occurs, since the envelope is supposed to describe the
+                         * CRS area of validity. Logs a warning and returns null, since it is a
+                         * legal return value according this method contract.
+                         */
+                        unexpectedException("getEnvelope", exception);
+                        envelope = null;
+                    }
+                }
+            }
+        }
+        return envelope;
+    }
+
+    /**
      * Returns {@code true} if the given CRS is horizontal. The current implementation considers a
      * CRS as horizontal if it is two-dimensional and comply with one of the following conditions:
      *
@@ -414,7 +514,7 @@ public final class CRS extends Static {
      *       Conversely, a future SIS versions may impose more conditions on <code>EngineeringCRS</code>.
      *       See <a href="http://issues.apache.org/jira/browse/SIS-161">SIS-161</a>.
      *
-     * @param  crs The coordinate reference system, or {@code null}.
+     * @param  crs  the coordinate reference system, or {@code null}.
      * @return {@code true} if the given CRS is non-null and likely horizontal, or {@code false} otherwise.
      *
      * @see #getHorizontalComponent(CoordinateReferenceSystem)
@@ -448,8 +548,8 @@ public final class CRS extends Static {
      * <p>In the special case where a three-dimensional geographic CRS is found, this method will create a
      * two-dimensional geographic CRS without the vertical axis.</p>
      *
-     * @param  crs The coordinate reference system, or {@code null}.
-     * @return The first horizontal CRS, or {@code null} if none.
+     * @param  crs  the coordinate reference system, or {@code null}.
+     * @return the first horizontal CRS, or {@code null} if none.
      *
      * @category information
      */
@@ -511,10 +611,10 @@ public final class CRS extends Static {
      * <em>in last resort</em>, only if it can not find an existing {@code VerticalCRS} instance.
      * <strong>Note that this is not a valid CRS according ISO 19111</strong> — use with care.</p>
      *
-     * @param  crs The coordinate reference system, or {@code null}.
+     * @param  crs  the coordinate reference system, or {@code null}.
      * @param  allowCreateEllipsoidal {@code true} for allowing the creation of orphan CRS for ellipsoidal heights.
      *         The recommended value is {@code false}.
-     * @return The first vertical CRS, or {@code null} if none.
+     * @return the first vertical CRS, or {@code null} if none.
      *
      * @category information
      */
@@ -560,8 +660,8 @@ public final class CRS extends Static {
      * Otherwise if the given CRS is compound, then this method searches for the first temporal component
      * in the order of the {@linkplain #getSingleComponents(CoordinateReferenceSystem) single components list}.
      *
-     * @param  crs The coordinate reference system, or {@code null}.
-     * @return The first temporal CRS, or {@code null} if none.
+     * @param  crs  the coordinate reference system, or {@code null}.
+     * @return the first temporal CRS, or {@code null} if none.
      *
      * @category information
      */
@@ -619,8 +719,8 @@ public final class CRS extends Static {
      * Note that such flat lists are the only one allowed by ISO/OGC standards for compound CRS.
      * The hierarchical structure is an Apache SIS flexibility.</div>
      *
-     * @param  crs The coordinate reference system, or {@code null}.
-     * @return The single coordinate reference systems, or an empty list if the given CRS is {@code null}.
+     * @param  crs  the coordinate reference system, or {@code null}.
+     * @return the single coordinate reference systems, or an empty list if the given CRS is {@code null}.
      * @throws ClassCastException if a CRS is neither a {@link SingleCRS} or a {@link CompoundCRS}.
      *
      * @see DefaultCompoundCRS#getSingleComponents()
@@ -666,12 +766,12 @@ public final class CRS extends Static {
      * This method does <strong>not</strong> attempt to build new CRS from the components.
      * For example it does not attempt to create a 3D geographic CRS from a 2D one + a vertical component.
      *
-     * @param  crs   The coordinate reference system to decompose, or {@code null}.
-     * @param  lower The first dimension to keep, inclusive.
-     * @param  upper The last  dimension to keep, exclusive.
-     * @return The sub-coordinate system, or {@code null} if the given {@code crs} was {@code null}
+     * @param  crs    the coordinate reference system to decompose, or {@code null}.
+     * @param  lower  the first dimension to keep, inclusive.
+     * @param  upper  the last  dimension to keep, exclusive.
+     * @return the sub-coordinate system, or {@code null} if the given {@code crs} was {@code null}
      *         or can not be decomposed for dimensions in the [{@code lower} … {@code upper}] range.
-     * @throws IndexOutOfBoundsException If the given index are out of bounds.
+     * @throws IndexOutOfBoundsException if the given index are out of bounds.
      *
      * @since 0.5
      *
@@ -706,8 +806,8 @@ check:  while (lower != 0 || upper != di
      * Returns the Greenwich longitude of the prime meridian of the given CRS in degrees.
      * If the prime meridian uses an other unit than degrees, then the value will be converted.
      *
-     * @param  crs The coordinate reference system from which to get the prime meridian.
-     * @return The Greenwich longitude (in degrees) of the prime meridian of the given CRS.
+     * @param  crs  the coordinate reference system from which to get the prime meridian.
+     * @return the Greenwich longitude (in degrees) of the prime meridian of the given CRS.
      *
      * @since 0.5
      *
@@ -738,10 +838,10 @@ check:  while (lower != 0 || upper != di
      *     META-INF/services/org.opengis.referencing.crs.CRSAuthorityFactory
      * }
      *
-     * @param  authority The authority of the desired factory (typically {@code "EPSG"} or {@code "OGC"}),
+     * @param  authority  the authority of the desired factory (typically {@code "EPSG"} or {@code "OGC"}),
      *         or {@code null} for the {@link org.apache.sis.referencing.factory.MultiAuthoritiesFactory}
      *         instance that manage all factories.
-     * @return The system-wide authority factory used by SIS for the given authority.
+     * @return the system-wide authority factory used by SIS for the given authority.
      * @throws FactoryException if no factory can be returned for the given authority.
      *
      * @see #forCode(String)
@@ -755,4 +855,12 @@ check:  while (lower != 0 || upper != di
         }
         return AuthorityFactories.ALL.getAuthorityFactory(CRSAuthorityFactory.class, authority, null);
     }
+
+    /**
+     * Invoked when an unexpected exception occurred. Those exceptions must be non-fatal, i.e. the caller
+     * <strong>must</strong> have a reasonable fallback (otherwise it should propagate the exception).
+     */
+    private static void unexpectedException(final String methodName, final Exception exception) {
+        Logging.unexpectedException(Logging.getLogger(Loggers.REFERENCING), CRS.class, methodName, exception);
+    }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -106,9 +106,9 @@ public final class IdentifiedObjects ext
      * values depend on the {@linkplain org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis#getUnit()
      * units of measurement}.</div>
      *
-     * @param  object The identified object to view as a properties map.
-     * @param  excludes The keys of properties to exclude from the map.
-     * @return A view of the identified object properties as an immutable map.
+     * @param  object    the identified object to view as a properties map.
+     * @param  excludes  the keys of properties to exclude from the map.
+     * @return a view of the identified object properties as an immutable map.
      */
     public static Map<String,?> getProperties(final IdentifiedObject object, final String... excludes) {
         ArgumentChecks.ensureNonNull("object", object);
@@ -122,9 +122,9 @@ public final class IdentifiedObjects ext
      * stop at the first match. This method is useful in the rare cases where the same authority
      * declares more than one name, and all those names are of interest.
      *
-     * @param  object The object to get the names and aliases from, or {@code null}.
-     * @param  authority The authority for the names to return, or {@code null} for any authority.
-     * @return The object's names and aliases, or an empty set if no name or alias matching the
+     * @param  object     the object to get the names and aliases from, or {@code null}.
+     * @param  authority  the authority for the names to return, or {@code null} for any authority.
+     * @return the object's names and aliases, or an empty set if no name or alias matching the
      *         specified authority has been found.
      */
     public static Set<String> getNames(final IdentifiedObject object, final Citation authority) {
@@ -157,9 +157,9 @@ public final class IdentifiedObjects ext
      * interfaces (for example {@link NamedIdentifier}). In such cases, the identifier view has
      * precedence.
      *
-     * @param  object The object to get the name from, or {@code null}.
-     * @param  authority The authority for the name to return, or {@code null} for any authority.
-     * @return The object's name (either an {@linkplain Identifier#getCode() identifier code}
+     * @param  object     the object to get the name from, or {@code null}.
+     * @param  authority  the authority for the name to return, or {@code null} for any authority.
+     * @return the object's name (either an {@linkplain Identifier#getCode() identifier code}
      *         or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
      *         specified authority has been found.
      *
@@ -174,10 +174,10 @@ public final class IdentifiedObjects ext
      * every properties are checked for null values, even the properties that are supposed to
      * be mandatory (not all implementation defines all mandatory values).
      *
-     * @param  object    The object to get the name from, or {@code null}.
-     * @param  authority The authority for the name to return, or {@code null} for any authority.
-     * @param  addTo     If non-null, the collection where to add all names found.
-     * @return The object's name (either an {@linkplain Identifier#getCode() identifier code}
+     * @param  object     the object to get the name from, or {@code null}.
+     * @param  authority  the authority for the name to return, or {@code null} for any authority.
+     * @param  addTo      if non-null, the collection where to add all names found.
+     * @return the object's name (either an {@linkplain Identifier#getCode() identifier code}
      *         or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
      *         specified authority has been found.
      */
@@ -265,10 +265,10 @@ public final class IdentifiedObjects ext
      * order and returns the first identifier with an {@linkplain NamedIdentifier#getAuthority() authority} citation
      * {@linkplain Citations#identifierMatches(Citation, Citation) matching} the specified authority.
      *
-     * @param  object The object to get the identifier from, or {@code null}.
-     * @param  authority The authority for the identifier to return, or {@code null} for
+     * @param  object     the object to get the identifier from, or {@code null}.
+     * @param  authority  the authority for the identifier to return, or {@code null} for
      *         the first identifier regardless its authority.
-     * @return The object's identifier, or {@code null} if no identifier matching the specified authority
+     * @return the object's identifier, or {@code null} if no identifier matching the specified authority
      *         has been found.
      *
      * @see AbstractIdentifiedObject#getIdentifier()
@@ -303,8 +303,8 @@ public final class IdentifiedObjects ext
      *       database looking for a match, use one of the search methods defined below.</li>
      * </ul>
      *
-     * @param  object The identified object, or {@code null}.
-     * @return A string representation of the first identifier or name, or {@code null} if none.
+     * @param  object  the identified object, or {@code null}.
+     * @return a string representation of the first identifier or name, or {@code null} if none.
      *
      * @see #getIdentifier(IdentifiedObject, Citation)
      * @see #lookupURN(IdentifiedObject, Citation)
@@ -337,8 +337,8 @@ public final class IdentifiedObjects ext
      *   <li><code>object.{@linkplain AbstractIdentifiedObject#getIdentifiers() getIdentifiers()}</code> in iteration order</li>
      * </ul>
      *
-     * @param  object The identified object, or {@code null}.
-     * @return The first name, alias or identifier which is a valid Unicode identifier, or {@code null} if none.
+     * @param  object  the identified object, or {@code null}.
+     * @return the first name, alias or identifier which is a valid Unicode identifier, or {@code null} if none.
      *
      * @see org.apache.sis.metadata.iso.ImmutableIdentifier
      * @see org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)
@@ -397,11 +397,11 @@ public final class IdentifiedObjects ext
      *
      * This method can be seen as a converse of {@link CRS#forCode(String)}.
      *
-     * @param  object The object (usually a {@linkplain org.apache.sis.referencing.crs.AbstractCRS
+     * @param  object  the object (usually a {@linkplain org.apache.sis.referencing.crs.AbstractCRS
      *         coordinate reference system}) whose identifier is to be found, or {@code null}.
-     * @param  authority The authority for the identifier to return, or {@code null} for
+     * @param  authority  the authority for the identifier to return, or {@code null} for
      *         the first identifier regardless its authority.
-     * @return The identifier, or {@code null} if none was found without ambiguity or if the given object was null.
+     * @return the identifier, or {@code null} if none was found without ambiguity or if the given object was null.
      * @throws FactoryException if an error occurred during the search.
      *
      * @see #newFinder(String)
@@ -455,9 +455,9 @@ public final class IdentifiedObjects ext
      *
      * This method can be seen as a converse of {@link CRS#forCode(String)}.
      *
-     * @param  object The object (usually a {@linkplain org.apache.sis.referencing.crs.AbstractCRS
+     * @param  object  the object (usually a {@linkplain org.apache.sis.referencing.crs.AbstractCRS
      *         coordinate reference system}) whose EPSG code is to be found, or {@code null}.
-     * @return The EPSG code, or {@code null} if none was found without ambiguity or if the given object was null.
+     * @return the EPSG code, or {@code null} if none was found without ambiguity or if the given object was null.
      * @throws FactoryException if an error occurred during the search.
      *
      * @see #newFinder(String)
@@ -476,7 +476,7 @@ public final class IdentifiedObjects ext
                         return null;
                     }
                 } catch (NumberFormatException e) {
-                    Logging.recoverableException(Logging.getLogger(Loggers.CRS_FACTORY), IdentifiedObjects.class, "lookupEPSG", e);
+                    Logging.recoverableException(Logging.getLogger(Loggers.REFERENCING), IdentifiedObjects.class, "lookupEPSG", e);
                 }
             }
         }
@@ -512,9 +512,9 @@ public final class IdentifiedObjects ext
      *     Set<IdentifiedObject> found = finder.find(object);
      * }</div>
      *
-     * @param  authority The authority of the objects to search (typically {@code "EPSG"} or {@code "OGC"}),
+     * @param  authority  the authority of the objects to search (typically {@code "EPSG"} or {@code "OGC"}),
      *         or {@code null} for searching among the objects created by all authorities.
-     * @return A finder to use for looking up unidentified objects.
+     * @return a finder to use for looking up unidentified objects.
      * @throws NoSuchAuthorityFactoryException if the given authority is not found.
      * @throws FactoryException if the finder can not be created for another reason.
      *
@@ -564,8 +564,8 @@ public final class IdentifiedObjects ext
      *
      * If the {@code object} argument is {@code null}, then this method returns {@code false}.
      *
-     * @param  object The object for which to check the name or alias, or {@code null}.
-     * @param  name The name to compare with the object name or aliases.
+     * @param  object  the object for which to check the name or alias, or {@code null}.
+     * @param  name    the name to compare with the object name or aliases.
      * @return {@code true} if the primary name or at least one alias matches the specified {@code name}.
      *
      * @see AbstractIdentifiedObject#isHeuristicMatchForName(String)
@@ -636,9 +636,9 @@ public final class IdentifiedObjects ext
      *
      * <p>The above tables may be expanded in any future SIS version.</p>
      *
-     * @param  type A type assignable to one of the types listed in above table.
-     * @param  identifier The identifier for which to format a URN, or {@code null}.
-     * @return The URN for the given identifier, or {@code null} if the given identifier was null
+     * @param  type  a type assignable to one of the types listed in above table.
+     * @param  identifier  the identifier for which to format a URN, or {@code null}.
+     * @return the URN for the given identifier, or {@code null} if the given identifier was null
      *         or can not be formatted by this method.
      *
      * @see #lookupURN(IdentifiedObject, Citation)
@@ -676,8 +676,8 @@ public final class IdentifiedObjects ext
      * the {@link org.apache.sis.metadata.iso.DefaultIdentifier} implementation is formatted as a tree.
      * This static method can be used when a "name-like" representation is needed for any implementation.
      *
-     * @param  identifier The identifier, or {@code null}.
-     * @return A string representation of the given identifier, or {@code null}.
+     * @param  identifier  the identifier, or {@code null}.
+     * @return a string representation of the given identifier, or {@code null}.
      *
      * @see org.apache.sis.metadata.iso.ImmutableIdentifier#toString()
      * @see NamedIdentifier#toString()

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -60,7 +60,7 @@ public class ProjectionException extends
     /**
      * Constructs a new exception with the specified detail message.
      *
-     * @param message The details message, or {@code null} if none.
+     * @param  message  the details message, or {@code null} if none.
      */
     public ProjectionException(final String message) {
         super(message);
@@ -70,7 +70,7 @@ public class ProjectionException extends
      * Constructs a new exception with the specified cause.
      * The details message is copied from the cause.
      *
-     * @param cause The cause, or {@code null} if none.
+     * @param  cause  the cause, or {@code null} if none.
      */
     public ProjectionException(final Throwable cause) {
         super(cause.getLocalizedMessage(), cause);
@@ -79,8 +79,8 @@ public class ProjectionException extends
     /**
      * Constructs a new exception with the specified detail message and cause.
      *
-     * @param message The details message, or {@code null} if none.
-     * @param cause   The cause, or {@code null} if none.
+     * @param  message  the details message, or {@code null} if none.
+     * @param  cause    the cause, or {@code null} if none.
      */
     public ProjectionException(final String message, final Throwable cause) {
         super(message, cause);
@@ -89,7 +89,7 @@ public class ProjectionException extends
     /**
      * Constructs a new exception with the specified detail message.
      *
-     * @param code One of the constants suitable for {@link Errors#format(short)}.
+     * @param  code  one of the constants suitable for {@link Errors#format(short)}.
      */
     ProjectionException(final short code) {
         this(Errors.format(code));

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java?rev=1755402&r1=1755401&r2=1755402&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java [UTF-8] Sat Aug  6 15:50:22 2016
@@ -36,7 +36,7 @@ import org.apache.sis.util.logging.Loggi
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
- * @version 0.7
+ * @version 0.8
  * @module
  */
 public final class Loggers extends Static {
@@ -91,6 +91,12 @@ public final class Loggers extends Stati
     public static final String COORDINATE_OPERATION = "org.apache.sis.referencing.operation";
 
     /**
+     * The logger name for operation related to the {@code sis-referencing} modules that do not fit
+     * into the {@link #CRS_FACTORY} or {@link #COORDINATE_OPERATION} categories.
+     */
+    public static final String REFERENCING = "org.apache.sis.referencing";
+
+    /**
      * The logger name for operation related to localization.
      */
     public static final String LOCALIZATION = "org.apache.sis.util.resources";



Mime
View raw message