sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1564821 [1/2] - in /sis/branches/JDK7/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/io/ sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/...
Date Wed, 05 Feb 2014 16:02:49 GMT
Author: desruisseaux
Date: Wed Feb  5 16:02:48 2014
New Revision: 1564821

URL: http://svn.apache.org/r1564821
Log:
Moved org.apache.sis.io.wkt from the sis-referencing module to the sis-metadata one,
in order to allow us to use it with identifiers. This is because the WKT 2 syntax is
slightly more complex than the WKT 1, so it may be worth to define ImmutableObject
as a FormattableObject subclass for letting it do its job itself.

Added:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingUtilities.java
      - copied, changed from r1564728, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/
      - copied from r1564728, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ReferencingUtilitiesTest.java
      - copied, changed from r1564728, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/
      - copied from r1564728, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java
      - copied, changed from r1564728, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java   (with props)
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/package-info.txt
      - copied unchanged from r1564728, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/package-info.txt
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/package-info.txt
      - copied unchanged from r1564728, sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/package-info.txt
Removed:
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/io/
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/
Modified:
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
    sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
    sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRSTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxisTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultEllipsoidTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultGeodeticDatumTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultPrimeMeridianTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/DefaultVerticalDatumTest.java
    sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -96,6 +96,32 @@ public final class MetadataUtilities ext
     }
 
     /**
+     * Ensures that the given argument value is {@code false}. This method is invoked by private setter methods,
+     * which are themselves invoked by JAXB at unmarshalling time. Invoking this method from those setter methods
+     * serves two purposes:
+     *
+     * <ul>
+     *   <li>Make sure that a singleton property is not defined twice in the XML document.</li>
+     *   <li>Protect ourselves against changes in immutable objects outside unmarshalling. It should
+     *       not be necessary since the setter methods shall not be public, but we are paranoiac.</li>
+     *   <li>Be a central point where we can trace all setter methods, in case we want to improve
+     *       warning or error messages in future SIS versions.</li>
+     * </ul>
+     *
+     * @param  name The property name, used only in case of error message to format.
+     * @param  isDefined Whether the property in the caller object is current defined.
+     * @return {@code true} if the caller can set the property.
+     * @throws IllegalStateException If {@code isDefined} is {@code true}.
+     */
+    public static boolean canSetProperty(final String name, final boolean isDefined) throws IllegalStateException {
+        if (isDefined) {
+            // Future SIS version could log a warning instead if a unmarshalling is in progress.
+            throw new IllegalStateException(Errors.format(Errors.Keys.ElementAlreadyPresent_1, name));
+        }
+        return true;
+    }
+
+    /**
      * Convenience method for logging a warning to the {@code ISOMetadata} logger.
      * The message will be produced using the {@link Messages} resources bundle.
      *

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -17,6 +17,9 @@
 package org.apache.sis.internal.metadata;
 
 import org.opengis.geometry.Envelope;
+import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.operation.Matrix;
+import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.metadata.iso.extent.DefaultExtent;
 import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
@@ -34,7 +37,7 @@ import org.apache.sis.util.resources.Err
  * implementation using Java reflection.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.3 (derived from geotk-3.18)
+ * @since   0.4 (derived from geotk-3.18)
  * @version 0.3
  * @module
  */
@@ -52,7 +55,7 @@ public abstract class ReferencingService
     /**
      * The services, fetched when first needed.
      */
-    private static ReferencingServices instance;
+    private static volatile ReferencingServices instance;
 
     /**
      * For subclass only. This constructor registers this instance as a {@link SystemListener}
@@ -73,7 +76,6 @@ public abstract class ReferencingService
         synchronized (ReferencingServices.class) {
             instance = null;
         }
-        SystemListener.remove(this);
     }
 
     /**
@@ -83,20 +85,50 @@ public abstract class ReferencingService
      * @throws UnsupportedOperationException If the {@code "sis-referencing"} module has not
      *         been found on the classpath.
      */
