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

commit b87ed440dbbd42fc654da67ab4bad9a3be28fa95
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Wed Jul 8 10:57:10 2026 +0200

    Fix the notification of tile read events which was lost after the image to 
show changed.
    Fix the display of pixel values which was broken when the coverage has no 
CRS.
---
 .../apache/sis/storage/geoheif/ImageResource.java  |  2 +-
 .../apache/sis/gui/coverage/CoverageCanvas.java    |  9 ++++++---
 .../apache/sis/gui/coverage/StyleController.java   |  2 +-
 .../org/apache/sis/gui/map/ValuesFormatter.java    |  4 ++--
 .../org/apache/sis/gui/map/ValuesUnderCursor.java  | 23 ++++++++++++++++++++--
 .../main/org/apache/sis/gui/referencing/Utils.java |  2 ++
 6 files changed, 33 insertions(+), 9 deletions(-)

diff --git 
a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java
 
b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java
index 0a293ed803..70b2dea484 100644
--- 
a/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java
+++ 
b/incubator/src/org.apache.sis.storage.geoheif/main/org/apache/sis/storage/geoheif/ImageResource.java
@@ -438,6 +438,7 @@ final class ImageResource extends TiledGridCoverageResource 
implements StoreReso
              * @throws Exception any I/O error, arithmetic error, raster 
format error or other kinds of error.
              */
             final void readTile(ChannelDataInput input, final Raster[] result) 
throws Exception {
+                iterator.fireTileReadStarted();
                 input = viewAsConsecutiveBytes(input);
                 Raster raster = reader.readTile(input);
                 raster = iterator.cache(iterator.moveRaster(raster));
@@ -458,7 +459,6 @@ final class ImageResource extends TiledGridCoverageResource 
implements StoreReso
             {
                 if (iterator.getRegionInsideTile(builder.regionLower, 
builder.regionUpper, builder.subsampling, false)) {
                     builder.pixelsToSampleValues(sampleModel);
-                    iterator.fireTileReadStarted();
                     return null;
                 }
                 return 
TilePlaceholder.empty(sampleModel).create(iterator.getTileLocation());
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 499a936c29..56bc9200e9 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
@@ -528,8 +528,9 @@ public class CoverageCanvas extends MapCanvasAWT {
      * If {@code true}, tiles will be shown by a translucent shape and fade 
away.
      *
      * @param  enabled  whether to show for a few seconds a visual indication 
of which tiles were read.
+     * @param  clear    whether to clear {@link #tileReadListener} if {@code 
enabled} is {@code false}.
      */
-    final void showTileReads(final boolean enabled) {
+    final void showTileReads(final boolean enabled, final boolean clear) {
         final GridCoverageResource resource = getResource();
         if (enabled) {
             if (tileReadListener == null) {
@@ -542,7 +543,9 @@ public class CoverageCanvas extends MapCanvasAWT {
             if (resource != null) {
                 resource.removeListener(TileReadEvent.class, tileReadListener);
             }
-            tileReadListener = null;
+            if (clear) {
+                tileReadListener = null;
+            }
         }
     }
 
@@ -1494,7 +1497,7 @@ public class CoverageCanvas extends MapCanvasAWT {
         if (TRACE) {
             trace("clear()");
         }
-        showTileReads(false);
+        showTileReads(false, false);
         isCoverageHidden = false;
         isCoverageAdjusting = true;
         try {
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyleController.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyleController.java
index b890b46523..8894332f59 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyleController.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/StyleController.java
@@ -164,7 +164,7 @@ final class StyleController extends ItemController {
             if (showTileReads == null) {
                 final Resources resources = 
Resources.forLocale(canvas.getLocale());
                 showTileReads = new ItemController(new 
MapItem(resources.getString(Resources.Keys.ShowTileReadEvents)));
-                showTileReads.selectedProperty().addListener((p,o,n) -> 
canvas.showTileReads(n));
+                showTileReads.selectedProperty().addListener((p,o,n) -> 
canvas.showTileReads(n, true));
                 showTileReads.setIndependent(true);
             }
             children.add(showTileReads);
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
index 31fde13778..bf1e702a10 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesFormatter.java
@@ -386,7 +386,7 @@ final class ValuesFormatter extends 
ValuesUnderCursor.Formatter {
 
         /** Returns the CRS of this position, or {@code null} if unspecified. 
*/
         @Override public CoordinateReferenceSystem 
getCoordinateReferenceSystem() {
-            return crs;
+            return isIgnoreable(crs) ? null : crs;
         }
     }
 
@@ -401,7 +401,7 @@ final class ValuesFormatter extends 
ValuesUnderCursor.Formatter {
     @Override
     DirectPosition copy(final DirectPosition point) {
         assert Thread.holdsLock(this);
-        final Position position = new Position(point, newSlice);
+        final var position = new Position(point, newSlice);
         newSlice = null;
         return position;
     }
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesUnderCursor.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesUnderCursor.java
index 5c03b0b831..d8dbd3d7da 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesUnderCursor.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/ValuesUnderCursor.java
@@ -20,6 +20,8 @@ import java.util.concurrent.atomic.AtomicReference;
 import javafx.scene.control.Menu;
 import javafx.application.Platform;
 import org.opengis.geometry.DirectPosition;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.gui.coverage.CoverageCanvas;
 import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.geometry.GeneralDirectPosition;
@@ -38,7 +40,7 @@ import org.apache.sis.gui.internal.BackgroundThreads;
  * thread using the {@link Formatter} inner class, which needs to be 
thread-safe.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.3
+ * @version 1.7
  * @since   1.1
  */
 public abstract class ValuesUnderCursor {
@@ -210,7 +212,24 @@ public abstract class ValuesUnderCursor {
          * @return a copy of the given position, or {@code null} if the 
position should be considered outside.
          */
         DirectPosition copy(final DirectPosition point) {
-            return new GeneralDirectPosition(point);
+            final var p = new GeneralDirectPosition(point);
+            if (isIgnoreable(point.getCoordinateReferenceSystem())) {
+                p.setCoordinateReferenceSystem(null);
+            }
+            return p;
+        }
+
+        /**
+         * Returns {@code true} if the given reference system should be 
ignored.
+         * We need to ignore "computer display" because this is a synthetic 
<abbr>CRS</abbr>
+         * added when the source coverage does not define its own 
<abbr>CRS</abbr>.
+         * If we do not remove that <abbr>CRS</abbr>, an exception will be 
thrown
+         * when the coverage will try to convert that <abbr>CRS</abbr>.
+         *
+         * @see org.apache.sis.gui.referencing.Utils#isIgnoreable
+         */
+        static boolean isIgnoreable(final CoordinateReferenceSystem system) {
+            return CommonCRS.Engineering.DISPLAY.datumUsedBy(system);
         }
 
         /**
diff --git 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
index fe8f9bc3c4..e7bad96f34 100644
--- 
a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
+++ 
b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/referencing/Utils.java
@@ -101,6 +101,8 @@ final class Utils {
 
     /**
      * Returns {@code true} if the given reference system should be ignored.
+     *
+     * @see 
org.apache.sis.gui.map.ValuesUnderCursor.Formatter#isIgnoreable(CoordinateReferenceSystem)
      */
     static boolean isIgnoreable(final ReferenceSystem system) {
         return (system instanceof CoordinateReferenceSystem c) && 
CommonCRS.Engineering.DISPLAY.datumUsedBy(c);

Reply via email to