sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1675090 - in /sis/branches/JDK6: ./ core/sis-metadata/src/main/java/org/apache/sis/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ ...
Date Tue, 21 Apr 2015 11:07:33 GMT
Author: desruisseaux
Date: Tue Apr 21 11:07:32 2015
New Revision: 1675090

URL: http://svn.apache.org/r1675090
Log:
Merge bug fixes from the JDK7 branch.

Modified:
    sis/branches/JDK6/   (props changed)
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
    sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PseudoMercator.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
    sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java
    sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
    sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java

Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Apr 21 11:07:32 2015
@@ -1,4 +1,4 @@
 /sis/branches/Android:1430670-1480699
-/sis/branches/JDK7:1394913-1674327
-/sis/branches/JDK8:1584960-1674318
+/sis/branches/JDK7:1394913-1675087
+/sis/branches/JDK8:1584960-1675086
 /sis/trunk:1394364-1508466,1519089-1519674

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -138,15 +138,6 @@ public class MetadataStandard implements
     public static final MetadataStandard ISO_19115;
 
     /**
-     * An instance working on ISO 19119 standard as defined by GeoAPI interfaces
-     * in the {@code org.opengis.service} package and sub-packages.
-     *
-     * @deprecated as of ISO 19115:2014 revision, merged with {@link #ISO_19115}.
-     */
-    @Deprecated
-    public static final MetadataStandard ISO_19119;
-
-    /**
      * An instance working on ISO 19123 standard as defined by GeoAPI interfaces
      * in the {@link org.opengis.coverage} package and sub-packages.
      */
@@ -157,12 +148,10 @@ public class MetadataStandard implements
         // If new StandardImplementation instances are added below, please update StandardImplementation.readResolve().
         ISO_19115 = new StandardImplementation("ISO 19115", "org.opengis.metadata.", "org.apache.sis.metadata.iso.", null, null);
         ISO_19111 = new StandardImplementation("ISO 19111", "org.opengis.referencing.", "org.apache.sis.referencing.", acronyms, new MetadataStandard[] {ISO_19115});
