sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/05: Make grid dimensions more tolerant to missing information.
Date Sun, 03 Nov 2019 22:51:28 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 59a43116d64175b79c915526916fdb5e79295264
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sun Nov 3 22:29:46 2019 +0100

    Make grid dimensions more tolerant to missing information.
---
 .../apache/sis/gui/dataset/MetadataOverview.java   | 70 +++++++++++++++-------
 .../org/apache/sis/internal/gui/Resources.java     | 10 ++++
 .../apache/sis/internal/gui/Resources.properties   |  2 +
 .../sis/internal/gui/Resources_fr.properties       |  4 +-
 4 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/MetadataOverview.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/MetadataOverview.java
index 6e8ba8d..dcd29a6 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/MetadataOverview.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/MetadataOverview.java
@@ -53,7 +53,6 @@ import org.opengis.metadata.extent.GeographicDescription;
 import org.opengis.metadata.extent.GeographicExtent;
 import org.opengis.metadata.identification.Identification;
 import org.opengis.metadata.spatial.Dimension;
-import org.opengis.metadata.spatial.CellGeometry;
 import org.opengis.metadata.spatial.SpatialRepresentation;
 import org.opengis.metadata.spatial.GridSpatialRepresentation;
 import org.opengis.referencing.ReferenceSystem;
@@ -378,17 +377,22 @@ final class MetadataOverview {
             }
             title.setText(text);
             /*
-             * The abstract, or if there is no abstract the credit as a fallback because
it can provide
-             * some hints about the product. The topic category (climatology, health, etc.)
follows.
+             * The abstract, or if there is no abstract the purpose, or if no purpose the
credit as a fallback.
+             * We use those fallback because they can provide some hints about the product.
+             * The topic category (climatology, health, etc.) follows.
              */
             short label = Resources.Keys.Abstract;
             text = owner.string(info.getAbstract());
             if (text == null) {
-                for (final InternationalString c : nonNull(info.getCredits())) {
-                    text = owner.string(c);
-                    if (text != null) {
-                        label = Resources.Keys.Credit;
-                        break;
+                label = Resources.Keys.Purpose;
+                text = owner.string(info.getPurpose());
+                if (text == null) {
+                    for (final InternationalString c : nonNull(info.getCredits())) {
+                        text = owner.string(c);
+                        if (text != null) {
+                            label = Resources.Keys.Credit;
+                            break;
+                        }
                     }
                 }
             }
@@ -607,26 +611,50 @@ final class MetadataOverview {
         /**
          * Invoked when new spatial representation information should be shown.
          * This method updates all fields in this section with the content of given information.
+         * The information to show depends on the {@code info} subtype.
          */
         @Override
         void buildContent(final SpatialRepresentation info) {
-            addLine(Resources.Keys.ReferenceSystem, IdentifiedObjects.getName(referenceSystem,
null));
             if (info instanceof GridSpatialRepresentation) {
-                final GridSpatialRepresentation sr = (GridSpatialRepresentation) info;
-                final StringBuffer buffer = new StringBuffer();
-                for (final Dimension dim : nonNull(sr.getAxisDimensionProperties())) {
-                    owner.getNumberFormat().format(dim.getDimensionSize(), buffer, new FieldPosition(0));
-                    buffer.append(' ').append(owner.string(Types.getCodeTitle(dim.getDimensionName()))).append("
× ");
-                }
-                if (buffer.length() != 0) {
-                    buffer.setLength(buffer.length() - 3);
-                    addLine(Resources.Keys.Dimensions, buffer.toString());
+                build((GridSpatialRepresentation) info);
+            }
+            addLine(Resources.Keys.ReferenceSystem, IdentifiedObjects.getName(referenceSystem,
null));
+        }
+
+        /**
+         * Adds information specific to the {@link GridSpatialRepresentation} subtype.
+         *
+         * @todo Change the representation for using a table instead. In addition of dimension
name and size,
+         *       the metadata may also provide a more meaningful title (e.g. "longitude"),
a description and
+         *       the resolution. Note that VectorSpatialRepresentation would also needs a
table.
+         */
+        private void build(final GridSpatialRepresentation info) {
+            int dimensionCount = 0;
+            final StringBuffer buffer = new StringBuffer();
+            for (final Dimension dim : nonNull(info.getAxisDimensionProperties())) {
+                final String  name = owner.string(Types.getCodeTitle(dim.getDimensionName()));
+                final Integer size = dim.getDimensionSize();
+                if (size != null) {
+                    owner.getNumberFormat().format(size, buffer, new FieldPosition(0));
+                    if (name != null) buffer.append(' ');
                 }
-                final CellGeometry cg = sr.getCellGeometry();
-                if (cg != null) {
-                    addLine(Resources.Keys.CellGeometry, owner.string(Types.getCodeTitle(cg)));
+                if (name != null) {
+                    buffer.append(name);
+                } else if (size == null) {
+                    buffer.append('?');
                 }
+                buffer.append(" × ");
+                dimensionCount++;
+            }
+            if (dimensionCount != 0) {
+                buffer.setLength(buffer.length() - 3);
+                addLine(Resources.Keys.Dimensions, buffer.toString());
+            }
+            final Integer nd = info.getNumberOfDimensions();
+            if (nd != null && nd != dimensionCount) {
+                addLine(Resources.Keys.NumberOfDimensions, owner.getNumberFormat().format(dimensionCount));
             }
+            addLine(Resources.Keys.CellGeometry, owner.string(Types.getCodeTitle(info.getCellGeometry())));
         }
     }
 
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
index fe471d6..80c905c 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
@@ -146,6 +146,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short Loading = 7;
 
         /**
+         * Number of dimensions:
+         */
+        public static final short NumberOfDimensions = 27;
+
+        /**
          * Open…
          */
         public static final short Open = 11;
@@ -161,6 +166,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short PublicationDate = 21;
 
         /**
+         * Purpose:
+         */
+        public static final short Purpose = 28;
+
+        /**
          * Reference system:
          */
         public static final short ReferenceSystem = 22;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
index b03df50..4f21493 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
@@ -38,9 +38,11 @@ Extent                 = Extent:
 File                   = File
 GeospatialFiles        = Geospatial data files
 Loading                = Loading\u2026
+NumberOfDimensions     = Number of dimensions:
 Open                   = Open\u2026
 OpenDataFile           = Open data file
 PublicationDate        = Publication date:
+Purpose                = Purpose:
 ReferenceSystem        = Reference system:
 ResourceIdentification = Resource identification
 SpatialRepresentation  = Spatial representation
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
index 33f7f8c..18aaea9 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
@@ -43,11 +43,13 @@ Extent                 = \u00c9tendue\u00a0:
 File                   = Fichier
 GeospatialFiles        = Fichiers de donn\u00e9es g\u00e9ospatiales
 Loading                = Chargement\u2026
+NumberOfDimensions     = Nombre de dimensions\u00a0:
 Open                   = Ouvrir\u2026
 OpenDataFile           = Ouvrir un fichier de donn\u00e9es
 PublicationDate        = Date de publication\u00a0:
+Purpose                = Objectif\u00a0:
 ReferenceSystem        = Syst\u00e8me de r\u00e9f\u00e9rence\u00a0:
 ResourceIdentification = Identification de la ressource
 SpatialRepresentation  = Repr\u00e9sentation spatiale
-TopicCategory          = Topic category\u00a0:
+TopicCategory          = Cat\u00e9gorie th\u00e9matique\u00a0:
 TypeOfResource         = Type de ressource\u00a0:


Mime
View raw message