sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1626345 [10/14] - in /sis/trunk: ./ core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/ core/sis-metada...
Date Fri, 19 Sep 2014 21:46:44 GMT
Copied: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java?p2=sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java&p1=sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/citation/DefaultContactTest.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -20,7 +20,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.logging.LogRecord;
 import org.opengis.metadata.citation.Telephone;
-import org.opengis.metadata.citation.TelephoneType;
 import org.apache.sis.internal.jaxb.Context;
 import org.apache.sis.util.logging.WarningListener;
 import org.apache.sis.test.DependsOnMethod;
@@ -106,7 +105,7 @@ public final strictfp class DefaultConta
          */
         assertSame("getPhone", tel2, contact.getPhone()); // Shall ignore the TelephoneType.SMS.
         assertEquals("warningOccured", "IgnoredPropertyAssociatedTo_1", resourceKey);
-        assertArrayEquals("warningOccured", new String[] {"TelephoneType[SMS]"}, parameters);
+        assertArrayEquals("warningOccured", new String[] {"SMS"}, parameters);
         verifyLegacyLists(tels);
     }
 
@@ -135,6 +134,7 @@ public final strictfp class DefaultConta
      */
     @Test
     @DependsOnMethod("testSetPhones")
+    @org.junit.Ignore("Pending completion of ISO 19115:2014 upgrade.")
     public void testSetPhone() {
         testSetPhone(false);
     }
@@ -145,6 +145,7 @@ public final strictfp class DefaultConta
      */
     @Test
     @DependsOnMethod("testSetPhones")
+    @org.junit.Ignore("Pending completion of ISO 19115:2014 upgrade.")
     public void testSetNonSISPhone() {
         testSetPhone(true);
     }
@@ -164,8 +165,6 @@ public final strictfp class DefaultConta
         final Telephone view;
         if (hideSIS) {
             view = new Telephone() {
-                @Override public String             getNumber()     {return tel.getNumber();}
-                @Override public TelephoneType      getNumberType() {return tel.getNumberType();}
                 @Override public Collection<String> getVoices()     {return tel.getVoices();}
                 @Override public Collection<String> getFacsimiles() {return tel.getFacsimiles();}
             };

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -27,7 +27,7 @@ import org.apache.sis.util.logging.Warni
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.apache.sis.test.Assert.*;
 import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
@@ -36,7 +36,7 @@ import static org.apache.sis.test.TestUt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final strictfp class DefaultLegalConstraintsTest extends XMLTestCase implements WarningListener<Object> {
@@ -119,4 +119,33 @@ public final strictfp class DefaultLegal
         assertEquals("warning", "NullCollectionElement_1", resourceKey);
         assertArrayEquals("warning", new String[] {"CodeListSet<Restriction>"}, parameters);
     }
+
+    /**
+     * Tests (un)marshalling of a XML fragment containing the {@link Restriction#LICENSE} code.
+     * The spelling changed between ISO 19115:2003 and 19115:2014, from "license" to "licence".
+     * We need to ensure that XML marshalling use the old spelling, until the XML schema is updated.
+     *
+     * @throws JAXBException If an error occurred during the during unmarshalling processes.
+     */
+    @Test
+    public void testLicenceCode() throws JAXBException {
+        final String xml =
+                "<gmd:MD_LegalConstraints xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
+                "  <gmd:useConstraints>\n" +
+                "    <gmd:MD_RestrictionCode"
+                        + " codeList=\"http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode\""
+                        + " codeListValue=\"license\">License</gmd:MD_RestrictionCode>\n" +
+                "  </gmd:useConstraints>\n" +
+                "</gmd:MD_LegalConstraints>\n";
+
+        final DefaultLegalConstraints c = new DefaultLegalConstraints();
+        c.getUseConstraints().add(Restriction.LICENSE);
+        assertXmlEquals(xml, marshal(c), "xmlns:*");
+        /*
+         * Unmarshall and ensure that we got back the original LICENCE code, not a new "LICENSE" code.
+         */
+        final DefaultLegalConstraints actual = unmarshal(xml);
+        assertSame(Restriction.LICENSE, getSingleton(actual.getUseConstraints()));
+        assertEquals(c, actual);
+    }
 }

Copied: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java?p2=sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java&p1=sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -19,9 +19,6 @@ package org.apache.sis.metadata.iso.iden
 import org.opengis.util.ScopedName;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.metadata.citation.OnlineResource;
-import org.opengis.metadata.identification.CoupledResource;
-import org.opengis.metadata.identification.OperationMetadata;
-import org.opengis.metadata.identification.DistributedComputingPlatform;
 import org.apache.sis.internal.jaxb.metadata.replace.ServiceParameterTest;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.test.DependsOn;
