sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1813466 - in /sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis: internal/referencing/provider/ referencing/operation/ referencing/operation/transform/
Date Thu, 26 Oct 2017 23:16:44 GMT
Author: desruisseaux
Date: Thu Oct 26 23:16:44 2017
New Revision: 1813466

URL: http://svn.apache.org/viewvc?rev=1813466&view=rev
Log:
Fix an "ellipsoid change" operation which was wrongly set to identity.
We use abridged Molodensky instead for now, even if all translation terms are zero.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MathTransformContext.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransform2D.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java?rev=1813466&r1=1813465&r2=1813466&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Affine.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -57,7 +57,7 @@ import org.apache.sis.referencing.operat
  * </table>
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.6
+ * @version 0.8
  * @since   0.5
  * @module
  */
@@ -283,6 +283,23 @@ public final class Affine extends Abstra
     }
 
     /**
+     * Returns parameter values for an identity transform of the given input and output dimensions.
+     * Callers can modify the returned parameters if desired.
+     *
+     * @param  dimension  the number of source and target dimensions.
+     * @return parameters for an identity transform of the given dimensions.
+     *
+     * @since 0.8
+     */
+    public static ParameterValueGroup identity(int dimension) {
+        final ParameterValueGroup values = TensorParameters.WKT1.createValueGroup(
+                Collections.singletonMap(NAME_KEY, Constants.AFFINE));
+        values.parameter(Constants.NUM_COL).setValue(++dimension);
+        values.parameter(Constants.NUM_ROW).setValue(  dimension);
+        return values;
+    }
+
+    /**
      * Returns the parameter values for the given matrix. This method is invoked by implementations
of
      * {@link org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterValues()}.
      *

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java?rev=1813466&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.referencing.provider;
+
+
+/**
+ * The method to use for applying a datum shift.
+ * Values are ordered from most accurate method to less accurate.
+ * This enumeration does not include datum shift based on grid files.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
+ * @module
+ */
+public enum DatumShiftMethod {
+    /**
+     * Transformation in geocentric domain (translation or position vector 7-parameters).
+     */
+    GEOCENTRIC_DOMAIN,
+
+    /**
+     * Approximation of geocentric translations.
+     */
+    MOLODENSKY,
+
+    /**
+     * Approximation of Molodensky transformations,
+     * which is itself an approximation of geocentric translations.
+     */
+    ABRIDGED_MOLODENSKY,
+
+    /**
+     * No datum shift applied (not even a change of ellipsoid).
+     * This method should be used only when a coarse accuracy (at least 3 km) is sufficient.
+     */
+    NONE;
+
+    /**
+     * Suggests an operation method for the given accuracy. This method contains accuracy
threshold (in metres)
+     * for allowing the use of Molodensky approximation instead than the Geocentric Translation
method.
+     * The accuracy of datum shifts with Molodensky approximation is about 5 or 10 metres.
+     * However for this method, we are not interested in absolute accuracy but rather in
the difference
+     * between Molodensky and Geocentric Translation methods, which is much lower (less than
1 m).
+     * We nevertheless use a relatively high threshold as a conservative approach.
+     *
+     * @param  desired  desired accuracy on Earth (metres).
+     * @return suggested datum shift method for an accuracy equals or better than the given
value.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-369">SIS-369</a>
+     */
+    public static DatumShiftMethod forAccuracy(final double desired) {
+        if (desired >= 5) {
+            return MOLODENSKY;
+        } else {
+            return GEOCENTRIC_DOMAIN;
+        }
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/DatumShiftMethod.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java?rev=1813466&r1=1813465&r2=1813466&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffine.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -226,7 +226,8 @@ public abstract class GeocentricAffine e
 
     /**
      * Returns the parameters for creating a datum shift operation.
-     * The operation method will be one of the {@code GeocentricAffine} subclasses.
+     * The operation method will be one of the {@code GeocentricAffine} subclasses,
+     * unless the specified {@code method} argument is {@link DatumShiftMethod#NONE}.
      * If no single operation method can be used, then this method returns {@code null}.
      *
      * <p>This method does <strong>not</strong> change the coordinate system
type.
@@ -235,19 +236,18 @@ public abstract class GeocentricAffine e
      * will cause this method to return {@code null}. In such case, it is caller's responsibility
to apply
      * the datum shift itself in Cartesian geocentric coordinates.</p>
      *
-     * @param sourceCS       the source coordinate system. Only the type and number of dimensions
is checked.
-     * @param targetCS       the target coordinate system. Only the type and number of dimensions
is checked.
-     * @param datumShift     the datum shift as a matrix.
-     * @param useMolodensky  {@code true} for allowing the use of Molodensky approximation,
or {@code false}
-     *                       for using the transformation in geocentric space (which should
be more accurate).
+     * @param  sourceCS    the source coordinate system. Only the type and number of dimensions
is checked.
+     * @param  targetCS    the target coordinate system. Only the type and number of dimensions
is checked.
+     * @param  datumShift  the datum shift as a matrix, or {@code null} if there is no datum
shift information.
+     * @param  method      the preferred datum shift method. Note that {@code createParameters(…)}
may overwrite.
      * @return the parameter values, or {@code null} if no single operation method can be
found.
      */
     public static ParameterValueGroup createParameters(final CoordinateSystem sourceCS,
-            final CoordinateSystem targetCS, final Matrix datumShift, boolean useMolodensky)
+            final CoordinateSystem targetCS, final Matrix datumShift, DatumShiftMethod method)
     {
         final boolean isEllipsoidal = (sourceCS instanceof EllipsoidalCS);
-        if (!(isEllipsoidal ? targetCS instanceof EllipsoidalCS
-                            : targetCS instanceof CartesianCS && sourceCS instanceof
CartesianCS))
+        if (!(isEllipsoidal ? (targetCS instanceof EllipsoidalCS)
+                            : (targetCS instanceof CartesianCS && sourceCS instanceof
CartesianCS)))
         {
             return null;        // Coordinate systems are not two EllipsoidalCS or two CartesianCS.
         }
@@ -256,43 +256,93 @@ public abstract class GeocentricAffine e
         if (dimension != targetCS.getDimension()) {
             dimension  = 4;     // Any value greater than 3 means "mismatched dimensions"
for this method.
         }
+        if (method == DatumShiftMethod.NONE) {
+            if (dimension <= 3) {
+                return Affine.identity(dimension);
+            } else if (isEllipsoidal) {
+                final ParameterDescriptorGroup descriptor;
+                switch (sourceCS.getDimension()) {
+                    case 2: descriptor = Geographic2Dto3D.PARAMETERS; break;
+                    case 3: descriptor = Geographic3Dto2D.PARAMETERS; break;
+                    default: return null;
+                }
+                return descriptor.createValue();
+            } else {
+                return null;
+            }
+        }
         /*
          * Try to convert the matrix into (tX, tY, tZ, rX, rY, rZ, dS) parameters.
-         * The matrix may not be convertible, in which case we will let the callers
+         * The matrix may not be convertible, in which case we will let the caller
          * uses the matrix directly in Cartesian geocentric coordinates.
          */
         final BursaWolfParameters parameters = new BursaWolfParameters(null, null);
-        try {
+        if (datumShift != null) try {
             parameters.setPositionVectorTransformation(datumShift, BURSAWOLF_TOLERANCE);
         } catch (IllegalArgumentException e) {
             log(Loggers.COORDINATE_OPERATION, "createParameters", e);
             return null;
+        } else {
+            /*
+             * If there is no datum shift parameters (not to be confused with identity),
then those parameters
+             * are assumed unknown. Using the most accurate methods would give a false impression
of accuracy,
+             * so we use the fastest method instead. Since all parameter values are zero,
Apache SIS should use
+             * the AbridgedMolodenskyTransform2D optimization.
+             */
+            method = DatumShiftMethod.ABRIDGED_MOLODENSKY;
         }
         final boolean isTranslation = parameters.isTranslation();
         final ParameterDescriptorGroup descriptor;
         /*
-         * Following "if" blocks are ordered from more accurate to less accurate datum shift
method
-         * supported by GeocentricAffine subclasses.
+         * Following "if" blocks are ordered from most accurate to less accurate datum shift
method
+         * supported by GeocentricAffine subclasses (except NONE which has already been handled).
+         * Special cases:
+         *
+         *   - If the datum shift is applied between geocentric CRS, then the Molodensky
approximations do not apply
+         *     as they are designed for transformations between geographic CRS only. User
preference is then ignored.
+         *
+         *   - Molodensky methods are approximations for datum shifts having only translation
terms in their Bursa-Wolf
+         *     parameters. If there is also a scale or rotation terms, then we can not use
Molodensky methods. The user
+         *     preference is then ignored.
          */
         if (!isEllipsoidal) {
-            useMolodensky = false;
+            method = DatumShiftMethod.GEOCENTRIC_DOMAIN;
             descriptor = isTranslation ? GeocentricTranslation.PARAMETERS
                                        : PositionVector7Param .PARAMETERS;
-        } else {
-            if (!isTranslation) {
-                useMolodensky = false;
-                descriptor = (dimension >= 3) ? PositionVector7Param3D.PARAMETERS
-                                              : PositionVector7Param2D.PARAMETERS;
-            } else if (!useMolodensky) {
+        } else if (!isTranslation) {
+            method = DatumShiftMethod.GEOCENTRIC_DOMAIN;
+            descriptor = (dimension >= 3) ? PositionVector7Param3D.PARAMETERS
+                                          : PositionVector7Param2D.PARAMETERS;
+        } else switch (method) {
+            case GEOCENTRIC_DOMAIN: {
                 descriptor = (dimension >= 3) ? GeocentricTranslation3D.PARAMETERS
                                               : GeocentricTranslation2D.PARAMETERS;
-            } else {
+                break;
+            }
+            case MOLODENSKY: {
                 descriptor = Molodensky.PARAMETERS;
+                break;
+            }
+            case ABRIDGED_MOLODENSKY: {
+                descriptor = AbridgedMolodensky.PARAMETERS;
+                break;
             }
+            default: throw new AssertionError(method);
         }
+        /*
+         * Following lines will set all Bursa-Wolf parameter values (scale, translation
+         * and rotation terms). In the particular case of Molodensky method, we have an
+         * additional parameter for the number of source and target dimensions (2 or 3).
+         */
         final Parameters values = createParameters(descriptor, parameters, isTranslation);
-        if (useMolodensky && dimension <= 3) {
-            values.getOrCreate(Molodensky.DIMENSION).setValue(dimension);
+        switch (method) {
+            case MOLODENSKY:
+            case ABRIDGED_MOLODENSKY: {
+                if (dimension <= 3) {
+                    values.getOrCreate(Molodensky.DIMENSION).setValue(dimension);
+                }
+                break;
+            }
         }
         return values;
     }

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java?rev=1813466&r1=1813465&r2=1813466&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractSingleOperation.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -173,10 +173,8 @@ class AbstractSingleOperation extends Ab
      * In the particular case of a {@linkplain PassThroughTransform pass through transform}
with more dimensions
      * than what we would expect from the given method, the check will rather be performed
against the
      * {@linkplain PassThroughTransform#getSubTransform() sub transform}.
-     *
-     * <p>The intend is to allow creation of a three-dimensional {@code ProjectedCRS}
with a two-dimensional
-     * {@code OperationMethod}, where the third-dimension just pass through. This is not
a recommended approach
-     * and we do not document that as a supported feature, but we do not prevent it neither.</p>
+     * The intend is to allow creation of a three-dimensional {@code ProjectedCRS} with a
two-dimensional
+     * {@code OperationMethod}, where the third-dimension just pass through.
      *
      * <p>This method tries to locates what seems to be the "core" of the given math
transform. The definition
      * of "core" is imprecise and may be adjusted in future SIS versions. The current algorithm
is as below:</p>

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java?rev=1813466&r1=1813465&r2=1813466&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -35,6 +35,8 @@ import org.opengis.parameter.ParameterVa
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.internal.referencing.CoordinateOperations;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
+import org.apache.sis.internal.referencing.provider.Affine;
+import org.apache.sis.internal.referencing.provider.DatumShiftMethod;
 import org.apache.sis.internal.referencing.provider.Geographic2Dto3D;
 import org.apache.sis.internal.referencing.provider.Geographic3Dto2D;
 import org.apache.sis.internal.referencing.provider.GeographicToGeocentric;
@@ -115,17 +117,6 @@ import static org.apache.sis.util.Utilit
  */
 public class CoordinateOperationFinder extends CoordinateOperationRegistry {
     /**
-     * The accuracy threshold (in metres) for allowing the use of Molodensky approximation
instead than the
-     * Geocentric Translation method. The accuracy of datum shifts with Molodensky approximation
is about 5
-     * or 10 metres. However for this constant, we are not interested in absolute accuracy
but rather in the
-     * difference between Molodensky and Geocentric Translation methods, which is much lower
(less than 1 m).
-     * We nevertheless use a relatively high threshold as a conservative approach.
-     *
-     * @see #desiredAccuracy
-     */
-    private static final double MOLODENSKY_ACCURACY = 5;
-
-    /**
      * Identifiers used as the basis for identifier of CRS used as an intermediate step.
      * The values can be of two kinds:
      *
@@ -441,7 +432,7 @@ public class CoordinateOperationFinder e
          * Actually we do not know if the longitude rotation should be before or after datum
shift. But this ambiguity
          * can usually be ignored because Bursa-Wolf parameters are always used with source
and target prime meridians
          * set to Greenwich in EPSG dataset 8.9.  For safety, the SIS's DefaultGeodeticDatum
class ensures that if the
-         * prime meridian are not the same, then the target meridian must be Greenwich.
+         * prime meridians are not the same, then the target meridian must be Greenwich.
          */
         final DefaultMathTransformFactory.Context context = ReferencingUtilities.createTransformContext(
                 sourceCRS, targetCRS, new MathTransformContext(sourceDatum, targetDatum));
@@ -497,20 +488,31 @@ public class CoordinateOperationFinder e
         final DefaultMathTransformFactory mtFactory = factorySIS.getDefaultMathTransformFactory();
         MathTransform before = null, after = null;
         ParameterValueGroup parameters;
-        if (datumShift != null) {
+        if (identifier == DATUM_SHIFT || identifier == ELLIPSOID_CHANGE) {
             /*
              * If the transform can be represented by a single coordinate operation, returns
that operation.
              * Possible operations are:
              *
-             *    - Geocentric translation         (in geocentric, geographic-2D or geographic-3D
domains)
              *    - Position Vector transformation (in geocentric, geographic-2D or geographic-3D
domains)
+             *    - Geocentric translation         (in geocentric, geographic-2D or geographic-3D
domains)
+             *    - [Abridged] Molodensky          (as an approximation of geocentric translation)
+             *    - Identity                       (if the desired accuracy is so large than
we can skip datum shift)
              *
-             * Otherwise, maybe we failed to create the operation because the coordinate
system type were not the same.
-             * Convert unconditionally to XYZ geocentric coordinates and apply the datum
shift in that coordinate space.
+             * TODO: if both CS are ellipsoidal but with different number of dimensions,
then we should use
+             * an intermediate 3D geographic CRS in order to enable the use of Molodensky
method if desired.
              */
-            parameters = GeocentricAffine.createParameters(sourceCS, targetCS, datumShift,
desiredAccuracy >= MOLODENSKY_ACCURACY);
+            final DatumShiftMethod preferredMethod = DatumShiftMethod.forAccuracy(desiredAccuracy);
+            parameters = GeocentricAffine.createParameters(sourceCS, targetCS, datumShift,
preferredMethod);
             if (parameters == null) {
-                parameters = TensorParameters.WKT1.createValueGroup(properties(Constants.AFFINE),
datumShift);
+                /*
+                 * Failed to select a coordinate operation. Maybe because the coordinate
system types are not the same.
+                 * Convert unconditionally to XYZ geocentric coordinates and apply the datum
shift in that CS space.
+                 */
+                if (datumShift != null) {
+                    parameters = TensorParameters.WKT1.createValueGroup(properties(Constants.AFFINE),
datumShift);
+                } else {
+                    parameters = Affine.identity(3);                        // Dimension
of geocentric CRS.
+                }
                 final CoordinateSystem normalized = CommonCRS.WGS84.geocentric().getCoordinateSystem();
                 before = mtFactory.createCoordinateSystemChange(sourceCS, normalized, sourceDatum.getEllipsoid());
                 after  = mtFactory.createCoordinateSystemChange(normalized, targetCS, targetDatum.getEllipsoid());
@@ -521,18 +523,20 @@ public class CoordinateOperationFinder e
             parameters = (isGeographicToGeocentric ? GeographicToGeocentric.PARAMETERS
                                                    : GeocentricToGeographic.PARAMETERS).createValue();
         } else {
+            /*
+             * Coordinate system change (including change in the number of dimensions) without
datum shift.
+             */
             final int sourceDim = sourceCS.getDimension();
             final int targetDim = targetCS.getDimension();
-            if ((sourceDim & ~1) == 2 && (sourceDim ^ targetDim) == 1    // sourceDim
== 2 or 3 and difference with targetDim is 1.
+            if ((sourceDim & ~1) == 2                           // sourceDim == 2 or
3.
+                    && (sourceDim ^ targetDim) == 1             // abs(sourceDim
- targetDim) == 1.
                     && (sourceCS instanceof EllipsoidalCS)
                     && (targetCS instanceof EllipsoidalCS))
             {
                 parameters = (sourceDim == 2 ? Geographic2Dto3D.PARAMETERS
                                              : Geographic3Dto2D.PARAMETERS).createValue();
             } else {
-                parameters = TensorParameters.WKT1.createValueGroup(properties(Constants.AFFINE));
     // Initialized to identity.
-                parameters.parameter(Constants.NUM_COL).setValue(targetDim + 1);
-                parameters.parameter(Constants.NUM_ROW).setValue(targetDim + 1);
+                parameters = Affine.identity(targetDim);
                 /*
                  * createCoordinateSystemChange(…) needs the ellipsoid associated to the
ellipsoidal coordinate system,
                  * if any. If none or both coordinate systems are ellipsoidal, then the ellipsoid
will be ignored (see

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MathTransformContext.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MathTransformContext.java?rev=1813466&r1=1813465&r2=1813466&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MathTransformContext.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/MathTransformContext.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -18,6 +18,8 @@ package org.apache.sis.referencing.opera
 
 import org.opengis.util.FactoryException;
 import org.opengis.referencing.cs.CartesianCS;
+import org.opengis.referencing.cs.SphericalCS;
+import org.opengis.referencing.cs.EllipsoidalCS;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.datum.GeodeticDatum;
 import org.opengis.referencing.operation.Matrix;
@@ -102,7 +104,7 @@ final class MathTransformContext extends
                 } else {
                     matrix = cm.multiply(rot);                  // Apply the rotation before
normalization.
                 }
-            } else {
+            } else if (cs == null || cs instanceof EllipsoidalCS || cs instanceof SphericalCS)
{
                 final Double value = rotation;
                 if (inverse) {
                     cm.convertBefore(0, null, value);           // Longitude is the first
axis in normalized CS.
@@ -110,6 +112,8 @@ final class MathTransformContext extends
                     cm.convertAfter(0, null, value);
                 }
                 matrix = cm;
+            } else {
+                throw new FactoryException(Errors.format(Errors.Keys.UnsupportedCoordinateSystem_1,
cs.getName()));
             }
         }
         return matrix;

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransform2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransform2D.java?rev=1813466&r1=1813465&r2=1813466&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransform2D.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbridgedMolodenskyTransform2D.java
[UTF-8] Thu Oct 26 23:16:44 2017
@@ -19,7 +19,6 @@ package org.apache.sis.referencing.opera
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import org.opengis.referencing.datum.Ellipsoid;
-import org.opengis.referencing.operation.TransformException;
 
 import static java.lang.Math.*;
 
@@ -94,11 +93,9 @@ final class AbridgedMolodenskyTransform2
      * than {@link MolodenskyTransform}, but the formulas are repeated and simplified here
for performance reasons.
      * In addition of using abridged Molodensky formulas, this method assumes that {@link
#tX}, {@link #tY} and
      * {@link #tZ} fields are zero.
-     *
-     * @throws TransformException if a point can not be transformed.
      */
     @Override
-    public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
throws TransformException {
+    public void transform(double[] srcPts, int srcOff, double[] dstPts, int dstOff, int numPts)
{
         System.arraycopy(srcPts, srcOff, dstPts, dstOff, numPts * 2);
         while (--numPts >= 0) {
             final double φ    = dstPts[++dstOff];



Mime
View raw message