-    public static synchronized ReferencingServices getInstance() throws UnsupportedOperationException {
-        if (instance == null) try {
-            instance = (ReferencingServices) Class.forName("org.apache.sis.internal.referencing.ServicesForMetadata").newInstance();
-        } catch (ClassNotFoundException exception) {
-            throw new UnsupportedOperationException(Errors.format(
-                    Errors.Keys.MissingRequiredModule_1, "sis-referencing"), exception);
-        } catch (ReflectiveOperationException exception) {
-            // Should never happen if we didn't broke our helper class.
-            throw new AssertionError(exception);
+    public static ReferencingServices getInstance() throws UnsupportedOperationException {
+        ReferencingServices c = instance;
+        if (c == null) {
+            synchronized (ReferencingServices.class) {
+                c = instance;
+                if (c == null) try {
+                    instance = c = (ReferencingServices) Class.forName("org.apache.sis.internal.referencing.ServicesForMetadata").newInstance();
+                } catch (ClassNotFoundException exception) {
+                    throw new UnsupportedOperationException(Errors.format(
+                            Errors.Keys.MissingRequiredModule_1, "sis-referencing"), exception);
+                } catch (ReflectiveOperationException exception) {
+                    // Should never happen if we didn't broke our helper class.
+                    throw new AssertionError(exception);
+                }
+            }
         }
-        return instance;
+        return c;
     }
 
     /**
+     * Returns the matrix for the given transform, or {@code null} if none.
+     *
+     * @param  tr The transform for which to get the matrix.
+     * @return The matrix, or {@code null} if none.
+     *
+     * @see org.apache.sis.referencing.operation.transform.LinearTransform#getMatrix()
+     *
+     * @since 0.4
+     */
+    public abstract Matrix getMatrix(MathTransform tr);
+
+    /**
+     * Converts the given object in a {@link org.apache.sis.io.wkt.FormattableObject} instance.
+     *
+     * @param  object The object to wrap.
+     * @return The given object converted to a {@code FormattableObject} instance.
+     *
+     * @see org.apache.sis.referencing.AbstractIdentifiedObject#castOrCopy(IdentifiedObject)
+     *
+     * @since 0.4
+     */
+    public abstract IdentifiedObject toFormattableObject(IdentifiedObject object);
+
+    /**
      * Sets a geographic bounding box from the specified envelope. If the envelope contains
      * a CRS, then the bounding box will be projected to a geographic CRS. Otherwise, the envelope
      * is assumed already in appropriate CRS.

Copied: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingUtilities.java (from r1564728, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingUtilities.java?p2=sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingUtilities.java&p1=sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java&r1=1564728&r2=1564821&rev=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingUtilities.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -14,9 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.referencing;
+package org.apache.sis.internal.metadata;
 
 import java.util.Collection;
+import java.util.Iterator;
 import javax.measure.unit.Unit;
 import org.opengis.parameter.*;
 import org.opengis.referencing.*;
@@ -24,10 +25,15 @@ import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
 import org.opengis.referencing.datum.*;
 import org.opengis.referencing.operation.*;
-import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.util.resources.Errors;
+import org.opengis.metadata.Identifier;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.util.GenericName;
+import org.opengis.util.NameSpace;
 import org.apache.sis.util.Static;
 
+import static org.apache.sis.internal.util.Citations.iterator;
+import static org.apache.sis.internal.util.Citations.identifierMatches;
+
 
 /**
  * A set of static methods working on GeoAPI referencing objects.
@@ -103,20 +109,93 @@ public final class ReferencingUtilities 
     }
 
     /**
-     * Retrieves the value at the specified row and column of the given matrix, wrapped in a {@code Number}.
-     * The {@code Number} type depends on the matrix accuracy.
-     *
-     * @param matrix The matrix from which to get the number.
-     * @param row    The row index, from 0 inclusive to {@link Matrix#getNumRow()} exclusive.
-     * @param column The column index, from 0 inclusive to {@link Matrix#getNumCol()} exclusive.
-     * @return       The current value at the given row and column.
-     */
-    public static Number getNumber(final Matrix matrix, final int row, final int column) {
-        if (matrix instanceof MatrixSIS) {
-            return ((MatrixSIS) matrix).getNumber(row, column);
-        } else {
-            return matrix.getElement(row, column);
+     * Returns an object name according the given authority. This method is {@code null}-safe:
+     * 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 ReferenceIdentifier#getCode() identifier code}
+     *         or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
+     *         specified authority has been found.
+     */
+    public static String getName(final IdentifiedObject object, final Citation authority, final Collection<String> addTo) {
+        if (object != null) {
+            Identifier identifier = object.getName();
+            if (authority == null) {
+                if (identifier != null) {
+                    final String name = identifier.getCode();
+                    if (name != null) {
+                        if (addTo == null) {
+                            return name;
+                        }
+                        addTo.add(name);
+                    }
+                }
+                final Iterator<GenericName> it = iterator(object.getAlias());
+                if (it != null) while (it.hasNext()) {
+                    final GenericName alias = it.next();
+                    if (alias != null) {
+                        final String name = (alias instanceof Identifier) ?
+                                ((Identifier) alias).getCode() : alias.toString();
+                        if (name != null) {
+                            if (addTo == null) {
+                                return name;
+                            }
+                            addTo.add(name);
+                        }
+                    }
+                }
+            } else {
+                if (identifier != null) {
+                    if (identifierMatches(authority, identifier.getAuthority())) {
+                        final String name = identifier.getCode();
+                        if (name != null) {
+                            if (addTo == null) {
+                                return name;
+                            }
+                            addTo.add(name);
+                        }
+                    }
+                }
+                final Iterator<GenericName> it = iterator(object.getAlias());
+                if (it != null) while (it.hasNext()) {
+                    final GenericName alias = it.next();
+                    if (alias != null) {
+                        if (alias instanceof Identifier) {
+                            identifier = (Identifier) alias;
+                            if (identifierMatches(authority, identifier.getAuthority())) {
+                                final String name = identifier.getCode();
+                                if (name != null) {
+                                    if (addTo == null) {
+                                        return name;
+                                    }
+                                    addTo.add(name);
+                                }
+                            }
+                        } else {
+                            final NameSpace ns = alias.scope();
+                            if (ns != null) {
+                                final GenericName scope = ns.name();
+                                if (scope != null) {
+                                    if (identifierMatches(authority, scope.toString())) {
+                                        final String name = alias.toString();
+                                        if (name != null) {
+                                            if (addTo == null) {
+                                                return name;
+                                            }
+                                            addTo.add(name);
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
         }
+        return null;
     }
 
     /**
@@ -129,8 +208,6 @@ public final class ReferencingUtilities 
      *
      * @param cs The coordinate system for which to get the unit, or {@code null}.
      * @return The unit for all axis in the given coordinate system, or {@code null}.
-     *
-     * @since 0.4
      */
     public static Unit<?> getUnit(final CoordinateSystem cs) {
         Unit<?> unit = null;
@@ -182,30 +259,4 @@ public final class ReferencingUtilities 
         }
         return sameContent;
     }
-
-    /**
-     * Ensures that the given argument value is {@code false}. This method is invoked by private setter methods,
-     * which are themselves invoked by JAXB at unmarshalling time. Invoking this method from those setter methods
-     * serves two purposes:
-     *
-     * <ul>
-     *   <li>Make sure that a singleton property is not defined twice in the XML document.</li>
-     *   <li>Protect ourselves against changes in immutable objects outside unmarshalling. It should
-     *       not be necessary since the setter methods shall not be public, but we are paranoiac.</li>
-     *   <li>Be a central point where we can trace all setter methods, in case we want to improve
-     *       warning or error messages in future SIS versions.</li>
-     * </ul>
-     *
-     * @param  name The property name, used only in case of error message to format.
-     * @param  isDefined Whether the property in the caller object is current defined.
-     * @return {@code true} if the caller can set the property.
-     * @throws IllegalStateException If {@code isDefined} is {@code true}.
-     */
-    public static boolean canSetProperty(final String name, final boolean isDefined) throws IllegalStateException {
-        if (isDefined) {
-            // Future SIS version could log a warning instead if a unmarshalling is in progress.
-            throw new IllegalStateException(Errors.format(Errors.Keys.ElementAlreadyPresent_1, name));
-        }
-        return true;
-    }
 }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1564821&r1=1564728&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -59,12 +59,11 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.Citations;
+import org.apache.sis.internal.metadata.ReferencingServices;
+import org.apache.sis.internal.metadata.ReferencingUtilities;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.metadata.iso.extent.Extents;
-import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.AbstractIdentifiedObject;
-import org.apache.sis.referencing.operation.transform.LinearTransform;
 
 
 /**
@@ -98,7 +97,7 @@ public class Formatter {
      * Accuracy of geographic bounding boxes, in number of fraction digits.
      * We use the accuracy recommended by ISO 19162.
      */
-    private static final int BBOX_ACCURACY = 2;
+    static final int BBOX_ACCURACY = 2;
 
     /**
      * Maximal accuracy of vertical extents, in number of fraction digits.
@@ -360,12 +359,12 @@ public class Formatter {
      * @return The preferred name, or {@code null} if the given object has no name.
      *
      * @see WKTFormat#getNameAuthority()
-     * @see IdentifiedObjects#getName(IdentifiedObject, Citation)
+     * @see org.apache.sis.referencing.IdentifiedObjects#getName(IdentifiedObject, Citation)
      */
     public String getName(final IdentifiedObject object) {
-        String name = IdentifiedObjects.getName(object, authority);
+        String name = ReferencingUtilities.getName(object, authority, null);
         if (name == null) {
-            name = IdentifiedObjects.getName(object, null);
+            name = ReferencingUtilities.getName(object, null, null);
         }
         return name;
     }
@@ -638,10 +637,12 @@ public class Formatter {
      *
      * @param object The identified object to append to the WKT, or {@code null} if none.
      */
-    public void append(final IdentifiedObject object) {
+    public void append(IdentifiedObject object) {
         if (object != null) {
-            append(object instanceof FormattableObject ? (FormattableObject) object :
-                   AbstractIdentifiedObject.castOrCopy(object));
+            if (!(object instanceof FormattableObject)) {
+                object = ReferencingServices.getInstance().toFormattableObject(object);
+            }
+            append((FormattableObject) object);
         }
     }
 
@@ -737,17 +738,20 @@ public class Formatter {
         if (transform != null) {
             if (transform instanceof FormattableObject) {
                 append((FormattableObject) transform);
-            } else if (transform instanceof LinearTransform) {
-                appendSeparator(true);
-                buffer.append("PARAM_MT").appendCodePoint(symbols.getOpeningBracket(0));
-                quote("Affine");
-                indent(+1);
-                append(((LinearTransform) transform).getMatrix());
-                indent(-1);
-                buffer.appendCodePoint(symbols.getClosingBracket(0));
             } else {
-                throw new UnformattableObjectException(Errors.format(
-                        Errors.Keys.IllegalClass_2, FormattableObject.class, transform.getClass()));
+                final Matrix matrix = ReferencingServices.getInstance().getMatrix(transform);
+                if (matrix != null) {
+                    appendSeparator(true);
+                    buffer.append("PARAM_MT").appendCodePoint(symbols.getOpeningBracket(0));
+                    quote("Affine");
+                    indent(+1);
+                    append(matrix);
+                    indent(-1);
+                    buffer.appendCodePoint(symbols.getClosingBracket(0));
+                } else {
+                    throw new UnformattableObjectException(Errors.format(
+                            Errors.Keys.IllegalClass_2, FormattableObject.class, transform.getClass()));
+                }
             }
         }
     }

Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1564821&r1=1564728&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -28,6 +28,7 @@ import java.text.ParsePosition;
 import javax.measure.unit.Unit;
 import javax.measure.unit.UnitFormat;
 import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.parameter.GeneralParameterValue;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
@@ -346,8 +347,8 @@ public class WKTFormat extends CompoundF
 
     /**
      * Formats the specified object as a Well Know Text. The given object shall be an instance of one of
-     * {@link FormattableObject}, {@link IdentifiedObject}, {@link MathTransform}, {@link GeneralParameterValue}
-     * or {@link Matrix}.
+     * {@link FormattableObject}, {@link IdentifiedObject}, {@link GeographicBoundingBox},
+     * {@link MathTransform}, {@link GeneralParameterValue} or {@link Matrix}.
      *
      * @param  object     The object to format.
      * @param  toAppendTo Where the text is to be appended.
@@ -397,6 +398,8 @@ public class WKTFormat extends CompoundF
                 formatter.append((GeneralParameterValue) object);
             } else if (object instanceof Matrix) {
                 formatter.append((Matrix) object);
+            } else if (object instanceof GeographicBoundingBox) {
+                formatter.append((GeographicBoundingBox) object, Formatter.BBOX_ACCURACY);
             } else {
                 throw new ClassCastException(Errors.format(
                         Errors.Keys.IllegalArgumentClass_2, "object", object.getClass()));

Copied: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ReferencingUtilitiesTest.java (from r1564728, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ReferencingUtilitiesTest.java?p2=sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ReferencingUtilitiesTest.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java&r1=1564728&r2=1564821&rev=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ReferencingUtilitiesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/internal/metadata/ReferencingUtilitiesTest.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.referencing;
+package org.apache.sis.internal.metadata;
 
 import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
@@ -24,7 +24,7 @@ import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.*;
+import static org.apache.sis.internal.metadata.ReferencingUtilities.*;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1564821&r1=1564728&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -16,26 +16,16 @@
  */
 package org.apache.sis.io.wkt;
 
-import java.util.Map;
-import java.util.HashMap;
-import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
-import org.apache.sis.metadata.iso.ImmutableIdentifier;
-import org.apache.sis.metadata.iso.extent.DefaultExtent;
-import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
-import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
+import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
-import org.apache.sis.metadata.iso.citation.HardCodedCitations;
-import org.apache.sis.referencing.AbstractReferenceSystem;
-import org.apache.sis.referencing.operation.matrix.Matrix4;
-import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.internal.util.X364;
+import org.apache.sis.test.mock.MatrixMock;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
-import static org.opengis.referencing.ReferenceSystem.*;
-import static org.apache.sis.referencing.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
 
 
 /**
@@ -58,48 +48,12 @@ public final strictfp class FormatterTes
     }
 
     /**
-     * Tests {@link Formatter#append(IdentifiedObject)} with a name that contains the quote character
-     * and optional information. We test that the closing quote character is doubled and the optional
-     * information properly formatted.
+     * Tests {@link Formatter#append(GeographicBoundingBox, int)}.
      */
     @Test
-    public void testAppendIdentifiedObject() {
-        final Map<String,Object> properties = new HashMap<>(8);
-        assertNull(properties.put(NAME_KEY, "My “object”."));
-        assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
-        assertNull(properties.put(REMARKS_KEY, "注です。"));
-        assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(
-                HardCodedCitations.OGP, "EPSG", "4326", "8.2", null)));
-        assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.",
-                new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77),
-                new DefaultVerticalExtent(10, 1000, HardCodedCRS.DEPTH),
-                new DefaultTemporalExtent()))); // TODO: needs sis-temporal module for testing that one.
-        final IdentifiedObject object = new AbstractReferenceSystem(properties);
-
-        assertWktEquals(Convention.WKT1,
-                // Closing quote conservatively omitted for WKT 1.
-                "ReferenceSystem[“My “object.”, AUTHORITY[“EPSG”, “4326”]]",
-                object);
-
-        assertWktEquals(Convention.WKT2,
-                "ReferenceSystem[“My “object””.”,\n" +
-                "  SCOPE[“Large scale topographic mapping and cadastre.”],\n" +
-                "  AREA[“Netherlands offshore.”],\n" +
-                "  BBOX[51.43, 2.54, 55.77, 6.40],\n" +
-                "  VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1.0]],\n" +
-                "  ID[“EPSG”, 4326, “8.2”, “OGP”],\n" +
-                "  REMARKS[“注です。”]]",
-                object);
-
-        assertWktEquals(Convention.WKT2_SIMPLIFIED,
-                "ReferenceSystem[“My “object””.”,\n" +
-                "  SCOPE[“Large scale topographic mapping and cadastre.”],\n" +
-                "  AREA[“Netherlands offshore.”],\n" +
-                "  BBOX[51.43, 2.54, 55.77, 6.40],\n" +
-                "  VERTICALEXTENT[-1000, -10],\n" +
-                "  ID[“EPSG”, 4326, “8.2”, “OGP”],\n" +
-                "  REMARKS[“注です。”]]",
-                object);
+    public void testAppendGeographicBoundingBox() {
+        assertWktEquals("BBOX[51.43, 2.54, 55.77, 6.40]",
+                new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77));
     }
 
     /**
@@ -107,7 +61,7 @@ public final strictfp class FormatterTes
      */
     @Test
     public void testAppendMatrix() {
-        final Matrix m = new Matrix4(
+        final Matrix m = new MatrixMock(4, 4,
                 1, 0, 4, 0,
                -2, 1, 0, 0,
                 0, 0, 1, 7,

Copied: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java (from r1564728, sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java?p2=sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java&p1=sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java&r1=1564728&r2=1564821&rev=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/MetadataAssert.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -14,46 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.referencing;
+package org.apache.sis.test;
 
-import java.awt.geom.Rectangle2D;
-import java.awt.geom.RectangularShape;
-import java.awt.geom.AffineTransform;
-import javax.measure.unit.Unit;
-import org.opengis.geometry.Envelope;
-import org.opengis.parameter.GeneralParameterValue;
-import org.opengis.parameter.ParameterDescriptor;
-import org.opengis.parameter.ParameterValue;
-import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.referencing.IdentifiedObject;
-import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.cs.AxisDirection;
-import org.opengis.referencing.cs.CoordinateSystemAxis;
-import org.opengis.referencing.cs.RangeMeaning;
 import org.apache.sis.io.wkt.Symbols;
 import org.apache.sis.io.wkt.WKTFormat;
 import org.apache.sis.io.wkt.Convention;
-import org.apache.sis.geometry.AbstractEnvelope;
-import org.apache.sis.geometry.GeneralDirectPosition;
-
-import static java.lang.StrictMath.*;
 
 
 /**
- * Assertion methods used by the {@code sis-referencing} module in addition of the ones inherited
+ * Assertion methods used by the {@code sis-metadata} module in addition of the ones inherited
  * from other modules and libraries.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @since   0.3 (derived from geotk-3.00)
+ * @since   0.4 (derived from geotk-3.00)
  * @version 0.4
  * @module
  */
-public strictfp class Assert extends org.apache.sis.test.Assert {
-    /**
-     * The tolerance threshold for strict comparisons of floating point values.
-     */
-    private static final double STRICT = 0;
-
+public strictfp class MetadataAssert extends Assert {
     /**
      * The formatter to be used by {@link #assertWktEquals(Object, String)}.
      * This formatter uses the {@code “…”} quotation marks instead of {@code "…"}
@@ -69,267 +47,7 @@ public strictfp class Assert extends org
     /**
      * For subclass constructor only.
      */
-    protected Assert() {
-    }
-
-    /**
-     * Compares the given coordinate system axis against the expected values.
-     *
-     * @param name          The expected axis name code.
-     * @param abbreviation  The expected axis abbreviation.
-     * @param direction     The expected axis direction.
-     * @param minimumValue  The expected axis minimal value.
-     * @param maximumValue  The expected axis maximal value.
-     * @param unit          The expected axis unit of measurement.
-     * @param rangeMeaning  The expected axis range meaning.
-     * @param axis          The axis to verify.
-     */
-    public static void assertAxisEquals(final String name, final String abbreviation, final AxisDirection direction,
-            final double minimumValue, final double maximumValue, final Unit<?> unit, final RangeMeaning rangeMeaning,
-            final CoordinateSystemAxis axis)
-    {
-        assertEquals("name",         name,         axis.getName().getCode());
-        assertEquals("abbreviation", abbreviation, axis.getAbbreviation());
-        assertEquals("direction",    direction,    axis.getDirection());
-        assertEquals("minimumValue", minimumValue, axis.getMinimumValue(), STRICT);
-        assertEquals("maximumValue", maximumValue, axis.getMaximumValue(), STRICT);
-        assertEquals("unit",         unit,         axis.getUnit());
-        assertEquals("rangeMeaning", rangeMeaning, axis.getRangeMeaning());
-    }
-
-    /**
-     * Asserts that the given parameter values are equal to the expected ones within
-     * a positive delta. Only the elements in the given descriptor are compared, and
-     * the comparisons are done in the units declared in the descriptor.
-     *
-     * @param expected  The expected parameter values.
-     * @param actual    The actual parameter values.
-     * @param tolerance The tolerance threshold for comparison of numerical values.
-     */
-    public static void assertParameterEquals(final ParameterValueGroup expected,
-            final ParameterValueGroup actual, final double tolerance)
-    {
-        for (final GeneralParameterValue candidate : expected.values()) {
-            if (!(candidate instanceof ParameterValue<?>)) {
-                throw new UnsupportedOperationException("Not yet implemented.");
-            }
-            final ParameterValue<?> value = (ParameterValue<?>) candidate;
-            final ParameterDescriptor<?> descriptor = value.getDescriptor();
-            final String   name       = descriptor.getName().getCode();
-            final Unit<?>  unit       = descriptor.getUnit();
-            final Class<?> valueClass = descriptor.getValueClass();
-            final ParameterValue<?> e = expected.parameter(name);
-            final ParameterValue<?> a = actual  .parameter(name);
-            if (unit != null) {
-                final double f = e.doubleValue(unit);
-                assertEquals(name, f, a.doubleValue(unit), tolerance);
-            } else if (valueClass == Float.class || valueClass == Double.class) {
-                final double f = e.doubleValue();
-                assertEquals(name, f, a.doubleValue(), tolerance);
-            } else {
-                assertEquals(name, e.getValue(), a.getValue());
-            }
-        }
-    }
-
-    /**
-     * Asserts that the given matrix is diagonal, and that all elements on the diagonal are equal
-     * to the given values. The matrix doesn't need to be square. The last row is handled especially
-     * if the {@code affine} argument is {@code true}.
-     *
-     * @param expected  The values which are expected on the diagonal. If the length of this array
-     *                  is less than the matrix size, then the last element in the array is repeated
-     *                  for all remaining diagonal elements.
-     * @param affine    If {@code true}, then the last row is expected to contains the value 1
-     *                  in the last column, and all other columns set to 0.
-     * @param matrix    The matrix to test.
-     * @param tolerance The tolerance threshold while comparing floating point values.
-     */
-    public static void assertDiagonalEquals(final double[] expected, final boolean affine,
-            final Matrix matrix, final double tolerance)
-    {
-        final int numRows = matrix.getNumRow();
-        final int numCols = matrix.getNumCol();
-        final StringBuilder buffer = new StringBuilder("matrix(");
-        final int bufferBase = buffer.length();
-        for (int j=0; j<numRows; j++) {
-            for (int i=0; i<numCols; i++) {
-                final double e;
-                if (affine && j == numRows-1) {
-                    e = (i == numCols-1) ? 1 : 0;
-                } else if (i == j) {
-                    e = expected[min(expected.length-1, i)];
-                } else {
-                    e = 0;
-                }
-                buffer.setLength(bufferBase);
-                assertEquals(buffer.append(j).append(',').append(i).append(')').toString(),
-                        e, matrix.getElement(j, i), tolerance);
-            }
-        }
-    }
-
-    /**
-     * Compares two affine transforms for equality.
-     *
-     * @param expected  The expected affine transform.
-     * @param actual    The actual affine transform.
-     * @param tolerance The tolerance threshold.
-     */
-    public static void assertTransformEquals(final AffineTransform expected, final AffineTransform actual, final double tolerance) {
-        assertEquals("scaleX",     expected.getScaleX(),     actual.getScaleX(),     tolerance);
-        assertEquals("scaleY",     expected.getScaleY(),     actual.getScaleY(),     tolerance);
-        assertEquals("shearX",     expected.getShearX(),     actual.getShearX(),     tolerance);
-        assertEquals("shearY",     expected.getShearY(),     actual.getShearY(),     tolerance);
-        assertEquals("translateX", expected.getTranslateX(), actual.getTranslateX(), tolerance);
-        assertEquals("translateY", expected.getTranslateY(), actual.getTranslateY(), tolerance);
-    }
-
-    /**
-     * Asserts that two rectangles have the same location and the same size.
-     *
-     * @param expected The expected rectangle.
-     * @param actual   The rectangle to compare with the expected one.
-     * @param tolx     The tolerance threshold on location along the <var>x</var> axis.
-     * @param toly     The tolerance threshold on location along the <var>y</var> axis.
-     */
-    public static void assertRectangleEquals(final RectangularShape expected,
-            final RectangularShape actual, final double tolx, final double toly)
-    {
-        assertEquals("Min X",    expected.getMinX(),    actual.getMinX(),    tolx);
-        assertEquals("Min Y",    expected.getMinY(),    actual.getMinY(),    toly);
-        assertEquals("Max X",    expected.getMaxX(),    actual.getMaxX(),    tolx);
-        assertEquals("Max Y",    expected.getMaxY(),    actual.getMaxY(),    toly);
-        assertEquals("Center X", expected.getCenterX(), actual.getCenterX(), tolx);
-        assertEquals("Center Y", expected.getCenterY(), actual.getCenterY(), toly);
-        assertEquals("Width",    expected.getWidth(),   actual.getWidth(),   tolx*2);
-        assertEquals("Height",   expected.getHeight(),  actual.getHeight(),  toly*2);
-    }
-
-    /**
-     * Tests if the given {@code outer} shape contains the given {@code inner} rectangle.
-     * This method will also verify class consistency by invoking the {@code intersects}
-     * method, and by interchanging the arguments.
-     *
-     * <p>This method can be used for testing the {@code outer} implementation -
-     * it should not be needed for standard JDK implementations.</p>
-     *
-     * @param outer The shape which is expected to contains the given rectangle.
-     * @param inner The rectangle which should be contained by the shape.
-     */
-    public static void assertContains(final RectangularShape outer, final Rectangle2D inner) {
-        assertTrue("outer.contains(inner)",   outer.contains  (inner));
-        assertTrue("outer.intersects(inner)", outer.intersects(inner));
-        if (outer instanceof Rectangle2D) {
-            assertTrue ("inner.intersects(outer)", inner.intersects((Rectangle2D) outer));
-            assertFalse("inner.contains(outer)",   inner.contains  ((Rectangle2D) outer));
-        }
-        assertTrue("outer.contains(centerX, centerY)",
-                outer.contains(inner.getCenterX(), inner.getCenterY()));
-    }
-
-    /**
-     * Tests if the given {@code outer} envelope contains the given {@code inner} envelope.
-     * This method will also verify class consistency by invoking the {@code intersects}
-     * method, and by interchanging the arguments.
-     *
-     * @param outer The envelope which is expected to contains the given inner envelope.
-     * @param inner The envelope which should be contained by the outer envelope.
-     */
-    public static void assertContains(final AbstractEnvelope outer, final Envelope inner) {
-        assertTrue("outer.contains(inner)",   outer.contains  (inner, true));
-        assertTrue("outer.contains(inner)",   outer.contains  (inner, false));
-        assertTrue("outer.intersects(inner)", outer.intersects(inner, true));
-        assertTrue("outer.intersects(inner)", outer.intersects(inner, false));
-        if (inner instanceof AbstractEnvelope) {
-            final AbstractEnvelope ai = (AbstractEnvelope) inner;
-            assertTrue ("inner.intersects(outer)", ai.intersects(outer, true));
-            assertTrue ("inner.intersects(outer)", ai.intersects(outer, false));
-            assertFalse("inner.contains(outer)",   ai.contains  (outer, true));
-            assertFalse("inner.contains(outer)",   ai.contains  (outer, false));
-        }
-        final GeneralDirectPosition median = new GeneralDirectPosition(inner.getDimension());
-        for (int i=median.getDimension(); --i>=0;) {
-            median.setOrdinate(i, inner.getMedian(i));
-        }
-        assertTrue("outer.contains(median)", outer.contains(median));
-    }
-
-    /**
-     * Tests if the given {@code r1} shape is disjoint with the given {@code r2} rectangle.
-     * This method will also verify class consistency by invoking the {@code contains}
-     * method, and by interchanging the arguments.
-     *
-     * <p>This method can be used for testing the {@code r1} implementation - it should not
-     * be needed for standard implementations.</p>
-     *
-     * @param r1 The first shape to test.
-     * @param r2 The second rectangle to test.
-     */
-    public static void assertDisjoint(final RectangularShape r1, final Rectangle2D r2) {
-        assertFalse("r1.intersects(r2)", r1.intersects(r2));
-        assertFalse("r1.contains(r2)",   r1.contains(r2));
-        if (r1 instanceof Rectangle2D) {
-            assertFalse("r2.intersects(r1)", r2.intersects((Rectangle2D) r1));
-            assertFalse("r2.contains(r1)",   r2.contains  ((Rectangle2D) r1));
-        }
-        for (int i=0; i<9; i++) {
-            final double x, y;
-            switch (i % 3) {
-                case 0: x = r2.getMinX();    break;
-                case 1: x = r2.getCenterX(); break;
-                case 2: x = r2.getMaxX();    break;
-                default: throw new AssertionError(i);
-            }
-            switch (i / 3) {
-                case 0: y = r2.getMinY();    break;
-                case 1: y = r2.getCenterY(); break;
-                case 2: y = r2.getMaxY();    break;
-                default: throw new AssertionError(i);
-            }
-            assertFalse("r1.contains(" + x + ", " + y + ')', r1.contains(x, y));
-        }
-    }
-
-    /**
-     * Tests if the given {@code e1} envelope is disjoint with the given {@code e2} envelope.
-     * This method will also verify class consistency by invoking the {@code contains} method,
-     * and by interchanging the arguments.
-     *
-     * @param e1 The first envelope to test.
-     * @param e2 The second envelope to test.
-     */
-    public static void assertDisjoint(final AbstractEnvelope e1, final Envelope e2) {
-        assertFalse("e1.intersects(e2)", e1.intersects(e2, false));
-        assertFalse("e1.intersects(e2)", e1.intersects(e2, true));
-        assertFalse("e1.contains(e2)",   e1.contains  (e2, false));
-        assertFalse("e1.contains(e2)",   e1.contains  (e2, true));
-        if (e2 instanceof AbstractEnvelope) {
-            final AbstractEnvelope ae = (AbstractEnvelope) e2;
-            assertFalse("e2.intersects(e1)", ae.intersects(e1, false));
-            assertFalse("e2.intersects(e1)", ae.intersects(e1, true));
-            assertFalse("e2.contains(e1)",   ae.contains  (e1, false));
-            assertFalse("e2.contains(e1)",   ae.contains  (e1, true));
-        }
-        final int dimension = e1.getDimension();
-        final int numCases = (int) round(pow(3, dimension));
-        final GeneralDirectPosition pos = new GeneralDirectPosition(dimension);
-        for (int index=0; index<numCases; index++) {
-            int n = index;
-            for (int i=0; i<dimension; i++) {
-                final double ordinate;
-                switch (n % 3) {
-                    case 0: ordinate = e2.getMinimum(i); break;
-                    case 1: ordinate = e2.getMedian (i); break;
-                    case 2: ordinate = e2.getMaximum(i); break;
-                    default: throw new AssertionError(i);
-                }
-                pos.setOrdinate(i, ordinate);
-                n /= 3;
-            }
-            assertEquals(0, n); // Opportunist check of this assert method.
-            assertFalse("e1.contains(" + pos + ')', e1.contains(pos));
-        }
+    protected MetadataAssert() {
     }
 
     /**

Added: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java?rev=1564821&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java (added)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.test.mock;
+
+import java.io.Serializable;
+import org.opengis.referencing.operation.Matrix;
+import org.apache.sis.util.ArgumentChecks;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * A dummy implementation of {@link Matrix}.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+@SuppressWarnings("serial")
+public final strictfp class MatrixMock implements Matrix, Cloneable, Serializable {
+    /**
+     * Matrix size.
+     */
+    private final int numRow, numCol;
+
+    /**
+     * Matrix elements.
+     */
+    private double[] elements;
+
+    /**
+     * Creates a new matrix of the given size with the given elements.
+     *
+     * @param numRow   Number of matrix rows.
+     * @param numCol   Number of matrix columns.
+     * @param elements Matrix element values.
+     */
+    public MatrixMock(final int numRow, final int numCol, final double... elements) {
+        assertEquals(numRow * numCol, elements.length);
+        this.numRow = numRow;
+        this.numCol = numCol;
+        this.elements = elements;
+    }
+
+    /**
+     * Returns the number of rows.
+     *
+     * @return Number of matrix rows.
+     */
+    @Override
+    public int getNumRow() {
+        return numRow;
+    }
+
+    /**
+     * Returns the number of columns.
+     *
+     * @return Number of matrix columns.
+     */
+    @Override
+    public int getNumCol() {
+        return numCol;
+    }
+
+    /**
+     * Return the index of the matrix element.
+     */
+    private int index(final int row, final int column) {
+        ArgumentChecks.ensureBetween("row",    0, numRow - 1, row);
+        ArgumentChecks.ensureBetween("column", 0, numCol - 1, column);
+        return row * numCol + column;
+    }
+
+    /**
+     * Returns the element at the given row and column.
+     *
+     * @param  row    Row index.
+     * @param  column Colum index.
+     * @return Matrix element at the given indices.
+     */
+    @Override
+    public double getElement(final int row, final int column) {
+        return elements[index(row, column)];
+    }
+
+    /**
+     * Sets the element at the given row and column.
+     *
+     * @param row    Row index.
+     * @param column Colum index.
+     * @param value  Matrix element at the given indices.
+     */
+    @Override
+    public void setElement(final int row, final int column, final double value) {
+        elements[index(row, column)] = value;
+    }
+
+    /**
+     * Returns {@code true} if this matrix is the identity matrix.
+     *
+     * @return {@code true} for the identity matrix.
+     */
+    @Override
+    public boolean isIdentity() {
+        if (numRow != numCol) {
+            return false;
+        }
+        for (int i=0; i<elements.length; i++) {
+            if (elements[i] != ((i % numCol) == 0 ? 1 : 0)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Returns a clone of this matrix.
+     *
+     * @return A clone of this matrix.
+     */
+    @Override
+    public Matrix clone() {
+        final MatrixMock copy;
+        try {
+            copy = (MatrixMock) super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new AssertionError(e);
+        }
+        copy.elements = copy.elements.clone();
+        return copy;
+    }
+}

Propchange: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/mock/MatrixMock.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -31,6 +31,7 @@ import org.junit.BeforeClass;
  */
 @Suite.SuiteClasses({
     org.apache.sis.internal.metadata.MetadataUtilitiesTest.class,
+    org.apache.sis.internal.metadata.ReferencingUtilitiesTest.class,
 
     // Classes using Java reflection.
     org.apache.sis.metadata.PropertyInformationTest.class,
@@ -80,7 +81,12 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.ImmutableIdentifierTest.class,
     org.apache.sis.metadata.iso.DefaultMetadataTest.class,
     org.apache.sis.metadata.iso.CustomMetadataTest.class,
-    org.apache.sis.metadata.iso.AllMetadataTest.class
+    org.apache.sis.metadata.iso.AllMetadataTest.class,
+
+    org.apache.sis.io.wkt.ConventionTest.class,
+    org.apache.sis.io.wkt.SymbolsTest.class,
+    org.apache.sis.io.wkt.ColorsTest.class,
+    org.apache.sis.io.wkt.FormatterTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/Code.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -25,7 +25,7 @@ import org.apache.sis.internal.util.Defi
 import org.apache.sis.referencing.NamedIdentifier;
 import org.apache.sis.metadata.iso.citation.Citations;
 
-import static org.apache.sis.internal.referencing.ReferencingUtilities.toURNType;
+import static org.apache.sis.internal.metadata.ReferencingUtilities.toURNType;
 
 
 /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -38,7 +38,7 @@ import org.opengis.referencing.ObjectFac
 import org.opengis.referencing.AuthorityFactory;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.ReferenceIdentifier;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.ReferencingUtilities;
 import org.apache.sis.internal.jaxb.referencing.Code;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
@@ -57,7 +57,7 @@ import static org.apache.sis.internal.ut
 import static org.apache.sis.internal.util.CollectionsExt.nonEmpty;
 import static org.apache.sis.internal.util.CollectionsExt.immutableSet;
 import static org.apache.sis.internal.util.Utilities.appendUnicodeIdentifier;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -39,7 +39,7 @@ import org.opengis.metadata.extent.Exten
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.apache.sis.internal.util.DefinitionURI;
 import org.apache.sis.internal.referencing.AxisDirections;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.ReferencingUtilities;
 import org.apache.sis.referencing.cs.DefaultVerticalCS;
 import org.apache.sis.referencing.cs.DefaultEllipsoidalCS;
 import org.apache.sis.referencing.crs.DefaultGeographicCRS;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/IdentifiedObjects.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -22,7 +22,6 @@ import java.util.LinkedHashSet;
 import java.util.Iterator;
 import java.util.Collection;
 
-import org.opengis.util.NameSpace;
 import org.opengis.util.GenericName;
 import org.opengis.metadata.Identifier;
 import org.opengis.metadata.citation.Citation;
@@ -34,6 +33,7 @@ import org.apache.sis.util.Static;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.iso.DefaultNameSpace;
 import org.apache.sis.metadata.iso.citation.Citations; // For javadoc.
+import org.apache.sis.internal.metadata.ReferencingUtilities;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.Characters.Filter.LETTERS_AND_DIGITS;
@@ -108,7 +108,7 @@ public final class IdentifiedObjects ext
      */
     public static Set<String> getNames(final IdentifiedObject object, final Citation authority) {
         final Set<String> names = new LinkedHashSet<>(8);
-        name(object, authority, names);
+        ReferencingUtilities.getName(object, authority, names);
         return names;
     }
 
@@ -145,97 +145,7 @@ public final class IdentifiedObjects ext
      * @see AbstractIdentifiedObject#getName()
      */
     public static String getName(final IdentifiedObject object, final Citation authority) {
-        return name(object, authority, null);
-    }
-
-    /**
-     * Returns an object name according the given authority. This method is {@code null}-safe:
-     * 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 ReferenceIdentifier#getCode() identifier code}
-     *         or a {@linkplain GenericName#tip() name tip}), or {@code null} if no name matching the
-     *         specified authority has been found.
-     */
-    private static String name(final IdentifiedObject object, final Citation authority, final Collection<String> addTo) {
-        if (object != null) {
-            Identifier identifier = object.getName();
-            if (authority == null) {
-                if (identifier != null) {
-                    final String name = identifier.getCode();
-                    if (name != null) {
-                        if (addTo == null) {
-                            return name;
-                        }
-                        addTo.add(name);
-                    }
-                }
-                final Iterator<GenericName> it = iterator(object.getAlias());
-                if (it != null) while (it.hasNext()) {
-                    final GenericName alias = it.next();
-                    if (alias != null) {
-                        final String name = (alias instanceof Identifier) ?
-                                ((Identifier) alias).getCode() : alias.toString();
-                        if (name != null) {
-                            if (addTo == null) {
-                                return name;
-                            }
-                            addTo.add(name);
-                        }
-                    }
-                }
-            } else {
-                if (identifier != null) {
-                    if (identifierMatches(authority, identifier.getAuthority())) {
-                        final String name = identifier.getCode();
-                        if (name != null) {
-                            if (addTo == null) {
-                                return name;
-                            }
-                            addTo.add(name);
-                        }
-                    }
-                }
-                final Iterator<GenericName> it = iterator(object.getAlias());
-                if (it != null) while (it.hasNext()) {
-                    final GenericName alias = it.next();
-                    if (alias != null) {
-                        if (alias instanceof Identifier) {
-                            identifier = (Identifier) alias;
-                            if (identifierMatches(authority, identifier.getAuthority())) {
-                                final String name = identifier.getCode();
-                                if (name != null) {
-                                    if (addTo == null) {
-                                        return name;
-                                    }
-                                    addTo.add(name);
-                                }
-                            }
-                        } else {
-                            final NameSpace ns = alias.scope();
-                            if (ns != null) {
-                                final GenericName scope = ns.name();
-                                if (scope != null) {
-                                    if (identifierMatches(authority, scope.toString())) {
-                                        final String name = alias.toString();
-                                        if (name != null) {
-                                            if (addTo == null) {
-                                                return name;
-                                            }
-                                            addTo.add(name);
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return null;
+        return ReferencingUtilities.getName(object, authority, null);
     }
 
     /**

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -28,7 +28,7 @@ import org.opengis.referencing.cs.Cartes
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.ReferencingUtilities;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.referencing.cs.AxesConvention;
@@ -38,6 +38,7 @@ import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;
@@ -284,7 +285,7 @@ public class AbstractCRS extends Abstrac
      * @throws IllegalStateException If the coordinate system has already been set.
      */
     final void setCoordinateSystem(final String name, final CoordinateSystem cs) {
-        if (cs != null && ReferencingUtilities.canSetProperty(name, coordinateSystem != null)) {
+        if (cs != null && canSetProperty(name, coordinateSystem != null)) {
             coordinateSystem = cs;
         }
     }

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultCompoundCRS.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -32,7 +32,7 @@ import org.apache.sis.referencing.cs.Axe
 import org.apache.sis.referencing.cs.DefaultCompoundCS;
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.metadata.ReferencingUtilities;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.util.collection.CheckedContainer;
 import org.apache.sis.util.resources.Errors;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -51,7 +51,7 @@ import static java.lang.Double.NEGATIVE_
 import static java.lang.Double.POSITIVE_INFINITY;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -37,7 +37,7 @@ import org.apache.sis.internal.metadata.
 
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.collection.Containers.property;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/BursaWolfParameters.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -30,11 +30,11 @@ import org.apache.sis.util.resources.Err
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 
 import static java.lang.Math.abs;
 import static org.apache.sis.util.ArgumentChecks.*;
 import static org.apache.sis.referencing.operation.matrix.Matrix4.SIZE;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.getNumber;
 
 // Related to JDK7
 import java.util.Objects;
@@ -535,6 +535,23 @@ public class BursaWolfParameters extends
     }
 
     /**
+     * Retrieves the value at the specified row and column of the given matrix, wrapped in a {@code Number}.
+     * The {@code Number} type depends on the matrix accuracy.
+     *
+     * @param matrix The matrix from which to get the number.
+     * @param row    The row index, from 0 inclusive to {@link Matrix#getNumRow()} exclusive.
+     * @param column The column index, from 0 inclusive to {@link Matrix#getNumCol()} exclusive.
+     * @return       The current value at the given row and column.
+     */
+    private static Number getNumber(final Matrix matrix, final int row, final int column) {
+        if (matrix instanceof MatrixSIS) {
+            return ((MatrixSIS) matrix).getNumber(row, column);
+        } else {
+            return matrix.getElement(row, column);
+        }
+    }
+
+    /**
      * Returns the region or timeframe in which a coordinate transformation based on those Bursa-Wolf parameters is
      * valid, or {@code null} if unspecified. If an extent was specified at construction time, then that extent is
      * returned. Otherwise the datum domain of validity (which may be {@code null}) is returned.

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -35,7 +35,7 @@ import org.apache.sis.util.ComparisonMod
 
 import static org.apache.sis.util.ArgumentChecks.ensureFinite;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultTemporalDatum.java Wed Feb  5 16:02:48 2014
@@ -31,7 +31,7 @@ import org.apache.sis.internal.metadata.
 import org.apache.sis.util.ComparisonMode;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;

Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultVerticalDatum.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -32,7 +32,7 @@ import org.apache.sis.internal.jaxb.Lega
 import org.apache.sis.internal.referencing.VerticalDatumTypes;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
+import static org.apache.sis.internal.metadata.MetadataUtilities.canSetProperty;
 
 // Related to JDK7
 import java.util.Objects;

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/AbstractReferenceSystemTest.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -19,13 +19,24 @@ package org.apache.sis.referencing;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Locale;
+import org.opengis.referencing.IdentifiedObject;
 import org.opengis.test.Validators;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.metadata.iso.ImmutableIdentifier;
+import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.metadata.iso.extent.DefaultExtent;
+import org.apache.sis.metadata.iso.extent.DefaultTemporalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultVerticalExtent;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.test.mock.VerticalCRSMock;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
+import static org.opengis.referencing.ReferenceSystem.*;
 import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.MetadataAssert.assertWktEquals;
 
 
 /**
@@ -78,4 +89,49 @@ public final strictfp class AbstractRefe
 
         assertNotSame(object, assertSerializedEquals(object));
     }
+
+    /**
+     * Tests WKT formatting with a name that contains the quote character and optional information.
+     * We test that the closing quote character is doubled and the optional information properly formatted.
+     */
+    @Test
+    @DependsOnMethod("testCreateFromMap")
+    public void testWKT() {
+        final Map<String,Object> properties = new HashMap<>(8);
+        assertNull(properties.put(NAME_KEY, "My “object”."));
+        assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
+        assertNull(properties.put(REMARKS_KEY, "注です。"));
+        assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(
+                HardCodedCitations.OGP, "EPSG", "4326", "8.2", null)));
+        assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.",
+                new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77),
+                new DefaultVerticalExtent(10, 1000, VerticalCRSMock.DEPTH),
+                new DefaultTemporalExtent()))); // TODO: needs sis-temporal module for testing that one.
+        final IdentifiedObject object = new AbstractReferenceSystem(properties);
+
+        assertWktEquals(Convention.WKT1,
+                // Closing quote conservatively omitted for WKT 1.
+                "ReferenceSystem[“My “object.”, AUTHORITY[“EPSG”, “4326”]]",
+                object);
+
+        assertWktEquals(Convention.WKT2,
+                "ReferenceSystem[“My “object””.”,\n" +
+                "  SCOPE[“Large scale topographic mapping and cadastre.”],\n" +
+                "  AREA[“Netherlands offshore.”],\n" +
+                "  BBOX[51.43, 2.54, 55.77, 6.40],\n" +
+                "  VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1.0]],\n" +
+                "  ID[“EPSG”, 4326, “8.2”, “OGP”],\n" +
+                "  REMARKS[“注です。”]]",
+                object);
+
+        assertWktEquals(Convention.WKT2_SIMPLIFIED,
+                "ReferenceSystem[“My “object””.”,\n" +
+                "  SCOPE[“Large scale topographic mapping and cadastre.”],\n" +
+                "  AREA[“Netherlands offshore.”],\n" +
+                "  BBOX[51.43, 2.54, 55.77, 6.40],\n" +
+                "  VERTICALEXTENT[-1000, -10],\n" +
+                "  ID[“EPSG”, 4326, “8.2”, “OGP”],\n" +
+                "  REMARKS[“注です。”]]",
+                object);
+    }
 }

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java?rev=1564821&r1=1564820&r2=1564821&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/Assert.java [UTF-8] Wed Feb  5 16:02:48 2014
@@ -25,14 +25,10 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterValue;
 import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.opengis.referencing.cs.RangeMeaning;
-import org.apache.sis.io.wkt.Symbols;
-import org.apache.sis.io.wkt.WKTFormat;
-import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.geometry.AbstractEnvelope;
 import org.apache.sis.geometry.GeneralDirectPosition;
 
@@ -48,25 +44,13 @@ import static java.lang.StrictMath.*;
  * @version 0.4
  * @module
  */
-public strictfp class Assert extends org.apache.sis.test.Assert {
+public strictfp class Assert extends org.apache.sis.test.MetadataAssert {
     /**
      * The tolerance threshold for strict comparisons of floating point values.
      */
     private static final double STRICT = 0;
 
     /**
-     * The formatter to be used by {@link #assertWktEquals(Object, String)}.
-     * This formatter uses the {@code “…”} quotation marks instead of {@code "…"}
-     * for easier readability of {@link String} constants in Java code.
-     */
-    private static final WKTFormat WKT_FORMAT = new WKTFormat(null, null);
-    static {
-        final Symbols s = new Symbols(Symbols.SQUARE_BRACKETS);
-        s.setPairedQuotes("“”", "\"\"");
-        WKT_FORMAT.setSymbols(s);
-    }
-
-    /**
      * For subclass constructor only.
      */
     protected Assert() {
@@ -331,40 +315,4 @@ public strictfp class Assert extends org
             assertFalse("e1.contains(" + pos + ')', e1.contains(pos));
         }
     }
-
-    /**
-     * Asserts that the WKT 2 of the given object is equal to the expected one.
-     * This method expected the {@code “…”} quotation marks instead of {@code "…"}
-     * for easier readability of {@link String} constants in Java code.
-     *
-     * @param expected The expected text, or {@code null} if {@code object} is expected to be null.
-     * @param object The object to format in <cite>Well Known Text</cite> format, or {@code null}.
-     */
-    public static void assertWktEquals(final String expected, final Object object) {
-        assertWktEquals(Convention.WKT2, expected, object);
-    }
-
-    /**
-     * Asserts that the WKT of the given object according the given convention is equal to the expected one.
-     * This method expected the {@code “…”} quotation marks instead of {@code "…"} for easier readability of
-     * {@link String} constants in Java code.
-     *
-     * @param convention The WKT convention to use.
-     * @param expected   The expected text, or {@code null} if {@code object} is expected to be null.
-     * @param object     The object to format in <cite>Well Known Text</cite> format, or {@code null}.
-     */
-    public static void assertWktEquals(final Convention convention, final String expected, final Object object) {
-        if (expected == null) {
-            assertNull(object);
-        } else {
-            assertNotNull(object);
-            final String wkt;
-            synchronized (WKT_FORMAT) {
-                WKT_FORMAT.setConvention(convention);
-                wkt = WKT_FORMAT.format(object);
-            }
-            assertMultilinesEquals((object instanceof IdentifiedObject) ?
-                    ((IdentifiedObject) object).getName().getCode() : object.getClass().getSimpleName(), expected, wkt);
-        }
-    }
 }



Mime
View raw message