You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2020/02/18 23:38:26 UTC

[sis] 01/02: Fix a ClassCastException reported on mailing list.

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 6f54acf4ba79f884fb5a010ee27d8d28236bb0a9
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue Feb 18 23:56:26 2020 +0100

    Fix a ClassCastException reported on mailing list.
---
 .../operation/transform/SpecializableTransform.java            | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SpecializableTransform.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SpecializableTransform.java
index 1d9e306..d86fa95 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SpecializableTransform.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/SpecializableTransform.java
@@ -254,7 +254,15 @@ class SpecializableTransform extends AbstractMathTransform implements Serializab
      * we do not know what was the last search result.
      */
     private SubArea locate(final DirectPosition pos) {
-        return (SubArea) RTreeNode.locate(domains, pos);
+        /*
+         * All nodes should be SubArea instances, except in some circumstances the root node.
+         * That root node may returned by `RTreeNode.locate(…)` if given position is inside
+         * the union of all bounding boxes, but not in the bounding box of any specific grid.
+         * In such case the caller will fallback on `DatumShiftGridGroup.interpolateInCell(…)`
+         * which perform a more extensive search for the nearest grid.
+         */
+        final RTreeNode node = RTreeNode.locate(domains, pos);
+        return (node instanceof SubArea) ? (SubArea) node : null;
     }
 
     /**