This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit d9b4d899a52b16868e184ac9d1e8f500907c9c5f Author: Martin Desruisseaux <[email protected]> AuthorDate: Wed Oct 24 16:39:23 2018 +0200 Do not block the creation of a GridGeometry if a MathTransform does not support the derivative operation. --- .../org/apache/sis/coverage/grid/GridGeometry.java | 22 ++++++++++++++++++---- .../org/apache/sis/internal/system/Modules.java | 5 +++++ pom.xml | 1 + 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java index 122eba6..d73198b 100644 --- a/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java +++ b/core/sis-raster/src/main/java/org/apache/sis/coverage/grid/GridGeometry.java @@ -41,9 +41,11 @@ import org.apache.sis.referencing.IdentifiedObjects; import org.apache.sis.referencing.operation.matrix.Matrices; import org.apache.sis.referencing.operation.transform.MathTransforms; import org.apache.sis.referencing.operation.transform.PassThroughTransform; +import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.raster.Resources; import org.apache.sis.util.resources.Vocabulary; import org.apache.sis.util.resources.Errors; +import org.apache.sis.util.logging.Logging; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.CharSequences; import org.apache.sis.util.Debug; @@ -276,14 +278,16 @@ public class GridGeometry implements Serializable { * The easiest way to estimate a resolution is then to ask for the derivative at some * arbitrary point. For this constructor, we take the grid center. */ + double[] resolution = null; final Matrix matrix = MathTransforms.getMatrix(gridToCRS); if (matrix != null) { resolution = resolution(matrix, 1); - } else if (extent != null && gridToCRS != null) { + } else if (extent != null && gridToCRS != null) try { resolution = resolution(gridToCRS.derivative(extent.getCentroid()), 0); - } else { - resolution = null; + } catch (TransformException e) { + recoverableException(e); } + this.resolution = resolution; nonLinears = findNonLinearTargets(gridToCRS); } @@ -340,9 +344,11 @@ public class GridGeometry implements Serializable { env = extent.toCRS(cornerToCRS); env.setCoordinateReferenceSystem(envelope.getCoordinateReferenceSystem()); this.envelope = new ImmutableEnvelope(env); - if (scales == null) { + if (scales == null) try { scales = gridToCRS.derivative(extent.getCentroid()); // 'gridToCRS' can not be null if 'cornerToCRS' is non-null. numToIgnore = 0; + } catch (TransformException e) { + recoverableException(e); } } else { this.extent = null; @@ -369,6 +375,14 @@ public class GridGeometry implements Serializable { } /** + * Invoked when a recoverable exception occurred. Those exceptions must be minor enough + * that they can be silently ignored in most cases. + */ + private static void recoverableException(final TransformException exception) { + Logging.recoverableException(Logging.getLogger(Modules.RASTER), GridGeometry.class, "transform", exception); + } + + /** * Creates a grid geometry with only an extent and a coordinate reference system. * This constructor can be used when the <cite>grid to CRS</cite> transform is unknown. * diff --git a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java index 305eb9a..e856457 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java +++ b/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java @@ -65,6 +65,11 @@ public final class Modules { /** * The {@value} module name. */ + public static final String RASTER = "org.apache.sis.raster"; + + /** + * The {@value} module name. + */ public static final String STORAGE = "org.apache.sis.storage"; /** diff --git a/pom.xml b/pom.xml index c6de25f..d836c56 100644 --- a/pom.xml +++ b/pom.xml @@ -554,6 +554,7 @@ <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> + <trimStackTrace>false</trimStackTrace> <environmentVariables> <SIS_DATA>${session.executionRootDirectory}/target</SIS_DATA> </environmentVariables>
