This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 7d95e45eee Fix an issue with an EngineeringCRS randomly not found, 
depending on thread execution order.
7d95e45eee is described below

commit 7d95e45eeed1ed1c2a4c8176a83a449070273983
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon May 4 14:58:48 2026 +0200

    Fix an issue with an EngineeringCRS randomly not found, depending on thread 
execution order.
---
 .../apache/sis/gui/coverage/CoverageCanvas.java    |  2 ++
 .../apache/sis/gui/coverage/CoverageExplorer.java  | 22 +++++++++++++++++-----
 .../org/apache/sis/gui/coverage/GridControls.java  |  6 +++---
 .../main/org/apache/sis/gui/coverage/GridView.java |  6 +++---
 .../sis/gui/coverage/StyledRenderingData.java      |  4 ++++
 5 files changed, 29 insertions(+), 11 deletions(-)

diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
index 039ca62293..499a936c29 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageCanvas.java
@@ -888,6 +888,8 @@ public class CoverageCanvas extends MapCanvasAWT {
      * This method is used for building a grid <abbr>CRS</abbr> for cell 
indices.
      * If this method returns an artificial name, it would cause an unusable 
menu
      * item to appear in the menu that offers different <abbr>CRS</abbr>.</p>
+     *
+     * @see ImageRequest#gridCrsName(GridCoverageResource, GridGeometry)
      */
     final Identifier gridCrsName() {
         return data.gridCrsName;
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
index 58ac7e3dd0..755d734d0e 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java
@@ -34,10 +34,14 @@ import javafx.event.ActionEvent;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
 import org.opengis.metadata.Identifier;
+import org.apache.sis.util.logging.Logging;
+import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.GridCoverageResource;
 import org.apache.sis.coverage.grid.GridCoverage;
+import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.portrayal.RenderException;
 import org.apache.sis.gui.Widget;
+import org.apache.sis.gui.map.StatusBar;
 import org.apache.sis.gui.internal.FontGIS;
 import org.apache.sis.gui.internal.Resources;
 import org.apache.sis.gui.internal.ToolbarButton;
@@ -45,8 +49,8 @@ import org.apache.sis.gui.internal.NonNullObjectProperty;
 import org.apache.sis.gui.internal.PrivateAccess;
 import org.apache.sis.gui.internal.BackgroundThreads;
 import org.apache.sis.gui.referencing.RecentReferenceSystems;
+import static org.apache.sis.gui.internal.LogHandler.LOGGER;
 import org.apache.sis.gui.dataset.WindowHandler;
-import org.apache.sis.gui.map.StatusBar;
 
 
 /**
@@ -607,15 +611,23 @@ public class CoverageExplorer extends Widget {
      * {@link #coverageProperty}. In the latter case, the {@code resource} and 
{@code coverage} arguments
      * given to this method may be the value that the properties already 
have.</p>
      *
-     * @param  name      value of {@link CoverageCanvas#gridCrsName()} or 
equivalent.
+     * @param  gridName  value of {@link CoverageCanvas#gridCrsName()} or 
equivalent.
      * @param  resource  the new source of coverage, or {@code null} if none.
      * @param  coverage  the new coverage, or {@code null} if none.
      */
-    final void notifyDataChanged(final Identifier name, final 
GridCoverageResource resource, final GridCoverage coverage) {
+    final void notifyDataChanged(final Identifier gridName, final 
GridCoverageResource resource, final GridCoverage coverage) {
         if (coverage != null) {
             BackgroundThreads.execute(() -> {
-                referenceSystems.setGridReferencing(true,
-                        (name == null) ? Map.of() : Map.of(name, 
coverage.getGridGeometry()));
+                final GridGeometry gg = coverage.getGridGeometry();
+                Identifier name = gridName;
+                if (name == null && resource != null) try {
+                    // May happen if `CoverageCanvas.setNewSource(…)` did not 
had the time to be executed.
+                    name = ImageRequest.gridCrsName(resource, gg);
+                } catch (DataStoreException e) {
+                    // Declare `setResource` as the public method invoking 
(indirectly) this method.
+                    Logging.recoverableException(LOGGER, 
CoverageExplorer.class, "setResource", e);
+                 }
+                referenceSystems.setGridReferencing(true, (name == null) ? 
Map.of() : Map.of(name, gg));
             });
         }
         /*
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridControls.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridControls.java
index 4ccccfeed1..c1e7513b24 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridControls.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridControls.java
@@ -104,11 +104,11 @@ final class GridControls extends ViewAndControls {
      * Invoked after {@link GridView#setImage(ImageRequest)} for updating the 
table of sample
      * dimensions when information become available. This method is invoked in 
JavaFX thread.
      *
-     * @param  name      value of {@link CoverageCanvas#gridCrsName()}.
+     * @param  gridName  value of {@link CoverageCanvas#gridCrsName()}.
      * @param  resource  the new source of coverage, or {@code null} if none.
      * @param  coverage  the new coverage, or {@code null} if none.
      */
-    final void notifyDataChanged(final Identifier name, final 
GridCoverageResource resource, final GridCoverage coverage) {
+    final void notifyDataChanged(final Identifier gridName, final 
GridCoverageResource resource, final GridCoverage coverage) {
         final ObservableList<SampleDimension> items = 
sampleDimensions.getItems();
         if (coverage != null) {
             items.setAll(coverage.getSampleDimensions());
@@ -116,7 +116,7 @@ final class GridControls extends ViewAndControls {
         } else {
             items.clear();
         }
-        owner.notifyDataChanged(name, resource, coverage);
+        owner.notifyDataChanged(gridName, resource, coverage);
     }
 
     /**
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridView.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridView.java
index 7503c841dd..1898ed4929 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridView.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/GridView.java
@@ -321,19 +321,19 @@ public class GridView extends Control {
     /**
      * Invoked after the image has been loaded or after failure.
      *
-     * @param  name      value equivalent to {@link 
CoverageCanvas#gridCrsName()}.
+     * @param  gridName  value equivalent to {@link 
CoverageCanvas#gridCrsName()}.
      * @param  resource  the new source of coverage, or {@code null} if none.
      * @param  coverage  the new coverage, or {@code null} if none.
      * @param  image     the loaded image, or {@code null} on failure.
      */
-    private void setLoadedImage(final Identifier name,
+    private void setLoadedImage(final Identifier gridName,
                                 final GridCoverageResource resource,
                                 final GridCoverage coverage,
                                 final RenderedImage image) {
         loader = null;          // Must be first for preventing cancellation.
         setImage(image);
         if (controls != null && !controls.isAdjustingSlice) {
-            controls.notifyDataChanged(name, resource, coverage);
+            controls.notifyDataChanged(gridName, resource, coverage);
         }
     }
 
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyledRenderingData.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyledRenderingData.java
index dd92f4a734..7f37fc85b8 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyledRenderingData.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyledRenderingData.java
@@ -23,6 +23,8 @@ import org.opengis.metadata.Identifier;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
 import org.apache.sis.storage.DataStoreException;
+import org.apache.sis.storage.GridCoverageResource;
+import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.PixelInCell;
 import org.apache.sis.image.ErrorHandler;
 import org.apache.sis.image.processing.isoline.Isolines;
@@ -42,6 +44,8 @@ import org.apache.sis.map.coverage.RenderingData;
 final class StyledRenderingData extends RenderingData {
     /**
      * Name of the grid <abbr>CRS</abbr>, derived from the resource identifier.
+     *
+     * @see ImageRequest#gridCrsName(GridCoverageResource, GridGeometry)
      */
     Identifier gridCrsName;
 

Reply via email to