sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1684478 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/parameter/ sis-referencing/src/main/java/org/apache/sis/referencing/crs/ sis-referencing/src/main/java/org...
Date Tue, 09 Jun 2015 17:01:57 GMT
Author: desruisseaux
Date: Tue Jun  9 17:01:56 2015
New Revision: 1684478

URL: http://svn.apache.org/r1684478
Log:
WKT: fixed handling of linear unit in projection parameters and added tests.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -875,9 +875,10 @@ final class GeodeticObjectParser extends
         final String        name       = element.pullString("name");
         final GeographicCRS geoCRS     = parseGeoGCS(element);
         final Unit<Length>  linearUnit = parseUnit(element, SI.METRE);
-        final Conversion    conversion = parseProjection(element, linearUnit,
-                (convention == Convention.WKT1_COMMON_UNITS) ? NonSI.DEGREE_ANGLE :
-                geoCRS.getCoordinateSystem().getAxis(0).getUnit().asType(Angle.class));
+        final boolean  usesCommonUnits = convention.usesCommonUnits();
+        final Conversion    conversion = parseProjection(element,
+                usesCommonUnits ? SI.METRE : linearUnit,
+                usesCommonUnits ? NonSI.DEGREE_ANGLE : geoCRS.getCoordinateSystem().getAxis(0).getUnit().asType(Angle.class));
         CoordinateSystemAxis axis0 = parseAxis(element, false, linearUnit, false);
         CoordinateSystemAxis axis1 = null;
         try {

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -481,6 +481,13 @@ public class DefaultParameterValue<T> ex
     }
 
     /**
+     * Returns {@code true} if the given value is an instance of one of the types documented in {@link #valueFile()}.
+     */
+    private static boolean isFile(final Object value) {
+        return (value instanceof URI || value instanceof URL || value instanceof File || value instanceof Path);
+    }
+
+    /**
      * Returns the exception to throw when an incompatible method is invoked for the value type.
      */
     private IllegalStateException incompatibleValue(final Object value) {
@@ -826,18 +833,13 @@ public class DefaultParameterValue<T> ex
      * while parameter values that are angles are given in the unit for the base geographic CRS.
      *
      * <div class="note"><b>Example:</b>
-     * The table below shows WKT representations of the map projection parameters of a projected CRS
+     * The snippet below show WKT representations of the map projection parameters of a projected CRS
      * (most other elements are omitted). The map projection uses a <cite>"Latitude of natural origin"</cite>
      * parameters which is set to 52 <strong>grads</strong>, as defined in the {@code UNIT[…]} element of the
      * enclosing CRS. A similar rule applies to <cite>“False easting”</cite> and <cite>“False northing”</cite>
      * parameters, which are in kilometres in this example.
      *
-     * <table class="sis">
-     * <caption>Parameters in a Projected CRS</caption>
-     * <tr>
-     *   <td>WKT 1</td>
-     *   <td>WKT 2</td>
-     * </tr><tr><td>
+     * <p><b>WKT 1:</b></p>
      * {@preformat wkt
      *   PROJCS[…,
      *     GEOGCS[…,
@@ -849,7 +851,8 @@ public class DefaultParameterValue<T> ex
      *     PARAMETER[“false_northing”, 2200.0],         // In kilometres
      *     UNIT[“km”, 1000]]                            // Unit for all lengths
      * }
-     * </td><td>
+     *
+     * <p><b>WKT 2:</b></p>
      * {@preformat wkt
      *   ProjectedCRS[…
      *     BaseGeodCRS[…
@@ -863,7 +866,7 @@ public class DefaultParameterValue<T> ex
      *     CS["Cartesian", 2],
      *       LengthUnit["km", 1000]]
      * }
-     * </td></tr></table></div>
+     * </div>
      *
      * @param  formatter The formatter where to format the inner content of this WKT element.
      * @return {@code "Parameter"} or {@code "ParameterFile"}.
@@ -882,34 +885,32 @@ public class DefaultParameterValue<T> ex
          * If this parameter value does not use the same unit, then we must convert it.
          * Otherwise we can write the value as-is.
          */
-        final Unit<?> unit = getUnit();  // Gives to users a chance to override this property.
-        final boolean sameUnit = Objects.equals(unit, targetUnit);
+        final T       value = getValue();   // Gives to users a chance to override this property.
+        final Unit<?> unit  = getUnit();    // Gives to users a chance to override this property.
+        double convertedValue = Double.NaN;
+        boolean sameUnit = Objects.equals(unit, targetUnit);
+        if (!sameUnit) try {
+            convertedValue = doubleValue(targetUnit);
+            sameUnit = (value instanceof Number) && ((Number) value).doubleValue() == convertedValue;
+        } catch (IllegalStateException exception) {
+            // May happen if a parameter is mandatory (e.g. "semi-major")
+            // but no value has been set for this parameter.
+            formatter.setInvalidWKT(descriptor, exception);
+        }
         if (isWKT1 && !sameUnit) {
-            double convertedValue;
-            try {
-                convertedValue = doubleValue(targetUnit);
-            } catch (IllegalStateException exception) {
-                // May happen if a parameter is mandatory (e.g. "semi-major")
-                // but no value has been set for this parameter.
-                formatter.setInvalidWKT(descriptor, exception);
-                convertedValue = Double.NaN;
-            }
             formatter.append(convertedValue);
+        } else if (!isWKT1 && (unit == null) && isFile(value)) {
+            formatter.append(value.toString(), null);
+            return WKTKeywords.ParameterFile;
         } else {
-            final T value = getValue();  // Gives to users a chance to override this property.
-            if (!isWKT1 && (unit == null) && (value instanceof URI || value instanceof URL
-                    || value instanceof File || value instanceof Path))
-            {
-                formatter.append(value.toString(), null);
-                return WKTKeywords.ParameterFile;
-            }
             formatter.appendAny(value);
         }
         /*
          * In the WKT 2 specification, the unit and the identifier are optional but recommended.
          * We follow that recommendation in strict WKT2 mode, but omit them in non-strict modes.
          * The only exception is when the parameter unit is not the same than the contextual unit,
-         * in which case we have no choice: we must format that unit.
+         * in which case we have no choice: we must format that unit, unless the numerical value
+         * is identical in both units (typically the 0 value).
          */
         if (!isWKT1 && (!sameUnit || !convention.isSimplified() || !hasContextualUnit(formatter))) {
             formatter.append(unit);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -41,7 +41,6 @@ import org.apache.sis.io.wkt.Formatter;
 import static org.apache.sis.util.Utilities.deepEquals;
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.internal.referencing.WKTUtilities.toFormattable;
-import static org.apache.sis.internal.referencing.ReferencingUtilities.canSetProperty;
 
 // Branch-dependent imports
 import java.util.Objects;
@@ -323,7 +322,9 @@ public class AbstractCRS extends Abstrac
      * @throws IllegalStateException If the coordinate system has already been set.
      */
     final void setCoordinateSystem(final String name, final CoordinateSystem cs) {
-        if (cs != null && canSetProperty(AbstractCRS.class, "setCoordinateSystem", name, coordinateSystem != null)) {
+        if (cs != null && ReferencingUtilities.canSetProperty(AbstractCRS.class,
+                "setCoordinateSystem", name, coordinateSystem != null))
+        {
             coordinateSystem = cs;
         }
     }
@@ -468,13 +469,14 @@ public class AbstractCRS extends Abstrac
         formatter.newLine();
         final boolean isWKT1 = formatter.getConvention().majorVersion() == 1;
         if (isWKT1 || !isBaseCRS(formatter)) {
-            formatCS(formatter, getCoordinateSystem(), isWKT1);
+            final CoordinateSystem cs = getCoordinateSystem();
+            formatCS(formatter, cs, ReferencingUtilities.getUnit(cs), isWKT1);
         }
         return keyword;
     }
 
     /**
-     * Returns {@code true} if the given formatter is in the process of formatting the base CRS of a
+     * Returns {@code true} if the given formatter is in the process of formatting the base CRS of an
      * {@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
@@ -495,15 +497,19 @@ public class AbstractCRS extends Abstrac
      * because ISO 19162 excludes the coordinate system definition in base CRS. Note however that WKT 1 includes the
      * coordinate systems.</p>
      *
+     * <div class="note"><b>Note:</b> the {@code unit} and {@code isWKT1} arguments could be computed by this method,
+     * but are requested in order to avoid computing them twice, because the caller usually have them anyway.</div>
+     *
      * @param formatter The formatter where to append the coordinate system.
      * @param cs        The coordinate system to append.
+     * @param unit      The value of {@code ReferencingUtilities.getUnit(cs)}.
      * @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) {
+    final void formatCS(final Formatter formatter, final CoordinateSystem cs, final Unit<?> unit, final boolean isWKT1) {
+        assert unit == ReferencingUtilities.getUnit(cs) : unit;
         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.
             formatter.append(unit);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -45,6 +45,7 @@ import org.apache.sis.referencing.Abstra
 import org.apache.sis.referencing.operation.DefaultConversion;
 import org.apache.sis.referencing.operation.DefaultOperationMethod;
 import org.apache.sis.referencing.cs.AxesConvention;
+import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.io.wkt.FormattableObject;
@@ -537,7 +538,8 @@ public class DefaultDerivedCRS extends A
                 }
             });
             if (!isBaseCRS(formatter)) {
-                formatCS(formatter, getCoordinateSystem(), isWKT1);
+                final CoordinateSystem cs = getCoordinateSystem();
+                formatCS(formatter, cs, ReferencingUtilities.getUnit(cs), isWKT1);
             }
             return keyword();
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -237,7 +237,7 @@ class DefaultGeodeticCRS extends Abstrac
          * the linear units will be formatted in the enclosing PROJCS[…] element.
          */
         if (!isBaseCRS) {
-            formatCS(formatter, cs, isWKT1);    // Will also format the axis unit.
+            formatCS(formatter, cs, ReferencingUtilities.getUnit(cs), isWKT1);    // Will also format the axes unit.
         } else if (convention.isSimplified()) {
             formatter.append(formatter.toContextualUnit(angularUnit));
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -382,10 +382,13 @@ public class DefaultProjectedCRS extends
             return super.formatTo(formatter);
         }
         WKTUtilities.appendName(this, formatter, null);
-        final boolean       isWKT1  = (formatter.getConvention().majorVersion() == 1);
-        final GeographicCRS baseCRS = getBaseCRS();
-        final Unit<Angle>   unit    = ReferencingUtilities.getAngularUnit(baseCRS.getCoordinateSystem());
-        final Unit<Angle>   oldUnit = formatter.addContextualUnit(unit);
+        final boolean       isWKT1      = (formatter.getConvention().majorVersion() == 1);
+        final CartesianCS   cs          = getCoordinateSystem();
+        final GeographicCRS baseCRS     = getBaseCRS();
+        final Unit<?>       lengthUnit  = ReferencingUtilities.getUnit(cs);
+        final Unit<Angle>   angularUnit = ReferencingUtilities.getAngularUnit(baseCRS.getCoordinateSystem());
+        final Unit<Angle>   oldAngle    = formatter.addContextualUnit(angularUnit);
+        final Unit<?>       oldLength   = formatter.addContextualUnit(lengthUnit);
         /*
          * 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"
@@ -409,9 +412,10 @@ public class DefaultProjectedCRS extends
          * of another derived CRS.
          */
         if (!isBaseCRS) {
-            formatCS(formatter, getCoordinateSystem(), isWKT1);
+            formatCS(formatter, cs, lengthUnit, isWKT1);
         }
-        formatter.restoreContextualUnit(unit, oldUnit);
+        formatter.restoreContextualUnit(lengthUnit, oldLength);
+        formatter.restoreContextualUnit(angularUnit, oldAngle);
         return isWKT1 ? WKTKeywords.ProjCS : isBaseCRS ? WKTKeywords.BaseProjCRS : WKTKeywords.ProjectedCRS;
     }
 

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultPrimeMeridian.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -27,6 +27,7 @@ import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.Identifier;
 import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.apache.sis.referencing.AbstractIdentifiedObject;
 import org.apache.sis.internal.metadata.WKTKeywords;
 import org.apache.sis.internal.jaxb.gco.Measure;
@@ -81,7 +82,7 @@ import java.util.Objects;
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Cédric Briançon (Geomatys)
  * @since   0.4
- * @version 0.4
+ * @version 0.6
  * @module
  *
  * @see org.apache.sis.referencing.CommonCRS#primeMeridian()
@@ -337,6 +338,57 @@ public class DefaultPrimeMeridian extend
     }
 
     /**
+     * Returns {@code true} if the given formatter is in the process of formatting the prime meridian of a base CRS
+     * of an {@link AbstractDerivedCRS}. In such case, base CRS coordinate system axes shall not be formatted, which
+     * has the consequence of bringing the {@code UNIT[…]} element right below the {@code PRIMEM[…]} one. Example:
+     *
+     * {@preformat wkt
+     *   ProjectedCRS[“NTF (Paris) / Lambert zone II”,
+     *     BaseGeodCRS[“NTF (Paris)”,
+     *       Datum[“Nouvelle Triangulation Francaise”,
+     *         Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]],
+     *       PrimeMeridian[“Paris”, 2.5969213],
+     *       AngleUnit[“grade”, 0.015707963267948967]],
+     *     Conversion[“Lambert zone II”,
+     *       etc...
+     * }
+     *
+     * If we were not formatting a base CRS, we would have many lines between {@code PrimeMeridian[…]} and
+     * {@code AngleUnit[…]} in the above example, which would make less obvious that the angle unit applies
+     * also to the prime meridian. It does not bring any ambiguity from an ISO 19162 standard point of view,
+     * but historically some other softwares interpreted the {@code PRIMEM[…]} units wrongly, which is why
+     * we try to find a compromise between keeping the WKT simple and avoiding an historical ambiguity.
+     *
+     * @see org.apache.sis.referencing.crs.AbstractCRS#isBaseCRS(Formatter)
+     */
+    private static boolean isElementOfBaseCRS(final Formatter formatter) {
+        return formatter.getEnclosingElement(2) instanceof GeneralDerivedCRS;
+    }
+
+    /**
+     * Returns {@code true} if {@link #formatTo(Formatter)} should conservatively format the angular unit
+     * even if it would be legal to omit it.
+     *
+     * <div class="section">Rational</div>
+     * According the ISO 19162 standard, it is legal to omit the {@code PrimeMeridian} angular unit when
+     * that unit is the same than the unit of the axes of the enclosing {@code GeographicCRS}. However the
+     * relationship between the CRS axes and the prime meridian is less obvious in WKT2 than it was in WKT1,
+     * because the WKT2 {@code UNIT[…]} element is far from the {@code PRIMEM[…]} element while it was just
+     * below it in WKT1.   Furthermore, the {@code PRIMEM[…]} unit is one source of incompatibility between
+     * various WKT1 parsers (i.e. some popular libraries are not conform to OGC 01-009 and ISO 19162).
+     * So we are safer to unconditionally format any unit other than degrees, even if we could legally
+     * omit them.
+     *
+     * <p>However in order to keep the WKT slightly simpler in {@link Convention#WKT2_SIMPLIFIED} mode,
+     * we make an exception to the above-cited safety if the {@code UNIT[…]} element is formatted right
+     * below the {@code PRIMEM[…]} one, which happen if we are inside a base CRS.
+     * See {@link #isElementOfBaseCRS(Formatter)} for more discussion.
+     */
+    private static boolean beConservative(final Formatter formatter, final Unit<Angle> targetUnit) {
+        return !targetUnit.equals(NonSI.DEGREE_ANGLE) && !isElementOfBaseCRS(formatter);
+    }
+
+    /**
      * Formats this prime meridian as a <cite>Well Known Text</cite> {@code PrimeMeridian[…]} element.
      *
      * @return {@code "PrimeMeridian"} (WKT 2) or {@code "PrimeM"} (WKT 1).
@@ -354,18 +406,7 @@ public class DefaultPrimeMeridian extend
             return WKTKeywords.PrimeM;
         }
         final Unit<Angle> angularUnit = getAngularUnit();   // Gives to users a chance to override properties.
-        if (!convention.isSimplified() || !targetUnit.equals(angularUnit) || !targetUnit.equals(NonSI.DEGREE_ANGLE)) {
-            /*
-             * Note on the equals(NonSI.DEGREE_ANGLE) check:
-             *
-             * In theory, that last check is not necessary since it would be legal to format the value in the
-             * unit of the axes of the enclosing GeographicCRS. However the relationship between the CRS axes
-             * and the prime meridian is less obvious in WKT2 than it was in WKT1, because the WKT2's UNIT[…]
-             * element is far from the PRIMEM[…] element while it was just below it in WKT1. Furthermore, the
-             * PRIMEM[…] unit is one source of incompatibility between various WKT1 parsers (e.g. GDAL is not
-             * conform to OGC 01-009 and ISO 19162). So we are safer to unconditionally format any unit other
-             * than degrees here, even if we could legally omit them.
-             */
+        if (!convention.isSimplified() || !targetUnit.equals(angularUnit) || beConservative(formatter, targetUnit)) {
             formatter.append(angularUnit);
         }
         return WKTKeywords.PrimeMeridian;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -23,6 +23,7 @@ import java.text.ParseException;
 import javax.measure.unit.SI;
 import javax.measure.unit.NonSI;
 import javax.measure.unit.Unit;
+import javax.measure.quantity.Length;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.referencing.cs.*;
 import org.opengis.referencing.crs.*;
@@ -128,12 +129,13 @@ public final strictfp class GeodeticObje
     }
 
     /**
-     * Verifies that the axes of the coordinate system are those of a projected CRS, in metres.
+     * Verifies that the axes of the coordinate system are those of a projected CRS,
+     * with (East, North) axis directions.
      */
-    private static void verifyProjectedCS(final CartesianCS cs) {
+    private static void verifyProjectedCS(final CartesianCS cs, final Unit<Length> unit) {
         assertEquals("dimension", 2, cs.getDimension());
-        assertUnboundedAxisEquals("Easting",  "E", AxisDirection.EAST,  SI.METRE, cs.getAxis(0));
-        assertUnboundedAxisEquals("Northing", "N", AxisDirection.NORTH, SI.METRE, cs.getAxis(1));
+        assertUnboundedAxisEquals("Easting",  "E", AxisDirection.EAST,  unit, cs.getAxis(0));
+        assertUnboundedAxisEquals("Northing", "N", AxisDirection.NORTH, unit, cs.getAxis(1));
     }
 
     /**
@@ -199,7 +201,7 @@ public final strictfp class GeodeticObje
      */
     @Test
     @DependsOnMethod("testGeographicCRS")
-    public void testAxisSwapping() throws ParseException {
+    public void testWithAxisSwapping() throws ParseException {
         verifyGeographicCRS(1, parse(GeographicCRS.class,
                "  GEOGCS[“WGS 84”,\n" +
                "    DATUM[“World Geodetic System 1984”,\n" +
@@ -215,11 +217,11 @@ public final strictfp class GeodeticObje
      *
      * @throws ParseException if the parsing failed.
      *
-     * @see #testImplicitAxesInSeconds()
+     * @see #testWithImplicitAxesInSeconds()
      */
     @Test
     @DependsOnMethod("testGeographicCRS")
-    public void testImplicitAxes() throws ParseException {
+    public void testWithImplicitAxes() throws ParseException {
         verifyGeographicCRS(0, parse(GeographicCRS.class,
                "  GEOGCS[“WGS 84”,\n" +
                "    DATUM[“World Geodetic System 1984”,\n" +
@@ -229,7 +231,7 @@ public final strictfp class GeodeticObje
     }
 
     /**
-     * Implementation of {@link #testGeographicCRS()} and {@link #testAxisSwapping()}.
+     * Implementation of {@link #testGeographicCRS()} and {@link #testWithAxisSwapping()}.
      * This test expects no {@code AUTHORITY} element on any component.
      *
      * @param swap 1 if axes are expected to be swapped, or 0 otherwise.
@@ -279,7 +281,7 @@ public final strictfp class GeodeticObje
                 "  AXIS[“Northing”, NORTH]]");
 
         assertNameAndIdentifierEqual("Mercator test", 0, crs);
-        verifyProjectedCS(crs.getCoordinateSystem());
+        verifyProjectedCS(crs.getCoordinateSystem(), SI.METRE);
         verifyGeographicCRS(0, crs.getBaseCRS());
 
         final GeodeticDatum datum = crs.getDatum();
@@ -293,12 +295,12 @@ public final strictfp class GeodeticObje
 
         assertEquals("Mercator (variant A)", crs.getConversionFromBase().getMethod().getName().getCode());
         final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
-        assertEquals("semi_major",   6378137.0, param.parameter("semi_major"      ).doubleValue(), STRICT);
-        assertEquals("semi_minor",   6356752.3, param.parameter("semi_minor"      ).doubleValue(), 0.1);
-        assertEquals("central_meridian", -20.0, param.parameter("central_meridian").doubleValue(), STRICT);
-        assertEquals("scale_factor",       1.0, param.parameter("scale_factor"    ).doubleValue(), STRICT);
-        assertEquals("false_easting", 500000.0, param.parameter("false_easting"   ).doubleValue(), STRICT);
-        assertEquals("false_northing",     0.0, param.parameter("false_northing"  ).doubleValue(), STRICT);
+        assertEquals("semi_major",   6378137.0, param.parameter("semi_major"      ).doubleValue(SI   .METRE),        STRICT);
+        assertEquals("semi_minor",   6356752.3, param.parameter("semi_minor"      ).doubleValue(SI   .METRE),        0.1);
+        assertEquals("central_meridian", -20.0, param.parameter("central_meridian").doubleValue(NonSI.DEGREE_ANGLE), STRICT);
+        assertEquals("scale_factor",       1.0, param.parameter("scale_factor"    ).doubleValue(Unit .ONE),          STRICT);
+        assertEquals("false_easting", 500000.0, param.parameter("false_easting"   ).doubleValue(SI   .METRE),        STRICT);
+        assertEquals("false_northing",     0.0, param.parameter("false_northing"  ).doubleValue(SI   .METRE),        STRICT);
     }
 
     /**
@@ -309,7 +311,7 @@ public final strictfp class GeodeticObje
      */
     @Test
     @DependsOnMethod("testGeographicCRS")
-    public void testNonGreenwichMeridian() throws ParseException {
+    public void testWithNonGreenwichMeridian() throws ParseException {
         String wkt = "GEOGCS[“NTF (Paris)”,\n" +
                      "  DATUM[“Nouvelle Triangulation Française (Paris)”,\n" +
                      "    SPHEROID[“Clarke 1880 (IGN)”, 6378249.2, 293.4660212936269]],\n" +
@@ -352,14 +354,14 @@ public final strictfp class GeodeticObje
     }
 
     /**
-     * Tests the parsing of a projected CRS using parameters in grades instead than degrees.
-     * The grad units are also used for the prime meridian.
+     * Tests the parsing of a projected CRS using angular values in grades instead than degrees
+     * and in lengths in kilometres instead than metres.
      *
      * @throws ParseException if the parsing failed.
      */
     @Test
-    @DependsOnMethod({"testNonGreenwichMeridian", "testProjectedCRS"})
-    public void testGradUnitInParameters() throws ParseException {
+    @DependsOnMethod({"testWithNonGreenwichMeridian", "testProjectedCRS"})
+    public void testWithLessCommonUnits() throws ParseException {
         String wkt = "PROJCS[“NTF (Paris) / Lambert zone II”," +
                      "  GEOGCS[“NTF (Paris)”," +
                      "    DATUM[“Nouvelle Triangulation Française (Paris)”," +
@@ -370,13 +372,13 @@ public final strictfp class GeodeticObje
                      "  PROJECTION[“Lambert Conformal Conic (1SP)”]," +  // Intentional swapping of "Conformal" and "Conic".
                      "  PARAMETER[“latitude_of_origin”, 52.0]," +        // In grads.
                      "  PARAMETER[“scale_factor”, 0.99987742]," +
-                     "  PARAMETER[“false_easting”, 600000]," +
-                     "  PARAMETER[“false_northing”, 2200000]," +
-                     "  UNIT[“metre”,1]]";
+                     "  PARAMETER[“false_easting”, 600.0]," +
+                     "  PARAMETER[“false_northing”, 2200.0]," +
+                     "  UNIT[“metre”,1000]]";
 
         ProjectedCRS crs = parse(ProjectedCRS.class, wkt);
         assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 0, crs);
-        verifyProjectedCS(crs.getCoordinateSystem());
+        verifyProjectedCS(crs.getCoordinateSystem(), SI.KILOMETRE);
         PrimeMeridian pm = verifyNTF(crs.getDatum());
         assertEquals("angularUnit", NonSI.GRADE, pm.getAngularUnit());
         assertEquals("greenwichLongitude", 2.5969213, pm.getGreenwichLongitude(), STRICT);
@@ -385,16 +387,18 @@ public final strictfp class GeodeticObje
         assertEquals("latitude_of_origin",  52.0, param.doubleValue(), STRICT);
         /*
          * Parse again using Convention.WKT1_COMMON_UNITS and ignoring AXIS[…] elements.
-         * See the comment in testNonGreenwichMeridian for a discussion. The new aspect
-         * tested by this method is that the unit should be ignored for the parameters
-         * in addition to the prime meridian.
+         * See the comment in 'testWithNonGreenwichMeridian()' method for a discussion.
+         * The new aspect tested by this method is that the unit should be ignored
+         * for the parameters in addition to the prime meridian.
          */
-        wkt = wkt.replace("2.5969213", "2.33722917");   // Convert unit in prime meridian.
-        wkt = wkt.replace("52.0", "46.8");              // Convert unit in “latitude_of_origin” parameter.
+        wkt = wkt.replace("2.5969213", "2.33722917");       // Convert unit in prime meridian.
+        wkt = wkt.replace("52.0",      "46.8");             // Convert unit in “latitude_of_origin” parameter.
+        wkt = wkt.replace("600.0",     "600000");           // Convert unit in “false_easting” parameter.
+        wkt = wkt.replace("2200.0",    "2200000");          // Convert unit in “false_northing” parameter.
         setConvention(Convention.WKT1_COMMON_UNITS, true);
         crs = parse(ProjectedCRS.class, wkt);
         assertNameAndIdentifierEqual("NTF (Paris) / Lambert zone II", 0, crs);
-        verifyProjectedCS(crs.getCoordinateSystem());
+        verifyProjectedCS(crs.getCoordinateSystem(), SI.KILOMETRE);
         pm = verifyNTF(crs.getDatum());
         assertEquals("angularUnit", NonSI.DEGREE_ANGLE, pm.getAngularUnit());
         assertEquals("greenwichLongitude", 2.33722917, pm.getGreenwichLongitude(), STRICT);
@@ -431,12 +435,12 @@ public final strictfp class GeodeticObje
      */
     private static ParameterValue<?> verifyNTF(final ParameterValueGroup param) {
         assertEquals("Lambert Conic Conformal (1SP)", param.getDescriptor().getName().getCode());
-        assertEquals("semi_major",     6378249.2, param.parameter("semi_major"      ).doubleValue(), STRICT);
-        assertEquals("semi_minor",     6356515.0, param.parameter("semi_minor"      ).doubleValue(), 1E-12);
-        assertEquals("central_meridian",     0.0, param.parameter("central_meridian").doubleValue(), STRICT);
-        assertEquals("scale_factor",  0.99987742, param.parameter("scale_factor"    ).doubleValue(), STRICT);
-        assertEquals("false_easting",   600000.0, param.parameter("false_easting"   ).doubleValue(), STRICT);
-        assertEquals("false_northing", 2200000.0, param.parameter("false_northing"  ).doubleValue(), STRICT);
+        assertEquals("semi_major",     6378249.2, param.parameter("semi_major"      ).doubleValue(SI   .METRE),        STRICT);
+        assertEquals("semi_minor",     6356515.0, param.parameter("semi_minor"      ).doubleValue(SI   .METRE),        1E-12);
+        assertEquals("central_meridian",     0.0, param.parameter("central_meridian").doubleValue(NonSI.DEGREE_ANGLE), STRICT);
+        assertEquals("scale_factor",  0.99987742, param.parameter("scale_factor"    ).doubleValue(Unit .ONE),          STRICT);
+        assertEquals("false_easting",   600000.0, param.parameter("false_easting"   ).doubleValue(SI   .METRE),        STRICT);
+        assertEquals("false_northing", 2200000.0, param.parameter("false_northing"  ).doubleValue(SI   .METRE),        STRICT);
         return param.parameter("latitude_of_origin");
     }
 
@@ -502,11 +506,11 @@ public final strictfp class GeodeticObje
      *
      * @throws ParseException if the parsing failed.
      *
-     * @see #testImplicitAxes()
+     * @see #testWithImplicitAxes()
      */
     @Test
-    @DependsOnMethod("testImplicitAxes")
-    public void testImplicitAxesInSeconds() throws ParseException {
+    @DependsOnMethod("testWithImplicitAxes")
+    public void testWithImplicitAxesInSeconds() throws ParseException {
         final GeographicCRS crs = parse(GeographicCRS.class,
                 "GEOGCS[“NAD83 / NFIS Seconds”," +
                 "DATUM[“North_American_Datum_1983”,\n" +
@@ -576,7 +580,7 @@ public final strictfp class GeodeticObje
                 "AXIS[“Easting”,East],AXIS[“Northing”,North]]");
 
         assertNameAndIdentifierEqual("FRANCE/NTF/Lambert III", 0, crs);
-        verifyProjectedCS(crs.getCoordinateSystem());
+        verifyProjectedCS(crs.getCoordinateSystem(), SI.METRE);
         final GeographicCRS geoCRS = crs.getBaseCRS();
         assertNameAndIdentifierEqual("NTF=GR3DF97A", 0, geoCRS);    // Inherited the datum name.
 
@@ -596,12 +600,12 @@ public final strictfp class GeodeticObje
 
         final ParameterValueGroup param = crs.getConversionFromBase().getParameterValues();
         assertEquals("Lambert Conic Conformal (1SP)", param.getDescriptor().getName().getCode());
-        assertEquals("semi_major",        6378249.2, param.parameter("semi_major"        ).doubleValue(), STRICT);
-        assertEquals("semi_minor",        6356515.0, param.parameter("semi_minor"        ).doubleValue(), 1E-12);
-        assertEquals("latitude_of_origin",     44.1, param.parameter("latitude_of_origin").doubleValue(), STRICT);
-        assertEquals("central_meridian", 2.33722917, param.parameter("central_meridian"  ).doubleValue(), STRICT);
-        assertEquals("scale_factor",    0.999877499, param.parameter("scale_factor"      ).doubleValue(), STRICT);
-        assertEquals("false_easting",      600000.0, param.parameter("false_easting"     ).doubleValue(), STRICT);
-        assertEquals("false_northing",     200000.0, param.parameter("false_northing"    ).doubleValue(), STRICT);
+        assertEquals("semi_major",        6378249.2, param.parameter("semi_major"        ).doubleValue(SI   .METRE),        STRICT);
+        assertEquals("semi_minor",        6356515.0, param.parameter("semi_minor"        ).doubleValue(SI   .METRE),        1E-12);
+        assertEquals("latitude_of_origin",     44.1, param.parameter("latitude_of_origin").doubleValue(NonSI.DEGREE_ANGLE), STRICT);
+        assertEquals("central_meridian", 2.33722917, param.parameter("central_meridian"  ).doubleValue(NonSI.DEGREE_ANGLE), STRICT);
+        assertEquals("scale_factor",    0.999877499, param.parameter("scale_factor"      ).doubleValue(Unit .ONE),          STRICT);
+        assertEquals("false_easting",      600000.0, param.parameter("false_easting"     ).doubleValue(SI   .METRE),        STRICT);
+        assertEquals("false_northing",     200000.0, param.parameter("false_northing"    ).doubleValue(SI   .METRE),        STRICT);
     }
 }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/WKTFormatTest.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -102,7 +102,8 @@ public final strictfp class WKTFormatTes
     public void testConsistencyOfWKT1_WithCommonUnits() throws ParseException {
         format = new WKTFormat(null, null);
         format.setConvention(Convention.WKT1_COMMON_UNITS);
-        parser = format;
+        parser = new WKTFormat(null, null);
+        parser.setConvention(Convention.WKT1);
         testConsistency();
     }
 
@@ -147,15 +148,14 @@ public final strictfp class WKTFormatTes
                 +   "AXIS[“Long”,EAST],"
                 +   "AUTHORITY[“EPSG”,“4807”]],"
                 + "PROJECTION[“Lambert_Conformal_Conic_1SP”],"
-                + "PARAMETER[“latitude_of_origin”,49.5],"
+                + "PARAMETER[“latitude_of_origin”,55],"             // 55 grads = 49.5 degrees
                 + "PARAMETER[“central_meridian”,0],"
                 + "PARAMETER[“scale_factor”,0.999877341],"
-                + "PARAMETER[“false_easting”,600000],"
-                + "PARAMETER[“false_northing”,1200000],"
-                + "UNIT[“metre”,1,AUTHORITY[“EPSG”,“9001”]],"
+                + "PARAMETER[“false_easting”,600],"
+                + "PARAMETER[“false_northing”,1200],"
+                + "UNIT[“km”,1000],"
                 + "AXIS[“X”,EAST],"
-                + "AXIS[“Y”,NORTH],"
-                + "AUTHORITY[“EPSG”,“27581”]]");
+                + "AXIS[“Y”,NORTH]]");
 
         testConsistency(
                 "VERT_CS[“mean sea level depth”,"

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java?rev=1684478&r1=1684477&r2=1684478&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java [UTF-8] Tue Jun  9 17:01:56 2015
@@ -94,7 +94,7 @@ public final strictfp class DefaultProje
                 "    AXIS[“Longitude”, EAST],\n" +
                 "    AXIS[“Latitude”, NORTH]],\n" +
                 "  PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n" +
-                "  PARAMETER[“latitude_of_origin”, 52.0],\n" +
+                "  PARAMETER[“latitude_of_origin”, 52.0],\n" +          // In grads
                 "  PARAMETER[“central_meridian”, 0.0],\n" +
                 "  PARAMETER[“scale_factor”, 0.99987742],\n" +
                 "  PARAMETER[“false_easting”, 600000.0],\n" +
@@ -107,6 +107,37 @@ public final strictfp class DefaultProje
     }
 
     /**
+     * Tests WKT 1 formatting using {@link Convention#WKT1_COMMON_UNITS}.
+     *
+     * @throws FactoryException if the CRS creation failed.
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT1_WithCommonUnits() throws FactoryException {
+        final ProjectedCRS crs = create(HardCodedCRS.NTF);
+        assertWktEquals(Convention.WKT1_COMMON_UNITS,
+                "PROJCS[“NTF (Paris) / Lambert zone II”,\n" +
+                "  GEOGCS[“NTF (Paris)”,\n" +
+                "    DATUM[“Nouvelle Triangulation Francaise”,\n" +
+                "      SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" +
+                "      PRIMEM[“Paris”, 2.33722917],\n" +                    // Note the conversion from 2.5969213 grads.
+                "    UNIT[“grade”, 0.015707963267948967],\n" +
+                "    AXIS[“Longitude”, EAST],\n" +
+                "    AXIS[“Latitude”, NORTH]],\n" +
+                "  PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n" +
+                "  PARAMETER[“latitude_of_origin”, 46.8],\n" +              // Note the conversion from 52 grads.
+                "  PARAMETER[“central_meridian”, 0.0],\n" +
+                "  PARAMETER[“scale_factor”, 0.99987742],\n" +
+                "  PARAMETER[“false_easting”, 600000.0],\n" +
+                "  PARAMETER[“false_northing”, 2200000.0],\n" +
+                "  UNIT[“meter”, 1],\n" +
+                "  AXIS[“Easting”, EAST],\n" +
+                "  AXIS[“Northing”, NORTH],\n" +
+                "  AUTHORITY[“EPSG”, “27572”]]",
+                crs);
+    }
+
+    /**
      * Tests WKT 1 formatting with a somewhat convolved case where the units of the prime meridian is not
      * the same than the unit of axes. Since the axis units is what we write in the {@code UNIT[…]} element,
      * the WKT formatter need to convert the unit of prime meridian and all parameter angular values.
@@ -114,7 +145,7 @@ public final strictfp class DefaultProje
      * @throws FactoryException if the CRS creation failed.
      */
     @Test
-    @DependsOnMethod("testWKT1")
+    @DependsOnMethod("testWKT1_WithCommonUnits")
     public void testWKT1_WithMixedUnits() throws FactoryException {
         final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
         Validators.validate(crs);   // Opportunist check.
@@ -123,12 +154,12 @@ public final strictfp class DefaultProje
                 "  GEOGCS[“NTF (Paris)”,\n" +
                 "    DATUM[“Nouvelle Triangulation Francaise”,\n" +
                 "      SPHEROID[“NTF”, 6378249.2, 293.4660212936269]],\n" +
-                "      PRIMEM[“Paris”, 2.33722917],\n" +                    // Note the conversion from 2.5969213 grades.
+                "      PRIMEM[“Paris”, 2.33722917],\n" +                    // Note the conversion from 2.5969213 grads.
                 "    UNIT[“degree”, 0.017453292519943295],\n" +
                 "    AXIS[“Longitude”, EAST],\n" +
                 "    AXIS[“Latitude”, NORTH]],\n" +
                 "  PROJECTION[“Lambert_Conformal_Conic_1SP”, AUTHORITY[“EPSG”, “9801”]],\n" +
-                "  PARAMETER[“latitude_of_origin”, 46.8],\n" +              // Note the conversion from 52 grades.
+                "  PARAMETER[“latitude_of_origin”, 46.8],\n" +              // Note the conversion from 52 grads.
                 "  PARAMETER[“central_meridian”, 0.0],\n" +
                 "  PARAMETER[“scale_factor”, 0.99987742],\n" +
                 "  PARAMETER[“false_easting”, 600000.0],\n" +
@@ -141,6 +172,62 @@ public final strictfp class DefaultProje
     }
 
     /**
+     * Tests WKT 2 formatting in simplified mode.
+     *
+     * @throws FactoryException if the CRS creation failed.
+     */
+    @Test
+    @DependsOnMethod("testWKT1")
+    public void testWKT2_Simplified() throws FactoryException {
+        ProjectedCRS crs = create(HardCodedCRS.NTF);
+        assertWktEquals(Convention.WKT2_SIMPLIFIED,
+                "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +
+                "  BaseGeodCRS[“NTF (Paris)”,\n" +
+                "    Datum[“Nouvelle Triangulation Francaise”,\n" +
+                "      Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]],\n" +
+                "      PrimeMeridian[“Paris”, 2.5969213],\n" +
+                "    Unit[“grade”, 0.015707963267948967]],\n" +
+                "  Conversion[“Lambert zone II”,\n" +
+                "    Method[“Lambert Conic Conformal (1SP)”],\n" +
+                "    Parameter[“Latitude of natural origin”, 52.0],\n" +
+                "    Parameter[“Longitude of natural origin”, 0.0],\n" +
+                "    Parameter[“Scale factor at natural origin”, 0.99987742],\n" +
+                "    Parameter[“False easting”, 600000.0],\n" +
+                "    Parameter[“False northing”, 2200000.0]],\n" +
+                "  CS[“Cartesian”, 2],\n" +
+                "    Axis[“Easting (E)”, east],\n" +
+                "    Axis[“Northing (N)”, north],\n" +
+                "    Unit[“metre”, 1],\n" +
+                "  Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]",
+                crs);
+        /*
+         * Try again, but with mixed units. It should force the formatter to add explicit
+         * unit declaration in PrimeMeridian[…] and some Parameter[…] elements.
+         */
+        crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
+        assertWktEquals(Convention.WKT2_SIMPLIFIED,
+                "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +
+                "  BaseGeodCRS[“NTF (Paris)”,\n" +
+                "    Datum[“Nouvelle Triangulation Francaise”,\n" +
+                "      Ellipsoid[“NTF”, 6378249.2, 293.4660212936269]],\n" +
+                "      PrimeMeridian[“Paris”, 2.5969213, Unit[“grade”, 0.015707963267948967]],\n" +
+                "    Unit[“degree”, 0.017453292519943295]],\n" +
+                "  Conversion[“Lambert zone II”,\n" +
+                "    Method[“Lambert Conic Conformal (1SP)”],\n" +
+                "    Parameter[“Latitude of natural origin”, 52.0, Unit[“grade”, 0.015707963267948967]],\n" +
+                "    Parameter[“Longitude of natural origin”, 0.0],\n" +
+                "    Parameter[“Scale factor at natural origin”, 0.99987742],\n" +
+                "    Parameter[“False easting”, 600000.0],\n" +
+                "    Parameter[“False northing”, 2200000.0]],\n" +
+                "  CS[“Cartesian”, 2],\n" +
+                "    Axis[“Easting (E)”, east],\n" +
+                "    Axis[“Northing (N)”, north],\n" +
+                "    Unit[“metre”, 1],\n" +
+                "  Id[“EPSG”, 27572, URI[“urn:ogc:def:crs:EPSG::27572”]]]",
+                crs);
+    }
+
+    /**
      * Tests WKT 2 formatting. Contrarily to the WKT 1 formatting, in this case it does not matter
      * if we mix the units of measurement because the unit is declared for each parameter and axis.
      *
@@ -148,7 +235,7 @@ public final strictfp class DefaultProje
      */
     @Test
     @DependsOnMethod("testWKT1")
-    public void testWKT2() throws FactoryException {
+    public void testWKT2_WithMixedUnits() throws FactoryException {
         final ProjectedCRS crs = create(HardCodedCRS.NTF_NORMALIZED_AXES);
         assertWktEquals(Convention.WKT2,
                 "ProjectedCRS[“NTF (Paris) / Lambert zone II”,\n" +
@@ -221,7 +308,7 @@ public final strictfp class DefaultProje
      * @throws FactoryException if the CRS creation failed.
      */
     @Test
-    @DependsOnMethod("testWKT2")
+    @DependsOnMethod("testWKT2_Simplified")
     public void testWKT2_ForEquirectangular() throws FactoryException {
         final ProjectedCRS crs = new GeodeticObjectBuilder()
                 .setConversionMethod("Equirectangular")



Mime
View raw message