sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1677828 [1/2] - in /sis/branches/JDK6: ./ core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-feature/src/test/java/org/apache/sis/feature/ core/sis-feature/src/test/java/org/apache/sis/test/suite/ core/sis-metadata/src/main/ja...
Date Tue, 05 May 2015 13:53:17 GMT
Author: desruisseaux
Date: Tue May  5 13:53:16 2015
New Revision: 1677828

URL: http://svn.apache.org/r1677828
Log:
Merge from the JDK7 branch.

Added:
    sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/LinkOperationTest.java
      - copied unchanged from r1677827, sis/branches/JDK7/core/sis-feature/src/test/java/org/apache/sis/feature/LinkOperationTest.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/DQ_PositionalAccuracy.java
      - copied unchanged from r1677827, sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/DQ_PositionalAccuracy.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_Conversion.java
      - copied unchanged from r1677827, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_Conversion.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java
      - copied unchanged from r1677827, sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/SC_GeographicCRS.java
    sis/branches/JDK6/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/NTF.xml
      - copied unchanged from r1677827, sis/branches/JDK7/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/NTF.xml
Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java
    sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
    sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java
    sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
    sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConversion.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCylindricalProjection.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPassThroughOperation.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultPlanarProjection.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultProjection.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/GeodeticObjectBuilder.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeocentricCRSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeodeticCRSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultGeographicCRSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
    sis/branches/JDK6/core/sis-referencing/src/test/resources/org/apache/sis/referencing/crs/WGS 84.xml
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue May  5 13:53:16 2015
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
-/sis/branches/JDK7:1394913-1677071
-/sis/branches/JDK8:1584960-1677068
+/sis/branches/JDK7:1394913-1677827
+/sis/branches/JDK8:1584960-1677787
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractOperation.java [UTF-8] Tue May  5 13:53:16 2015
@@ -17,6 +17,8 @@
 package org.apache.sis.feature;
 
 import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
 import org.opengis.util.GenericName;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
@@ -94,12 +96,12 @@ public abstract class AbstractOperation
      * The value returned by this method depends on the value returned by {@link #getResult()}:
      *
      * <ul>
-     *   <li>If {@code getResult()}} returns {@code null},
+     *   <li>If {@code getResult()} returns {@code null},
      *       then this method should return {@code null}.</li>
-     *   <li>If {@code getResult()}} returns an instance of {@link AttributeType},
+     *   <li>If {@code getResult()} returns an instance of {@link AttributeType},
      *       then this method shall return an instance of {@link Attribute}
      *       and the {@code Attribute.getType() == getResult()} relation should hold.</li>
-     *   <li>If {@code getResult()}} returns an instance of {@link FeatureAssociationRole},
+     *   <li>If {@code getResult()} returns an instance of {@link FeatureAssociationRole},
      *       then this method shall return an instance of {@link FeatureAssociation}
      *       and the {@code FeatureAssociation.getRole() == getResult()} relation should hold.</li>
      * </ul>
@@ -120,6 +122,23 @@ public abstract class AbstractOperation
     public abstract Property apply(Feature feature, ParameterValueGroup parameters);
 
     /**
+     * Returns the names of feature properties that this operation needs for performing its task.
+     *
+     * <div class="note"><b>Rational:</b>
+     * this information is needed for writing the {@code SELECT} SQL statement to send to a database server.
+     * The requested columns will typically be all attributes declared in a {@code FeatureType}, but also
+     * any additional columns needed for the operation while not necessarily included in the {@code FeatureType}.
+     * </div>
+     *
+     * The default implementation returns an empty set.
+     *
+     * @return The names of feature properties needed by this operation for performing its task.
+     */
+    public Set<String> getDependencies() {
+        return Collections.emptySet();
+    }
+
+    /**
      * Returns a hash code value for this operation.
      * The default implementation computes a hash code from the {@linkplain #getParameters() parameters}
      * and {@linkplain #getResult() result type}.

Modified: sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java [UTF-8] Tue May  5 13:53:16 2015
@@ -158,10 +158,12 @@ final class DenseFeature extends Abstrac
         if (properties != null) {
             assert c.length == properties.length;
             for (final Map.Entry<String, Integer> entry : indices.entrySet()) {
-                final int   index  = entry.getValue();
-                final Object value = properties[index];
-                if (value != null) {
-                    c[index] = createProperty(entry.getKey(), value);
+                final int index = entry.getValue();
+                if (index >= 0) {
+                    final Object value = properties[index];
+                    if (value != null) {
+                        c[index] = createProperty(entry.getKey(), value);
+                    }
                 }
             }
         }

Modified: sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-feature/src/main/java/org/apache/sis/feature/LinkOperation.java [UTF-8] Tue May  5 13:53:16 2015
@@ -16,8 +16,10 @@
  */
 package org.apache.sis.feature;
 
+import java.util.Set;
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Collections;
 import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
@@ -30,6 +32,7 @@ import org.apache.sis.util.ArgumentCheck
 import org.opengis.feature.Feature;
 import org.opengis.feature.IdentifiedType;
 import org.opengis.feature.Property;
+import org.opengis.feature.PropertyType;
 
 
 /**
@@ -74,7 +77,7 @@ final class LinkOperation extends Abstra
     /**
      * The type of the result.
      */
-    private final IdentifiedType result;
+    private final PropertyType result;
 
     /**
      * The name of the referenced attribute or feature association.
@@ -87,7 +90,7 @@ final class LinkOperation extends Abstra
      * @param identification The name of the link, together with optional information.
      * @param propertyType   The referenced attribute or feature association.
      */
