sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1671213 [2/2] - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ sis-referencing/src/main/java/org/apache/sis/parameter/ sis-referencing/src/main/java/org/apache/sis/referencing/operat...
Date Fri, 03 Apr 2015 23:01:16 GMT
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
[UTF-8] Fri Apr  3 23:01:15 2015
@@ -17,30 +17,31 @@
 package org.apache.sis.referencing.operation.projection;
 
 import org.opengis.util.FactoryException;
-import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.referencing.provider.AbstractMercator;
+import org.apache.sis.internal.referencing.provider.Mercator1SP;
 import org.apache.sis.internal.referencing.provider.Mercator2SP;
-import org.apache.sis.internal.referencing.provider.PseudoMercator;
+import org.apache.sis.internal.referencing.provider.MercatorSpherical;
+import org.apache.sis.internal.referencing.provider.RegionalMercator;
 import org.apache.sis.internal.referencing.provider.MillerCylindrical;
-import org.apache.sis.internal.referencing.Formulas;
+import org.apache.sis.internal.referencing.provider.PseudoMercator;
 import org.apache.sis.internal.util.DoubleDouble;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
 import org.apache.sis.referencing.operation.matrix.Matrix2;
-import org.apache.sis.referencing.IdentifiedObjects;
 import org.apache.sis.parameter.Parameters;
-import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.Workaround;
 
 import static java.lang.Math.*;
 import static java.lang.Double.*;
 
 
 /**
- * <cite>Mercator Cylindrical</cite> projection (EPSG codes 9804, 9805, 1026,
1024, <span class="deprecated">9841</span>).
+ * <cite>Mercator Cylindrical</cite> projection (EPSG codes 9804, 9805, 1026,
1024, 1044, <span class="deprecated">9841</span>).
  * See the <a href="http://mathworld.wolfram.com/MercatorProjection.html">Mercator
projection on MathWorld</a> for an overview.
  *
  * <div class="section">Description</div>
@@ -80,19 +81,28 @@ public class Mercator extends Normalized
     private static final long serialVersionUID = 2564172914329253286L;
 
     /**
-     * Same parameter than {@link Mercator2SP#STANDARD_PARALLEL}, but declared as optional
-     * for allowing this class to process <cite>"Mercator (variant A)"</cite>
parameters.
-     */
-    private static final ParameterDescriptor<Double> STANDARD_PARALLEL = makeOptional(Mercator2SP.STANDARD_PARALLEL);
-
-    /**
-     * Codes for special kinds of Mercator projection.
+     * Codes for special kinds of Mercator projection. We do not provide such codes in public
API because
+     * they duplicate the functionality of {@link OperationMethod} instances. We use them
only for convenience.
+     *
+     * <p><b>CONVENTION:</b> Spherical cases must be odd, all other cases
must be even. This allow us to perform
+     * quick checks for all spherical cases using {@code if ((type & SPHERICAL) != 0)}.</p>
      */
-    static final byte PSEUDO = 1, MILLER = 2;
+    static final byte SPHERICAL = 1, PSEUDO = 3,    // Must be odd and SPHERICAL must be
1.
+                      REGIONAL  = 2, MILLER = 4;    // Must be even.
 
     /**
-     * 0 if this projection is a standard Mercator, {@link #PSEUDO} if this projection is
the "Pseudo Mercator" case.
+     * The type of Mercator projection. Possible values are:
+     * <ul>
+     *   <li>0                  if this projection is a Mercator variant A or B.</li>
+     *   <li>{@link #REGIONAL}  if this projection is the "Mercator (variant C)" case.</li>
+     *   <li>{@link #SPHERICAL} if this projection is the "Mercator (Spherical)" case.</li>
+     *   <li>{@link #PSEUDO}    if this projection is the "Pseudo Mercator" case.</li>
+     *   <li>{@link #MILLER}    if this projection is the "Miller Cylindrical" case.</li>
+     * </ul>
+     *
      * Other cases may be added in the future.
+     *
+     * @see #getType(ParameterDescriptorGroup)
      */
     final byte type;
 
@@ -103,6 +113,8 @@ public class Mercator extends Normalized
      * <ul>
      *   <li><cite>"Mercator (variant A)"</cite>, also known as <cite>"Mercator