-        ISO_19119 = new MetadataStandard      ("ISO 19119", "org.opengis.service.", ISO_19111.dependencies);
         ISO_19123 = new MetadataStandard      ("ISO 19123", "org.opengis.coverage.", new MetadataStandard[] {ISO_19111});
         INSTANCES = new MetadataStandard[] {
             ISO_19111,
             ISO_19115,
-            ISO_19119,
             ISO_19123
         };
         SystemListener.add(new SystemListener(Modules.METADATA) {

Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/Citations.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -72,7 +72,7 @@ public final class Citations extends Sta
      *
      * @since 0.4
      *
-     * @deprecated The OGP organization is now known as IOGP. This citation will be removed in SIS 0.6
+     * @deprecated The OGP organization is now known as IOGP. This citation will be removed in SIS 0.7
      *             because of this name change and for avoiding confusion with {@link #EPSG} citation.
      */
     @Deprecated

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -20,6 +20,7 @@ import java.awt.geom.AffineTransform;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.MathTransform;
+import org.apache.sis.internal.system.Semaphores;
 
 // Branch-dependent imports
 import org.apache.sis.internal.jdk7.Objects;
@@ -111,12 +112,35 @@ public final class ParameterizedAffine e
     /**
      * Returns the parameter values for this map projection.
      *
+     * <p><b>Hack:</b> this method normally returns the matrix parameters in case of doubt. However if
+     * {@link Semaphores#PROJCS} is set, then this method returns the map projection parameters even
+     * if they are not a complete description of this math transform. This internal hack shall be used
+     * only by {@link org.apache.sis.referencing.operation.DefaultSingleOperation}.</p>
+     *
+     * <p><b>Use case of above hack:</b> consider an "Equidistant Cylindrical (Spherical)" map projection
+     * from a {@code GeographiCRS} base using (latitude, longitude) axis order. We need to concatenate an
+     * affine transform performing the axis swapping before the actual map projection. The concatenated
+     * transform is part of {@code SingleOperation}, which is itself part of {@code ProjecteCRS}.
+     * Consequently we have two conflicting needs:</p>
+     *
+     * <ul>
+     *   <li>If this method is queried from a {@code SingleOperation} instance (usually indirectly as part of a
+     *     {@code ProjectedCRS}), then we want to return the "Equidistant Cylindrical (Spherical)" map projection
+     *     parameters without bothering about axis swapping, because the later is described by the {@code Axis["…"]}
+     *     elements in the enclosing {@code ProjectedCRS} instance.</li>
+     *   <li>But if this {@code MathTransform} is formatted directly (not as a component of {@code ProjectedCRS}),
+     *     then we want to format it as a matrix, otherwise the users would have no way to see that an axis swapping
+     *     has been applied.</li>
+     * </ul>
+     *
+     * The {@code Semaphores.PROJCS} flag is SIS internal mechanism for distinguish the two above-cited cases.
+     *
      * @return The map projection parameters if they are an accurate description of this transform,
      *         or the generic affine parameters in case of doubt.
      */
     @Override
     public ParameterValueGroup getParameterValues() {
-        return isDefinitive ? parameters : super.getParameterValues();
+        return isDefinitive || Semaphores.query(Semaphores.PROJCS) ? parameters : super.getParameterValues();
     }
 
     /**
@@ -133,7 +157,8 @@ public final class ParameterizedAffine e
         if (super.equals(object)) {
             if (object instanceof ParameterizedAffine) {
                 final ParameterizedAffine that = (ParameterizedAffine) object;
-                return Objects.equals(this.parameters, that.parameters);
+                return (this.isDefinitive == that.isDefinitive) &&
+                       Objects.equals(this.parameters, that.parameters);
             }
             return true;
         }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -72,17 +72,6 @@ public final class LambertConformal2SP e
     public static final ParameterDescriptor<Double> STANDARD_PARALLEL_2;
 
     /**
-     * The operation parameter descriptor for the <cite>Scale factor</cite> (not necessarily at natural origin)
-     * parameter value. Valid values range is (0 … ∞) and default value is 1.
-     *
-     * <p>This parameter is used by {@link LambertConformal1SP} and is not formally a parameter of
-     * {@link LambertConformal2SP} projections. Nevertheless we declare it is as an optional parameter because
-     * it is sometime used in Well Known Text (WKT). However it shall be interpreted as a <cite>Scale factor at
-     * the standard parallels</cite> rather than at the natural origin.</p>
-     */
-    static final ParameterDescriptor<Double> SCALE_FACTOR;
-
-    /**
      * The operation parameter descriptor for the <cite>Easting at false origin</cite> (Ef) parameter value.
      * Valid values range is unrestricted and default value is 0 metre.
      */
@@ -149,13 +138,16 @@ public final class LambertConformal2SP e
                 .addName(Citations.GEOTIFF, "StdParallel2")
                 .addName(Citations.PROJ4,   "lat_2"));
         /*
-         * Remove the EPSG name and identifier at least for the scale factor, because its meaning does not fit well
-         * in this context. The EPSG name is "Scale factor at natural origin" while actually the scale factor applied
-         * here would rather be at the standard parallels.
+         * The scale factor is used by LambertConformal1SP and is not formally a parameter of LambertConformal2SP.
+         * Nevertheless we declare it is as an optional parameter because it is sometime used in Well Known Text,
+         * but we omit the EPSG name and identifier because its meaning does not fit well in this context.
+         * The EPSG name is "Scale factor at natural origin" while actually the scale factor applied here
+         * would rather be at the standard parallels.
          */
-        SCALE_FACTOR = createScale(builder
+        final ParameterDescriptor<Double> scaleFactor = createScale(builder
                 .addNamesAndIdentifiers(Mercator2SP.SCALE_FACTOR)
-                .setRemarks(notFormalParameter("Lambert Conic Conformal (1SP)")).setDeprecated(true));
+                .setRemarks(notFormalParameter("Lambert Conic Conformal (1SP)"))
+                .setRequired(false).setDeprecated(true));
 
         PARAMETERS = builder
             .addIdentifier(IDENTIFIER)
@@ -174,7 +166,7 @@ public final class LambertConformal2SP e
                     LONGITUDE_OF_FALSE_ORIGIN,
                     STANDARD_PARALLEL_1,
                     STANDARD_PARALLEL_2,
-                    SCALE_FACTOR,
+                    scaleFactor,           // Not formally a LambertConformal2SP parameter.
                     EASTING_AT_FALSE_ORIGIN,
                     NORTHING_AT_FALSE_ORIGIN);
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.internal.referencing.provider;
 
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.apache.sis.parameter.ParameterBuilder;
 
@@ -48,6 +49,19 @@ public final class MercatorSpherical ext
     static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
+        /*
+         * The scale factor is used by Mercator1SP and is not formally a parameter of "Mercator (Spherical)" projection.
+         * Nevertheless we declare it as an optional parameter because it was used in EPSG:7.9:3785 (the legacy "Popular
+         * Visualisation CRS / Mercator", now deprecated). But at the difference of what we did in Mercator2SP, we keep
+         * the EPSG name here since there is no "standard parallel" parameter.  So the "Scale factor at natural origin"
+         * parameter name still okay provided that the "Latitude of natural origin" parameter value stay zero (which is
+         * normally enforced by the Mercator1SP.LATITUDE_OF_ORIGIN minimum and maximum values).
+         */
+        final ParameterDescriptor<Double> scaleFactor = createScale(builder
+                .addNamesAndIdentifiers(Mercator1SP.SCALE_FACTOR)
+                .setRemarks(Mercator2SP.SCALE_FACTOR.getRemarks())
+                .setRequired(false));
+
         PARAMETERS = builder
             .addIdentifier(IDENTIFIER)
             .addDeprecatedIdentifier("9841", IDENTIFIER)
@@ -56,6 +70,7 @@ public final class MercatorSpherical ext
             .createGroupForMapProjection(
                     Mercator1SP.LATITUDE_OF_ORIGIN,
                     Mercator1SP.CENTRAL_MERIDIAN,
+                    scaleFactor,
                     FALSE_EASTING,
                     FALSE_NORTHING);
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PseudoMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PseudoMercator.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PseudoMercator.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PseudoMercator.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -44,7 +44,7 @@ public final class PseudoMercator extend
     /**
      * The group of all parameters expected by this coordinate operation.
      */
-    public static final ParameterDescriptorGroup PARAMETERS;
+    static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
         PARAMETERS = builder

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptor.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -251,33 +251,6 @@ public class DefaultParameterDescriptor<
     }
 
     /**
-     * Creates an optional or mandatory parameter. As a consequence of the merge with ISO 19115 {@code SV_Parameter},
-     * {@code DefaultParameterDescriptor} has been generalized to accept an arbitrary amount of occurrences.
-     *
-     * @param properties   The properties to be given to the identified object.
-     * @param valueClass   The class that describes the type of the parameter value.
-     * @param valueDomain  The minimum value, maximum value and unit of measurement, or {@code null} if none.
-     * @param validValues  The list of valid values, or {@code null} if there is no restriction.
-     *                     This property is mostly for restricting values to a {@linkplain CodeList code list}
-     *                     or enumeration subset. It is not necessary to provide this property when all values
-     *                     from the code list or enumeration are valid.
-     * @param defaultValue The default value for the parameter, or {@code null} if none.
-     * @param required     {@code true} if this parameter is mandatory, or {@code false} if it is optional.
-     *
-     * @deprecated Replaced by the constructor with explicit minimum and maximum number of occurrences.
-     */
-    @Deprecated
-    public DefaultParameterDescriptor(final Map<String,?> properties,
-                                      final Class<T>      valueClass,
-                                      final Range<?>      valueDomain,
-                                      final T[]           validValues,
-                                      final T             defaultValue,
-                                      final boolean       required)
-    {
-        this(properties, required ? 1 : 0, 1, valueClass, valueDomain, validValues, defaultValue);
-    }
-
-    /**
      * Creates a new descriptor with the same values than the specified one.
      * This copy constructor provides a way to convert an arbitrary implementation into a SIS one or a
      * user-defined one (as a subclass), usually in order to leverage some implementation-specific API.

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -52,7 +52,7 @@ import static org.apache.sis.util.Utilit
  *
  * {@preformat java
  *     public class Mercator {
- *         public static final ParameterDescriptorGroup PARAMETERS;
+ *         static final ParameterDescriptorGroup PARAMETERS;
  *         static {
  *             ParameterBuilder builder = new ParameterBuilder();
  *             builder.setCodeSpace(Citations.EPSG, "EPSG").setRequired(true);

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCompoundCS.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -18,10 +18,10 @@ package org.apache.sis.referencing.cs;
 
 import java.util.Map;
 import java.util.List;
-import javax.measure.unit.Unit;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.cs.CoordinateSystemAxis;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.internal.util.Utilities;
 import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.util.Workaround;
 import org.apache.sis.util.iso.Types;
@@ -150,12 +150,9 @@ public class DefaultCompoundCS extends A
         for (final CoordinateSystemAxis axis : axes) {
             buffer.append(separator).append(Types.getCodeLabel(axis.getDirection()));
             separator = ", ";
-            final Unit<?> unit = axis.getUnit();
-            if (unit != null) {
-                final String symbol = unit.toString();
-                if (!symbol.isEmpty()) {
-                    buffer.append(" (").append(symbol).append(')');
-                }
+            final String symbol = Utilities.toString(axis.getUnit());
+            if (symbol != null && !symbol.isEmpty()) {
+                buffer.append(" (").append(symbol).append(')');
             }
         }
         return buffer.append('.').toString();

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -91,7 +91,6 @@ public class LambertConformal extends No
      * @param  type One of {@link #SP1}, {@link #SP2} or {@link #BELGIUM} constants.
      * @return The roles map to give to super-class constructor.
      */
