sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1828691 - in /sis/branches/JDK8: core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ core/sis-referencing/src/main/java/org/apache/sis/parameter/ core/sis-referencing/src/main/java/org/apache/sis/referencing/op...
Date Mon, 09 Apr 2018 10:03:18 GMT
Author: desruisseaux
Date: Mon Apr  9 10:03:18 2018
New Revision: 1828691

URL: http://svn.apache.org/viewvc?rev=1828691&view=rev
Log:
Register ObliqueMercator in META-INF. Add or fix GeoTIFF keys for ObliqueMercator. Fix the
way Parameters.getValue(…) handles optional parameters with units of measurement.

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorCenter.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorTwoPoints.java
    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/ObliqueMercator.java
    sis/branches/JDK8/core/sis-referencing/src/main/resources/META-INF/services/org.opengis.referencing.operation.OperationMethod
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Molodensky.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -61,7 +61,7 @@ import org.apache.sis.util.Debug;
  *
  * @author  Rueben Schulz (UBC)
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.7
  * @module
  */
@@ -212,12 +212,12 @@ public final class Molodensky extends Ge
          *   3) OGC 01-009 explicitly said that angles are in degrees and heights in metres.
          *   4) The above is consistent with what we do for map projections.
          */
-        double sa = values.doubleValue(SRC_SEMI_MAJOR);
-        double sb = values.doubleValue(SRC_SEMI_MINOR);
-        double ta = optional(values,   TGT_SEMI_MAJOR);
-        double tb = optional(values,   TGT_SEMI_MINOR);
-        double Δa = optional(values, AXIS_LENGTH_DIFFERENCE);
-        double Δf = optional(values, FLATTENING_DIFFERENCE);
+        double sa = values.doubleValue( SRC_SEMI_MAJOR);
+        double sb = values.doubleValue( SRC_SEMI_MINOR);
+        double ta = optional   (values, TGT_SEMI_MAJOR);
+        double tb = optional   (values, TGT_SEMI_MINOR);
+        double Δa = conditional(values, AXIS_LENGTH_DIFFERENCE, ta);
+        double Δf = conditional(values, FLATTENING_DIFFERENCE,  tb);
         if (Double.isNaN(ta)) {
             ta = sa + Δa;
         }