-    LinkOperation(final Map<String, ?> identification, final IdentifiedType propertyType) {
+    LinkOperation(final Map<String, ?> identification, final PropertyType propertyType) {
         super(identification);
         result = propertyType;
         propertyName = propertyType.getName().toString();
@@ -110,6 +113,14 @@ final class LinkOperation extends Abstra
     }
 
     /**
+     * Returns the names of feature properties that this operation needs for performing its task.
+     */
+    @Override
+    public Set<String> getDependencies() {
+        return Collections.singleton(propertyName);
+    }
+
+    /**
      * Returns the property from the referenced attribute of feature association.
      *
      * @param  feature    The feature from which to get the property.

Modified: sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultFeatureTypeTest.java [UTF-8] Tue May  5 13:53:16 2015
@@ -48,7 +48,7 @@ import org.opengis.feature.PropertyType;
 public final strictfp class DefaultFeatureTypeTest extends TestCase {
     /**
      * Creates a simple feature type without super-types.
-     * The feature contains the following attribute:
+     * The feature contains the following attributes:
      *
      * <ul>
      *   <li>{@code city}       as a  {@link String}  (mandatory)</li>
@@ -142,15 +142,14 @@ public final strictfp class DefaultFeatu
             final DefaultFeatureType universityCity, final DefaultAttributeType<?> temperature, final Class<T> regionType)
     {
         return new DefaultFeatureType(singletonMap(DefaultFeatureType.NAME_KEY, "World metropolis"), false,
-                new DefaultFeatureType[] {
+                new DefaultFeatureType[] {          // Super types
                     metropolis,
                     universityCity
                 },
-                new DefaultAttributeType<?>[] {
+                new DefaultAttributeType<?>[] {     // Properties
                     new DefaultAttributeType<T>(singletonMap(DefaultAttributeType.NAME_KEY, "region"), regionType, 1, 1, null),
                     temperature
                 });
-
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] Tue May  5 13:53:16 2015
@@ -42,6 +42,7 @@ import org.junit.BeforeClass;
     org.apache.sis.feature.DefaultAssociationRoleTest.class,
     org.apache.sis.feature.SingletonAssociationTest.class,
     org.apache.sis.feature.AbstractOperationTest.class,
+    org.apache.sis.feature.LinkOperationTest.class,
     org.apache.sis.feature.FeatureFormatTest.class,
     org.apache.sis.feature.FeaturesTest.class
 })

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gts/TM_PeriodDuration.java [UTF-8] Tue May  5 13:53:16 2015
@@ -178,6 +178,8 @@ public final class TM_PeriodDuration ext
      * @param e The exception.
      */
     private static void warningOccured(final String methodName, final Exception e) {
-        Context.warningOccured(Context.current(), TM_PeriodDuration.class, methodName, e, true);
+        if (TemporalUtilities.REPORT_MISSING_MODULE || !e.getMessage().contains("sis-temporal")) {
+            Context.warningOccured(Context.current(), TM_PeriodDuration.class, methodName, e, true);
+        }
     }
 }

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Tue May  5 13:53:16 2015
@@ -1375,22 +1375,21 @@ public class Formatter implements Locali
      * Applications can test {@link #isInvalidWKT()} later for checking WKT validity.
      *
      * <p>If any {@code setInvalidWKT(…)} method is invoked more than once during formatting,
-     * then only information about the first failure will be retained.</p>
+     * then only information about the last failure will be retained. The reason is that the
+     * last failure is typically the enclosing element.</p>
      *
      * @param unformattable The object that can not be formatted,
      * @param cause The cause for the failure to format, or {@code null} if the cause is not an exception.
      */
     public void setInvalidWKT(final IdentifiedObject unformattable, final Exception cause) {
         ArgumentChecks.ensureNonNull("unformattable", unformattable);
-        if (invalidElement == null) {
-            String name;
-            final Identifier id = unformattable.getName();
-            if (id == null || (name = id.getCode()) == null) {
-                name = getName(unformattable.getClass());
-            }
-            invalidElement = name;
-            errorCause     = cause;
+        String name;
+        final Identifier id = unformattable.getName();
+        if (id == null || (name = id.getCode()) == null) {
+            name = getName(unformattable.getClass());
         }
+        invalidElement = name;
+        errorCause     = cause;
         highlightError = true;
     }
 

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -28,6 +28,7 @@ import org.opengis.referencing.cs.Affine
 import org.opengis.referencing.cs.CartesianCS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.crs.SingleCRS;
+import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.referencing.AbstractReferenceSystem;
@@ -79,7 +80,7 @@ import org.apache.sis.internal.jdk7.Obje
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see AbstractCS
@@ -88,7 +89,7 @@ import org.apache.sis.internal.jdk7.Obje
 @XmlType(name="AbstractCRSType")
 @XmlRootElement(name = "AbstractCRS")
 @XmlSeeAlso({
-    DefaultProjectedCRS.class,
+    AbstractDerivedCRS.class,
     DefaultGeodeticCRS.class,
     DefaultVerticalCRS.class,
     DefaultTemporalCRS.class,
@@ -462,18 +463,43 @@ public class AbstractCRS extends Abstrac
         formatter.newLine();
         formatter.append(toFormattable(getDatum()));
         formatter.newLine();
-        formatCS(formatter, getCoordinateSystem(), formatter.getConvention().majorVersion() == 1);
+        final boolean isWKT1 = formatter.getConvention().majorVersion() == 1;
+        if (isWKT1 || !isBaseCRS(formatter)) {
+            formatCS(formatter, getCoordinateSystem(), isWKT1);
+        }
         return keyword;
     }
 
     /**
+     * Returns {@code true} if the given formatter is in the process of formatting the base CRS of a
+     * {@link AbstractDerivedCRS}. In such case, the coordinate system axes shall not be formatted.
+     *
+     * <p>This method should return {@code true} when {@code this} CRS is the value returned by
+     * {@link GeneralDerivedCRS#getBaseCRS()} (typically {@link AbstractDerivedCRS#getBaseCRS()}).
+     * Since the base CRS is the only CRS enclosed in derived CRS, we should have no ambiguity
+     * (assuming that the user did not created some weird subclass).</p>
+     *
+     * <p>This method should be invoked for WKT 2 formatting only.</p>
+     */
+    static boolean isBaseCRS(final Formatter formatter) {
+        return formatter.getEnclosingElement(1) instanceof GeneralDerivedCRS;
+    }
+
+    /**
      * Formats the given coordinate system.
      *
+     * <p>In WKT 2 format, this method should not be invoked if {@link #isBaseCRS(Formatter)} returned {@code true}
+     * because ISO 19162 excludes the coordinate system definition in base CRS. Note however that WKT 1 includes the
+     * coordinate systems.</p>
+     *
      * @param formatter The formatter where to append the coordinate system.
      * @param cs        The coordinate system to append.
      * @param isWKT1    {@code true} if formatting WKT 1, or {@code false} for WKT 2.
      */
     final void formatCS(final Formatter formatter, final CoordinateSystem cs, final boolean isWKT1) {
+        assert (formatter.getConvention().majorVersion() == 1) == isWKT1 : isWKT1;
+        assert isWKT1 || !isBaseCRS(formatter) : isWKT1;    // Condition documented in javadoc.
+
         final Unit<?> unit    = ReferencingUtilities.getUnit(cs);
         final Unit<?> oldUnit = formatter.addContextualUnit(unit);
         if (isWKT1) { // WKT 1 writes unit before axes, while WKT 2 writes them after axes.

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractDerivedCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -17,21 +17,21 @@
 package org.apache.sis.referencing.crs;
 
 import java.util.Map;
-import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.referencing.datum.Datum;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.operation.Conversion;
-import org.opengis.geometry.MismatchedDimensionException;
 import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.NoninvertibleTransformException;
+import org.opengis.geometry.MismatchedDimensionException;
 import org.apache.sis.referencing.operation.DefaultConversion;
-import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.system.Semaphores;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ComparisonMode;
-import org.apache.sis.io.wkt.Formatter;
 
 import static org.apache.sis.util.Utilities.deepEquals;
 
@@ -41,13 +41,19 @@ import static org.apache.sis.util.Utilit
  * {@linkplain org.apache.sis.referencing.operation.DefaultConversion conversion} from another CRS
  * (not by a {@linkplain org.apache.sis.referencing.datum.AbstractDatum datum}).
  *
+ * @param <C> The conversion type, either {@code Conversion} or {@code Projection}.
+ *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.6
  * @version 0.6
  * @module
  */
-@XmlTransient   // TODO: GML not yet investigated
-class AbstractDerivedCRS extends AbstractCRS implements GeneralDerivedCRS {
+@XmlType(name="AbstractGeneralDerivedCRSType")
+@XmlRootElement(name = "AbstractGeneralDerivedCRS")
+@XmlSeeAlso({
+    DefaultProjectedCRS.class
+})
+abstract class AbstractDerivedCRS<C extends Conversion> extends AbstractCRS implements GeneralDerivedCRS {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -57,7 +63,8 @@ class AbstractDerivedCRS extends Abstrac
      * The conversion from the {@linkplain #getBaseCRS() base CRS} to this CRS.
      * The base CRS of this {@code GeneralDerivedCRS} is {@link Conversion#getSourceCRS()}.
      */
-    private final Conversion conversionFromBase;
+    @XmlElement(name = "conversion", required = true)
+    private final C conversionFromBase;
 
     /**
      * Constructs a new object in which every attributes are set to a null value.
@@ -74,29 +81,29 @@ class AbstractDerivedCRS extends Abstrac
      * {@linkplain AbstractCRS#AbstractCRS(Map, CoordinateSystem) super-class constructor}.
      *
      * @param  properties The properties to be given to the new derived CRS object.
-     * @param  baseCRS Coordinate reference system to base the derived CRS on.
-     * @param  conversionFromBase The conversion from the base CRS to this derived CRS.
-     * @param  derivedCS The coordinate system for the derived CRS. The number of axes
+     * @param  baseCRS    Coordinate reference system to base the derived CRS on.
+     * @param  conversion The conversion from the base CRS to this derived CRS.
+     * @param  derivedCS  The coordinate system for the derived CRS. The number of axes
      *         must match the target dimension of the {@code baseToDerived} transform.
      * @throws MismatchedDimensionException if the source and target dimension of {@code baseToDerived}
      *         do not match the dimension of {@code base} and {@code derivedCS} respectively.
      */
     AbstractDerivedCRS(final Map<String,?>    properties,
+                       final Class<C>         baseType,
                        final SingleCRS        baseCRS,
-                       final Conversion       conversionFromBase,
-                       final CoordinateSystem derivedCS,
-                       final Class<? extends Conversion> type)
+                       final Conversion       conversion,
+                       final CoordinateSystem derivedCS)
             throws MismatchedDimensionException
     {
         super(properties, derivedCS);
         ArgumentChecks.ensureNonNull("baseCRS", baseCRS);
-        ArgumentChecks.ensureNonNull("conversionFromBase", conversionFromBase);
-        final MathTransform baseToDerived = conversionFromBase.getMathTransform();
+        ArgumentChecks.ensureNonNull("conversionFromBase", conversion);   // "conversionFromBase" is the name used by subclass constructors.
+        final MathTransform baseToDerived = conversion.getMathTransform();
         if (baseToDerived != null) {
             ArgumentChecks.ensureDimensionMatches("baseCRS",   baseToDerived.getSourceDimensions(), baseCRS);
             ArgumentChecks.ensureDimensionMatches("derivedCS", baseToDerived.getTargetDimensions(), derivedCS);
         }
-        this.conversionFromBase = DefaultConversion.castOrCopy(conversionFromBase).specialize(type, baseCRS, this);
+        conversionFromBase = DefaultConversion.castOrCopy(conversion).specialize(baseType, baseCRS, this);
     }
 
     /**
@@ -108,22 +115,17 @@ class AbstractDerivedCRS extends Abstrac
      *
      * @param crs The coordinate reference system to copy.
      */
-    protected AbstractDerivedCRS(final GeneralDerivedCRS crs) {
+    AbstractDerivedCRS(final GeneralDerivedCRS crs, final Class<C> baseType) {
         super(crs);
-        conversionFromBase = crs.getConversionFromBase();
+        conversionFromBase = DefaultConversion.castOrCopy(crs.getConversionFromBase())
+                .specialize(baseType, crs.getBaseCRS(), this);
     }
 
     /**
      * Returns the GeoAPI interface implemented by this class.
-     * The default implementation returns {@code GeneralDerivedCRS.class}.
-     * Subclasses implementing a more specific GeoAPI interface shall override this method.
-     *
-     * @return The coordinate reference system interface implemented by this class.
      */
     @Override
-    public Class<? extends GeneralDerivedCRS> getInterface() {
-        return GeneralDerivedCRS.class;
-    }
+    public abstract Class<? extends GeneralDerivedCRS> getInterface();
 
     /**
      * Returns the datum of the {@linkplain #getBaseCRS() base CRS}.
@@ -131,19 +133,7 @@ class AbstractDerivedCRS extends Abstrac
      * @return The datum of the base CRS.
      */
     @Override
-    public Datum getDatum() {
-        return getBaseCRS().getDatum();
-    }
-
-    /**
-     * Returns the base coordinate reference system.
-     *
-     * @return The base coordinate reference system.
-     */
-    @Override
-    public SingleCRS getBaseCRS() {
-        return (SingleCRS) conversionFromBase.getSourceCRS();
-    }
+    public abstract Datum getDatum();
 
     /**
      * Returns the conversion from the {@linkplain #getBaseCRS() base CRS} to this CRS.
@@ -151,7 +141,7 @@ class AbstractDerivedCRS extends Abstrac
      * @return The conversion to this CRS.
      */
     @Override
-    public Conversion getConversionFromBase() {
+    public C getConversionFromBase() {
         return conversionFromBase;
     }
 
@@ -166,9 +156,6 @@ class AbstractDerivedCRS extends Abstrac
      */
     @Override
     public boolean equals(final Object object, final ComparisonMode mode) {
-        if (object == this) {
-            return true; // Slight optimization.
-        }
         if (super.equals(object, mode)) {
             final boolean strict = (mode == ComparisonMode.STRICT);
             /*
@@ -206,27 +193,4 @@ class AbstractDerivedCRS extends Abstrac
                + 31 * conversionFromBase.getSourceCRS().hashCode()
                + 37 * conversionFromBase.getMathTransform().hashCode();
     }
-
-    /**
-     * Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation of this CRS.
-     *
-     * @return {@code "Fitted_CS"} (WKT 1).
-     */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendName(this, formatter, null);
-        final Conversion conversionFromBase = getConversionFromBase();  // Gives to users a chance to override.
-        MathTransform inverse = conversionFromBase.getMathTransform();
-        try {
-            inverse = inverse.inverse();
-        } catch (NoninvertibleTransformException exception) {
-            // TODO: provide a more accurate error message.
-            throw new IllegalStateException(exception.getLocalizedMessage(), exception);
-        }
-        formatter.newLine();
-        formatter.append(inverse);
-        formatter.newLine();
-        formatter.append(WKTUtilities.toFormattable(getBaseCRS()));
-        return "Fitted_CS";
-    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -18,11 +18,20 @@ package org.apache.sis.referencing.crs;
 
 import java.util.Map;
 import javax.xml.bind.annotation.XmlTransient;
+import org.opengis.parameter.GeneralParameterValue;
+import org.opengis.referencing.datum.Datum;
 import org.opengis.referencing.crs.SingleCRS;
 import org.opengis.referencing.crs.DerivedCRS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.operation.Conversion;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.opengis.geometry.MismatchedDimensionException;
+import org.apache.sis.referencing.operation.DefaultOperationMethod;
+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.ComparisonMode;
 
 
 /**
@@ -45,7 +54,7 @@ import org.opengis.geometry.MismatchedDi
  * @module
  */
 @XmlTransient   // TODO: GML not yet investigated
-public class DefaultDerivedCRS extends AbstractDerivedCRS implements DerivedCRS {
+public class DefaultDerivedCRS extends AbstractDerivedCRS<Conversion> implements DerivedCRS {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -118,7 +127,7 @@ public class DefaultDerivedCRS extends A
                              final CoordinateSystem derivedCS)
             throws MismatchedDimensionException
     {
-        super(properties, baseCRS, conversionFromBase, derivedCS, Conversion.class);
+        super(properties, Conversion.class, baseCRS, conversionFromBase, derivedCS);
     }
 
     /**
@@ -133,7 +142,7 @@ public class DefaultDerivedCRS extends A
      * @see #castOrCopy(DerivedCRS)
      */
     protected DefaultDerivedCRS(final DerivedCRS crs) {
-        super(crs);
+        super(crs, Conversion.class);
     }
 
     /**
@@ -166,4 +175,121 @@ public class DefaultDerivedCRS extends A
     public Class<? extends DerivedCRS> getInterface() {
         return DerivedCRS.class;
     }
+
+    /**
+     * Returns the datum of the {@linkplain #getBaseCRS() base CRS}.
+     *
+     * @return The datum of the base CRS.
+     */
+    @Override
+    public Datum getDatum() {
+        return getBaseCRS().getDatum();
+    }
+
+    /**
+     * Returns the CRS on which the conversion is applied.
+     * This CRS defines the {@linkplain #getDatum() datum} of this CRS and (at least implicitly)
+     * the {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS() source}
+     * of the {@linkplain #getConversionFromBase() conversion from base}.
+     *
+     * @return The base coordinate reference system.
+     */
+    @Override
+    public SingleCRS getBaseCRS() {
+        return (SingleCRS) super.getConversionFromBase().getSourceCRS();
+    }
+
+    /**
+     * Returns the conversion from the {@linkplain #getBaseCRS() base CRS} to this CRS.
+     * In Apache SIS, the conversion source and target CRS are set to the following values:
+     *
+     * <ul>
+     *   <li>The conversion {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS()
+     *       source CRS} is the {@linkplain #getBaseCRS() base CRS} of {@code this} CRS.</li>
+     *   <li>The conversion {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getTargetCRS()
+     *       target CRS} is {@code this} CRS.
+     * </ul>
+     *
+     * <div class="note"><b>Note:</b>
+     * This is different than ISO 19111, which allows source and target CRS to be {@code null}.</div>
+     *
+     * @return The conversion to this CRS.
+     */
+    @Override
+    public Conversion getConversionFromBase() {
+        return super.getConversionFromBase();
+    }
+
+    /**
+     * Compares this coordinate reference system with the specified object for equality.
+     *
+     * @param  object The object to compare to {@code this}.
+     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
+     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
+     *         relevant to coordinate transformations.
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public boolean equals(final Object object, final ComparisonMode mode) {
+        return (object == this) || super.equals(object, mode);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    protected long computeHashCode() {
+        return super.computeHashCode();
+    }
+
+    /**
+     * Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation of this CRS.
+     *
+     * @return {@code "Fitted_CS"} (WKT 1) or a type-dependent keyword (WKT 2).
+     */
+    @Override
+    protected String formatTo(final Formatter formatter) {
+        WKTUtilities.appendName(this, formatter, null);
+        final boolean isWKT1 = (formatter.getConvention().majorVersion() == 1);
+        final Conversion conversion = getConversionFromBase();  // Gives to users a chance to override.
+        /*
+         * Both WKT 1 and WKT 2 format the base CRS. But WKT 1 formats the MathTransform before the base CRS,
+         * while WKT 2 formats the conversion method and parameter values after the base CRS.
+         */
+        if (isWKT1) {
+            MathTransform inverse = conversion.getMathTransform();
+            try {
+                inverse = inverse.inverse();
+            } catch (NoninvertibleTransformException exception) {
+                formatter.setInvalidWKT(this, exception);
+                inverse = null;
+            }
+            formatter.newLine();
+            formatter.append(inverse);
+        }
+        formatter.newLine();
+        formatter.append(WKTUtilities.toFormattable(getBaseCRS()));
+        if (isWKT1) {
+            return "Fitted_CS";
+        } else {
+            formatter.append(new FormattableObject() {     // Format inside a "DefiningConversion" element.
+                @Override protected String formatTo(final Formatter formatter) {
+                    WKTUtilities.appendName(conversion, formatter, null);
+                    formatter.newLine();
+                    formatter.append(DefaultOperationMethod.castOrCopy(conversion.getMethod()));
+                    formatter.newLine();
+                    for (final GeneralParameterValue param : conversion.getParameterValues().values()) {
+                        WKTUtilities.append(param, formatter);
+                    }
+                    return "DerivingConversion";
+                }
+            });
+            if (!isBaseCRS(formatter)) {
+                formatCS(formatter, getCoordinateSystem(), isWKT1);
+            }
+            return "EngineeringCRS"; // TODO: may be GeodeticCRS, VerticalCRS, etc.
+        }
+    }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultEngineeringCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -62,7 +62,7 @@ import static org.apache.sis.util.Argume
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  */
 @XmlType(name = "EngineeringCRSType", propOrder = {
@@ -85,7 +85,7 @@ public class DefaultEngineeringCRS exten
     /**
      * The datum.
      */
-    @XmlElement(name = "engineeringDatum")
+    @XmlElement(name = "engineeringDatum", required = true)
     private final EngineeringDatum datum;
 
     /**
@@ -260,6 +260,7 @@ public class DefaultEngineeringCRS exten
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        return (formatter.getConvention().majorVersion() == 1) ? "Local_CS" : "EngineeringCRS";
+        return (formatter.getConvention().majorVersion() == 1) ? "Local_CS"
+               : isBaseCRS(formatter) ? "BaseEngCRS" : "EngineeringCRS";
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeocentricCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -245,7 +245,7 @@ public class DefaultGeocentricCRS extend
      *   GEOCCS["Geocentric",
      *     DATUM["World Geodetic System 1984",
      *       SPHEROID["WGS84", 6378137.0, 298.257223563]],
-     *     PRIMEM["Greenwich", 0.0],
+     *       PRIMEM["Greenwich", 0.0],
      *     UNIT["metre", 1],
      *     AXIS["X", OTHER],
      *     AXIS["Y", EAST],

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -71,7 +71,7 @@ class DefaultGeodeticCRS extends Abstrac
     /**
      * The datum.
      */
-    @XmlElement(name = "geodeticDatum")
+    @XmlElement(name = "geodeticDatum", required = true)
     private final GeodeticDatum datum;
 
     /**
@@ -168,66 +168,81 @@ class DefaultGeodeticCRS extends Abstrac
 
     /**
      * Formats this CRS as a <cite>Well Known Text</cite> {@code GeodeticCRS[…]} element.
+     * More information about the WKT format is documented in subclasses.
      *
      * @return {@code "GeodeticCRS"} (WKT 2) or {@code "GeogCS"}/{@code "GeocCS"} (WKT 1).
      */
     @Override
     protected String formatTo(final Formatter formatter) {
         WKTUtilities.appendName(this, formatter, null);
-        final boolean isWKT1 = (formatter.getConvention().majorVersion() == 1);
-        formatDatum(formatter, getDatum(), isWKT1);
+        final Convention convention = formatter.getConvention();
+        final boolean isWKT1 = (convention.majorVersion() == 1);
+        /*
+         * Unconditionally format the datum element, followed by the prime meridian.
+         * The prime meridian is part of datum according ISO 19111, but is formatted
+         * as a sibling (rather than a child) element in WKT for historical reasons.
+         */
+        final GeodeticDatum datum = getDatum();     // Gives subclasses a chance to override.
+        formatter.newLine();
+        formatter.append(toFormattable(datum));
+        formatter.newLine();
+        final PrimeMeridian pm = datum.getPrimeMeridian();
+        if (convention != Convention.WKT2_SIMPLIFIED ||
+                ReferencingUtilities.getGreenwichLongitude(pm, NonSI.DEGREE_ANGLE) != 0)
+        {
+            formatter.indent(1);
+            formatter.append(toFormattable(pm));
+            formatter.indent(-1);
+            formatter.newLine();
+        }
+        /*
+         * Get the coordinate system to format. This will also determine the units to write and the keyword to
+         * return in WKT 1 format. Note that for the WKT 1 format, we need to replace the coordinate system by
+         * an instance conform to the legacy conventions.
+         *
+         * We can not delegate the work below to subclasses,  because XML unmarshalling of a geodetic CRS will
+         * NOT create an instance of a subclass (because the distinction between geographic and geocentric CRS
+         * is not anymore in ISO 19111:2007).
+         */
         CoordinateSystem cs = getCoordinateSystem();
+        final boolean isBaseCRS;
         if (isWKT1) {
-            /*
-             * Replaces the given coordinate system by an instance conform to the conventions used in WKT 1.
-             * Note that we can not delegate this task to subclasses, because XML unmarshalling of a geodetic
-             * CRS will NOT create an instance of a subclass (because the distinction between geographic and
-             * geocentric CRS is not anymore in ISO 19111:2007).
-             */
             if (!(cs instanceof EllipsoidalCS)) { // Tested first because this is the most common case.
                 if (cs instanceof CartesianCS) {
                     cs = Legacy.forGeocentricCRS((CartesianCS) cs, true);
                 } else {
-                    formatter.setInvalidWKT(cs, null);
+                    formatter.setInvalidWKT(cs, null);  // SphericalCS was not supported in WKT 1.
                 }
             }
+            isBaseCRS = false;
+        } else {
+            isBaseCRS = isBaseCRS(formatter);
         }
-        formatCS(formatter, cs, isWKT1);
-        if (!isWKT1) {
-            return "GeodeticCRS";
+        /*
+         * Format the coordinate system, except if this CRS is the base CRS of an AbstractDerivedCRS in WKT 2 format.
+         * This is because ISO 19162 omits the coordinate system definition of enclosed base CRS in order to simplify
+         * the WKT. The 'formatCS(…)' method may write axis unit before or after the axes depending on whether we are
+         * formatting WKT version 1 or 2 respectively.
+         *
+         * Note that even if we do not format the CS, we may still write the units if we are formatting in "simplified"
+         * mode (as opposed to the more verbose mode). This looks like the opposite of what we would expect, but this is
+         * because formatting the unit here allow us to avoid repeating the unit in projection parameters when this CRS
+         * is part of a ProjectedCRS.
+         */
+        if (!isBaseCRS) {
+            formatCS(formatter, cs, isWKT1);    // Will also format the axis unit.
+        } else if (convention.isSimplified()) {
+            formatter.append(formatter.toContextualUnit(ReferencingUtilities.getAngularUnit(cs)));
         }
         /*
-         * For WKT1, the keyword depends on the subclass: "GeogCS" for GeographicCRS,
-         * or 'GeocCS" for GeocentricCRS. However we can not rely on the subclass for
-         * choosing the keyword, because in some situations (after XML unmarhaling)
-         * we only have a GeodeticCRS. We need to make the choice here. The CS type
-         * is a sufficient criterion.
+         * For WKT 1, the keyword depends on the subclass: "GeogCS" for GeographicCRS or "GeocCS" for GeocentricCRS.
+         * However we can not rely on the subclass for choosing the keyword, because after XML unmarhaling we only
+         * have a GeodeticCRS. We need to make the choice in this base class. The CS type is a sufficient criterion.
          */
-        return (cs instanceof EllipsoidalCS) ? "GeogCS" : "GeocCS";
-    }
-
-    /**
-     * Formats the given geodetic datum to the given formatter. This is part of the WKT formatting
-     * for a geodetic CRS, either standalone or as part of a projected CRS.
-     *
-     * @param formatter Where to format the datum.
-     * @param datum     The datum to format.
-     * @param isWKT1    {@code true} if formatting WKT 1, or {@code false} for WKT 2.
-     *
-     * @see #formatCS(Formatter, CoordinateSystem, boolean)
-     */
-    static void formatDatum(final Formatter formatter, final GeodeticDatum datum, final boolean isWKT1) {
-        formatter.newLine();
-        formatter.append(toFormattable(datum));
-        formatter.newLine();
-        formatter.indent(isWKT1 ? 0 : +1);
-        final PrimeMeridian pm = datum.getPrimeMeridian();
-        if (formatter.getConvention() != Convention.WKT2_SIMPLIFIED ||
-                ReferencingUtilities.getGreenwichLongitude(pm, NonSI.DEGREE_ANGLE) != 0)
-        {
-            formatter.append(toFormattable(pm));
+        if (isWKT1) {
+            return (cs instanceof EllipsoidalCS) ? "GeogCS" : "GeocCS";
+        } else {
+            return isBaseCRS ? "BaseGeodCRS" : "GeodeticCRS";
         }
-        formatter.indent(isWKT1 ? 0 : -1);
-        formatter.newLine();
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeographicCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import javax.xml.bind.annotation.XmlTransient;
 import org.opengis.metadata.Identifier;
 import org.opengis.referencing.datum.GeodeticDatum;
+import org.opengis.referencing.crs.GeodeticCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.cs.EllipsoidalCS;
 import org.opengis.referencing.cs.CoordinateSystem;
@@ -32,6 +33,7 @@ import org.apache.sis.referencing.cs.Axe
 import org.apache.sis.referencing.AbstractReferenceSystem;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.measure.Longitude;
+import org.apache.sis.util.resources.Errors;
 
 import static org.apache.sis.internal.util.Constants.CRS;
 import static org.apache.sis.internal.util.Constants.EPSG;
@@ -56,7 +58,7 @@ import static org.apache.sis.internal.ut
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.5
+ * @version 0.6
  * @module
  */
 @XmlTransient
@@ -141,6 +143,21 @@ public class DefaultGeographicCRS extend
     }
 
     /**
+     * For {@link SC_GeographicCRS} JAXB adapter only. This is needed because GML does not have "GeographicCRS" type.
+     * Instead, the unmarshalling process will give us a "GeodeticCRS" object with the constraint that the coordinate
+     * system shall be ellipsoidal. This constructor will be invoked for converting the GeodeticCRS instance to a
+     * GeographicCRS instance.
+     */
+    DefaultGeographicCRS(final GeodeticCRS crs) {
+        super(crs);
+        final CoordinateSystem cs = super.getCoordinateSystem();
+        if (!(cs instanceof EllipsoidalCS)) {
+            throw new IllegalArgumentException(Errors.format(
+                    Errors.Keys.IllegalClass_2, EllipsoidalCS.class, cs.getClass()));
+        }
+    }
+
+    /**
      * Constructs a new coordinate reference system 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.
@@ -265,18 +282,18 @@ public class DefaultGeographicCRS extend
      *        AngleUnit["degree", 0.017453292519943295],
      *      Area["World"],
      *      BBox[-90.00, -180.00, 90.00, 180.00],
-     *      Scope["Used by GPS satellite navigation system."]
+     *      Scope["Used by GPS satellite navigation system."],
      *      Id["EPSG", 4326, Citation["IOGP"], URI["urn:ogc:def:crs:EPSG::4326"]]]
      * }
      *
      * <p>Same coordinate reference system using WKT 1.</p>
      *
      * {@preformat wkt
-     *   GEOGCS["WGS 84"
-     *      DATUM["World Geodetic System 1984"
-     *        SPHEROID["WGS84", 6378137.0, 298.257223563]]
-     *      PRIMEM["Greenwich", 0.0]
-     *      UNIT["degree", 0.017453292519943295]
+     *   GEOGCS["WGS 84",
+     *      DATUM["World Geodetic System 1984",
+     *        SPHEROID["WGS84", 6378137.0, 298.257223563]],
+     *        PRIMEM["Greenwich", 0.0],
+     *      UNIT["degree", 0.017453292519943295],
      *      AXIS["Latitude", NORTH],
      *      AXIS["Longitude", EAST],
      *      AUTHORITY["EPSG", "4326"]]

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultImageCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -67,7 +67,7 @@ public class DefaultImageCRS extends Abs
     /**
      * The datum.
      */
-    @XmlElement(name = "imageDatum")
+    @XmlElement(name = "imageDatum", required = true)
     private final ImageDatum datum;
 
     /**
@@ -264,12 +264,10 @@ public class DefaultImageCRS extends Abs
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        /*
-         * Note: super.formatTo(formatter) will usually format a DefaultImageDatum instance,
-         * which will declare this WKT has invalid if the formatter convention is a WKT 1 one.
-         * So we do not redo this check here.
-         */
         super.formatTo(formatter);
+        if (formatter.getConvention().majorVersion() == 1) {
+            formatter.setInvalidWKT(this, null);
+        }
         return "ImageCRS";
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -20,6 +20,7 @@ import java.util.Map;
 import javax.measure.unit.Unit;
 import javax.measure.quantity.Angle;
 import javax.measure.quantity.Length;
+import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.parameter.ParameterValue;
@@ -42,6 +43,7 @@ import org.apache.sis.internal.util.Cons
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.util.ComparisonMode;
 
 import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
 
@@ -66,8 +68,12 @@ import static org.apache.sis.internal.re
  * @version 0.6
  * @module
  */
+@XmlType(name="ProjectedCRSType", propOrder = {
+    "baseCRS",
+    "coordinateSystem"
+})
 @XmlRootElement(name = "ProjectedCRS")
-public class DefaultProjectedCRS extends AbstractDerivedCRS implements ProjectedCRS {
+public class DefaultProjectedCRS extends AbstractDerivedCRS<Projection> implements ProjectedCRS {
     /**
      * Serial number for inter-operability with different versions.
      */
@@ -135,12 +141,12 @@ public class DefaultProjectedCRS extends
      *         do not match the dimension of {@code base} and {@code derivedCS} respectively.
      */
     public DefaultProjectedCRS(final Map<String,?> properties,
-                               final Conversion    conversionFromBase,
                                final GeographicCRS baseCRS,
+                               final Conversion    conversionFromBase,
                                final CartesianCS   derivedCS)
             throws MismatchedDimensionException
     {
-        super(properties, baseCRS, conversionFromBase, derivedCS, Projection.class);
+        super(properties, Projection.class, baseCRS, conversionFromBase, derivedCS);
     }
 
     /**
@@ -155,7 +161,7 @@ public class DefaultProjectedCRS extends
      * @see #castOrCopy(ProjectedCRS)
      */
     protected DefaultProjectedCRS(final ProjectedCRS crs) {
-        super(crs);
+        super(crs, Projection.class);
     }
 
     /**
@@ -195,43 +201,50 @@ public class DefaultProjectedCRS extends
      * @return The datum of the base CRS.
      */
     @Override
-    @XmlElement(name="geodeticDatum")
     public GeodeticDatum getDatum() {
-        return (GeodeticDatum) super.getDatum();
-    }
-
-    /**
-     * Used by JAXB only (invoked by reflection).
-     */
-    private void setDatum(final GeodeticDatum datum) {
-        throw new UnsupportedOperationException(); // TODO
+        return getBaseCRS().getDatum();
     }
 
     /**
-     * Returns the base coordinate reference system, which must be geographic.
+     * Returns the geographic CRS on which the map projection is applied.
+     * This CRS defines the {@linkplain #getDatum() datum} of this CRS and (at least implicitly)
+     * the {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS() source}
+     * of the {@linkplain #getConversionFromBase() conversion from base}.
      *
-     * @return The base CRS.
+     * @return The base coordinate reference system, which must be geographic.
      */
     @Override
+    @XmlElement(name = "baseGeodeticCRS", required = true)  // Note: older GML version used "baseGeographicCRS".
     public GeographicCRS getBaseCRS() {
-        return (GeographicCRS) super.getBaseCRS();
+        return (GeographicCRS) super.getConversionFromBase().getSourceCRS();
     }
 
     /**
      * Returns the map projection from the {@linkplain #getBaseCRS() base CRS} to this CRS.
+     * In Apache SIS, the conversion source and target CRS are set to the following values:
+     *
+     * <ul>
+     *   <li>The conversion {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS()
+     *       source CRS} is the {@linkplain #getBaseCRS() base CRS} of {@code this} CRS.</li>
+     *   <li>The conversion {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getTargetCRS()
+     *       target CRS} is {@code this} CRS.
+     * </ul>
+     *
+     * <div class="note"><b>Note:</b>
+     * This is different than ISO 19111, which allows source and target CRS to be {@code null}.</div>
      *
      * @return The map projection from base CRS to this CRS.
      */
     @Override
     public Projection getConversionFromBase() {
-        return (Projection) super.getConversionFromBase();
+        return super.getConversionFromBase();
     }
 
     /**
      * Returns the coordinate system.
      */
     @Override
-    @XmlElement(name="cartesianCS")
+    @XmlElement(name="cartesianCS", required = true)
     public CartesianCS getCoordinateSystem() {
         return (CartesianCS) super.getCoordinateSystem();
     }
@@ -244,8 +257,79 @@ public class DefaultProjectedCRS extends
     }
 
     /**
+     * Compares this coordinate reference system with the specified object for equality.
+     *
+     * @param  object The object to compare to {@code this}.
+     * @param  mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or
+     *         {@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only properties
+     *         relevant to coordinate transformations.
+     * @return {@code true} if both objects are equal.
+     */
+    @Override
+    public boolean equals(final Object object, final ComparisonMode mode) {
+        return (object == this) || super.equals(object, mode);
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * @return {@inheritDoc}
+     */
+    @Override
+    protected long computeHashCode() {
+        return super.computeHashCode();
+    }
+
+    /**
      * Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation of this CRS.
      *
+     * <div class="note"><b>Example:</b> Well-Known Text (version 2)
+     * of a projected coordinate reference system using the Lambert Conformal method.
+     *
+     * {@preformat wkt
+     *   ProjectedCRS[“NTF (Paris) / Lambert zone II”,
+     *     BaseGeodCRS[“NTF (Paris)”,
+     *       Datum[“Nouvelle Triangulation Francaise”,
+     *         Ellipsoid[“NTF”, 6378249.2, 293.4660212936269, LengthUnit[“metre”, 1]]],
+     *         PrimeMeridian[“Paris”, 2.5969213, AngleUnit[“grade”, 0.015707963267948967]]],
+     *     Conversion[“Lambert zone II”,
+     *       Method[“Lambert Conic Conformal (1SP)”, Id[“EPSG”, 9801, Citation[“IOGP”]]],
+     *       Parameter[“Latitude of natural origin”, 52.0, AngleUnit[“grade”, 0.015707963267948967], Id[“EPSG”, 8801]],
+     *       Parameter[“Longitude of natural origin”, 0.0, AngleUnit[“degree”, 0.017453292519943295], Id[“EPSG”, 8802]],
+     *       Parameter[“Scale factor at natural origin”, 0.99987742, ScaleUnit[“unity”, 1], Id[“EPSG”, 8805]],
+     *       Parameter[“False easting”, 600000.0, LengthUnit[“metre”, 1], Id[“EPSG”, 8806]],
+     *       Parameter[“False northing”, 2200000.0, LengthUnit[“metre”, 1], Id[“EPSG”, 8807]]],
+     *     CS[“Cartesian”, 2],
+     *       Axis[“Easting (E)”, east, Order[1]],
+     *       Axis[“Northing (N)”, north, Order[2]],
+     *       LengthUnit[“metre”, 1],
+     *     Id[“EPSG”, 27572, Citation[“IOGP”], URI[“urn:ogc:def:crs:EPSG::27572”]]]
+     * }
+     *
+     * <p>Same coordinate reference system using WKT 1.</p>
+     *
+     * {@preformat wkt
+     *   PROJCS[“NTF (Paris) / Lambert zone II”,
+     *     GEOGCS[“NTF (Paris)”,
+     *       DATUM[“Nouvelle Triangulation Francaise”,
+     *         SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],
+     *         PRIMEM[“Paris”, 2.33722917],
+     *       UNIT[“degree”, 0.017453292519943295],
+     *       AXIS[“Longitude”, EAST],
+     *       AXIS[“Latitude”, NORTH]],
+     *     PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],
+     *     PARAMETER[“latitude_of_origin”, 46.8],
+     *     PARAMETER[“central_meridian”, 0.0],
+     *     PARAMETER[“scale_factor”, 0.99987742],
+     *     PARAMETER[“false_easting”, 600000.0],
+     *     PARAMETER[“false_northing”, 2200000.0],
+     *     UNIT[“metre”, 1],
+     *     AXIS[“Easting”, EAST],
+     *     AXIS[“Northing”, NORTH],
+     *     AUTHORITY[“EPSG”, “27572”]]
+     * }
+     * </div>
+     *
      * @return {@code "ProjectedCRS"} (WKT 2) or {@code "ProjCS"} (WKT 1).
      */
     @Override
@@ -256,62 +340,34 @@ public class DefaultProjectedCRS extends
         final GeographicCRS baseCRS    = getBaseCRS();
         final Unit<Angle>   unit       = ReferencingUtilities.getAngularUnit(baseCRS.getCoordinateSystem());
         final Unit<Angle>   oldUnit    = formatter.addContextualUnit(unit);
+        /*
+         * Format the enclosing base CRS. Note that WKT 1 formats a full GeographicCRS while WKT 2 formats only
+         * the datum with the prime meridian (no coordinate system) and uses a different keyword ("BaseGeodCRS"
+         * instead of "GeodeticCRS"). The DefaultGeodeticCRS.formatTo(Formatter) method detects when the CRS to
+         * format is part of an enclosing ProjectedCRS and will adapt accordingly.
+         */
         formatter.newLine();
-        if (isWKT1) {
-            formatter.append(toFormattable(baseCRS));
-        } else {
-            /*
-             * WKT 1 (above case) formatted a full GeographicCRS while WKT 2 (this case) formats
-             * only the datum and the prime meridian.  It does not format the coordinate system,
-             * and uses a different keyword ("BaseGeodCRS" instead of "GeogCS").
-             *
-             * Note that we format the unit in "simplified" mode, not in verbose mode. This looks
-             * like the opposite of what we would expect, but this is because formatting the unit
-             * here allow us to avoid repeating the unit in many projection parameters.
-             */
-            formatter.append(new BaseCRS(baseCRS, isWKT1, convention.isSimplified() ? unit : null));
-        }
+        formatter.append(toFormattable(baseCRS));
         formatter.newLine();
         final Parameters p = new Parameters(this);
+        final boolean isBaseCRS;
         if (isWKT1) {
             p.append(formatter);    // Format outside of any "Conversion" element.
+            isBaseCRS = false;
         } else {
             formatter.append(p);    // Format inside a "Conversion" element.
+            isBaseCRS = isBaseCRS(formatter);
+        }
+        /*
+         * In WKT 2 format, the coordinate system axes are written only if this projected CRS is not the base CRS
+         * of another derived CRS.
+         */
+        if (!isBaseCRS) {
+            formatCS(formatter, getCoordinateSystem(), isWKT1);
         }
-        formatCS(formatter, getCoordinateSystem(), isWKT1);
         formatter.removeContextualUnit(unit);
         formatter.addContextualUnit(oldUnit);
-        return isWKT1 ? "ProjCS" : "ProjectedCRS";
-    }
-
-    /**
-     * Temporary object for formatting the {@code BaseGeodCRS} element inside a {@code ProjectedCRS} element.
-     */
-    private static final class BaseCRS extends FormattableObject {
-        /** The base CRS. */
-        private final GeographicCRS baseCRS;
-
-        /** {@code true} for WKT 1 formatting, or {@code false} for WKT 2. */
-        private final boolean isWKT1;
-
-        /** Coordinate axis units. */
-        private final Unit<Angle> angularUnit;
-
-        /** Creates a new temporary {@code BaseGeodCRS} element. */
-        BaseCRS(final GeographicCRS baseCRS, final boolean isWKT1, final Unit<Angle> angularUnit) {
-            this.baseCRS     = baseCRS;
-            this.isWKT1      = isWKT1;
-            this.angularUnit = angularUnit;
-        }
-
-        /** Formats this {@code BaseGeodCRS} element. */
-        @Override protected String formatTo(final Formatter formatter) {
-            WKTUtilities.appendName(baseCRS, formatter, null);
-            DefaultGeodeticCRS.formatDatum(formatter, baseCRS.getDatum(), isWKT1);
-            formatter.append(angularUnit);  // May be null.
-            formatter.newLine();
-            return "BaseGeodCRS";
-        }
+        return isWKT1 ? "ProjCS" : isBaseCRS ? "BaseProjCRS" : "ProjectedCRS";
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultTemporalCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -55,7 +55,7 @@ import static org.apache.sis.util.Argume
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see org.apache.sis.referencing.datum.DefaultTemporalDatum
@@ -75,7 +75,7 @@ public class DefaultTemporalCRS extends
     /**
      * The datum.
      */
-    @XmlElement(name = "temporalDatum")
+    @XmlElement(name = "temporalDatum", required = true)
     private final TemporalDatum datum;
 
     /**
@@ -229,7 +229,7 @@ public class DefaultTemporalCRS extends
      * @return The coordinate system.
      */
     @Override
-    @XmlElement(name = "timeCS")
+    @XmlElement(name = "timeCS", required = true)
     public TimeCS getCoordinateSystem() {
         return (TimeCS) super.getCoordinateSystem();
     }
@@ -307,12 +307,10 @@ public class DefaultTemporalCRS extends
      */
     @Override
     protected String formatTo(final Formatter formatter) {
-        /*
-         * Note: super.formatTo(formatter) will usually format a DefaultTemporalDatum instance,
-         * which will declare this WKT has invalid if the formatter convention is a WKT 1 one.
-         * So we do not redo this check here.
-         */
         super.formatTo(formatter);
-        return "TimeCRS";
+        if (formatter.getConvention().majorVersion() == 1) {
+            formatter.setInvalidWKT(this, null);
+        }
+        return isBaseCRS(formatter) ? "BaseTimeCRS" : "TimeCRS";
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultVerticalCRS.java [UTF-8] Tue May  5 13:53:16 2015
@@ -47,7 +47,7 @@ import static org.apache.sis.util.Argume
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see org.apache.sis.referencing.datum.DefaultVerticalDatum
@@ -67,7 +67,7 @@ public class DefaultVerticalCRS extends
     /**
      * The datum.
      */
-    @XmlElement(name = "verticalDatum")
+    @XmlElement(name = "verticalDatum", required = true)
     private final VerticalDatum datum;
 
     /**
@@ -200,7 +200,7 @@ public class DefaultVerticalCRS extends
      * @return The coordinate system.
      */
     @Override
-    @XmlElement(name = "verticalCS")
+    @XmlElement(name = "verticalCS", required = true)
     public VerticalCS getCoordinateSystem() {
         return (VerticalCS) super.getCoordinateSystem();
     }
@@ -238,6 +238,7 @@ public class DefaultVerticalCRS extends
     @Override
     protected String formatTo(final Formatter formatter) {
         super.formatTo(formatter);
-        return (formatter.getConvention().majorVersion() == 1) ? "Vert_CS" : "VerticalCRS";
+        return (formatter.getConvention().majorVersion() == 1) ? "Vert_CS"
+               : isBaseCRS(formatter) ? "BaseVertCRS" : "VerticalCRS";
     }
 }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/package-info.java [UTF-8] Tue May  5 13:53:16 2015
@@ -88,8 +88,8 @@
     @XmlJavaTypeAdapter(CD_ImageDatum.class),
     @XmlJavaTypeAdapter(CD_TemporalDatum.class),
     @XmlJavaTypeAdapter(CD_VerticalDatum.class),
+    @XmlJavaTypeAdapter(CS_CartesianCS.class),      // Must be before CS_AffineCS.
     @XmlJavaTypeAdapter(CS_AffineCS.class),
-    @XmlJavaTypeAdapter(CS_CartesianCS.class),
     @XmlJavaTypeAdapter(CS_CylindricalCS.class),
     @XmlJavaTypeAdapter(CS_EllipsoidalCS.class),
     @XmlJavaTypeAdapter(CS_LinearCS.class),
@@ -98,6 +98,8 @@
     @XmlJavaTypeAdapter(CS_TimeCS.class),
     @XmlJavaTypeAdapter(CS_UserDefinedCS.class),
     @XmlJavaTypeAdapter(CS_VerticalCS.class),
+    @XmlJavaTypeAdapter(CC_Conversion.class),
+    @XmlJavaTypeAdapter(SC_GeographicCRS.class),
     @XmlJavaTypeAdapter(StringAdapter.class),
     @XmlJavaTypeAdapter(InternationalStringConverter.class)
 })

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java [UTF-8] Tue May  5 13:53:16 2015
@@ -742,18 +742,15 @@ public class DefaultCoordinateSystemAxis
      * Returns the enclosing coordinate system, or {@code null} if none. In ISO 19162 compliant WKT the coordinate
      * <strong>reference</strong> system should be the first parent ({@code formatter.getEnclosingElement(1)}) and
      * the coordinate system shall be obtained from that CRS (yes, this is convolved. This is because of historical
-     * reasons, since compatibility with WKT 1 was a requirement of WKT 2). But we nevertheless walk over all parents
-     * in case someone format unusual things.
+     * reasons, since compatibility with WKT 1 was a requirement of WKT 2).
      */
     private static CoordinateSystem getEnclosingCS(final Formatter formatter) {
-        int depth = 1;
-        for (Object e; (e = formatter.getEnclosingElement(depth)) != null; depth++) {
-            if (e instanceof CoordinateReferenceSystem) {   // This is what we expect in standard WKT.
-                return ((CoordinateReferenceSystem) e).getCoordinateSystem();
-            }
-            if (e instanceof CoordinateSystem) {    // In case someone formats something unusual.
-                return (CoordinateSystem) e;
-            }
+        final FormattableObject e = formatter.getEnclosingElement(1);
+        if (e instanceof CoordinateReferenceSystem) {   // This is what we expect in standard WKT.
+            return ((CoordinateReferenceSystem) e).getCoordinateSystem();
+        }
+        if (e instanceof CoordinateSystem) {    // Not standard WKT, but conceptually the right thing.
+            return (CoordinateSystem) e;
         }
         return null;
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Tue May  5 13:53:16 2015
@@ -19,6 +19,10 @@ package org.apache.sis.referencing.opera
 import java.util.Map;
 import java.util.Collection;
 import java.util.Collections;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.quality.PositionalAccuracy;
@@ -84,6 +88,18 @@ import org.apache.sis.internal.jdk7.Obje
  * @version 0.6
  * @module
  */
+@XmlType(name="AbstractCoordinateOperationType", propOrder = {
+    "domainOfValidity",
+    "scope",
+    "operationVersion",
+    "coordinateOperationAccuracy",
+//  "sourceCRS",    // TODO
+//  "targetCRS"
+})
+@XmlRootElement(name = "AbstractCoordinateOperation")
+@XmlSeeAlso({
+    AbstractSingleOperation.class
+})
 public class AbstractCoordinateOperation extends AbstractIdentifiedObject implements CoordinateOperation {
     /**
      * Serial number for inter-operability with different versions.
@@ -95,6 +111,7 @@ public class AbstractCoordinateOperation
      *
      * @see #getSourceCRS()
      */
+//  @XmlElement
     private final CoordinateReferenceSystem sourceCRS;
 
     /**
@@ -102,6 +119,7 @@ public class AbstractCoordinateOperation
      *
      * @see #getTargetCRS()
      */
+//  @XmlElement
     private final CoordinateReferenceSystem targetCRS;
 
     /**
@@ -116,21 +134,25 @@ public class AbstractCoordinateOperation
      * Version of the coordinate transformation
      * (i.e., instantiation due to the stochastic nature of the parameters).
      */
+    @XmlElement
     private final String operationVersion;
 
     /**
      * Estimate(s) of the impact of this operation on point accuracy, or {@code null} if none.
      */
+    @XmlElement
     private final Collection<PositionalAccuracy> coordinateOperationAccuracy;
 
     /**
      * Area in which this operation is valid, or {@code null} if not available.
      */
+    @XmlElement
     private final Extent domainOfValidity;
 
     /**
      * Description of domain of usage, or limitations of usage, for which this operation is valid.
      */
+    @XmlElement
     private final InternationalString scope;
 
     /**
@@ -140,6 +162,23 @@ public class AbstractCoordinateOperation
     private final MathTransform transform;
 
     /**
+     * Constructs a new object in which every attributes are set to a null value.
+     * <strong>This is not a valid object.</strong> This constructor is strictly
+     * reserved to JAXB, which will assign values to the fields using reflexion.
+     */
+    AbstractCoordinateOperation() {
+        super(org.apache.sis.internal.referencing.NilReferencingObject.INSTANCE);
+        sourceCRS = null;
+        targetCRS = null;
+        interpolationCRS = null;
+        operationVersion = null;
+        coordinateOperationAccuracy = null;
+        domainOfValidity = null;
+        scope = null;
+        transform = null;
+    }
+
+    /**
      * Constructs a new coordinate operation with the same values than the specified defining conversion,
      * together with the specified source and target CRS. This constructor is used by {@link DefaultConversion} only.
      */
@@ -255,6 +294,8 @@ public class AbstractCoordinateOperation
                                        final MathTransform             transform)
     {
         super(properties);
+        ArgumentChecks.ensureNonNull("transform", transform);
+
         this.sourceCRS        = sourceCRS;
         this.targetCRS        = targetCRS;
         this.interpolationCRS = interpolationCRS;

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java [UTF-8] Tue May  5 13:53:16 2015
@@ -17,6 +17,9 @@
 package org.apache.sis.referencing.operation;
 
 import java.util.Map;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlRootElement;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.Matrix;
@@ -48,6 +51,14 @@ import org.apache.sis.internal.jdk7.Obje
  * @version 0.6
  * @module
  */
+@XmlType(name="AbstractSingleOperationType", propOrder = {
+//  "method",   // TODO
+//  "parameters"
+})
+@XmlRootElement(name = "AbstractSingleOperation")
+@XmlSeeAlso({
+    DefaultConversion.class
+})
 class AbstractSingleOperation extends AbstractCoordinateOperation implements SingleOperation, Parameterized {
     /**
      * Serial number for inter-operability with different versions.
@@ -65,6 +76,16 @@ class AbstractSingleOperation extends Ab
     private final ParameterValueGroup parameters;
 
     /**
+     * Constructs a new object in which every attributes are set to a null value.
+     * <strong>This is not a valid object.</strong> This constructor is strictly
+     * reserved to JAXB, which will assign values to the fields using reflexion.
+     */
+    AbstractSingleOperation() {
+        method = null;
+        parameters = null;
+    }
+
+    /**
      * Creates a coordinate operation from the given properties.
      */
     public AbstractSingleOperation(final Map<String,?>             properties,
@@ -75,8 +96,7 @@ class AbstractSingleOperation extends Ab
                                    final MathTransform             transform)
     {
         super(properties, sourceCRS, targetCRS, interpolationCRS, transform);
-        ArgumentChecks.ensureNonNull("method",    method);
-        ArgumentChecks.ensureNonNull("transform", transform);
+        ArgumentChecks.ensureNonNull("method", method);
         checkDimensions(method, transform, properties);
         this.method = method;
         /*

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperation.java [UTF-8] Tue May  5 13:53:16 2015
@@ -145,7 +145,7 @@ public class DefaultConcatenatedOperatio
      * @param  factory       The math transform factory to use.
      * @param  wantTransform {@code true} if the concatenated math transform should be computed.
      *         This is set to {@code false} only when this method invokes itself recursively.
-     * @return The concatenated math transform.
+     * @return The concatenated math transform, or {@code null} if {@code wantTransform} was {@code false}.
      * @throws FactoryException if the factory can not concatenate the math transforms.
      */
     private static MathTransform expand(final CoordinateOperation[] operations,
@@ -253,6 +253,39 @@ public class DefaultConcatenatedOperatio
     }
 
     /**
+     * Creates a new coordinate operation 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.
+     *
+     * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p>
+     *
+     * @param operation The coordinate operation to copy.
+     *
+     * @see #castOrCopy(ConcatenatedOperation)
+     */
+    protected DefaultConcatenatedOperation(final ConcatenatedOperation operation) {
+        super(operation);
+        operations = operation.getOperations();
+    }
+
+    /**
+     * Returns a SIS coordinate operation implementation with the values of the given arbitrary implementation.
+     * If the given object is already an instance of {@code DefaultConcatenatedOperation}, then it is returned
+     * unchanged. Otherwise a new {@code DefaultConcatenatedOperation} instance is created using the
+     * {@linkplain #DefaultConcatenatedOperation(ConcatenatedOperation) copy constructor} and returned.
+     * Note that this is a <cite>shallow</cite> copy operation, since the other properties contained in the given
+     * object are not recursively copied.
+     *
+     * @param  object The object to get as a SIS implementation, or {@code null} if none.
+     * @return A SIS implementation containing the values of the given object (may be the
+     *         given object itself), or {@code null} if the argument was null.
+     */
+    public static DefaultConcatenatedOperation castOrCopy(final ConcatenatedOperation object) {
+        return (object == null) || (object instanceof DefaultConcatenatedOperation)
+                ? (DefaultConcatenatedOperation) object : new DefaultConcatenatedOperation(object);
+    }
+
+    /**
      * Returns the GeoAPI interface implemented by this class.
      * The SIS implementation returns {@code ConcatenatedOperation.class}.
      *

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java?rev=1677828&r1=1677827&r2=1677828&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultConicProjection.java [UTF-8] Tue May  5 13:53:16 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.referencing.operation;
 
+import javax.xml.bind.annotation.XmlTransient;
 import org.opengis.referencing.operation.Conversion;
 import org.opengis.referencing.operation.ConicProjection;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -32,6 +33,7 @@ import org.opengis.referencing.crs.Coord
  * @see org.apache.sis.referencing.crs.DefaultProjectedCRS
  * @see <a href="http://mathworld.wolfram.com/ConicProjection.html">Conic projection on MathWorld</a>
  */
+@XmlTransient
 final class DefaultConicProjection extends DefaultProjection implements ConicProjection {
     /**
      * Serial number for inter-operability with different versions.
@@ -47,9 +49,9 @@ final class DefaultConicProjection exten
      * @param sourceCRS  The source CRS.
      * @param targetCRS  The target CRS.
      */
-    public DefaultConicProjection(final Conversion                definition,
-                                  final CoordinateReferenceSystem sourceCRS,
-                                  final CoordinateReferenceSystem targetCRS)
+    DefaultConicProjection(final Conversion                definition,
+                           final CoordinateReferenceSystem sourceCRS,
+                           final CoordinateReferenceSystem targetCRS)
     {
         super(definition, sourceCRS, targetCRS);
     }



Mime
View raw message