-    @SuppressWarnings("fallthrough")
     private static Map<ParameterRole, ParameterDescriptor<Double>> roles(final byte type) {
         final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
                 new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.opera
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
-import java.util.EnumMap;
 import java.io.Serializable;
 import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterValue;
@@ -27,7 +26,6 @@ import org.opengis.parameter.ParameterVa
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.parameter.GeneralParameterDescriptor;
-import org.opengis.parameter.ParameterNotFoundException;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransform2D;
@@ -215,7 +213,7 @@ public abstract class NormalizedProjecti
          * <p>Unless specified otherwise, this is always mapped to a parameter named {@code "semi_major"}.
          * {@code NormalizedProjection} subclasses typically do not need to provide a value for this key.</p>
          */
-        SEMI_MAJOR(Constants.SEMI_MAJOR),
+        SEMI_MAJOR,
 
         /**
          * Maps the <cite>semi-minor axis length</cite> parameter (symbol: <var>b</var>).
@@ -224,7 +222,7 @@ public abstract class NormalizedProjecti
          * <p>Unless specified otherwise, this is always mapped to a parameter named {@code "semi_minor"}.
          * {@code NormalizedProjection} subclasses typically do not need to provide a value for this key.</p>
          */
-        SEMI_MINOR(Constants.SEMI_MINOR),
+        SEMI_MINOR,
 
         /**
          * Maps the parameter for the latitude where to compute the <cite>radius of conformal sphere</cite>
@@ -239,7 +237,7 @@ public abstract class NormalizedProjecti
          * of the Earth may be an ellipsoid rather than a sphere. In the majority of cases, this enumeration should
          * not be used.</p>
          */
-        LATITUDE_OF_CONFORMAL_SPHERE_RADIUS(null),
+        LATITUDE_OF_CONFORMAL_SPHERE_RADIUS,
 
         /**
          * Maps the <cite>central meridian</cite> parameter (symbol: λ₀).
@@ -254,7 +252,7 @@ public abstract class NormalizedProjecti
          *   <li>Longitude of projection centre</li>
          * </ul>
          */
-        CENTRAL_MERIDIAN(Constants.CENTRAL_MERIDIAN),
+        CENTRAL_MERIDIAN,
 
         /**
          * Maps the <cite>scale factor</cite> parameter (symbol: <var>k</var>₀).
@@ -267,7 +265,7 @@ public abstract class NormalizedProjecti
          *   <li>Scale factor on pseudo standard parallel</li>
          * </ul>
          */
-        SCALE_FACTOR(Constants.SCALE_FACTOR),
+        SCALE_FACTOR,
 
         /**
          * Maps the <cite>false easting</cite> parameter (symbol: <var>FE</var>).
@@ -280,7 +278,7 @@ public abstract class NormalizedProjecti
          *   <li>Easting at projection centre</li>
          * </ul>
          */
-        FALSE_EASTING(Constants.FALSE_EASTING),
+        FALSE_EASTING,
 
         /**
          * Maps the <cite>false northing</cite> parameter (symbol: <var>FN</var>).
@@ -293,62 +291,7 @@ public abstract class NormalizedProjecti
          *   <li>Northing at projection centre</li>
          * </ul>
          */
-        FALSE_NORTHING(Constants.FALSE_NORTHING);
-
-        /**
-         * The OGC name for this parameter. This is used only when inferring automatically the role map.
-         * We use the OGC name instead than the EPSG name because OGC names are identical for a wider
-         * range of projections (e.g. {@code "scale_factor"} for almost all projections).
-         */
-        private final String name;
-
-        /**
-         * Creates a new parameter role associated to the given OGC name.
-         */
-        private ParameterRole(final String name) {
-            this.name = name;
-        }
-
-        /**
-         * Provides default (<var>role</var> → <var>parameter</var>) associations for the given map projection.
-         * This is a convenience method for a typical set of parameters found in map projections.
-         * This method expects a {@code projection} argument containing descriptors for the given parameters
-         * (using OGC names):
-         *
-         * <ul>
-         *   <li>{@code "semi_major"}</li>
-         *   <li>{@code "semi_minor"}</li>
-         *   <li>{@code "central_meridian"}</li>
-         *   <li>{@code "scale_factor"}</li>
-         *   <li>{@code "false_easting"}</li>
-         *   <li>{@code "false_northing"}</li>
-         * </ul>
-         *
-         * <div class="note"><b>Note:</b>
-         * Apache SIS uses EPSG names as much as possible, but this method is an exception to this rule.
-         * In this particular case we use OGC names because they are identical for a wide range of projections.
-         * For example there is at least {@linkplain #SCALE_FACTOR three different EPSG names} for the
-         * <cite>"scale factor"</cite> parameter, which OGC defines only {@code "scale_factor"} for all of them.</div>
-         *
-         * @param  projection The map projection method for which to infer (<var>role</var> → <var>parameter</var>) associations.
-         * @return The parameters associated to most role in this enumeration.
-         * @throws ParameterNotFoundException if one of the above-cited parameters is not found in the given projection method.
-         * @throws ClassCastException if a parameter has been found but is not an instance of {@code ParameterDescriptor<Double>}.
-         */
-        public static Map<ParameterRole, ParameterDescriptor<Double>> defaultMap(final OperationMethod projection)
-                throws ParameterNotFoundException, ClassCastException
-        {
-            final ParameterDescriptorGroup parameters = projection.getParameters();
-            final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles =
-                    new EnumMap<ParameterRole, ParameterDescriptor<Double>>(ParameterRole.class);
-            for (final ParameterRole role : values()) {
-                if (role.name != null) {
-                    final GeneralParameterDescriptor p = parameters.descriptor(role.name);
-                    roles.put(role, Parameters.cast((ParameterDescriptor<?>) p, Double.class));
-                }
-            }
-            return roles;
-        }
+        FALSE_NORTHING
     }
 
     /**
@@ -414,17 +357,14 @@ public abstract class NormalizedProjecti
      * @param method     Description of the map projection parameters.
      * @param parameters The parameters of the projection to be created.
      * @param roles Parameters to look for <cite>central meridian</cite>, <cite>scale factor</cite>,
-     *        <cite>false easting</cite>, <cite>false northing</cite> and other values, or {@code null}
-     *        for the {@linkplain ParameterRole#defaultMap(OperationMethod) default associations}.
+     *        <cite>false easting</cite>, <cite>false northing</cite> and other values.
      */
     protected NormalizedProjection(final OperationMethod method, final Parameters parameters,
-            Map<ParameterRole, ? extends ParameterDescriptor<Double>> roles)
+            final Map<ParameterRole, ? extends ParameterDescriptor<Double>> roles)
     {
-        ensureNonNull("method", method);
+        ensureNonNull("method",     method);
         ensureNonNull("parameters", parameters);
-        if (roles == null) {
-            roles = ParameterRole.defaultMap(method);
-        }
+        ensureNonNull("roles",      roles);
         context = new ContextualParameters(method);
         /*
          * Note: we do not use Map.getOrDefault(K,V) below because the user could have explicitly associated

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -485,33 +485,24 @@ class ConcatenatedTransform extends Abst
         final List<Object> transforms = getPseudoSteps();
         if (transforms.size() == 1 || Semaphores.query(Semaphores.PROJCS)) {
             for (final Object candidate : transforms) {
-                if (!(candidate instanceof Parameterized)) {
-                    /*
-                     * If a step does not implement the Parameterized interface, we conservatively
-                     * handle it as if it was a non-linear step: we should return its parameters
-                     * (which are null), or return null if there is more non-linear steps.
-                     */
-                    return null;
-                }
-                if (param != null) {
-                    /*
-                     * We found more than one Parameterized step. If both steps are non-linear,
-                     * we fail (return null) because we don't know which one to choose. If both
-                     * steps are linear, we fail for the same reason   (actually the later case
-                     * should never occur, since consecutive linear transforms should have been
-                     * concatenated in a single affine transform. But we check as a safety). If
-                     * the previous step was linear and the current candidate is non-linear, we
-                     * retain the current candidate. Otherwise we discart it.
-                     */
-                    final boolean isLinear = (candidate instanceof LinearTransform);
-                    if ((param instanceof LinearTransform) == isLinear) {
+                /*
+                 * Search for non-linear parameters only, ignoring affine transforms and the matrices
+                 * computed by ContextualParameters. Note that the 'transforms' list is guaranteed to
+                 * contains at least one non-linear parameter, otherwise we would not have created a
+                 * ConcatenatedTransform instance.
+                 */
+                if (!(candidate instanceof Matrix) && !(candidate instanceof LinearTransform)) {
+                    if ((param == null) && (candidate instanceof Parameterized)) {
+                        param = (Parameterized) candidate;
+                    } else {
+                        /*
+                         * Found more than one group of non-linear parameters, or found an object
+                         * that do not declare its parameters.  In the later case, conservatively
+                         * returns 'null' because we do not know what the real parameters are.
+                         */
                         return null;
                     }
-                    if (isLinear) {
-                        continue;
-                    }
                 }
-                param = (Parameterized) candidate;
             }
         }
         return param;

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -18,6 +18,9 @@ package org.apache.sis.referencing.opera
 
 import java.util.List;
 import java.util.Arrays;