@@ -243,15 +243,16 @@ public final class Molodensky extends Ge
      * Returns the value of the given parameter, or NaN if undefined.
      */
     private static double optional(final Parameters values, final ParameterDescriptor<Double>
parameter) {
-        try {
-            final Double value = values.getValue(parameter);
-            if (value != null) {
-                return value;
-            }
-        } catch (ParameterNotFoundException | IllegalStateException e) {
-            // Ignore - this is okay for this method contract.
-        }
-        return Double.NaN;
+        final Double value = values.getValue(parameter);
+        return (value != null) ? value : Double.NaN;
+    }
+
+    /**
+     * Returns the value of the given parameter as a mandatory parameter if {@code condition}
is NaN,
+     * or an optional parameter otherwise.
+     */
+    private static double conditional(Parameters values, ParameterDescriptor<Double>
parameter, double condition) {
+        return Double.isNaN(condition) ? values.doubleValue(parameter) : optional(values,
parameter);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -83,7 +83,7 @@ public class ObliqueMercator extends Abs
     /**
      * The group of all parameters expected by this coordinate operation.
      */
-    private static final ParameterDescriptorGroup PARAMETERS;
+    static final ParameterDescriptorGroup PARAMETERS_A;
     static {
         final ParameterBuilder builder = builder();
 
@@ -111,6 +111,7 @@ public class ObliqueMercator extends Abs
 
         RECTIFIED_GRID_ANGLE = builder
                 .addIdentifier("8814")
+                .addIdentifier(Citations.GEOTIFF, "3096")
                 .addName("Angle from Rectified to Skew Grid")
                 .addName(Citations.OGC,     "rectified_grid_angle")
                 .addName(Citations.ESRI,    "XY_Plane_Rotation")
@@ -125,7 +126,7 @@ public class ObliqueMercator extends Abs
                 .rename    (Citations.GEOTIFF, "ScaleAtCenter")
                 .rename    (Citations.NETCDF));                                 // Remove
the netCDF name.
 
-        PARAMETERS = builder
+        PARAMETERS_A = builder
                 .addIdentifier(IDENTIFIER_A)
                 .addName("Hotine Oblique Mercator (variant A)")                 // Starting
from EPSG version 7.6
                 .addName("Hotine Oblique Mercator")                             // Prior
to EPSG version 7.6
@@ -136,6 +137,7 @@ public class ObliqueMercator extends Abs
                 .addName      (Citations.S57,     "HOM")
                 .addIdentifier(Citations.S57,     "5")
                 .addName      (Citations.GEOTIFF, "CT_ObliqueMercator_Hotine")
+                .addIdentifier(Citations.GEOTIFF, "3")
                 .createGroupForMapProjection(
                         LATITUDE_OF_CENTRE,
                         LONGITUDE_OF_CENTRE,
@@ -150,7 +152,7 @@ public class ObliqueMercator extends Abs
      * Constructs a new provider.
      */
     public ObliqueMercator() {
-        super(PARAMETERS);
+        super(PARAMETERS_A);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorCenter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorCenter.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorCenter.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorCenter.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -22,6 +22,8 @@ import org.opengis.parameter.ParameterDe
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.metadata.iso.citation.Citations;
 
+import static org.apache.sis.referencing.IdentifiedObjects.getIdentifier;
+
 
 /**
  * The provider for <cite>"Hotine Oblique Mercator (variant B)"</cite> projection
(EPSG:9815).
@@ -69,7 +71,7 @@ public final class ObliqueMercatorCenter
                 .reidentify(Citations.EPSG,    "8816")
                 .reidentify(Citations.GEOTIFF, "3090")
                 .rename(Citations.EPSG, "Easting at projection centre")
-                .rename(Citations.GEOTIFF, "ProjCenterEastingGeoKey")
+                .rename(Citations.GEOTIFF, "CenterEasting")
                 .rename(Citations.NETCDF));                                 // Delete the
netCDF name.
 
         NORTHING_AT_CENTRE = createShift(builder
@@ -77,7 +79,7 @@ public final class ObliqueMercatorCenter
                 .reidentify(Citations.EPSG,    "8817")
                 .reidentify(Citations.GEOTIFF, "3091")
                 .rename(Citations.EPSG, "Northing at projection centre")
-                .rename(Citations.GEOTIFF, "ProjCenterNorthingGeoKey")
+                .rename(Citations.GEOTIFF, "CenterNorthing")
                 .rename(Citations.NETCDF));                                 // Delete the
netCDF name.
 
         PARAMETERS = builder
@@ -92,7 +94,7 @@ public final class ObliqueMercatorCenter
                 .addName      (Citations.S57,     "OME")
                 .addIdentifier(Citations.S57,     "9")
                 .addName      (Citations.GEOTIFF, "CT_ObliqueMercator")
-                .addIdentifier(Citations.GEOTIFF, "3")
+                .addIdentifier(getIdentifier(PARAMETERS_A, Citations.GEOTIFF))      // Same
GeoTIFF identifier.
                 .addName      (Citations.PROJ4,   "omerc")
                 .createGroupForMapProjection(
                         LATITUDE_OF_CENTRE,

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorTwoPoints.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorTwoPoints.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorTwoPoints.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercatorTwoPoints.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -20,6 +20,10 @@ import javax.xml.bind.annotation.XmlTran
 import org.opengis.parameter.ParameterDescriptor;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.metadata.iso.citation.Citations;
+import org.apache.sis.measure.MeasurementRange;
+import org.apache.sis.measure.Longitude;
+import org.apache.sis.measure.Latitude;
+import org.apache.sis.measure.Units;
 
 
 /**
@@ -48,10 +52,17 @@ public class ObliqueMercatorTwoPoints ex
 
     static {
         final ParameterBuilder builder = builder().setCodeSpace(Citations.ESRI, "ESRI");
-        LAT_OF_1ST_POINT  = createLatitude (builder.addName("Latitude_Of_1st_Point"), false);
-        LAT_OF_2ND_POINT  = createLatitude (builder.addName("Latitude_Of_2nd_Point"), false);
-        LONG_OF_1ST_POINT = createLongitude(builder.addName("Longitude_Of_1st_Point"));
-        LONG_OF_2ND_POINT = createLongitude(builder.addName("Longitude_Of_2nd_Point"));
+        LAT_OF_1ST_POINT  = create(builder.addName("Latitude_Of_1st_Point"),   Latitude.MIN_VALUE,
 Latitude.MAX_VALUE);
+        LAT_OF_2ND_POINT  = create(builder.addName("Latitude_Of_2nd_Point"),   Latitude.MIN_VALUE,
 Latitude.MAX_VALUE);
+        LONG_OF_1ST_POINT = create(builder.addName("Longitude_Of_1st_Point"), Longitude.MIN_VALUE,
Longitude.MAX_VALUE);
+        LONG_OF_2ND_POINT = create(builder.addName("Longitude_Of_2nd_Point"), Longitude.MIN_VALUE,
Longitude.MAX_VALUE);
+    }
+
+    /**
+     * Creates a descriptor for a latitude or longitude parameter in degrees with no default
value.
+     */
+    private static ParameterDescriptor<Double> create(final ParameterBuilder builder,
final double min, final double max) {
+        return builder.createBounded(MeasurementRange.create(min, false, max, false, Units.DEGREE),
null);
     }
 
     /**

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=1828691&r1=1828690&r2=1828691&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] Mon Apr  9 10:03:18 2018
@@ -100,7 +100,7 @@ import org.apache.sis.util.Debug;
  * overriding one method has no impact on other methods.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.4
  * @module
  */
@@ -498,17 +498,17 @@ public abstract class Parameters impleme
     public <T> T getValue(final ParameterDescriptor<T> parameter) throws ParameterNotFoundException
{
         final ParameterValue<?> p = getParameter(parameter);
         if (p != null) {
-            final Object value;
             final Class<T> type = parameter.getValueClass();
             final Unit<?>  unit = parameter.getUnit();
-            if (unit == null) {
-                value = p.getValue();
-            } else if (type.isArray()) {
-                value = p.doubleValueList(unit);
-            } else {
-                value = p.doubleValue(unit);
-            }
-            if (value != null) {
+            Object value = p.getValue();
+            if (value != null) {                // Tested first for avoiding IllegalStateException
in call to doubleValue().
+                if (unit != null) {
+                    if (type.isArray()) {
+                        value = p.doubleValueList(unit);
+                    } else {
+                        value = p.doubleValue(unit);
+                    }
+                }
                 return ObjectConverters.convert(value, type);
             }
         }
@@ -517,8 +517,8 @@ public abstract class Parameters impleme
 
     /**
      * Returns the value of the parameter identified by the given descriptor, or throws an
exception if none.
-     * The default implementation invokes {@link #getValue(ParameterDescriptor)} and verifies
that the returned
-     * value is non-null.
+     * The default implementation performs the same work than {@link #getValue(ParameterDescriptor)}
and verifies
+     * that the returned value is non-null.
      *
      * @param  <T>        the type of the parameter value.
      * @param  parameter  the name or alias of the parameter to look for, together with the
desired type and unit of value.
@@ -533,13 +533,30 @@ public abstract class Parameters impleme
      * @since 0.7
      */
     public <T> T getMandatoryValue(final ParameterDescriptor<T> parameter) throws
ParameterNotFoundException {
-        final T value = getValue(parameter);
-        if (value != null) {
-            return value;
-        } else {
-            throw new IllegalStateException(Resources.format(Resources.Keys.MissingValueForParameter_1,
-                    Verifier.getDisplayName(parameter)));
+        final ParameterValue<?> p = getParameter(parameter);
+        if (p != null) {
+            final Class<T> type = parameter.getValueClass();
+            final Unit<?>  unit = parameter.getUnit();
+            final Object value;
+            if (unit == null) {
+                value = p.getValue();
+            } else if (type.isArray()) {
+                value = p.doubleValueList(unit);
+            } else {
+                value = p.doubleValue(unit);
+            }
+            final T result;
+            if (value != null) {
+                result = ObjectConverters.convert(value, type);
+            } else {
+                result = parameter.getDefaultValue();
+            }
+            if (result != null) {
+                return result;
+            }
         }
+        throw new IllegalStateException(Resources.format(Resources.Keys.MissingValueForParameter_1,
+                Verifier.getDisplayName(parameter)));
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -172,7 +172,8 @@ public class ObliqueMercator extends Con
         final double rν2 = initializer.rν2(sinφ).value;                              
  // rν² = (1 - ℯ²⋅sin²φc)
         final double A   = Br / rν2;                                                   
// a and kc handled later.
         final double D   = Br / (cosφ * sqrt(rν2));
-        final double F   = D + copySign(sqrt(Math.max(D*D - 1, 0)), φc);
+        final double sD1 = sqrt(Math.max(D*D - 1, 0));
+        final double F   = D + copySign(sD1, φc);
         H = F * pow(expOfNorthing(φc, eccentricity*sinφ), -B);                        
 // expOfNorthing(…) = 1/t
         /*
          * Next coefficients depend on whether the user specified azimuth or two points.
@@ -271,7 +272,7 @@ public class ObliqueMercator extends Con
             if (abs(abs(αc) - PI/2) < ANGULAR_TOLERANCE) {
                 uc = A * (λc - λ0);
             } else {
-                uc = ArB * atan2(sqrt(D*D - 1), cos(αc));
+                uc = ArB * atan2(sD1, cos(αc));
             }
             denormalize.convertBefore(1, null, -copySign(uc, φc));
         }

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=1828691&r1=1828690&r2=1828691&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] Mon Apr  9 10:03:18 2018
@@ -46,6 +46,10 @@ org.apache.sis.internal.referencing.prov
 org.apache.sis.internal.referencing.provider.PolarStereographicNorth
 org.apache.sis.internal.referencing.provider.PolarStereographicSouth
 org.apache.sis.internal.referencing.provider.ObliqueStereographic
+org.apache.sis.internal.referencing.provider.ObliqueMercator
+org.apache.sis.internal.referencing.provider.ObliqueMercatorCenter
+org.apache.sis.internal.referencing.provider.ObliqueMercatorTwoPoints
+org.apache.sis.internal.referencing.provider.ObliqueMercatorTwoPointsCenter
 org.apache.sis.internal.referencing.provider.ZonedTransverseMercator
 org.apache.sis.internal.referencing.provider.NTv2
 org.apache.sis.internal.referencing.provider.NADCON

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/ProvidersTest.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -92,16 +92,16 @@ public final strictfp class ProvidersTes
             AlbersEqualArea.class,
             TransverseMercator.class,
             TransverseMercatorSouth.class,
-            ObliqueMercator.class,
-            ObliqueMercatorCenter.class,
-            ObliqueMercatorTwoPoints.class,
-            ObliqueMercatorTwoPointsCenter.class,
             PolarStereographicA.class,
             PolarStereographicB.class,
             PolarStereographicC.class,
             PolarStereographicNorth.class,
             PolarStereographicSouth.class,
             ObliqueStereographic.class,
+            ObliqueMercator.class,
+            ObliqueMercatorCenter.class,
+            ObliqueMercatorTwoPoints.class,
+            ObliqueMercatorTwoPointsCenter.class,
             ZonedTransverseMercator.class,
             NTv2.class,
             NADCON.class,

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/ObliqueMercatorTest.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -55,15 +55,11 @@ public final strictfp class ObliqueMerca
         values.parameter("semi_major")         .setValue(ellipsoid.getSemiMajorAxis());
         values.parameter("semi_minor")         .setValue(ellipsoid.getSemiMinorAxis());
         values.parameter("azimuth")            .setValue(azimuth);
-        values.parameter("rectified_grid_angle").setValue(azimuth);
         values.parameter("longitude_of_center").setValue(cx);
         values.parameter("latitude_of_center") .setValue(cy);
         return new ObliqueMercator(method, Parameters.castOrWrap(values));
     }
 
-    // TODO: supprimer rectified_grid_angle. Nécessite de modifier Parameters.getValue(),
-    // ce qui peut rendre inutile Molodensky.optional(…).
-
     /**
      * Creates a projection and derivates a few points.
      *
@@ -72,7 +68,7 @@ public final strictfp class ObliqueMerca
     @Test
     public void testEllipsoidalDerivative() throws TransformException {
         tolerance = 1E-9;
-        transform = create(0, 0, 0);
+        transform = create(5, 10, 20);
         validate();
 
         final double delta = toRadians(100.0 / 60) / 1852;      // Approximatively 100 metres.
@@ -96,7 +92,7 @@ public final strictfp class ObliqueMerca
 
         final double delta = toRadians(100.0 / 60) / 1852;      // Approximatively 100 metres.
         derivativeDeltas = new double[] {delta, delta};
-        verifyInverse(0.15, 0.2);
+        verifyInverse(toRadians(15), toRadians(25));
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -39,7 +39,6 @@ import org.apache.sis.internal.referenci
 import org.apache.sis.internal.referencing.provider.Mercator1SP;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.util.Constants;
-import org.apache.sis.util.CharSequences;
 
 // Test dependencies
 import org.apache.sis.referencing.cs.HardCodedCS;
@@ -57,7 +56,7 @@ import static org.opengis.test.Assert.*;
  * files found on the classpath.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
  * @since   0.6
  * @module
  */
@@ -178,13 +177,15 @@ public final strictfp class DefaultMathT
 
     /**
      * Tests the creation of all registered map projections.
-     * Only the semi-axis lengths are specified. For the rest, we rely on default values.
+     * This test sets the semi-axis lengths and a few other mandatory parameter values.
+     * For remaining parameters, we rely on default values.
      *
      * @throws FactoryException if the construction of a map projection failed.
      *
      * @since 0.7
      */
     @Test
+    @SuppressWarnings("fallthrough")
     public void testAllMapProjections() throws FactoryException {
         /*
          * Gets all map projections and creates a projection using the WGS84 ellipsoid
@@ -195,24 +196,50 @@ public final strictfp class DefaultMathT
         final Collection<OperationMethod> methods = mtFactory.getAvailableMethods(Projection.class);
         for (final OperationMethod method : methods) {
             final String classification = method.getName().getCode();
-            ParameterValueGroup param = mtFactory.getDefaultParameters(classification);
-            param.parameter("semi_major").setValue(6377563.396);
-            param.parameter("semi_minor").setValue(6356256.909237285);
+            ParameterValueGroup pg = mtFactory.getDefaultParameters(classification);
+            pg.parameter("semi_major").setValue(6377563.396);
+            pg.parameter("semi_minor").setValue(6356256.909237285);
+            /*
+             * Most parameters have default values, typically 0° or 0 metre, so we don't
need to specify them for
+             * the purpose of this test. But some map projections have mandatory parameters
without default value.
+             * In those cases, we must specify an arbitrary value otherwise the instantiation
will fail.  When we
+             * need to specify only one value, that value is remembered for opportunist verification.
+             */
+            String param = null;
+            double value = Double.NaN;
+            switch (classification) {
+                case "Polar Stereographic (variant A)":           param = "Latitude of natural
origin"; value = 90; break;
+                case "Polar Stereographic (variant B)":
+                case "Polar Stereographic (variant C)":           param = "Latitude of standard
parallel"; value = 80; break;
+                case "Hotine Oblique Mercator (variant A)":
+                case "Hotine Oblique Mercator (variant B)":       param = "Azimuth of initial
line"; value = 30; break;
+                case "Lambert Conic Conformal (1SP)":
+                case "Lambert Conic Conformal (West Orientated)": param = "Latitude of natural
origin"; value = 45; break;
+                case "Lambert Conic Conformal (2SP Michigan)":    param = "Ellipsoid scaling
factor"; value = 1;  // Fall through for defining standard parallels too.
+                case "Lambert Conic Conformal (2SP Belgium)":
+                case "Lambert Conic Conformal (2SP)":
+                case "Albers Equal Area": {
+                    pg.parameter("Latitude of 1st standard parallel").setValue(30);
+                    pg.parameter("Latitude of 2nd standard parallel").setValue(50);
+                    break;
+                }
+                case "Hotine_Oblique_Mercator_Two_Point_Center":
+                case "Hotine_Oblique_Mercator_Two_Point_Natural_Origin": {
+                    pg.parameter( "Latitude_Of_1st_Point").setValue(30);
+                    pg.parameter( "Latitude_Of_2nd_Point").setValue(50);
+                    pg.parameter("Longitude_Of_1st_Point").setValue(10);
+                    pg.parameter("Longitude_Of_2nd_Point").setValue(20);
+                    break;
+                }
+            }
+            if (param != null) {
+                pg.parameter(param).setValue(value);
+            }
             final MathTransform mt;
             try {
-                mt = mtFactory.createParameterizedTransform(param);
+                mt = mtFactory.createParameterizedTransform(pg);
             } catch (InvalidGeodeticParameterException e) {
-                /*
-                 * Some map projections have mandatory parameters which we ignore for now
-                 * except for a few well-known projection that we know should not fail.
-                 */
-                if (classification.contains("Mercator")) {
-                    throw e;
-                }
-                out.print(classification);
-                out.print(CharSequences.spaces(42 - classification.length()));
-                out.print(": ");
-                out.println(e.getLocalizedMessage());
+                fail(classification + ": " + e.getLocalizedMessage());
                 continue;
             }
             /*
@@ -223,10 +250,14 @@ public final strictfp class DefaultMathT
                 continue;
             }
             assertInstanceOf(classification, Parameterized.class, mt);
-            param = ((Parameterized) mt).getParameterValues();
-            assertEquals(classification, param.getDescriptor().getName().getCode());
-            assertEquals(classification, 6377563.396,       param.parameter("semi_major").doubleValue(),
1E-4);
-            assertEquals(classification, 6356256.909237285, param.parameter("semi_minor").doubleValue(),
1E-4);
+            pg = ((Parameterized) mt).getParameterValues();
+            assertNotNull(classification, pg);
+            assertEquals(classification, pg.getDescriptor().getName().getCode());
+            assertEquals(classification, 6377563.396,       pg.parameter("semi_major").doubleValue(),
1E-4);
+            assertEquals(classification, 6356256.909237285, pg.parameter("semi_minor").doubleValue(),
1E-4);
+            if (param != null) {
+                assertEquals(classification, value, pg.parameter(param).doubleValue(), 1E-4);
+            }
             /*
              * Creates a ProjectedCRS from the map projection. This part is more an integration
test than
              * a DefaultMathTransformFactory test. Again, the intent is to verify that the
properties are

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java?rev=1828691&r1=1828690&r2=1828691&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/GeoKeys.java
[UTF-8] Mon Apr  9 10:03:18 2018
@@ -84,7 +84,8 @@ final class GeoKeys {
     /** A ratio.               */ public static final short ScaleAtNatOrigin     = 3092;
     /** A ratio.               */ public static final short ScaleAtCenter        = 3093;
     /** In AzimuthUnit.        */ public static final short AzimuthAngle         = 3094;
-    /** In AngularUnit.        */ public static final short StraightVertPoleLong = 3095;
   // Last projection parameter (for now)
+    /** In AngularUnit.        */ public static final short StraightVertPoleLong = 3095;
+    /** In AzimuthUnit.        */ public static final short RectifiedGridAngle   = 3096;
   // Last projection parameter (for now)
 
     // 6.2.4 Vertical CS Keys
     /** Section 6.3.4.1 codes. */ public static final short VerticalCSType       = 4096;
@@ -105,7 +106,7 @@ final class GeoKeys {
      *         or -1 if the given key is not for a map projection parameter.
      */
     static int unitOf(final short key) {
-        if (key < StdParallel1 || key > StraightVertPoleLong) {
+        if (key < StdParallel1 || key > RectifiedGridAngle) {
             return -1;
         }
         switch (key) {
@@ -114,11 +115,12 @@ final class GeoKeys {
             case FalseOriginEasting:
             case FalseOriginNorthing:
             case CenterEasting:
-            case CenterNorthing:    return LINEAR;
+            case CenterNorthing:     return LINEAR;
             case ScaleAtNatOrigin:
-            case ScaleAtCenter:     return RATIO;
-            case AzimuthAngle:      return AZIMUTH;
-            default:                return ANGULAR;
+            case ScaleAtCenter:      return RATIO;
+            case RectifiedGridAngle: // Note: GDAL seems to use angular unit here.
+            case AzimuthAngle:       return AZIMUTH;
+            default:                 return ANGULAR;
         }
     }
 



Mime
View raw message