(1SP)"</cite>.</li>
      *   <li><cite>"Mercator (variant B)"</cite>, also known as <cite>"Mercator
(2SP)"</cite>.</li>
+     *   <li><cite>"Mercator (variant C)"</cite>.</li>
+     *   <li><cite>"Mercator (Spherical)"</cite>.</li>
      *   <li><cite>"Popular Visualisation Pseudo Mercator"</cite>.</li>
      *   <li><cite>"Miller Cylindrical"</cite>.</li>
      * </ul>
@@ -111,20 +123,46 @@ public class Mercator extends Normalized
      * @param parameters The parameter values of the projection to create.
      */
     public Mercator(final OperationMethod method, final Parameters parameters) {
-        super(method, parameters, Mercator2SP.FALSE_EASTING, Mercator2SP.FALSE_NORTHING);
-        double φ1 = toRadians(getAndStore(parameters, STANDARD_PARALLEL));
-        double φ0 = parameters.doubleValue(Mercator2SP.LATITUDE_OF_ORIGIN);
-        double λ0 = getAndStore(parameters, Mercator2SP.CENTRAL_MERIDIAN);
-        double k0 = getAndStore(parameters, Mercator2SP.SCALE_FACTOR);
+        this(method, parameters, getType(parameters.getDescriptor()));
+    }
+
+    /**
+     * Work around for RFE #4093999 in Sun's bug database
+     * ("Relax constraint on placement of this()/super() call in constructors").
+     */
+    @Workaround(library="JDK", version="1.7")
+    private Mercator(final OperationMethod method, final Parameters parameters, final byte
type) {
+        super(method, parameters,
+                (type == REGIONAL) ? RegionalMercator .EASTING_AT_FALSE_ORIGIN : AbstractMercator.FALSE_EASTING,
+                (type == REGIONAL) ? RegionalMercator.NORTHING_AT_FALSE_ORIGIN : AbstractMercator.FALSE_NORTHING);
+        this.type = type;
         /*
-         * The "Latitude of origin" is not formally a parameter of Mercator projection, except
in variant A (1SP)
-         * where the parameter is included in the EPSG dataset for completeness in CRS labelling
but is not allowed
-         * to be assigned any value other than zero.
-         */
-        if (!(abs(φ0) <= Formulas.ANGULAR_TOLERANCE)) {   // Use '!' for catching NaN.
-            throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalParameterValue_2,
-                    Mercator2SP.LATITUDE_OF_ORIGIN.getName(), φ0));
-        }
+         * The "Longitude of natural origin" parameter is found in all Mercator projections
and is mandatory.
+         * Since this is usually the Greenwich meridian, the default value is 0°. We keep
the value in degrees
+         * for now; it will be converted to radians later.
+         */
+        double λ0 = getAndStore(parameters, Mercator1SP.CENTRAL_MERIDIAN);
+        /*
+         * The "Latitude of natural origin" is not formally a parameter of Mercator projection.
But the parameter
+         * is included for completeness in CRS labelling, with the restriction (specified
in EPSG documentation)
+         * that the value must be zero. The EPSG dataset provides this parameter for "Mercator
variant A" (1SP),
+         * but Apache SIS accepts it also for other projections because we found some Well
Known Text (WKT) strings
+         * containing it.
+         *
+         * According EPSG documentation, the only exception to the above paragraph is "Mercator
variant C", where
+         * the parameter is named "Latitude of false origin" and can have any value. While
strictly speaking the
+         * "Latitude of origin" can not have a non-zero value, if it still have non-zero
value we will process as
+         * for "Latitude of false origin".
+         */
+        double φ0 = toRadians(getAndStore(parameters, (type == REGIONAL)
+                ? RegionalMercator.LATITUDE_OF_FALSE_ORIGIN : Mercator1SP.LATITUDE_OF_ORIGIN));
+        /*
+         * In theory, the "Latitude of 1st standard parallel" and the "Scale factor at natural
origin" parameters
+         * are mutually exclusive. The former is for projections of category "2SP" (namely
variant B and C) while
+         * the later is for projections "1SP" (namely variant A and spherical).
+         */
+        double φ1 = toRadians(getAndStore(parameters, Mercator2SP.STANDARD_PARALLEL));
+        double k0 = getAndStore(parameters, Mercator1SP.SCALE_FACTOR);
         /*
          * A correction that allows us to employ a standard parallel that is not correspondent
to the equator,
          * as described in Snyder and al. at page 47. This is the same correction factor
than the one applied
@@ -135,9 +173,10 @@ public class Mercator extends Normalized
          * should never have both the scale factor and a standard parallel. Nevertheless
we sometime see such
          * CRS definitions.
          */