+import java.util.Map;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
 import java.io.Serializable;
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.MathTransform;
@@ -35,6 +38,7 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.referencing.WKTUtilities;
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
+import org.apache.sis.parameter.Parameters;
 import org.apache.sis.parameter.Parameterized;
 import org.apache.sis.parameter.DefaultParameterValue;
 import org.apache.sis.referencing.operation.matrix.Matrices;
@@ -127,7 +131,7 @@ import org.apache.sis.internal.jdk7.Obje
  * @see org.apache.sis.referencing.operation.projection.NormalizedProjection
  * @see AbstractMathTransform#getContextualParameters()
  */
-public class ContextualParameters extends FormattableObject implements ParameterValueGroup, Cloneable, Serializable {
+public class ContextualParameters extends Parameters implements Serializable {
     /**
      * For cross-version compatibility.
      */
@@ -369,13 +373,45 @@ public class ContextualParameters extend
     {
         if (!isFrozen) {
             isFrozen = true;
-            for (int i=0; i < values.length; i++) {
-                final ParameterValue<?> p = values[i];
+            /*
+             * Sort the parameter values in the same order than the parameter descriptor. This is not essential,
+             * but makes easier to read 'toString()' output by ensuring a consistent order for most projections.
+             * Some WKT parsers other than SIS may also require the parameter values to be listed in that specific
+             * order. We proceed by first copying all parameters in a temporary HashMap:
+             */
+            final Map<ParameterDescriptor<?>, ParameterValue<?>> parameters =
+                    new IdentityHashMap<ParameterDescriptor<?>, ParameterValue<?>>(values.length);
+            for (ParameterValue<?> p : values) {
                 if (p == null) {
-                    values = Arrays.copyOf(values, i);  // Trim extra values.
-                    break;
+                    break;  // The first null value in the array indicates the end of sequence.
+                }
+                p = DefaultParameterValue.unmodifiable(p);
+                final ParameterDescriptor<?> desc = p.getDescriptor();
+                if (parameters.put(desc, p) != null) {
+                    // Should never happen unless ParameterValue.descriptor changed (contract violation).
+                    throw new IllegalStateException(Errors.format(Errors.Keys.ElementAlreadyPresent_1, desc.getName()));
+                }
+            }
+            /*
+             * Then, copy all HashMap values back to the 'values' array in the order they are declared in the
+             * descriptor. Implementation note: the iteration termination condition uses the values array, not
+             * the descriptors list, because the former is often shorter than the later. We should never reach
+             * the end of descriptors list before the end of values array because 'descriptors' contains all
+             * 'parameters' keys. This is verified by the 'assert' below.
+             */
+            values = new ParameterValue<?>[parameters.size()];
+            assert descriptor.descriptors().containsAll(parameters.keySet());
+            final Iterator<GeneralParameterDescriptor> it = descriptor.descriptors().iterator();
+            for (int i=0; i < values.length;) {
+                /*
+                 * No need to check for it.hasNext(), since a NoSuchElementException below would be a bug in
+                 * our algorithm (or a concurrent change in the 'descriptor.descriptors()' list, which would
+                 * be a contract violation). See above 'assert'.
+                 */
+                final ParameterValue<?> p = parameters.get(it.next());
+                if (p != null) {
+                    values[i++] = p;
                 }
-                values[i] = DefaultParameterValue.unmodifiable(p);
             }
         }
         /*
@@ -419,11 +455,6 @@ public class ContextualParameters extend
         for (int i=0; i < values.length; i++) {
             ParameterValue<?> p = values[i];
             if (p == null) {
-                /*
-                 * No existing parameter instance. Create a new one if this ContextualParameter
-                 * is still modifiable.
-                 */
-                ensureModifiable();
                 p = ((ParameterDescriptor<?>) desc).createValue();
                 values[i] = p;
             } else if (p.getDescriptor() != desc) {  // Identity comparison should be okay here.
@@ -431,7 +462,17 @@ public class ContextualParameters extend
             }
             return p;   // Found or created a parameter.
         }
-        ensureModifiable();
+        /*
+         * We may reach this point if map projection construction is completed (i.e. 'completeTransform(…)' has
+         * been invoked) and the user asks for a parameter which is not one of the parameters that we retained.
+         * Returns a parameter initialized to the default value, which is the actual value (otherwise we would
+         * have stored that parameter).  Note: we do not bother making the parameter immutable for performance
+         * reason. If the user invokes a setter method on the returned parameter, he may get a false impression
+         * that this ContextualParameters is still modifiable. We presume that such scenario would be rare.
+         */
+        if (isFrozen) {
+            return ((ParameterDescriptor<?>) desc).createValue();
+        }
         /*
          * Should never reach this point. If it happen anyway, this means that the descriptor now accepts
          * more parameters than what it declared at ContextualParameteres construction time, or that some
@@ -508,12 +549,7 @@ public class ContextualParameters extend
         /*
          * Now proceed to the clone of this ContextualParameters instance.
          */
-        final ContextualParameters clone;
-        try {
-            clone = (ContextualParameters) super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError(e);    // Should never happen since we are cloneable.
-        }
+        final ContextualParameters clone = (ContextualParameters) super.clone();
         clone.values      = param;
         clone.normalize   = normalize.clone();
         clone.denormalize = denormalize.clone();
@@ -547,30 +583,20 @@ public class ContextualParameters extend
     }
 
     /**
-     * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a transform using this group of parameters.
-     *
-     * <div class="note"><b>Compatibility note:</b>
-     * {@code Param_MT} is defined in the WKT 1 specification only.
-     * If the {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2,
-     * then this method silently uses the WKT 1 convention without raising an error.</div>
-     *
-     * @return {@code "Param_MT"}.
+     * Formats the <cite>Well Known Text</cite> for the transform or the inverse of the transform
+     * that would be built from the enclosing {@code ContextualParameters}.
      */
-    @Override
-    protected String formatTo(final Formatter formatter) {
-        WKTUtilities.appendParamMT(this, formatter);
-        return "Param_MT";
-    }
+    private final class WKT extends FormattableObject implements Parameterized {
+        /**
+         * {@code true} if this proxy is for the inverse transform instead than the direct one.
+         */
+        private final boolean inverse;
 
-    /**
-     * Formats the <cite>Well Known Text</cite> for the inverse of the transform that would be built
-     * from the enclosing {@code ContextualParameters}.
-     */
-    private final class InverseWKT extends FormattableObject implements Parameterized {
         /**
          * Creates a new object to be formatted instead than the enclosing transform.
          */
-        InverseWKT() {
+        WKT(final boolean inverse) {
+            this.inverse = inverse;
         }
 
         /**
@@ -590,12 +616,24 @@ public class ContextualParameters extend
         }
 
         /**
-         * Process to the WKT formatting of the inverse transform.
+         * Formats a <cite>Well Known Text</cite> version 1 (WKT 1) element for a transform using this group of parameters.
+         *
+         * <div class="note"><b>Compatibility note:</b>
+         * {@code Param_MT} is defined in the WKT 1 specification only.
+         * If the {@linkplain Formatter#getConvention() formatter convention} is set to WKT 2,
+         * then this method silently uses the WKT 1 convention without raising an error.</div>
+         *
+         * @return {@code "Param_MT"}.
          */
         @Override
         protected String formatTo(final Formatter formatter) {
-            formatter.append(ContextualParameters.this);
-            return "Inverse_MT";
+            if (inverse) {
+                formatter.append(new WKT(false));
+                return "Inverse_MT";
+            } else {
+                WKTUtilities.appendParamMT(ContextualParameters.this, formatter);
+                return "Param_MT";
+            }
         }
     }
 
@@ -705,7 +743,7 @@ public class ContextualParameters extend
                 transforms.add(index++, before);
             }
         }
-        transforms.set(index, inverse ? new InverseWKT() : this);
+        transforms.set(index, new WKT(inverse));
         if (after == null) {
             if (hasAfter) {
                 final Object old = transforms.remove(index + 1);

Modified: sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -672,7 +672,7 @@ public class DefaultMathTransformFactory
          * "elt_0_0", "elt_0_1", etc.  The following code just forwards those parameters to the newly
          * created transform; it does not change the operation.
          */
-        if (parameterized instanceof ParameterizedAffine) {
+        if (parameterized instanceof ParameterizedAffine && !(mt instanceof ParameterizedAffine)) {
             mt = ((ParameterizedAffine) parameterized).newTransform(mt);
         }
         return mt;

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/CoordinateOperationMethodsHTML.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -23,7 +23,6 @@ import java.util.List;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.io.IOException;
-import javax.measure.unit.Unit;
 import org.opengis.util.FactoryException;
 import org.opengis.util.GenericName;
 import org.opengis.metadata.Identifier;
@@ -35,6 +34,7 @@ import org.opengis.referencing.crs.Coord
 import org.opengis.referencing.crs.GeneralDerivedCRS;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.util.Constants;
+import org.apache.sis.internal.util.Utilities;
 import org.apache.sis.measure.Range;
 import org.apache.sis.measure.Latitude;
 import org.apache.sis.measure.Longitude;
@@ -46,7 +46,6 @@ import org.apache.sis.referencing.operat
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.Characters;
 import org.apache.sis.util.Numbers;
-import org.apache.sis.util.Workaround;
 import org.apache.sis.test.HTMLGenerator;
 
 // Branch-dependent imports
@@ -481,20 +480,10 @@ public final class CoordinateOperationMe
      * Returns the string representation of the given parameter unit,
      * or an empty string (never {@code null}) if none.
      */
-    @Workaround(library="JSR-275", version="0.9.3")
     private static String getUnit(final ParameterDescriptor<?> param) {
-        final Unit<?> unit = param.getUnit();
-        if (unit != null) {
-            final String text;
-            try {
-                text = unit.toString();
-                if (!text.isEmpty()) {
-                    return text.equals("deg") ? "°" : " " + text;
-                }
-            } catch (IllegalArgumentException e) {
-                // Workaround for JSR-275 implementation bug.
-                // Do nothing, we will returns the empty string below.
-            }
+        final String unit = Utilities.toString(param.getUnit());
+        if (unit != null && !unit.isEmpty()) {
+            return " " + unit;
         }
         return "";
     }

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -22,7 +22,6 @@ import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.GeneralParameterDescriptor;
 import org.apache.sis.metadata.iso.citation.Citations;
-import org.apache.sis.internal.util.Constants;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/AbstractCRSTest.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -48,7 +48,7 @@ public final strictfp class AbstractCRST
                     new AbstractCS (singletonMap(NAME_KEY, "My strange CS"),
                     HardCodedAxes.TIME, HardCodedAxes.ALTITUDE, HardCodedAxes.GEODETIC_LATITUDE, HardCodedAxes.GEODETIC_LONGITUDE));
         expected =  new AbstractCRS(singletonMap(NAME_KEY, "My CRS"),
-                    new AbstractCS (singletonMap(NAME_KEY, "Coordinate system: East (deg), North (deg), Up (m), Future (d)."),
+                    new AbstractCS (singletonMap(NAME_KEY, "Coordinate system: East (°), North (°), Up (m), Future (d)."),
                     HardCodedAxes.GEODETIC_LONGITUDE, HardCodedAxes.GEODETIC_LATITUDE, HardCodedAxes.ALTITUDE, HardCodedAxes.TIME));
         actual   =  toTest.forConvention(AxesConvention.RIGHT_HANDED);
 

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/DefaultSphericalCSTest.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -43,7 +43,7 @@ public final strictfp class DefaultSpher
         final AbstractCS normalized = SPHERICAL.forConvention(AxesConvention.CONVENTIONALLY_ORIENTED);
         assertNotSame(SPHERICAL, normalized);
         assertEquals(new DefaultSphericalCS(
-            Collections.singletonMap(AbstractCS.NAME_KEY, "Spherical CS: East (deg), North (deg), Up (m)."),
+            Collections.singletonMap(AbstractCS.NAME_KEY, "Spherical CS: East (°), North (°), Up (m)."),
             HardCodedAxes.SPHERICAL_LONGITUDE,
             HardCodedAxes.SPHERICAL_LATITUDE,
             HardCodedAxes.GEOCENTRIC_RADIUS

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/ContextualParametersTest.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -112,15 +112,16 @@ public final strictfp class ContextualPa
     @Test
     public void testSameTransform() throws FactoryException {
         final ContextualParameters p = create(1, 1);
+        p.parameter("Mandatory 1").setValue(4);
         final MathTransform kernel = MathTransforms.linear(3, 4);
         assertEquals(kernel, p.completeTransform(DefaultMathTransformFactoryTest.factory(), kernel));
         try {
-            p.parameter("Mandatory 1");
+            p.parameter("Mandatory 1").setValue(10);
             fail("Shall not be allowed to modify an immutable instance.");
-        } catch (IllegalStateException e) {
+        } catch (UnsupportedOperationException e) {
             // This is the expected exception.
             final String message = e.getMessage();
-            assertTrue(message, message.contains("ContextualParameters"));
+            assertTrue(message, message.contains("ParameterValue"));
         }
     }
 

Modified: sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-referencing/src/test/java/org/apache/sis/test/HTMLGenerator.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -24,6 +24,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.BufferedWriter;
 import java.io.OutputStreamWriter;
+import java.io.Closeable;
 import org.opengis.util.InternationalString;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Deprecable;
@@ -41,7 +42,7 @@ import org.apache.sis.util.Deprecable;
  * @version 0.6
  * @module
  */
-public abstract class HTMLGenerator implements java.io.Closeable {
+public abstract class HTMLGenerator implements Closeable {
     /**
      * The encoding of the files to generate.
      */

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/UnitAdapter.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -19,6 +19,7 @@ package org.apache.sis.internal.jaxb.gco
 import javax.measure.unit.Unit;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.util.Utilities;
 
 
 /**
@@ -54,7 +55,7 @@ public class UnitAdapter extends XmlAdap
      */
     @Override
     public String marshal(final Unit<?> value) {
-        return (value != null) ? value.toString() : null;
+        return Utilities.toString(value);
     }
 
     /**

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -59,7 +59,7 @@ public final class DefaultFactories exte
 
     /**
      * Return the default factory implementing the given interface.
-     * This method returns only Apache SIS implementation of factories, and ignore all other.
+     * This method gives preference to Apache SIS implementation of factories if present.
      * This is a temporary mechanism while we are waiting for a real dependency injection mechanism.
      *
      * @param  <T>  The interface type.
@@ -69,6 +69,7 @@ public final class DefaultFactories exte
     public static synchronized <T> T forClass(final Class<T> type) {
         T factory = type.cast(FACTORIES.get(type));
         if (factory == null && !FACTORIES.containsKey(type)) {
+            T fallback = null;
             for (final T candidate : ServiceLoader.load(type)) {
                 final Class<?> ct = candidate.getClass();
                 if (ct.getName().startsWith("org.apache.sis.")) {
@@ -76,9 +77,13 @@ public final class DefaultFactories exte
                         throw new ServiceConfigurationError("Found two implementations of " + type);
                     }
                     factory = candidate;
-                    break;
+                } else if (fallback == null) {
+                    fallback = candidate;
                 }
             }
+            if (factory == null) {
+                factory = fallback;
+            }
             FACTORIES.put(type, factory);
         }
         return factory;

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/util/Utilities.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -18,9 +18,11 @@ package org.apache.sis.internal.util;
 
 import java.util.Formatter;
 import java.util.FormattableFlags;
+import javax.measure.unit.Unit;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Classes;
 import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.Workaround;
 
 
 /**
@@ -28,7 +30,7 @@ import org.apache.sis.util.CharSequences
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.4
+ * @version 0.6
  * @module
  */
 public final class Utilities extends Static {
@@ -39,6 +41,31 @@ public final class Utilities extends Sta
     }
 
     /**
+     * Returns the string representation of the given unit, or {@code null} if none.
+     * This method is used as a workaround for a bug in JSR-275, which sometime throws
+     * an exception in the {@link Unit#toString()} method.
+     *
+     * @param  unit The unit for which to get a string representation, or {@code null}.
+     * @return The string representation of the given string (may be an empty string), or {@code null}.
+     *
+     * @since 0.6
+     */
+    @Workaround(library="JSR-275", version="0.9.3")
+    public static String toString(final Unit<?> unit) {
+        if (unit != null) try {
+            String text = unit.toString();
+            if (text.equals("deg")) {
+                text = "°";
+            }
+            return text;
+        } catch (IllegalArgumentException e) {
+            // Workaround for JSR-275 implementation bug.
+            // Do nothing, we will return null below.
+        }
+        return null;
+    }
+
+    /**
      * Appends to the given buffer only the characters that are valid for a Unicode identifier.
      * The given separator character is append before the given {@code text} only if the buffer
      * is not empty and at least one {@code text} character is valid.

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -922,61 +922,6 @@ search:     for (; fromIndex <= toIndex;
     }
 
     /**
-     * Formats the given elements as a (typically) comma-separated list. This method is similar to
-     * {@link java.util.AbstractCollection#toString()} or {@link java.util.Arrays#toString(Object[])}
-     * except for the following:
-     *
-     * <ul>
-     *   <li>There is no leading {@code '['} or trailing {@code ']'} characters.</li>
-     *   <li>Null elements are ignored instead than formatted as {@code "null"}.</li>
-     *   <li>If the {@code collection} argument is null or contains only null elements,
-     *       then this method returns {@code null}.</li>
-     *   <li>In the common case where the collection contains a single {@link String} element,
-     *       that string is returned directly (no object duplication).</li>
-     * </ul>
-     *
-     * @param  collection The elements to format in a (typically) comma-separated list, or {@code null}.
-     * @param  separator  The element separator, which is usually {@code ", "}.
-     * @return The (typically) comma-separated list, or {@code null} if the given {@code collection}
-     *         was null or contains only null elements.
-     *
-     * @see java.util.StringJoiner
-     * @see java.util.Arrays#toString(Object[])
-     *
-     * @deprecated As of JDK8, use {@code java.util.StringJoiner} instead.
-     */
-    @Deprecated
-    public static String toString(final Iterable<?> collection, final String separator) {
-        ArgumentChecks.ensureNonNull("separator", separator);
-        String list = null;
-        if (collection != null) {
-            StringBuilder buffer = null;
-            for (final Object element : collection) {
-                if (element != null) {
-                    if (list == null) {
-                        list = element.toString();
-                    } else {
-                        if (buffer == null) {
-                            buffer = new StringBuilder(list);
-                        }
-                        buffer.append(separator);
-                        if (element instanceof CharSequence) {
-                            // StringBuilder has numerous optimizations for this case.
-                            buffer.append((CharSequence) element);
-                        } else {
-                            buffer.append(element);
-                        }
-                    }
-                }
-            }
-            if (buffer != null) {
-                list = buffer.toString();
-            }
-        }
-        return list;
-    }
-
-    /**
      * Replaces some Unicode characters by ASCII characters on a "best effort basis".
      * For example the {@code 'é'} character is replaced by {@code 'e'} (without accent).
      *

Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -30,11 +30,8 @@ import java.lang.reflect.InvocationTarge
 import java.lang.reflect.UndeclaredThrowableException;
 import org.opengis.annotation.UML;
 import org.opengis.util.CodeList;
-import org.opengis.util.NameFactory;
-import org.opengis.util.GenericName;
 import org.opengis.util.InternationalString;
 import org.opengis.util.Enumerated;
-import org.opengis.metadata.Identifier;
 import org.apache.sis.util.Static;
 import org.apache.sis.util.Locales;
 import org.apache.sis.util.CharSequences;
@@ -42,7 +39,6 @@ import org.apache.sis.util.ArgumentCheck
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.collection.BackingStoreException;
-import org.apache.sis.internal.system.DefaultFactories;
 
 
 /**
@@ -754,41 +750,4 @@ public final class Types extends Static
         }
         return copy;
     }
-
-    /**
-     * Converts the given value to an array of generic names. If the given value is an instance of
-     * {@link GenericName}, {@link String} or any other type enumerated below, then it is converted
-     * and returned in an array of length 1. If the given value is an array or a collection, then an
-     * array of same length is returned where each element has been converted.
-     *
-     * <p>Allowed types or element types are:</p>
-     * <ul>
-     *   <li>{@link GenericName}, to be casted and returned as-is.</li>
-     *   <li>{@link CharSequence} (usually a {@link String} or an {@link InternationalString}),
-     *       to be parsed as a generic name using the {@link DefaultNameSpace#DEFAULT_SEPARATOR ':'} separator.</li>
-     *   <li>{@link Identifier}, its {@linkplain Identifier#getCode() code} to be parsed as a generic name
-     *       using the {@link DefaultNameSpace#DEFAULT_SEPARATOR ':'} separator.</li>
-     * </ul>
-     *
-     * If {@code value} is an array or a collection containing {@code null} elements,
-     * then the corresponding element in the returned array will also be {@code null}.
-     *
-     * @param  value The object to cast into an array of generic names, or {@code null}.
-     * @param  factory The factory to use for creating names, or {@code null} for the default.
-     * @return The generic names, or {@code null} if the given {@code value} was null.
-     *         Note that it may be the {@code value} reference itself casted to {@code GenericName[]}.
-     * @throws ClassCastException if {@code value} can't be casted.
-     *
-     * @deprecated Moved to {@link DefaultNameFactory#toGenericNames(Object)}.
-     */
-    @Deprecated
-    public static GenericName[] toGenericNames(Object value, NameFactory factory) throws ClassCastException {
-        if (value == null) {
-            return null;
-        }
-        if (!(factory instanceof DefaultNameFactory)) {
-            factory = DefaultFactories.forBuildin(NameFactory.class);
-        }
-       return ((DefaultNameFactory) factory).toGenericNames(value);
-    }
 }

Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1675090&r1=1675089&r2=1675090&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java [UTF-8] Tue Apr 21 11:07:32 2015
@@ -232,17 +232,6 @@ public final strictfp class CharSequence
     }
 
     /**
-     * Tests the {@link CharSequences#toString(Iterable, String)} method.
-     */
-    @Test
-    @SuppressWarnings("deprecation")
-    public void testToString() {
-        assertEquals("4, 8, 12, 9", CharSequences.toString(Arrays.asList(4, 8, 12, 9), ", "));
-        assertSame  ("singleton",   CharSequences.toString(Arrays.asList("singleton"), ", "));
-        assertNull  (               CharSequences.toString(null, ", "));
-    }
-
-    /**
      * Tests the {@link CharSequences#toASCII(CharSequence)} method.
      */
     @Test



Mime
View raw message