sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Netcdf file opened with the UCAR library should use NetcdfDataset.Enhance.CoordSystems at construction time. Enhancements just before requesting coordinate systems is sometime too late. The symptom we observed was that if metadata were requested before the resources, no grid resources were found because the CS were not found. Invoking NetcdfDataset.enhance(…) at construction time fix that.
Date Sat, 13 Apr 2019 22:04:43 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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new d6d1dce  Netcdf file opened with the UCAR library should use NetcdfDataset.Enhance.CoordSystems
at construction time. Enhancements just before requesting coordinate systems is sometime too
late. The symptom we observed was that if metadata were requested before the resources, no
grid resources were found because the CS were not found. Invoking NetcdfDataset.enhance(…)
at construction time fix that.
d6d1dce is described below

commit d6d1dce6612c80dd19a2812f592b76eee9d5cd8f
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sun Apr 14 00:01:33 2019 +0200

    Netcdf file opened with the UCAR library should use NetcdfDataset.Enhance.CoordSystems
at construction time.
    Enhancements just before requesting coordinate systems is sometime too late. The symptom
we observed was that
    if metadata were requested before the resources, no grid resources were found because
the CS were not found.
    Invoking NetcdfDataset.enhance(…) at construction time fix that.
---
 .../org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java  | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
index 6433e1a..cb011c1 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/ucar/DecoderWrapper.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.EnumSet;
 import java.util.Formatter;
 import java.util.Collection;
+import java.util.Collections;
 import java.io.IOException;
 import ucar.nc2.Group;
 import ucar.nc2.Attribute;
@@ -126,7 +127,9 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
             throws IOException
     {
         super(geomlib, listeners);
-        file = NetcdfDataset.openDataset(filename, false, this);
+        final NetcdfDataset ds = NetcdfDataset.openDataset(filename, false, this);
+        ds.enhance(Collections.singleton(NetcdfDataset.Enhance.CoordSystems));
+        file = ds;
         groups = new Group[1];
         initialize();
     }
@@ -451,6 +454,13 @@ public final class DecoderWrapper extends Decoder implements CancelTask
{
                 final NetcdfDataset ds = (NetcdfDataset) file;
                 final EnumSet<NetcdfDataset.Enhance> mode = EnumSet.copyOf(ds.getEnhanceMode());
                 if (mode.add(NetcdfDataset.Enhance.CoordSystems)) {
+                    /*
+                     * Should not happen with NetcdfDataset opened by the constructor expecting
a filename,
+                     * because that constructor already enhanced the dataset. It may happen
however if the
+                     * NetcdfDataset was given explicitly by the user. We try to increase
the chances to
+                     * get information we need, but it is not guaranteed to work; it may
be too late if we
+                     * already started to use the NetcdfDataset before this point.
+                     */
                     ds.enhance(mode);
                 }
                 systems = ds.getCoordinateSystems();


Mime
View raw message