sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Do not list "bounds" variable as coverage variables.
Date Fri, 08 Jan 2021 13:19:14 GMT
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 f5fe8429784ccbfffc5f7e40e1b0a1750ce91ee3
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Jan 7 22:48:19 2021 +0100

    Do not list "bounds" variable as coverage variables.
---
 .../java/org/apache/sis/gui/coverage/GridView.java |  1 +
 .../org/apache/sis/internal/netcdf/Variable.java   | 22 ++++++++++++++++++++--
 .../apache/sis/internal/netcdf/VariableRole.java   |  6 ++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
index 5593346..49e6fb1 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
@@ -381,6 +381,7 @@ public class GridView extends Control {
         @Override
         protected void failed() {
             terminated(null);
+            setImage((RenderedImage) null);
             final GridCoverageResource resource = request.resource;
             final GridView owner = GridView.this;
             if (resource instanceof StoreListeners) {
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
index 29461cf..31c7a2d 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
@@ -88,6 +88,13 @@ public abstract class Variable extends Node {
     protected static final int STRING_DIMENSION = 2;
 
     /**
+     * The role of this variable (axis, coverage, feature, <i>etc.</i>), or {@code
null} if not yet determined.
+     *
+     * @see #getRole()
+     */
+    private VariableRole role;
+
+    /**
      * The unit of measurement, parsed from {@link #getUnitsString()} when first needed.
      * We do not try to parse the unit at construction time because this variable may be
      * never requested by the user.
@@ -443,14 +450,25 @@ public abstract class Variable extends Node {
 
     /**
      * Returns whether this variable is used as a coordinate system axis, a coverage or something
else.
-     * This is a shortcut for {@link Convention#roleOf(Variable)}, except that {@code this}
can not be null.
+     * The role is determined by {@linkplain Convention#roleOf conventions}, except {@link
VariableRole#BOUNDS}
+     * which is determined by this method (because it depends on other variables).
      *
      * @return role of this variable.
      *
      * @see Convention#roleOf(Variable)
      */
     public final VariableRole getRole() {
-        return decoder.convention().roleOf(this);
+        if (role == null) {
+            final String name = getName();
+            for (final Variable variable : decoder.getVariables()) {
+                if (name.equalsIgnoreCase(variable.getAttributeAsString(CF.BOUNDS))) {
+                    role = VariableRole.BOUNDS;
+                    return role;
+                }
+            }
+            role = decoder.convention().roleOf(this);
+        }
+        return role;
     }
 
     /**
diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/VariableRole.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/VariableRole.java
index 675575b..2c37ac8 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/VariableRole.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/VariableRole.java
@@ -42,6 +42,12 @@ public enum VariableRole {
     FEATURE,
 
     /**
+     * Values of the variable are bounds of values of another variable.
+     * For example it may be the bounds of coordinate values specified by an axis.
+     */
+    BOUNDS,
+
+    /**
      * Unidentified kind of variable.
      */
     OTHER


Mime
View raw message