Author: desruisseaux
Date: Tue Jul 21 15:36:44 2015
New Revision: 1692154

URL: http://svn.apache.org/r1692154
Log:
Fix an ambiguity when determine the projection variant by checking the 
OperationMethod name instead than the ParameterValueGroup name.

Modified:
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
    
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java?rev=1692154&r1=1692153&r2=1692154&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/Parameters.java
 [UTF-8] Tue Jul 21 15:36:44 2015
@@ -138,6 +138,7 @@ public abstract class Parameters impleme
     }
 
     /** Wrappers used as a fallback by {@link 
Parameters#castOrWrap(ParameterValueGroup)}. */
+    @SuppressWarnings("CloneDoesntCallSuperClone")
     private static final class Wrapper extends Parameters implements 
Serializable {
         private static final long serialVersionUID = -5491790565456920471L;
         private final ParameterValueGroup delegate;
@@ -299,11 +300,9 @@ public abstract class Parameters impleme
             final Identifier group = descriptor.getName();
             if (group != null) {    // Paranoiac check (should never be null)
                 final Citation authority = group.getAuthority();
-                if (authority != null) {
-                    final String name = IdentifiedObjects.getName(source, 
group.getAuthority());
-                    if (name != null) {
-                        return name;
-                    }
+                final String name = IdentifiedObjects.getName(source, 
authority);
+                if (name != null || authority == null) {
+                    return name;
                 }
             }
         }

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java?rev=1692154&r1=1692153&r2=1692154&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
 [UTF-8] Tue Jul 21 15:36:44 2015
@@ -21,7 +21,6 @@ import java.util.EnumMap;
 import org.opengis.util.FactoryException;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
-import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.OperationMethod;
@@ -83,21 +82,21 @@ public class LambertConformal extends Co
      *
      * <p><b>CONVENTION:</b> Codes for SP1 case must be odd, and codes for SP2 
case must be even.
      *
-     * @see #getVariant(ParameterDescriptorGroup)
+     * @see #getVariant(OperationMethod)
      */
     private static final byte SP1  = 1,  WEST    = 3,                   // 
Must be odd
                               SP2  = 2,  BELGIUM = 4,  MICHIGAN = 6;    // 
Must be even
 
     /**
-     * Returns the type of the projection based on the name and identifier of 
the given parameter group.
+     * Returns the type of the projection based on the name and identifier of 
the given operation method.
      * If this method can not identify the type, then the parameters should be 
considered as a 2SP case.
      */
-    private static byte getVariant(final ParameterDescriptorGroup parameters) {
-        if (identMatch(parameters, "(?i).*\\bBelgium\\b.*",  
LambertConformalBelgium .IDENTIFIER)) return BELGIUM;
-        if (identMatch(parameters, "(?i).*\\bMichigan\\b.*", 
LambertConformalMichigan.IDENTIFIER)) return MICHIGAN;
-        if (identMatch(parameters, "(?i).*\\bWest\\b.*",     
LambertConformalWest    .IDENTIFIER)) return WEST;
-        if (identMatch(parameters, "(?i).*\\b2SP\\b.*",      
LambertConformal2SP     .IDENTIFIER)) return SP2;
-        if (identMatch(parameters, "(?i).*\\b1SP\\b.*",      
LambertConformal1SP     .IDENTIFIER)) return SP1;
+    private static byte getVariant(final OperationMethod method) {
+        if (identMatch(method, "(?i).*\\bBelgium\\b.*",  
LambertConformalBelgium .IDENTIFIER)) return BELGIUM;
+        if (identMatch(method, "(?i).*\\bMichigan\\b.*", 
LambertConformalMichigan.IDENTIFIER)) return MICHIGAN;
+        if (identMatch(method, "(?i).*\\bWest\\b.*",     LambertConformalWest  
  .IDENTIFIER)) return WEST;
+        if (identMatch(method, "(?i).*\\b2SP\\b.*",      LambertConformal2SP   
  .IDENTIFIER)) return SP2;
+        if (identMatch(method, "(?i).*\\b1SP\\b.*",      LambertConformal1SP   
  .IDENTIFIER)) return SP1;
         return 0; // Unidentified case, to be considered as 2SP.
     }
 
@@ -186,7 +185,7 @@ public class LambertConformal extends Co
      * @param parameters The parameter values of the projection to create.
      */
     public LambertConformal(final OperationMethod method, final Parameters 
parameters) {
-        this(method, parameters, getVariant(parameters.getDescriptor()));
+        this(method, parameters, getVariant(method));
     }
 
     /**

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=1692154&r1=1692153&r2=1692154&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] Tue Jul 21 15:36:44 2015
@@ -20,7 +20,6 @@ import java.util.Map;
 import java.util.EnumMap;
 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;
@@ -93,19 +92,19 @@ public class Mercator extends ConformalP
      * <p><b>CONVENTION:</b> <strong>Spherical cases must be odd, all other 
cases must be even.</strong>
      * This allow us to perform quick checks for all spherical cases using 
{@code if ((type & SPHERICAL) != 0)}.</p>
      *
-     * @see #getVariant(ParameterDescriptorGroup)
+     * @see #getVariant(OperationMethod)
      */
     private static final byte SPHERICAL = 1, PSEUDO = 3,    // Must be odd and 
SPHERICAL must be 1.
                               REGIONAL  = 2, MILLER = 4;    // Must be even.
 
     /**
-     * Returns the variant of the projection based on the name and identifier 
of the given parameter group.
+     * Returns the variant of the projection based on the name and identifier 
of the given operation method.
      */
-    private static byte getVariant(final ParameterDescriptorGroup parameters) {
-        if (identMatch(parameters, "(?i).*\\bvariant\\s*C\\b.*", 
RegionalMercator .IDENTIFIER)) return REGIONAL;
-        if (identMatch(parameters, "(?i).*\\bSpherical\\b.*",    
MercatorSpherical.IDENTIFIER)) return SPHERICAL;
-        if (identMatch(parameters, "(?i).*\\bPseudo.*",          
PseudoMercator   .IDENTIFIER)) return PSEUDO;
-        if (identMatch(parameters, "(?i).*\\bMiller.*",          null))        
                 return MILLER;
+    private static byte getVariant(final OperationMethod method) {
+        if (identMatch(method, "(?i).*\\bvariant\\s*C\\b.*", RegionalMercator 
.IDENTIFIER)) return REGIONAL;
+        if (identMatch(method, "(?i).*\\bSpherical\\b.*",    
MercatorSpherical.IDENTIFIER)) return SPHERICAL;
+        if (identMatch(method, "(?i).*\\bPseudo.*",          PseudoMercator   
.IDENTIFIER)) return PSEUDO;
+        if (identMatch(method, "(?i).*\\bMiller.*",          null))            
             return MILLER;
         return 0;
     }
 
@@ -121,7 +120,7 @@ public class Mercator extends ConformalP
      *
      * Other cases may be added in the future.
      *
-     * @see #getVariant(ParameterDescriptorGroup)
+     * @see #getVariant(OperationMethod)
      */
     private final byte variant;
 
@@ -192,7 +191,7 @@ public class Mercator extends ConformalP
      * @param parameters The parameter values of the projection to create.
      */
     public Mercator(final OperationMethod method, final Parameters parameters) 
{
-        this(method, parameters, getVariant(parameters.getDescriptor()));
+        this(method, parameters, getVariant(method));
     }
 
     /**

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=1692154&r1=1692153&r2=1692154&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] Tue Jul 21 15:36:44 2015
@@ -453,7 +453,7 @@ public abstract class NormalizedProjecti
     }
 
     /**
-     * Returns {@code true} if the projection specified by the given 
parameters has the given keyword or identifier.
+     * Returns {@code true} if the projection specified by the given method 
has the given keyword or identifier.
      * If non-null, the given identifier is presumed in the EPSG namespace and 
has precedence over the keyword.
      *
      * <div class="note"><b>Implementation note:</b>
@@ -464,19 +464,19 @@ public abstract class NormalizedProjecti
      *
      * @param  parameters The user-specified parameters.
      * @param  regex      The regular expression to use when using the 
operation name as the criterion.
-     * @param  identifier The identifier to compare against the parameter 
group name.
-     * @return {@code true} if the given parameter group name contains the 
given keyword
+     * @param  identifier The identifier to compare against the operation 
method name.
+     * @return {@code true} if the name of the given operation method contains 
the given keyword
      *         or has an EPSG identifier equals to the given identifier.
      */
-    static boolean identMatch(final ParameterDescriptorGroup parameters, final 
String regex, final String identifier) {
+    static boolean identMatch(final OperationMethod method, final String 
regex, final String identifier) {
         if (identifier != null) {
-            for (final Identifier id : parameters.getIdentifiers()) {
+            for (final Identifier id : method.getIdentifiers()) {
                 if (Constants.EPSG.equals(id.getCodeSpace())) {
                     return identifier.equals(id.getCode());
                 }
             }
         }
-        return parameters.getName().getCode().replace('_',' ').matches(regex);
+        return method.getName().getCode().replace('_',' ').matches(regex);
     }
 
     /**
@@ -501,7 +501,7 @@ public abstract class NormalizedProjecti
         final Double defaultValue = descriptor.getDefaultValue();
         if (defaultValue == null || !defaultValue.equals(value)) {
             MapProjection.validate(descriptor, value);
-            context.parameter(descriptor.getName().getCode()).setValue(value);
+            context.getOrCreate(descriptor).setValue(value);
         }
         return value;
     }

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java?rev=1692154&r1=1692153&r2=1692154&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
 [UTF-8] Tue Jul 21 15:36:44 2015
@@ -20,7 +20,6 @@ import java.util.Map;
 import java.util.EnumMap;
 import org.opengis.util.FactoryException;
 import org.opengis.parameter.ParameterDescriptor;
-import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.MathTransformFactory;
 import org.opengis.referencing.operation.OperationMethod;
@@ -68,20 +67,20 @@ public class PolarStereographic extends
      * <p>We do not provide such codes in public API because they duplicate 
the functionality of
      * {@link OperationMethod} instances. We use them only for constructors 
convenience.</p>
      *
-     * @see #getVariant(ParameterDescriptorGroup)
+     * @see #getVariant(OperationMethod)
      */
     private static final byte A = 1, B = 2, C = 3, NORTH = 4, SOUTH = 5;
 
     /**
-     * Returns the type of the projection based on the name and identifier of 
the given parameter group.
+     * Returns the type of the projection based on the name and identifier of 
the given operation method.
      * If this method can not identify the type, then the parameters should be 
considered as a 2SP case.
      */
-    private static byte getVariant(final ParameterDescriptorGroup parameters) {
-        if (identMatch(parameters, "(?i).*\\bvariant\\s*A\\b.*",  
PolarStereographicA.IDENTIFIER)) return A;
-        if (identMatch(parameters, "(?i).*\\bvariant\\s*B\\b.*",  
PolarStereographicB.IDENTIFIER)) return B;
-        if (identMatch(parameters, "(?i).*\\bvariant\\s*C\\b.*",  
PolarStereographicC.IDENTIFIER)) return C;
-        if (identMatch(parameters, "(?i).*\\bNorth\\b.*",         null)) 
return NORTH;
-        if (identMatch(parameters, "(?i).*\\bSouth\\b.*",         null)) 
return SOUTH;
+    private static byte getVariant(final OperationMethod method) {
+        if (identMatch(method, "(?i).*\\bvariant\\s*A\\b.*",  
PolarStereographicA.IDENTIFIER)) return A;
+        if (identMatch(method, "(?i).*\\bvariant\\s*B\\b.*",  
PolarStereographicB.IDENTIFIER)) return B;
+        if (identMatch(method, "(?i).*\\bvariant\\s*C\\b.*",  
PolarStereographicC.IDENTIFIER)) return C;
+        if (identMatch(method, "(?i).*\\bNorth\\b.*",         null)) return 
NORTH;
+        if (identMatch(method, "(?i).*\\bSouth\\b.*",         null)) return 
SOUTH;
         return 0; // Unidentified case, to be considered as variant B.
     }
 
@@ -122,7 +121,7 @@ public class PolarStereographic extends
      * @param parameters The parameter values of the projection to create.
      */
     public PolarStereographic(final OperationMethod method, final Parameters 
parameters) {
-        this(method, parameters, getVariant(parameters.getDescriptor()));
+        this(method, parameters, getVariant(method));
     }
 
     /**

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java?rev=1692154&r1=1692153&r2=1692154&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
 [UTF-8] Tue Jul 21 15:36:44 2015
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.opera
 import java.util.Map;
 import java.util.EnumMap;
 import org.opengis.parameter.ParameterDescriptor;
-import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.OperationMethod;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
@@ -93,10 +92,10 @@ public class TransverseMercator extends
     }
 
     /**
-     * Returns the type of the projection based on the name and identifier of 
the given parameter group.
+     * Returns the type of the projection based on the name and identifier of 
the given operation method.
      */
-    private static boolean isSouth(final ParameterDescriptorGroup parameters) {
-        return identMatch(parameters, "(?i).*\\bSouth\\b.*", 
TransverseMercatorSouth.IDENTIFIER);
+    private static boolean isSouth(final OperationMethod method) {
+        return identMatch(method, "(?i).*\\bSouth\\b.*", 
TransverseMercatorSouth.IDENTIFIER);
     }
 
     /**
@@ -112,7 +111,7 @@ public class TransverseMercator extends
      * @param parameters The parameter values of the projection to create.
      */
     public TransverseMercator(final OperationMethod method, final Parameters 
parameters) {
-        super(method, parameters, roles(isSouth(parameters.getDescriptor())));
+        super(method, parameters, roles(isSouth(method)));
         final double φ0 = toRadians(getAndStore(parameters,
                 
org.apache.sis.internal.referencing.provider.TransverseMercator.LATITUDE_OF_ORIGIN));
         final double rs = parameters.doubleValue(MapProjection.SEMI_MINOR)

Modified: 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
URL: 
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java?rev=1692154&r1=1692153&r2=1692154&view=diff
==============================================================================
--- 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
 [UTF-8] (original)
+++ 
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
 [UTF-8] Tue Jul 21 15:36:44 2015
@@ -368,6 +368,7 @@ public class ContextualParameters extend
      *
      * @see 
org.apache.sis.referencing.operation.projection.NormalizedProjection#createMapProjection(MathTransformFactory)
      */
+    @SuppressWarnings("AssignmentToForLoopParameter")
     public MathTransform completeTransform(final MathTransformFactory factory, 
final MathTransform kernel)
             throws FactoryException
     {


Reply via email to