@@ -47,8 +44,9 @@ public final strictfp class DefaultCoupl
      * Creates the resource to use for testing purpose.
      */
     static DefaultCoupledResource create() {
-        final DefaultOperationMetadata operation = new DefaultOperationMetadata("Get Map",
-                DistributedComputingPlatform.WEB_SERVICES, null);
+        final DefaultOperationMetadata operation = new DefaultOperationMetadata();
+        operation.setOperationName("Get Map");
+        operation.setDistributedComputingPlatforms(singleton("WEB_SERVICES"));
         operation.setParameters(singleton((ParameterDescriptor<?>) ServiceParameterTest.create()));
         operation.setConnectPoints(singleton(NilReason.MISSING.createNilObject(OnlineResource.class)));
 
@@ -64,13 +62,13 @@ public final strictfp class DefaultCoupl
     @Test
     public void testOperationNameResolve() {
         final DefaultCoupledResource resource  = DefaultCoupledResourceTest.create();
-        final OperationMetadata      operation = resource.getOperation();
+        final DefaultOperationMetadata operation = resource.getOperation();
         /*
          * Test OperationName replacement when the name matches.
          */
         resource.setOperation(new OperationName(operation.getOperationName()));
         assertNotSame("Before resolve", operation, resource.getOperation());
-        OperationName.resolve(singleton(operation), singleton((CoupledResource) resource));
+        OperationName.resolve(singleton(operation), singleton(resource));
         assertSame("After resolve", operation, resource.getOperation());
         /*
          * If the name doesn't match, no replacement shall be done.
@@ -78,7 +76,7 @@ public final strictfp class DefaultCoupl
         final OperationName other = new OperationName("Other");
         resource.setOperation(other);
         assertSame("Before resolve", other, resource.getOperation());
-        OperationName.resolve(singleton(operation), singleton((CoupledResource) resource));
+        OperationName.resolve(singleton(operation), singleton(resource));
         assertSame("After resolve", other, resource.getOperation());
     }
 }

Copied: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java?p2=sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java&p1=sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -18,7 +18,6 @@ package org.apache.sis.metadata.iso.iden
 
 import javax.xml.bind.JAXBException;
 import org.opengis.metadata.citation.Citation;
-import org.opengis.metadata.identification.CouplingType;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.test.DependsOn;
@@ -59,7 +58,7 @@ public final strictfp class DefaultServi
                 "A dummy service for testing purpose.");                // abstract
         id.setServiceTypeVersions(singleton("1.0"));
         id.setCoupledResources(singleton(resource));
-        id.setCouplingType(CouplingType.LOOSE);
+        id.setCouplingType("LOOSE");
         id.setContainsOperations(singleton(resource.getOperation()));
         return id;
     }
@@ -70,6 +69,7 @@ public final strictfp class DefaultServi
      * @throws JAXBException If an error occurred during the during marshalling process.
      */
     @Test
+    @org.junit.Ignore("Pending completion of ISO 19115:2014 upgrade.")
     public void testMarshal() throws JAXBException {
         assertMarshalEqualsFile(XML_FILE, create(), "xlmns:*", "xsi:schemaLocation");
     }

Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.5
  * @module
  */
 @Suite.SuiteClasses({
@@ -52,7 +52,6 @@ import org.junit.BeforeClass;
     // XML marshalling.
     org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
     org.apache.sis.internal.jaxb.code.PT_LocaleTest.class,
-    org.apache.sis.internal.jaxb.gml.TimePeriodTest.class,
     org.apache.sis.xml.FreeTextMarshallingTest.class,
     org.apache.sis.xml.NilReasonMarshallingTest.class,
     org.apache.sis.xml.AnchorMarshallingTest.class,
@@ -60,6 +59,7 @@ import org.junit.BeforeClass;
     org.apache.sis.xml.XLinkMarshallingTest.class,
 
     // ISO implementations.
+    org.apache.sis.metadata.iso.citation.DefaultContactTest.class,
     org.apache.sis.metadata.iso.citation.DefaultCitationDateTest.class,
     org.apache.sis.metadata.iso.citation.DefaultCitationTest.class,
     org.apache.sis.metadata.iso.maintenance.DefaultScopeDescriptionTest.class,
@@ -72,6 +72,9 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.identification.DefaultResolutionTest.class,
     org.apache.sis.metadata.iso.identification.DefaultBrowseGraphicTest.class,
     org.apache.sis.metadata.iso.identification.DefaultDataIdentificationTest.class,
+    org.apache.sis.internal.jaxb.metadata.replace.ServiceParameterTest.class,
+    org.apache.sis.metadata.iso.identification.DefaultCoupledResourceTest.class,
+    org.apache.sis.metadata.iso.identification.DefaultServiceIdentificationTest.class,
     org.apache.sis.metadata.iso.quality.AbstractElementTest.class,
     org.apache.sis.metadata.iso.quality.AbstractPositionalAccuracyTest.class,
     org.apache.sis.metadata.iso.lineage.DefaultLineageTest.class,

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/AffineTransform2D.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -62,18 +62,22 @@ public class AffineTransform2D extends I
     private static final long serialVersionUID = -5299837898367149069L;
 
     /**
-     * The inverse transform. This field will be computed only when needed.
+     * The matrix, or {@code null} if not yet computed.
+     *
+     * <p>This field is also used for determining if the affine transform is mutable.
+     * If this field is {@code null} (which should be a temporary state), then this means that
+     * this affine transform is still under construction. This field <strong>must</strong> be
+     * set to a non-null value before an {@link AffineTransform2D} instance is published.</p>
+     *
+     * @see #getMatrix()
+     * @see #freeze()
      */
-    private transient volatile AffineTransform2D inverse;
+    private AffineMatrix matrix;
 
     /**
-     * {@code true} if this transform is mutable. This field may be temporarily set
-     * to {@code true} during construction, but <strong>must</strong> be reset to
-     * {@code false} before an {@link AffineTransform2D} instance is published.
-     *
-     * @see #freeze()
+     * The inverse transform. This field will be computed only when needed.
      */
-    private transient boolean mutable;
+    private transient volatile AffineTransform2D inverse;
 
     /**
      * Constructs a <strong>temporarily mutable</strong> identity affine transform.
@@ -82,7 +86,6 @@ public class AffineTransform2D extends I
      */
     public AffineTransform2D() {
         super();
-        mutable = true;
     }
 
     /**
@@ -94,7 +97,9 @@ public class AffineTransform2D extends I
      */
     public AffineTransform2D(final AffineTransform transform, final boolean mutable) {
         super(transform);
-        this.mutable = mutable;
+        if (!mutable) {
+            freeze();
+        }
     }
 
     /**
@@ -104,9 +109,20 @@ public class AffineTransform2D extends I
      */
     public AffineTransform2D(final AffineTransform transform) {
         super(transform);
-        mutable = true;
         forcePositiveZeros();
-        mutable = false;
+        freeze();
+    }
+
+    /**
+     * Constructs a new {@code AffineTransform2D} from the given 9 or 18 values.
+     *
+     * @param elements The matrix elements, optionally with error terms.
+     */
+    public AffineTransform2D(final double[] elements) {
+        super(pz(elements[0]), pz(elements[3]),
+              pz(elements[1]), pz(elements[4]),
+              pz(elements[2]), pz(elements[5]));
+        matrix = new AffineMatrix(this, elements);
     }
 
     /**
@@ -124,6 +140,7 @@ public class AffineTransform2D extends I
      */
     public AffineTransform2D(double m00, double m10, double m01, double m11, double m02, double m12) {
         super(pz(m00), pz(m10), pz(m01), pz(m11), pz(m02), pz(m12));
+        freeze();
     }
 
     /**
@@ -150,9 +167,11 @@ public class AffineTransform2D extends I
 
     /**
      * Makes this {@code AffineTransform2D} immutable.
+     * This method shall be invoked exactly once.
      */
     public final void freeze() {
-        mutable = false;
+        assert matrix == null;
+        matrix = new AffineMatrix(this, null);
     }
 
     /**
@@ -163,7 +182,7 @@ public class AffineTransform2D extends I
      */
     @Override
     protected final void checkPermission() throws UnsupportedOperationException {
-        if (!mutable) {
+        if (matrix != null) {
             super.checkPermission();
         }
     }
@@ -261,7 +280,7 @@ public class AffineTransform2D extends I
      */
     @Override
     public final Matrix getMatrix() {
-        return AffineTransforms2D.toMatrix(this);
+        return matrix;
     }
 
     /**

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ImmutableAffineTransform.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ImmutableAffineTransform.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ImmutableAffineTransform.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ImmutableAffineTransform.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -31,7 +31,7 @@ import org.apache.sis.util.resources.Err
  * @version 0.5
  * @module
  */
-class ImmutableAffineTransform extends AffineTransform {
+public class ImmutableAffineTransform extends AffineTransform {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -295,6 +295,8 @@ class ImmutableAffineTransform extends A
 
     /**
      * Checks for {@linkplain #checkPermission() permission} before inverting this transform.
+     *
+     * @throws java.awt.geom.NoninvertibleTransformException If the matrix can not be inverted.
      */
     @Override
     public final void invert() throws NoninvertibleTransformException {

Copied: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java (from r1625241, sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java?p2=sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java&p1=sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/AbstractParameterDescriptor.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -19,10 +19,10 @@ package org.apache.sis.parameter;
 import java.util.Map;
 import javax.measure.unit.Unit;
 import org.opengis.util.InternationalString;
-import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
+import org.apache.sis.internal.jaxb.metadata.replace.ServiceParameter;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.io.wkt.Formatter;
@@ -31,8 +31,6 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.util.Debug;
 
-import static org.apache.sis.util.Utilities.deepEquals;
-
 // Branch-dependent imports
 import org.apache.sis.internal.jdk7.Objects;
 
@@ -201,9 +199,15 @@ public abstract class AbstractParameterD
      */
     protected AbstractParameterDescriptor(final GeneralParameterDescriptor descriptor) {
         super(descriptor);
-        description   = descriptor.getDescription();
         minimumOccurs = crop(descriptor.getMinimumOccurs());
         maximumOccurs = crop(descriptor.getMaximumOccurs());
+        if (descriptor instanceof AbstractParameterDescriptor) {
+            description = ((AbstractParameterDescriptor) descriptor).getDescription();
+        } else if (descriptor instanceof ServiceParameter) {
+            description = ((ServiceParameter) descriptor).getDescription();
+        } else {
+            description = null;
+        }
     }
 
     /**
@@ -226,22 +230,10 @@ public abstract class AbstractParameterD
     }
 
     /**
-     * Returns an indication if the parameter is an input to the service, an output or both.
-     * The default implementation returns {@link ParameterDirection#IN}.
-     *
-     * @return Indication if the parameter is an input or output to the service, or {@code null} if unspecified.
-     */
-    @Override
-    public ParameterDirection getDirection() {
-        return ParameterDirection.IN;
-    }
-
-    /**
      * Returns a narrative explanation of the role of the parameter.
      *
      * @return A narrative explanation of the role of the parameter, or {@code null} if none.
      */
-    @Override
     public InternationalString getDescription() {
         return description;
     }
@@ -286,8 +278,7 @@ public abstract class AbstractParameterD
                 default: {
                     final GeneralParameterDescriptor that = (GeneralParameterDescriptor) object;
                     return getMinimumOccurs() == that.getMinimumOccurs() &&
-                           getMaximumOccurs() == that.getMaximumOccurs() &&
-                           deepEquals(getDescription(), that.getDescription(), mode);
+                           getMaximumOccurs() == that.getMaximumOccurs();
                 }
             }
         }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -27,15 +27,11 @@ import org.apache.sis.util.Classes;
 import org.apache.sis.util.Numbers;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.io.wkt.Formatter;
-import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.MeasurementRange;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.CollectionsExt;
-import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.AbstractIdentifiedObject;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.ArgumentChecks.ensureCanCast;
@@ -68,24 +64,17 @@ import org.apache.sis.internal.jdk7.Obje
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.4 (derived from geotk-2.0)
- * @version 0.4
+ * @version 0.5
  * @module
  *
  * @see DefaultParameterValue
  * @see DefaultParameterDescriptorGroup
  */
-public class DefaultParameterDescriptor<T> extends AbstractIdentifiedObject implements ParameterDescriptor<T> {
+public class DefaultParameterDescriptor<T> extends AbstractParameterDescriptor implements ParameterDescriptor<T> {
     /**
      * Serial number for inter-operability with different versions.
      */
-    private static final long serialVersionUID = 7433401733923393656L;
-
-    /**
-     * {@code true} if this parameter is mandatory, or {@code false} if it is optional.
-     *
-     * @see #getMinimumOccurs()
-     */
-    private final boolean required;
+    private static final long serialVersionUID = -1978932430298071693L;
 
     /**
      * The class that describe the type of parameter values.
@@ -126,7 +115,7 @@ public class DefaultParameterDescriptor<
 
     /**
      * Constructs a descriptor from the given properties. The properties map is given unchanged to the
-     * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
+     * {@linkplain AbstractParameterDescriptor#AbstractParameterDescriptor(Map) super-class constructor}.
      * The following table is a reminder of main (not all) properties:
      *
      * <table class="sis">
@@ -152,6 +141,11 @@ public class DefaultParameterDescriptor<
      *     <td>{@link #getIdentifiers()}</td>
      *   </tr>
      *   <tr>
+     *     <td>{@value org.apache.sis.parameter.AbstractParameterDescriptor#DESCRIPTION_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getDescription()}</td>
+     *   </tr>
+     *   <tr>
      *     <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
      *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
      *     <td>{@link #getRemarks()}</td>
@@ -179,25 +173,29 @@ public class DefaultParameterDescriptor<
      * If both {@code valueDomain} and {@code validValues} are non-null, then all valid values shall be contained
      * in the value domain.
      *
-     * @param properties   The properties to be given to the identified object.
-     * @param valueClass   The class that describes the type of the parameter value.
-     * @param valueDomain  The minimum value, maximum value and unit of measurement, or {@code null} if none.
-     * @param validValues  The list of valid values, or {@code null} if there is no restriction.
-     *                     This property is mostly for restricting values to a {@linkplain CodeList code list}
-     *                     or enumeration subset. It is not necessary to provide this property when all values
-     *                     from the code list or enumeration are valid.
-     * @param defaultValue The default value for the parameter, or {@code null} if none.
-     * @param required     {@code true} if this parameter is mandatory, or {@code false} if it is optional.
+     * @param properties    The properties to be given to the identified object.
+     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times} that values
+     *                      for this parameter group are required, or 0 if no restriction.
+     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times} that values
+     *                      for this parameter group are required, or {@link Integer#MAX_VALUE} if no restriction.
+     * @param valueClass    The class that describes the type of the parameter value.
+     * @param valueDomain   The minimum value, maximum value and unit of measurement, or {@code null} if none.
+     * @param validValues   The list of valid values, or {@code null} if there is no restriction.
+     *                      This property is mostly for restricting values to a {@linkplain CodeList code list}
+     *                      or enumeration subset. It is not necessary to provide this property when all values
+     *                      from the code list or enumeration are valid.
+     * @param defaultValue  The default value for the parameter, or {@code null} if none.
      */
     @SuppressWarnings("unchecked")
     public DefaultParameterDescriptor(final Map<String,?> properties,
+                                      final int           minimumOccurs,
+                                      final int           maximumOccurs,
                                       final Class<T>      valueClass,
                                       final Range<?>      valueDomain,
                                       final T[]           validValues,
-                                      final T             defaultValue,
-                                      final boolean       required)
+                                      final T             defaultValue)
     {
-        super(properties);
+        super(properties, minimumOccurs, maximumOccurs);
         ensureNonNull("valueClass",   valueClass);
         ensureCanCast("defaultValue", valueClass, defaultValue);
         if (valueDomain != null) {
@@ -218,7 +216,6 @@ public class DefaultParameterDescriptor<
                         .getString(Errors.Keys.IllegalRange_2, valueDomain.getMinValue(), valueDomain.getMaxValue()));
             }
         }
-        this.required     = required;
         this.valueClass   = valueClass;
         this.valueDomain  = valueDomain;
         this.defaultValue = Numerics.cached(defaultValue);
@@ -254,6 +251,33 @@ public class DefaultParameterDescriptor<
     }
 
     /**
+     * Creates an optional or mandatory parameter. As a consequence of the merge with ISO 19115 {@code SV_Parameter},
+     * {@code DefaultParameterDescriptor} has been generalized to accept an arbitrary amount of occurrences.
+     *
+     * @param properties   The properties to be given to the identified object.
+     * @param valueClass   The class that describes the type of the parameter value.
+     * @param valueDomain  The minimum value, maximum value and unit of measurement, or {@code null} if none.
+     * @param validValues  The list of valid values, or {@code null} if there is no restriction.
+     *                     This property is mostly for restricting values to a {@linkplain CodeList code list}
+     *                     or enumeration subset. It is not necessary to provide this property when all values
+     *                     from the code list or enumeration are valid.
+     * @param defaultValue The default value for the parameter, or {@code null} if none.
+     * @param required     {@code true} if this parameter is mandatory, or {@code false} if it is optional.
+     *
+     * @deprecated Replaced by the constructor with explicit minimum and maximum number of occurrences.
+     */
+    @Deprecated
+    public DefaultParameterDescriptor(final Map<String,?> properties,
+                                      final Class<T>      valueClass,
+                                      final Range<?>      valueDomain,
+                                      final T[]           validValues,
+                                      final T             defaultValue,
+                                      final boolean       required)
+    {
+        this(properties, required ? 1 : 0, 1, valueClass, valueDomain, validValues, defaultValue);
+    }
+
+    /**
      * Creates a new descriptor with the same values than the specified one.
      * This copy constructor provides a way to convert an arbitrary implementation into a SIS one or a
      * user-defined one (as a subclass), usually in order to leverage some implementation-specific API.
@@ -267,7 +291,6 @@ public class DefaultParameterDescriptor<
     @SuppressWarnings("unchecked")
     protected DefaultParameterDescriptor(final ParameterDescriptor<T> descriptor) {
         super(descriptor);
-        required     = descriptor.getMinimumOccurs() != 0;
         valueClass   = descriptor.getValueClass();
         validValues  = descriptor.getValidValues();
         defaultValue = descriptor.getDefaultValue();
@@ -308,30 +331,6 @@ public class DefaultParameterDescriptor<
     }
 
     /**
-     * The minimum number of times that values for this parameter are required.
-     * A value of 0 means an optional parameter and a value of 1 means a mandatory parameter.
-     *
-     * @see #getMaximumOccurs()
-     */
-    @Override
-    public int getMinimumOccurs() {
-        return required ? 1 : 0;
-    }
-
-    /**
-     * The maximum number of times that values for this parameter can be included.
-     * For a {@code ParameterDescriptor}, the value is always 1.
-     *
-     * @return The maximum occurrence.
-     *
-     * @see #getMinimumOccurs()
-     */
-    @Override
-    public int getMaximumOccurs() {
-        return 1;
-    }
-
-    /**
      * Creates a new parameter value instance initialized with the {@linkplain #getDefaultValue() default value}.
      * The {@linkplain DefaultParameterDescriptor parameter descriptor} for the created parameter value will be
      * {@code this} object.
@@ -507,8 +506,7 @@ public class DefaultParameterDescriptor<
                 }
                 case STRICT: {
                     final DefaultParameterDescriptor<?> that = (DefaultParameterDescriptor<?>) object;
-                    return                    this.required   == that.required     &&
-                                              this.valueClass == that.valueClass   &&
+                    return                    this.valueClass == that.valueClass   &&
                            Objects.    equals(this.validValues,  that.validValues) &&
                            Objects.    equals(this.valueDomain,  that.valueDomain) &&
                            Objects.deepEquals(this.defaultValue, that.defaultValue);
@@ -525,31 +523,6 @@ public class DefaultParameterDescriptor<
      */
     @Override
     protected long computeHashCode() {
-        return Arrays.deepHashCode(new Object[] {required, valueClass, valueDomain, defaultValue})
-                + super.computeHashCode();
-    }
-
-    /**
-     * Formats this parameter as a pseudo-<cite>Well Known Text</cite> element. The WKT specification
-     * does not define any representation of parameter descriptors. Apache SIS fallback on the
-     * {@linkplain DefaultParameterValue#formatTo(Formatter) same representation than parameter value},
-     * with the descriptor {@linkplain #getDefaultValue() default value} in place of the parameter value.
-     * The text formatted by this method is {@linkplain Formatter#setInvalidWKT flagged as invalid WKT}.
-     *
-     * @param  formatter The formatter where to format the inner content of this WKT element.
-     * @return {@code "Parameter"}.
-     */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendName(this, formatter, ElementKind.PARAMETER);
-        formatter.setInvalidWKT(this, null);
-        formatter.appendAny(defaultValue);
-        final Unit<?> unit = getUnit();
-        if (unit != null) {
-            if (!formatter.getConvention().isSimplified() || !unit.equals(formatter.toContextualUnit(unit))) {
-                formatter.append(unit);
-            }
-        }
-        return "Parameter";
+        return Arrays.deepHashCode(new Object[] {valueClass, valueDomain, defaultValue}) + super.computeHashCode();
     }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -22,21 +22,15 @@ import java.util.List;
 import java.util.HashSet;
 import java.util.Collections;
 import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.parameter.InvalidParameterNameException;
-import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
-import org.apache.sis.internal.referencing.WKTUtilities;
-import org.apache.sis.io.wkt.FormattableObject;
-import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.util.Debug;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -89,27 +83,17 @@ import static org.apache.sis.util.Utilit
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.4 (derived from geotk-2.0)
- * @version 0.4
+ * @version 0.5
  * @module
  *
  * @see DefaultParameterValueGroup
  * @see DefaultParameterDescriptor
  */
-public class DefaultParameterDescriptorGroup extends AbstractIdentifiedObject implements ParameterDescriptorGroup {
+public class DefaultParameterDescriptorGroup extends AbstractParameterDescriptor implements ParameterDescriptorGroup {
     /**
      * Serial number for inter-operability with different versions.
      */
-    private static final long serialVersionUID = -4613190550542423839L;
-
-    /**
-     * The minimum number of times that values for this parameter group are required.
-     */
-    private final int minimumOccurs;
-
-    /**
-     * The maximum number of times that values for this parameter group are required.
-     */
-    private final int maximumOccurs;
+    private static final long serialVersionUID = 6058599597772994456L;
 
     /**
      * The {@linkplain #descriptors() parameter descriptors} for this group.
@@ -118,7 +102,7 @@ public class DefaultParameterDescriptorG
 
     /**
      * Constructs a parameter group from a set of properties. The properties map is given unchanged to the
-     * {@linkplain AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}.
+     * {@linkplain AbstractParameterDescriptor#AbstractParameterDescriptor(Map) super-class constructor}.
      * The following table is a reminder of main (not all) properties:
      *
      * <table class="sis">
@@ -144,6 +128,11 @@ public class DefaultParameterDescriptorG
      *     <td>{@link #getIdentifiers()}</td>
      *   </tr>
      *   <tr>
+     *     <td>{@value org.apache.sis.parameter.AbstractParameterDescriptor#DESCRIPTION_KEY}</td>
+     *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
+     *     <td>{@link #getDescription()}</td>
+     *   </tr>
+     *   <tr>
      *     <td>{@value org.opengis.referencing.IdentifiedObject#REMARKS_KEY}</td>
      *     <td>{@link org.opengis.util.InternationalString} or {@link String}</td>
      *     <td>{@link #getRemarks()}</td>
@@ -151,10 +140,10 @@ public class DefaultParameterDescriptorG
      * </table>
      *
      * @param properties    The properties to be given to the identified object.
-     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times}
-     *                      that values for this parameter group are required.
-     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times}
-     *                      that values for this parameter group are required.
+     * @param minimumOccurs The {@linkplain #getMinimumOccurs() minimum number of times} that values
+     *                      for this parameter group are required, or 0 if no restriction.
+     * @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times} that values
+     *                      for this parameter group are required, or {@link Integer#MAX_VALUE} if no restriction.
      * @param parameters    The {@linkplain #descriptors() parameter descriptors} for this group.
      *
      * @throws InvalidParameterNameException If a parameter name is duplicated.
@@ -162,13 +151,7 @@ public class DefaultParameterDescriptorG
     public DefaultParameterDescriptorGroup(final Map<String,?> properties,
             final int minimumOccurs, final int maximumOccurs, GeneralParameterDescriptor... parameters)
     {
-        super(properties);
-        this.minimumOccurs = minimumOccurs;
-        this.maximumOccurs = maximumOccurs;
-        if (minimumOccurs < 0  || minimumOccurs > maximumOccurs || maximumOccurs == 0) {
-            throw new IllegalArgumentException(Errors.getResources(properties).getString(
-                    Errors.Keys.IllegalRange_2, minimumOccurs, maximumOccurs));
-        }
+        super(properties, minimumOccurs, maximumOccurs);
         ArgumentChecks.ensureNonNull("parameters", parameters);
         parameters = parameters.clone();
         for (int i=0; i<parameters.length; i++) {
@@ -198,8 +181,6 @@ public class DefaultParameterDescriptorG
      */
     protected DefaultParameterDescriptorGroup(final ParameterDescriptorGroup descriptor) {
         super(descriptor);
-        minimumOccurs = descriptor.getMinimumOccurs();
-        maximumOccurs = descriptor.getMaximumOccurs();
         final List<GeneralParameterDescriptor> c = descriptor.descriptors();
         if (descriptor instanceof DefaultParameterDescriptorGroup &&
                 ((DefaultParameterDescriptorGroup) descriptor).descriptors == c)
@@ -282,27 +263,6 @@ public class DefaultParameterDescriptorG
     }
 
     /**
-     * The minimum number of times that values for this parameter group or parameter are required.
-     * A value of 0 means an optional parameter.
-     *
-     * @return The minimum occurrence.
-     */
-    @Override
-    public int getMinimumOccurs() {
-        return minimumOccurs;
-    }
-
-    /**
-     * The maximum number of times that values for this parameter group are required.
-     *
-     * @return The maximum occurrence.
-     */
-    @Override
-    public int getMaximumOccurs() {
-        return maximumOccurs;
-    }
-
-    /**
      * Creates a new instance of {@linkplain DefaultParameterValueGroup parameter value group}
      * initialized with the {@linkplain DefaultParameterDescriptor#getDefaultValue default values}.
      * The {@linkplain DefaultParameterValueGroup#getDescriptor() parameter descriptor} for the
@@ -375,16 +335,10 @@ public class DefaultParameterDescriptorG
         if (super.equals(object, mode)) {
             switch (mode) {
                 case STRICT: {
-                    final DefaultParameterDescriptorGroup that = (DefaultParameterDescriptorGroup) object;
-                    return minimumOccurs == that.minimumOccurs &&
-                           maximumOccurs == that.maximumOccurs &&
-                           descriptors.equals(that.descriptors);
+                    return descriptors.equals(((DefaultParameterDescriptorGroup) object).descriptors);
                 }
                 default: {
-                    final ParameterDescriptorGroup that = (ParameterDescriptorGroup) object;
-                    return getMinimumOccurs() == that.getMinimumOccurs() &&
-                           getMaximumOccurs() == that.getMaximumOccurs() &&
-                           deepEquals(descriptors(), that.descriptors(), mode);
+                    return deepEquals(descriptors(), ((ParameterDescriptorGroup) object).descriptors(), mode);
                 }
             }
         }
@@ -400,60 +354,4 @@ public class DefaultParameterDescriptorG
     protected long computeHashCode() {
         return super.computeHashCode() + descriptors.hashCode();
     }
-
-    /**
-     * Returns a string representation of this descriptor.
-     * The default implementation delegates to {@link ParameterFormat}.
-     *
-     * <p>This method is for information purpose only and may change in future SIS version.</p>
-     */
-    @Debug
-    @Override
-    public String toString() {
-        return ParameterFormat.sharedFormat(this);
-    }
-
-    /**
-     * Prints a string representation of this descriptor to the {@linkplain System#out standard output stream}.
-     * If a {@linkplain java.io.Console console} is attached to the running JVM (i.e. if the application is run
-     * from the command-line and the output is not redirected to a file) and if Apache SIS thinks that the console
-     * supports the ANSI escape codes (a.k.a. X3.64), then a syntax coloring will be applied.
-     *
-     * <p>This is a convenience method for debugging purpose and for console applications.</p>
-     */
-    @Debug
-    @Override
-    public void print() {
-        ParameterFormat.print(this);
-    }
-
-    /**
-     * Formats this group as a pseudo-<cite>Well Known Text</cite> element. The WKT specification
-     * does not define any representation of parameter descriptors. Apache SIS fallback on a list
-     * of {@linkplain DefaultParameterDescriptor#formatTo(Formatter) single descriptors}.
-     * The text formatted by this method is {@linkplain Formatter#setInvalidWKT flagged as invalid WKT}.
-     *
-     * @param  formatter The formatter where to format the inner content of this WKT element.
-     * @return {@code "ParameterGroup"}.
-     */
-    @Override
-    @SuppressWarnings({"unchecked","rawtypes"})
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendName(this, formatter, null);
-        formatter.setInvalidWKT(this, null);
-        for (GeneralParameterDescriptor parameter : descriptors) {
-            if (!(parameter instanceof FormattableObject)) {
-                if (parameter instanceof ParameterDescriptor<?>) {
-                    parameter = new DefaultParameterDescriptor((ParameterDescriptor<?>) parameter);
-                } else if (parameter instanceof ParameterDescriptorGroup) {
-                    parameter = new DefaultParameterDescriptorGroup((ParameterDescriptorGroup) parameter);
-                } else {
-                    continue;
-                }
-            }
-            formatter.newLine();
-            formatter.append((FormattableObject) parameter);
-        }
-        return "ParameterGroup";
-    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterBuilder.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -276,8 +276,8 @@ public class ParameterBuilder extends Bu
         final ParameterDescriptor<T> descriptor;
         onCreate(false);
         try {
-            descriptor = new DefaultParameterDescriptor<T>(properties,
-                    valueClass, valueDomain, validValues, defaultValue, required);
+            descriptor = new DefaultParameterDescriptor<T>(properties, required ? 1 : 0, 1,
+                    valueClass, valueDomain, validValues, defaultValue);
         } finally {
             onCreate(true);
         }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterFormat.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -50,7 +50,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.resources.Vocabulary;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.internal.referencing.NameToIdentifier;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.util.CollectionsExt;
 import org.apache.sis.internal.util.X364;
 

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterTableRow.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -38,7 +38,7 @@ import org.apache.sis.io.wkt.Colors;
 import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.RangeFormat;
-import org.apache.sis.internal.referencing.NameToIdentifier;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.util.X364;
 
 import static org.apache.sis.internal.util.X364.*;

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -17,8 +17,10 @@
 package org.apache.sis.parameter;
 
 import javax.measure.unit.Unit;
-import org.opengis.parameter.ParameterDescriptor;
+import org.opengis.util.MemberName;
 import org.opengis.parameter.ParameterValue;
+import org.opengis.parameter.ParameterDescriptor;
+import org.apache.sis.internal.jaxb.metadata.replace.ServiceParameter;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.NumberRange;
 import org.apache.sis.measure.MeasurementRange;
@@ -31,7 +33,7 @@ import org.apache.sis.util.Static;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.4 (derived from geotk-2.1)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class Parameters extends Static {
@@ -136,4 +138,33 @@ public final class Parameters extends St
         }
         return null;
     }
+
+    /**
+     * Gets the parameter name as an instance of {@code MemberName}.
+     * This method performs the following checks:
+     *
+     * <ul>
+     *   <li>If the {@linkplain DefaultParameterDescriptor#getName()} primary name is an instance of {@code MemberName},
+     *       returns that primary name.</li>
+     *   <li>Otherwise this method searches for the first {@linkplain DefaultParameterDescriptor#getAlias() alias}
+     *       which is an instance of {@code MemberName}. If found, that alias is returned.</li>
+     *   <li>If no alias is found, then this method tries to build a member name from the primary name and the
+     *       {@linkplain DefaultParameterDescriptor#getValueClass() value class}, using the mapping defined in
+     *       {@link org.apache.sis.util.iso.DefaultTypeName} javadoc.</li>
+     * </ul>
+     *
+     * This method can be used as a bridge between the parameter object
+     * defined by ISO 19111 (namely {@code CC_OperationParameter}) and the one
+     * defined by ISO 19115 (namely {@code SV_Parameter}).
+     *
+     * @param  parameter The parameter from which to get the name (may be {@code null}).
+     * @return The member name, or {@code null} if none.
+     *
+     * @see org.apache.sis.util.iso.Names#createMemberName(CharSequence, String, CharSequence, Class)
+     *
+     * @since 0.5
+     */
+    public static MemberName getMemberName(final ParameterDescriptor<?> parameter) {
+        return ServiceParameter.getMemberName(parameter);
+    }
 }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorParameters.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -140,9 +140,9 @@ public class TensorParameters<E> impleme
         final Map<String,Object> properties = new HashMap<String,Object>(4);
         properties.put(ReferenceIdentifier.AUTHORITY_KEY, Citations.OGC);
         properties.put(ReferenceIdentifier.CODE_KEY, "num_row");
-        numRow = new DefaultParameterDescriptor<Integer>(properties, Integer.class, valueDomain, null, defaultSize, true);
+        numRow = new DefaultParameterDescriptor<Integer>(properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
         properties.put(ReferenceIdentifier.CODE_KEY, "num_col");
-        numCol = new DefaultParameterDescriptor<Integer>(properties, Integer.class, valueDomain, null, defaultSize, true);
+        numCol = new DefaultParameterDescriptor<Integer>(properties, 1, 1, Integer.class, valueDomain, null, defaultSize);
         WKT1 = new TensorParameters<Double>(Double.class, "elt_", "_", numRow, numCol);
     }
 
@@ -378,7 +378,7 @@ public class TensorParameters<E> impleme
         final Map<String,Object> properties = new HashMap<String,Object>(4);
         properties.put(ReferenceIdentifier.CODE_KEY, indicesToName(indices));
         properties.put(ReferenceIdentifier.AUTHORITY_KEY, dimensions[0].getName().getAuthority());
-        return new DefaultParameterDescriptor<E>(properties, elementType, null, null, isDiagonal ? one : zero, false);
+        return new DefaultParameterDescriptor<E>(properties, 0, 1, elementType, null, null, isDiagonal ? one : zero);
     }
 
     /**

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/TensorValues.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -31,10 +31,10 @@ import org.opengis.parameter.GeneralPara
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterNotFoundException;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.util.Numerics;
+import org.apache.sis.io.wkt.ElementKind;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Classes;
@@ -42,7 +42,6 @@ import org.apache.sis.util.CharSequences
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.Debug;
 
 
 /**
@@ -55,10 +54,10 @@ import org.apache.sis.util.Debug;
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.0)
- * @version 0.4
+ * @version 0.5
  * @module
  */
-final class TensorValues<E> extends AbstractIdentifiedObject
+final class TensorValues<E> extends AbstractParameterDescriptor
         implements ParameterDescriptorGroup, ParameterValueGroup, Cloneable
 {
     /**
@@ -90,7 +89,7 @@ final class TensorValues<E> extends Abst
      */
     @SuppressWarnings({"unchecked","rawtypes"})
     TensorValues(final Map<String,?> properties, final TensorParameters<E> descriptors) {
-        super(properties);
+        super(properties, 1, 1);
         this.descriptors = descriptors;
         dimensions = new ParameterValue[descriptors.rank()];
         for (int i=0; i<dimensions.length; i++) {
@@ -171,22 +170,6 @@ final class TensorValues<E> extends Abst
     }
 
     /**
-     * Returns 1 since this group is considered mandatory.
-     */
-    @Override
-    public int getMinimumOccurs() {
-        return 1;
-    }
-
-    /**
-     * Returns 1 since we expect exactly one instance of this group.
-     */
-    @Override
-    public int getMaximumOccurs() {
-        return 1;
-    }
-
-    /**
      * Returns the current tensor dimensions.
      */
     private int[] dimensions() {
@@ -453,24 +436,6 @@ final class TensorValues<E> extends Abst
     }
 
     /**
-     * Returns a string representation of this group.
-     */
-    @Debug
-    @Override
-    public String toString() {
-        return ParameterFormat.sharedFormat(this);
-    }
-
-    /**
-     * Prints a string representation of this group to the {@linkplain System#out standard output stream}.
-     */
-    @Debug
-    @Override
-    public void print() {
-        ParameterFormat.print(this);
-    }
-
-    /**
      * Formats this group as a pseudo-<cite>Well Known Text</cite> element.
      *
      * @param  formatter The formatter where to format the inner content of this WKT element.
@@ -478,7 +443,7 @@ final class TensorValues<E> extends Abst
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        super.formatTo(formatter);
+        WKTUtilities.appendName(this, formatter, ElementKind.PARAMETER);
         WKTUtilities.append(this, formatter);
         return "ParameterGroup";
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/UninitializedParameter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/UninitializedParameter.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/UninitializedParameter.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/UninitializedParameter.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -33,7 +33,7 @@ import org.apache.sis.referencing.Identi
  * @version 0.4
  * @module
  */
-final class UninitializedParameter implements GeneralParameterValue, Serializable {
+final class UninitializedParameter implements GeneralParameterValue, Serializable { // Intentionally non-Cloneable.
     /**
      * For cross-version serialization compatibility.
      */

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -20,8 +20,19 @@
  * An explanation for this package is provided in the {@linkplain org.opengis.parameter OpenGIS® javadoc}.
  * The remaining discussion on this page is specific to the SIS implementation.
  *
- * <p>Parameters are organized in <cite>groups</cite>. A group may be for example the set of all parameters needed
- * for the definition of a <cite>Mercator projection</cite>.
+ * <p>There is three categories of classes in this package:</p>
+ * <ul>
+ *   <li><b>Parameter descriptors</b> are immutable types that describes the parameters needed by an operation or a
+ *     process. Descriptors contain information like parameter name, optionality, repeatability and value type, but
+ *     do not contain the actual parameter value.</li>
+ *   <li><b>Parameter values</b> are (<var>descriptor</var>, <var>value</var>) tuples, together with convenience methods
+ *     for performing unit conversions and getting the values as instances of some commonly used types.</li>
+ *   <li>Builders, formatters and static methods aim to simplify the creation of {@code ParameterDescriptor}s,
+ *     the search for parameter values and visualizing them in a tabular format.</li>
+ * </ul>
+ *
+ * <p>Parameters are organized in <cite>groups</cite>.
+ * A group may be for example the set of all parameters needed for the definition of a <cite>Mercator projection</cite>.
  * Parameter groups have some similarities with {@code java.util.Map} where:</p>
  *
  * <ul>
@@ -73,7 +84,7 @@
  * if the given value is not assignable to the expected class or is not inside the value domain.
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @since   0.4 (derived from geotk-2.0)
+ * @since   0.5 (derived from geotk-2.0)
  * @version 0.4
  * @module
  */

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -379,7 +379,7 @@ public class AbstractIdentifiedObject ex
      *
      * <ul>
      *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
-     *   <li>Otherwise if the given object is is an instance of
+     *   <li>Otherwise if the given object is an instance of
      *       {@link org.opengis.referencing.cs.CoordinateReferenceSystem},
      *       {@link org.opengis.referencing.cs.CoordinateSystem},
      *       {@link org.opengis.referencing.cs.CoordinateSystemAxis},

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/NamedIdentifier.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -32,7 +32,7 @@ import org.opengis.metadata.citation.Cit
 import org.opengis.metadata.Identifier;
 import org.opengis.referencing.ReferenceIdentifier;
 import org.opengis.parameter.InvalidParameterValueException;
-import org.apache.sis.internal.referencing.NameToIdentifier;
+import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.metadata.iso.ImmutableIdentifier;

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -195,7 +195,7 @@ public class AbstractCRS extends Abstrac
      *
      * <ul>
      *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
-     *   <li>Otherwise if the given object is is an instance of
+     *   <li>Otherwise if the given object is an instance of
      *       {@link org.opengis.referencing.crs.GeodeticCRS} (including the
      *       {@link org.opengis.referencing.crs.GeographicCRS} and
      *       {@link org.opengis.referencing.crs.GeocentricCRS} subtypes),

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/AbstractCS.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -238,7 +238,7 @@ public class AbstractCS extends Abstract
      *
      * <ul>
      *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
-     *   <li>Otherwise if the given object is is an instance of
+     *   <li>Otherwise if the given object is an instance of
      *       {@link org.opengis.referencing.cs.AffineCS},
      *       {@link org.opengis.referencing.cs.CartesianCS},
      *       {@link org.opengis.referencing.cs.SphericalCS},

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/AbstractDatum.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -224,7 +224,7 @@ public class AbstractDatum extends Abstr
      *
      * <ul>
      *   <li>If the given object is {@code null}, then this method returns {@code null}.</li>
-     *   <li>Otherwise if the given object is is an instance of
+     *   <li>Otherwise if the given object is an instance of
      *       {@link org.opengis.referencing.datum.GeodeticDatum},
      *       {@link org.opengis.referencing.datum.VerticalDatum},
      *       {@link org.opengis.referencing.datum.TemporalDatum},

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/GeneralMatrix.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -22,6 +22,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.DoubleDouble;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
 
 
 /**
@@ -35,12 +36,12 @@ import org.apache.sis.internal.util.Doub
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.2)
- * @version 0.4
+ * @version 0.5
  * @module
  *
  * @see Matrices#createDiagonal(int, int)
  */
-class GeneralMatrix extends MatrixSIS {
+class GeneralMatrix extends MatrixSIS implements ExtendedPrecisionMatrix {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -132,8 +133,13 @@ class GeneralMatrix extends MatrixSIS {
         ensureValidSize(numRow, numCol);
         this.numRow = (short) numRow;
         this.numCol = (short) numCol;
-        elements = new double[numRow * numCol];
-        getElements(matrix, numRow, numCol, elements);
+        if (matrix instanceof ExtendedPrecisionMatrix) {
+            elements = ((ExtendedPrecisionMatrix) matrix).getExtendedElements();
+            assert (elements.length % (numRow * numCol)) == 0;
+        } else {
+            elements = new double[numRow * numCol];
+            getElements(matrix, numRow, numCol, elements);
+        }
     }
 
     /**
@@ -320,6 +326,15 @@ class GeneralMatrix extends MatrixSIS {
     }
 
     /**
+     * Returns a copy of all matrix elements, potentially followed by the error terms for extended-precision arithmetic.
+     * Matrix elements are returned in a flat, row-major (column indices vary fastest) array.
+     */
+    @Override
+    public final double[] getExtendedElements() {
+        return elements.clone();
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/matrix/Matrices.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -30,6 +30,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.referencing.AxisDirections;
+import org.apache.sis.internal.referencing.ExtendedPrecisionMatrix;
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk7.JDK7;
@@ -64,7 +65,7 @@ import org.apache.sis.internal.jdk7.Obje
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4 (derived from geotk-2.2)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class Matrices extends Static {
@@ -678,11 +679,13 @@ public final class Matrices extends Stat
         if (size != matrix.getNumCol()) {
             return new NonSquareMatrix(matrix);
         }
-        switch (size) {
-            case 1: return new Matrix1(matrix);
-            case 2: return new Matrix2(matrix);
-            case 3: return new Matrix3(matrix);
-            case 4: return new Matrix4(matrix);
+        if (!(matrix instanceof ExtendedPrecisionMatrix)) {
+            switch (size) {
+                case 1: return new Matrix1(matrix);
+                case 2: return new Matrix2(matrix);
+                case 3: return new Matrix3(matrix);
+                case 4: return new Matrix4(matrix);
+            }
         }
         return new GeneralMatrix(matrix);
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -33,7 +33,6 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.SingleOperation;
 import org.apache.sis.geometry.GeneralDirectPosition;
 import org.apache.sis.parameter.Parameterized;
-import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.FormattableObject;
@@ -867,51 +866,6 @@ public abstract class AbstractMathTransf
     }
 
     /**
-     * Helper method for implementation of {@link #equals(Object, ComparisonMode)} methods in
-     * {@link LinearTransform} implementations. Those implementations shall replace completely the
-     * {@link #equals(Object, ComparisonMode)} default implementation, <strong>except</strong> for
-     * {@link ComparisonMode#STRICT} which should continue to rely on the default implementation.
-     * The pattern is:
-     *
-     * {@preformat java
-     *     public boolean equals(Object object, ComparisonMode mode) {
-     *         if (object == this) { // Slight optimization
-     *             return true;
-     *         }
-     *         if (mode != ComparisonMode.STRICT) {
-     *             return equals(this, object, mode);
-     *         }
-     *         if (super.equals(object, mode)) {
-     *             // Compare the internal fields here.
-     *         }
-     *         return false;
-     *     }
-     * }
-     *
-     * Note that this pattern considers {@link ComparisonMode#BY_CONTRACT} as synonymous to
-     * {@code IGNORE_METADATA} rather than {@code STRICT}. This is valid if we consider that
-     * the behavior of the math transform is completely specified by its matrix.
-     *
-     * @param  t1  The first transform to compare.
-     * @param  t2  The second transform to compare, or {@code null} if none.
-     * @param  mode The strictness level of the comparison.
-     * @return {@code true} if both transforms are equal.
-     */
-    static boolean equals(final LinearTransform t1, final Object t2, final ComparisonMode mode) {
-        if (t2 instanceof LinearTransform) {
-            final Matrix m1 = t1.getMatrix();
-            if (m1 != null) {
-                final Matrix m2 = ((LinearTransform) t2).getMatrix();
-                if (m1 instanceof LenientComparable) {
-                    return ((LenientComparable) m1).equals(m2, mode);
-                }
-                return Matrices.equals(m1, m2, mode);
-            }
-        }
-        return false;
-    }
-
-    /**
      * Formats the inner part of a <cite>Well Known Text</cite> version 1 (WKT 1) element.
      * The default implementation formats all parameter values returned by {@link #getParameterValues()}.
      * The parameter group name is used as the math transform name.
@@ -944,7 +898,7 @@ public abstract class AbstractMathTransf
      * @see AbstractMathTransform2D#beforeFormat(List, int, boolean)
      * @see ConcatenatedTransform#getPseudoSteps()
      */
-    int beforeFormat(List<MathTransform> transforms, int index, boolean inverse) {
+    int beforeFormat(List<Object> transforms, int index, boolean inverse) {
         return index;
     }
 

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -26,7 +26,6 @@ import java.awt.geom.PathIterator;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.IllegalPathStateException;
 import org.opengis.referencing.operation.Matrix;
-import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransform2D;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
@@ -103,8 +102,15 @@ public abstract class AbstractMathTransf
      */
     @Override
     public Point2D transform(final Point2D ptSrc, final Point2D ptDst) throws TransformException {
+        return transform(this, ptSrc, ptDst);
+    }
+
+    /**
+     * Implementation of {@link #transform(DirectPosition, DirectPosition)} shared by the inverse transform.
+     */
+    static Point2D transform(final AbstractMathTransform tr, final Point2D ptSrc, final Point2D ptDst) throws TransformException {
         final double[] ord = new double[] {ptSrc.getX(), ptSrc.getY()};
-        transform(ord, 0, ord, 0, false);
+        tr.transform(ord, 0, ord, 0, false);
         if (ptDst != null) {
             ptDst.setLocation(ord[0], ord[1]);
             return ptDst;
@@ -285,8 +291,15 @@ public abstract class AbstractMathTransf
      */
     @Override
     public Matrix derivative(final Point2D point) throws TransformException {
+        return derivative(this, point);
+    }
+
+    /**
+     * Implementation of {@link #derivative(DirectPosition)} shared by the inverse transform.
+     */
+    static Matrix derivative(final AbstractMathTransform tr, final Point2D point) throws TransformException {
         final double[] coordinate = new double[] {point.getX(), point.getY()};
-        final Matrix derivative = transform(coordinate, 0, null, 0, true);
+        final Matrix derivative = tr.transform(coordinate, 0, null, 0, true);
         if (derivative == null) {
             throw new TransformException(Errors.format(Errors.Keys.CanNotComputeDerivative));
         }
@@ -340,11 +353,66 @@ public abstract class AbstractMathTransf
         }
 
         /**
+         * Transforms the specified {@code ptSrc} and stores the result in {@code ptDst}.
+         * The default implementation invokes {@link #transform(double[], int, double[], int, boolean)}
+         * using a temporary array of doubles.
+         *
+         * @param  ptSrc The coordinate point to be transformed.
+         * @param  ptDst The coordinate point that stores the result of transforming {@code ptSrc},
+         *               or {@code null} if a new point shall be created.
+         * @return The coordinate point after transforming {@code ptSrc} and storing the result in {@code ptDst},
+         *         or in a new point if {@code ptDst} was null.
+         * @throws TransformException If the point can not be transformed.
+         *
+         * @see MathTransform2D#transform(Point2D, Point2D)
+         */
+        @Override
+        public Point2D transform(final Point2D ptSrc, final Point2D ptDst) throws TransformException {
+            return AbstractMathTransform2D.transform(this, ptSrc, ptDst);
+        }
+
+        /**
+         * Transforms the specified shape. The default implementation computes quadratic curves
+         * using three points for each line segment in the shape. The returned object is often
+         * a {@link Path2D}, but may also be a {@link Line2D} or a {@link QuadCurve2D} if such
+         * simplification is possible.
+         *
+         * @param  shape Shape to transform.
+         * @return Transformed shape, or {@code shape} if this transform is the identity transform.
+         * @throws TransformException if a transform failed.
+         */
+        @Override
+        public Shape createTransformedShape(final Shape shape) throws TransformException {
+            return isIdentity() ? shape : AbstractMathTransform2D.createTransformedShape(this, shape, null, null, false);
+        }
+
+        /**
+         * Gets the derivative of this transform at a point.
+         * The default implementation performs the following steps:
+         *
+         * <ul>
+         *   <li>Copy the coordinate in a temporary array and pass that array to the
+         *       {@link #transform(double[], int, double[], int, boolean)} method,
+         *       with the {@code derivate} boolean argument set to {@code true}.</li>
+         *   <li>If the later method returned a non-null matrix, returns that matrix.
+         *       Otherwise throws {@link TransformException}.</li>
+         * </ul>
+         *
+         * @param  point The coordinate point where to evaluate the derivative.
+         * @return The derivative at the specified point as a 2×2 matrix.
+         * @throws TransformException if the derivative can not be evaluated at the specified point.
+         */
+        @Override
+        public Matrix derivative(final Point2D point) throws TransformException {
+            return AbstractMathTransform2D.derivative(this, point);
+        }
+
+        /**
          * Same work than {@link AbstractMathTransform2D#beforeFormat(List, int, boolean)}
          * but with the knowledge that this transform is an inverse transform.
          */
         @Override
-        final int beforeFormat(final List<MathTransform> transforms, final int index, final boolean inverse) {
+        final int beforeFormat(final List<Object> transforms, final int index, final boolean inverse) {
             return AbstractMathTransform2D.this.beforeFormat(transforms, index, !inverse);
         }
     }

Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -30,6 +30,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.parameter.Parameterized;
+import org.apache.sis.referencing.operation.matrix.Matrices;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.internal.referencing.Semaphores;
 import org.apache.sis.util.Classes;
@@ -38,6 +39,7 @@ import org.apache.sis.util.ComparisonMod
 import org.apache.sis.util.Utilities;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.Formatter;
+import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.util.resources.Errors;
 
 
@@ -63,6 +65,16 @@ class ConcatenatedTransform extends Abst
     private static final long serialVersionUID = 5772066656987558634L;
 
     /**
+     * Tolerance threshold for considering a matrix as identity. Since the value used here is smaller
+     * than 1 ULP (about 2.22E-16), it applies only the the zero terms in the matrix. The terms on the
+     * diagonal are still expected to be exactly 1.
+     *
+     * @todo Try to remove completely this tolerance threshold after we applied double-double arithmetic
+     *       to all matrices.
+     */
+    private static final double IDENTITY_TOLERANCE = 1E-16;
+
+    /**
      * The first math transform.
      */
     protected final MathTransform transform1;
@@ -229,6 +241,9 @@ class ConcatenatedTransform extends Abst
             final Matrix matrix2 = MathTransforms.getMatrix(tr2);
             if (matrix2 != null) {
                 final Matrix matrix = MatrixSIS.castOrCopy(matrix2).multiply(matrix1);
+                if (Matrices.isIdentity(matrix, IDENTITY_TOLERANCE)) {
+                    return MathTransforms.identity(matrix.getNumRow() - 1);
+                }
                 /*
                  * NOTE: It is quite tempting to "fix rounding errors" in the matrix before to create the transform.
                  * But this is often wrong for datum shift transformations (Molodensky and the like) since the datum
@@ -409,11 +424,11 @@ class ConcatenatedTransform extends Abst
      * (<var>normalize</var>, <var>unitary projection</var>, <var>denormalize</var>) tuples are replaced by single
      * (<var>projection</var>) elements, which does not need to be instances of {@link MathTransform}.
      */
-    private List<MathTransform> getPseudoSteps() {
-        final List<MathTransform> transforms = new ArrayList<MathTransform>();
+    private List<Object> getPseudoSteps() {
+        final List<Object> transforms = new ArrayList<Object>();
         getSteps(transforms);
         /*
-         * Pre-process the transforms before to format. Some steps may be* merged, or new
+         * Pre-process the transforms before to format. Some steps may be merged, or new
          * steps may be created. Do not move size() out of the loop, because it may change.
          */
         for (int i=0; i<transforms.size(); i++) {
@@ -430,7 +445,7 @@ class ConcatenatedTransform extends Abst
      *
      * @param transforms The list where to add concatenated transforms.
      */
-    private void getSteps(final List<MathTransform> transforms) {
+    private void getSteps(final List<? super MathTransform> transforms) {
         if (transform1 instanceof ConcatenatedTransform) {
             ((ConcatenatedTransform) transform1).getSteps(transforms);
         } else {
@@ -468,7 +483,7 @@ class ConcatenatedTransform extends Abst
      */
     private Parameterized getParameterised() {
         Parameterized param = null;
-        final List<MathTransform> transforms = getPseudoSteps();
+        final List<Object> transforms = getPseudoSteps();
         if (transforms.size() == 1 || Semaphores.query(Semaphores.PROJCS)) {
             for (final Object candidate : transforms) {
                 if (!(candidate instanceof Parameterized)) {
@@ -888,7 +903,7 @@ class ConcatenatedTransform extends Abst
      */
     @Override
     public String formatTo(final Formatter formatter) {
-        final List<MathTransform> transforms;
+        final List<? super MathTransform> transforms;
         if (formatter.getConvention() == Convention.INTERNAL) {
             transforms = getSteps();
         } else {
@@ -902,9 +917,13 @@ class ConcatenatedTransform extends Abst
         if (transforms.size() == 1) {
             return formatter.delegateTo(transforms.get(0));
         }
-        for (final MathTransform step : transforms) {
+        for (final Object step : transforms) {
             formatter.newLine();
-            formatter.append(step);
+            if (step instanceof FormattableObject) {
+                formatter.append((FormattableObject) step); // May not implement MathTransform.
+            } else {
+                formatter.append((MathTransform) step);
+            }
         }
         return "Concat_MT";
     }



Mime
View raw message