-        k0 *= cos(φ1);
-        if (!isSpherical()) {
-            k0 /= rν(sin(φ1));
+        switch (type) {
+            case PSEUDO:    /* Do nothing since a is taken as the radius. */ break;
+            case SPHERICAL: k0 *= radiusOfConformalSphere(sin(φ1));          break;
+            default:        k0 *= cos(φ1) / rν(sin(φ1));                     break;
         }
         /*
          * In principle we should rotate the central meridian (λ0) in the normalization
transform, as below:
@@ -158,15 +197,12 @@ public class Mercator extends Normalized
             offset.multiply(-λ0);
             denormalize.concatenate(0, null, offset);
         }
-        final ParameterDescriptorGroup descriptor = parameters.getDescriptor();
-        if (IdentifiedObjects.isHeuristicMatchForName(descriptor, MillerCylindrical.NAME))
{
+        if (φ0 != 0) {
+            denormalize.concatenate(0, null, new DoubleDouble(-log(expOfNorthing(φ0, excentricity
* sin(φ0)))));
+        }
+        if (type == MILLER) {
             normalize  .concatenate(1, new DoubleDouble(0.8),  null);
             denormalize.concatenate(1, new DoubleDouble(1.25), null);
-            type = MILLER;
-        } else if (IdentifiedObjects.isHeuristicMatchForName(descriptor, PseudoMercator.NAME))
{
-            type = PSEUDO;
-        } else {
-            type = 0;
         }
     }
 
@@ -179,6 +215,17 @@ public class Mercator extends Normalized
     }
 
     /**
+     * Returns the type of the projection based on the name and identifier of the given parameter
group.
+     */
+    private static byte getType(final ParameterDescriptorGroup parameters) {
+        if (identMatch(parameters, RegionalMercator .NAME, RegionalMercator .IDENTIFIER))
return REGIONAL;
+        if (identMatch(parameters, MercatorSpherical.NAME, MercatorSpherical.IDENTIFIER))
return SPHERICAL;
+        if (identMatch(parameters, PseudoMercator   .NAME, PseudoMercator   .IDENTIFIER))
return PSEUDO;
+        if (identMatch(parameters, MillerCylindrical.NAME, null))                       
 return MILLER;
+        return 0;
+    }
+
+    /**
      * Returns the sequence of <cite>normalization</cite> → {@code this} →
<cite>denormalization</cite> transforms
      * as a whole. The transform returned by this method except (<var>longitude</var>,
<var>latitude</var>)
      * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>)
coordinates in <em>metres</em>.
@@ -194,7 +241,7 @@ public class Mercator extends Normalized
     @Override
     public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException
{
         Mercator kernel = this;
-        if (isSpherical() || type == PSEUDO) {
+        if (isSpherical() || (type & SPHERICAL) != 0) {
             kernel = new Spherical(this);
         }
         return context.completeTransform(factory, kernel);
@@ -335,7 +382,7 @@ public class Mercator extends Normalized
          */
         Spherical(final Mercator other) {
             super(other);
-            if (type != PSEUDO) {
+            if ((type & SPHERICAL) == 0) {
                 ensureSpherical();
             }
         }
@@ -374,8 +421,9 @@ public class Mercator extends Normalized
             /*
              * Following part is common to all spherical projections: verify, store and return.
              */
-            assert (type == PSEUDO) || (Assertions.checkDerivative(derivative, super.transform(srcPts,
srcOff, dstPts, dstOff, derivate))
-                    && Assertions.checkTransform(dstPts, dstOff, λ, y)); // dstPts
= result from ellipsoidal formulas.
+            assert ((type & SPHERICAL) != 0)
+                   || (Assertions.checkDerivative(derivative, super.transform(srcPts, srcOff,
dstPts, dstOff, derivate))
+                   && Assertions.checkTransform(dstPts, dstOff, λ, y)); // dstPts
= result from ellipsoidal formulas.
             if (dstPts != null) {
                 dstPts[dstOff  ] = λ;
                 dstPts[dstOff+1] = y;
@@ -427,7 +475,7 @@ public class Mercator extends Normalized
             double x = srcPts[srcOff  ];
             double y = srcPts[srcOff+1];
             y = PI/2 - 2 * atan(exp(-y));     // Part of Snyder (7-4)
-            assert (type == PSEUDO) || checkInverseTransform(srcPts, srcOff, dstPts, dstOff,
x, y);
+            assert ((type & SPHERICAL) != 0) || checkInverseTransform(srcPts, srcOff,
dstPts, dstOff, x, y);
             dstPts[dstOff  ] = x;
             dstPts[dstOff+1] = y;
         }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
[UTF-8] Fri Apr  3 23:01:15 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.opera
 import java.util.List;
 import java.util.ArrayList;
 import java.io.Serializable;
+import org.opengis.metadata.Identifier;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
@@ -242,6 +243,26 @@ public abstract class NormalizedProjecti
     }
 
     /**
+     * Returns {@code true} if the projection specified by the given parameters has the given
name or identifier.
+     * If non-null, the given identifier is presumed in the EPSG namespace and has precedence
over the name.
+     *
+     * @param  parameters The user-specified parameters.
+     * @param  name       The name to compare against the parameter group name.
+     * @param  identifier The identifier to compare against the parameter group name.
+     * @return {@code true} if the given parameter group has a name or EPSG identifier matching
the given ones.
+     */
+    static boolean identMatch(final ParameterDescriptorGroup parameters, final String name,
final String identifier) {
+        if (identifier != null) {
+            for (final Identifier id : parameters.getIdentifiers()) {
+                if (identifier.equals(id.getCode()) && Constants.EPSG.equals(id.getCodeSpace()))
{
+                    return true;
+                }
+            }
+        }
+        return IdentifiedObjects.isHeuristicMatchForName(parameters, name);
+    }
+
+    /**
      * Returns a parameter descriptor with the same properties than the given one, except
that the parameter is
      * optional. This is sometime needed when invoking {@link #getAndStore(Parameters, ParameterDescriptor)}
for
      * a parameter value which is mandatory in principle, but may be absent because the parameters
for the same
@@ -627,6 +648,21 @@ public abstract class NormalizedProjecti
     }
 
     /**
+     * Computes the radius of conformal sphere (Rc) at latitude φ. This is used when the
user requested
+     * explicitely spherical formulas for example with <cite>"Mercator (Spherical)"</cite>
projection
+     * (EPSG:1026), but the figure of the Earth used is an ellipsoid rather than a sphere.
+     *
+     * <p><b>Source:</b> <cite>Geomatics Guidance Note Number 7,
part 2, version 49</cite> from EPSG:
+     * table 3 in section 1.2 and explanation in section 1.3.3.1.</p>
+     *
+     * @param  sinφ The sine of the φ latitude in radians.
+     * @return Radius of conformal sphere at latitude φ.
+     */
+    final double radiusOfConformalSphere(final double sinφ) {
+        return sqrt(1 - excentricitySquared) / (1 - excentricitySquared * (sinφ*sinφ));
+    }
+
+    /**
      * Computes part of the Mercator projection for the given latitude. This formula is also
part of
      * Lambert Conic Conformal projection, since Mercator can be considered as a special
case of that
      * Lambert projection with the equator as the single standard parallel.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
[UTF-8] Fri Apr  3 23:01:15 2015
@@ -3,7 +3,9 @@
 org.apache.sis.internal.referencing.provider.Affine
 org.apache.sis.internal.referencing.provider.LongitudeRotation
 org.apache.sis.internal.referencing.provider.EquidistantCylindrical
-org.apache.sis.internal.referencing.provider.Mercator2SP
 org.apache.sis.internal.referencing.provider.Mercator1SP
+org.apache.sis.internal.referencing.provider.Mercator2SP
+org.apache.sis.internal.referencing.provider.MercatorSpherical
 org.apache.sis.internal.referencing.provider.PseudoMercator
+org.apache.sis.internal.referencing.provider.RegionalMercator
 org.apache.sis.internal.referencing.provider.MillerCylindrical

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/AllProvidersTest.java
[UTF-8] Fri Apr  3 23:01:15 2015
@@ -53,9 +53,11 @@ public final strictfp class AllProviders
             Affine.class,
             LongitudeRotation.class,
             EquidistantCylindrical.class,
-            Mercator2SP.class,
             Mercator1SP.class,
+            Mercator2SP.class,
+            MercatorSpherical.class,
             PseudoMercator.class,
+            RegionalMercator.class,
             MillerCylindrical.class
         };
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] Fri Apr  3 23:01:15 2015
@@ -16,16 +16,20 @@
  */
 package org.apache.sis.internal.referencing.provider;
 
+import java.util.Iterator;
 import org.opengis.util.GenericName;
 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.ReferencingAssert;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
+import static org.apache.sis.internal.util.Constants.SEMI_MAJOR;
+import static org.apache.sis.internal.util.Constants.SEMI_MINOR;
 
 
 /**
@@ -42,77 +46,81 @@ public final strictfp class MapProjectio
      */
     @Test
     public void testSemiAxes() {
-        assertOgcNameEquals(Constants.SEMI_MAJOR, MapProjection.SEMI_MAJOR);
-        assertOgcNameEquals(Constants.SEMI_MINOR, MapProjection.SEMI_MINOR);
+        assertParamEquals(null, SEMI_MAJOR, true, MapProjection.SEMI_MAJOR);
+        assertParamEquals(null, SEMI_MINOR, true, MapProjection.SEMI_MINOR);
     }
 
     /**
      * Verifies some {@link Mercator1SP} parameter descriptors.
      */
     @Test
+    @DependsOnMethod("testSemiAxes")
     public void testMercator1SP() {
-        assertEpsgNameEquals("Mercator (variant A)",           Mercator1SP.PARAMETERS);
-        assertEpsgNameEquals("Latitude of natural origin",     Mercator1SP.LATITUDE_OF_ORIGIN);
-        assertEpsgNameEquals("Longitude of natural origin",    Mercator1SP.CENTRAL_MERIDIAN);
-        assertEpsgNameEquals("Scale factor at natural origin", Mercator1SP.SCALE_FACTOR);
-        assertEpsgNameEquals("False easting",                  Mercator1SP.FALSE_EASTING);
-        assertEpsgNameEquals("False northing",                 Mercator1SP.FALSE_NORTHING);
-
-        assertOgcAliasEquals("Mercator_1SP",       Mercator1SP.PARAMETERS);
-        assertOgcAliasEquals("latitude_of_origin", Mercator1SP.LATITUDE_OF_ORIGIN);
-        assertOgcAliasEquals("central_meridian",   Mercator1SP.CENTRAL_MERIDIAN);
-        assertOgcAliasEquals("scale_factor",       Mercator1SP.SCALE_FACTOR);
-        assertOgcAliasEquals("false_easting",      Mercator1SP.FALSE_EASTING);
-        assertOgcAliasEquals("false_northing",     Mercator1SP.FALSE_NORTHING);
+        final Iterator<GeneralParameterDescriptor> it = Mercator1SP.PARAMETERS.descriptors().iterator();
+        assertParamEquals("Mercator (variant A)",           "Mercator_1SP",       true, Mercator1SP.PARAMETERS);
+        assertParamEquals(null,                              SEMI_MAJOR,          true, it.next());
+        assertParamEquals(null,                              SEMI_MINOR,          true, it.next());
+        assertParamEquals("Latitude of natural origin",     "latitude_of_origin", true, it.next());
+        assertParamEquals("Longitude of natural origin",    "central_meridian",   true, it.next());
+        assertParamEquals("Scale factor at natural origin", "scale_factor",       true, it.next());
+        assertParamEquals("False easting",                  "false_easting",      true, it.next());
+        assertParamEquals("False northing",                 "false_northing",     true, it.next());
+        assertFalse(it.hasNext());
+        assertIsForcedToZero((ParameterDescriptor<?>) Mercator1SP.PARAMETERS.descriptor("latitude_of_origin"));
     }
 
     /**
      * Verifies some {@link Mercator2SP} parameter descriptors.
      */
     @Test
+    @DependsOnMethod("testSemiAxes")
     public void testMercator2SP() {
-        assertEpsgNameEquals("Mercator (variant B)",              Mercator2SP.PARAMETERS);
-        assertEpsgNameEquals("Latitude of 1st standard parallel", Mercator2SP.STANDARD_PARALLEL);
-        assertEpsgNameEquals("Latitude of natural origin",        Mercator2SP.LATITUDE_OF_ORIGIN);
-        assertEpsgNameEquals("Longitude of natural origin",       Mercator2SP.CENTRAL_MERIDIAN);
-        assertEpsgNameEquals("Scale factor at natural origin",    Mercator2SP.SCALE_FACTOR);
-        assertEpsgNameEquals("False easting",                     Mercator2SP.FALSE_EASTING);
-        assertEpsgNameEquals("False northing",                    Mercator2SP.FALSE_NORTHING);
-
-        assertOgcAliasEquals("Mercator_2SP",        Mercator2SP.PARAMETERS);
-        assertOgcAliasEquals("standard_parallel_1", Mercator2SP.STANDARD_PARALLEL);
-        assertOgcAliasEquals("latitude_of_origin",  Mercator2SP.LATITUDE_OF_ORIGIN);
-        assertOgcAliasEquals("central_meridian",    Mercator2SP.CENTRAL_MERIDIAN);
-        assertOgcAliasEquals("scale_factor",        Mercator2SP.SCALE_FACTOR);
-        assertOgcAliasEquals("false_easting",       Mercator2SP.FALSE_EASTING);
-        assertOgcAliasEquals("false_northing",      Mercator2SP.FALSE_NORTHING);
+        final Iterator<GeneralParameterDescriptor> it = Mercator2SP.PARAMETERS.descriptors().iterator();
+        assertParamEquals("Mercator (variant B)",              "Mercator_2SP",        true,
 Mercator2SP.PARAMETERS);
+        assertParamEquals(null,                                 SEMI_MAJOR,           true,
it.next());
+        assertParamEquals(null,                                 SEMI_MINOR,           true,
it.next());
+        assertParamEquals("Latitude of 1st standard parallel", "standard_parallel_1", true,
 it.next());
+        assertParamEquals("Latitude of natural origin",        "latitude_of_origin",  false,
it.next());
+        assertParamEquals("Longitude of natural origin",       "central_meridian",    true,
 it.next());
+        assertParamEquals(null,                                "scale_factor",        false,
it.next());
+        assertParamEquals("False easting",                     "false_easting",       true,
 it.next());
+        assertParamEquals("False northing",                    "false_northing",      true,
 it.next());
+        assertFalse(it.hasNext());
+        assertIsForcedToZero((ParameterDescriptor<?>) Mercator1SP.PARAMETERS.descriptor("latitude_of_origin"));
     }
 
     /**
      * Asserts that the primary name of the given parameter is the given name in the EPSG
namespace.
+     * Then asserts that the first alias (ignoring other EPSG alias) of the given parameter
is the
+     * given name in the OGC namespace.
      */
-    private static void assertEpsgNameEquals(final String expected, final GeneralParameterDescriptor
actual) {
-        ReferencingAssert.assertEpsgIdentifierEquals(expected, actual.getName());
-    }
-
-    /**
-     * Asserts that the primary name of the given parameter is the given name in the OGC
namespace.
-     */
-    private static void assertOgcNameEquals(final String expected, final GeneralParameterDescriptor
actual) {
-        ReferencingAssert.assertOgcIdentifierEquals(expected, actual.getName());
+    private static void assertParamEquals(final String epsgName, final String ogcName, final
boolean isMandatory,
+            final GeneralParameterDescriptor actual)
+    {
+        if (epsgName != null) {
+            ReferencingAssert.assertEpsgIdentifierEquals(epsgName, actual.getName());
+        } else {
+            ReferencingAssert.assertOgcIdentifierEquals(ogcName, actual.getName());
+        }
+        assertEquals("minimumOccurs", isMandatory ? 1 : 0, actual.getMinimumOccurs());
+        if (epsgName != null) {
+            for (final GenericName alias : actual.getAlias()) {
+                if (alias instanceof Identifier && ((Identifier) alias).getAuthority()
!= Citations.OGP) {
+                    ReferencingAssert.assertOgcIdentifierEquals(ogcName, (Identifier) alias);
+                    return;
+                }
+            }
+            fail("OGC alias not found.");
+        }
     }
 
     /**
-     * Asserts that the first alias (ignoring other EPSG alias)
-     * of the given parameter is the given name in the OGC namespace.
+     * Asserts the the given parameter forces its value to zero.
+     * This test is mostly for {@link AbstractMercator#LATITUDE_OF_ORIGIN}.
      */
-    private static void assertOgcAliasEquals(final String expected, final GeneralParameterDescriptor
actual) {
-        for (final GenericName alias : actual.getAlias()) {
-            if (alias instanceof Identifier && ((Identifier) alias).getAuthority()
!= Citations.OGP) {
-                ReferencingAssert.assertOgcIdentifierEquals(expected, (Identifier) alias);
-                return;
-            }
-        }
-        fail("OGC alias not found.");
+    private static void assertIsForcedToZero(final ParameterDescriptor<?> parameter)
{
+        final Double zero = Double.valueOf(0);
+        assertEquals("minimumValue", zero, parameter.getMinimumValue());
+        assertEquals("maximumValue", zero, parameter.getMaximumValue());
     }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
[UTF-8] Fri Apr  3 23:01:15 2015
@@ -104,9 +104,10 @@ public final class Messages extends Inde
         public static final short MismatchedEllipsoidAxisLength_3 = 9;
 
         /**
-         * This parameter borrowed from the “{0}” projection is not formally a “{1}”
parameter.
+         * This parameter borrowed from the “{0}” projection is not formally a parameter
of this
+         * projection.
          */
-        public static final short NotFormalProjectionParameter_2 = 10;
+        public static final short NotFormalProjectionParameter_1 = 10;
 
         /**
          * Property “{0}” is hidden by “{1}”.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
[ISO-8859-1] Fri Apr  3 23:01:15 2015
@@ -24,5 +24,5 @@ IgnoredPropertyAssociatedTo_1   = Ignore
 PropertyHiddenBy_2              = Property \u201c{0}\u201d is hidden by \u201c{1}\u201d.
 LocalesDiscarded                = Text were discarded for some locales.
 MismatchedEllipsoidAxisLength_3 = The \u201c{1}\u201d parameter could have been omitted.
But it has been given a value of {2} which does not match the definition of the \u201c{0}\u201d
ellipsoid.
-NotFormalProjectionParameter_2  = This parameter borrowed from the \u201c{0}\u201d projection
is not formally a \u201c{1}\u201d parameter.
+NotFormalProjectionParameter_1  = This parameter borrowed from the \u201c{0}\u201d projection
is not formally a parameter of this projection.
 UnparsableValueStoredAsText_2   = Can not parse \u201c{1}\u201d as an instance of \u2018{0}\u2019.
The value is stored as plain text instead, but will be ignored by some processing.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties?rev=1671213&r1=1671212&r2=1671213&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
[ISO-8859-1] Fri Apr  3 23:01:15 2015
@@ -24,5 +24,5 @@ IgnoredPropertyAssociatedTo_1   = Une pr
 PropertyHiddenBy_2              = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb est
masqu\u00e9e par \u00ab\u202f{1}\u202f\u00bb.
 LocalesDiscarded                = Des textes ont \u00e9t\u00e9 ignor\u00e9s pour certaines
langues.
 MismatchedEllipsoidAxisLength_3 = Le param\u00e8tre \u00ab\u202f{1}\u202f\u00bb aurait pu
\u00eatre omis. Mais il lui a \u00e9t\u00e9 donn\u00e9 la valeur {2} qui ne correspond pas
\u00e0 la d\u00e9finition de l\u2019ellipso\u00efde \u00ab\u202f{0}\u202f\u00bb.
-NotFormalProjectionParameter_2  = Ce param\u00e8tre emprunt\u00e9 \u00e0 la projection \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas formellement un param\u00e8tre de \u00ab\u202f{1}\u202f\u00bb.
+NotFormalProjectionParameter_1  = Ce param\u00e8tre emprunt\u00e9 \u00e0 la projection \u00ab\u202f{0}\u202f\u00bb
n\u2019est pas formellement un param\u00e8tre de cette projection.
 UnparsableValueStoredAsText_2   = La valeur \u00ab\u202f{1}\u202f\u00bb ne peut pas \u00eatre
interpr\u00e9t\u00e9e comme une instance de \u2018{0}\u2019. Elle est donc m\u00e9moris\u00e9e
sous sa forme textuelle, mais sera ignor\u00e9e par certains traitements.



Mime
View raw message