sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1770076 - in /sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis: internal/netcdf/Variable.java storage/netcdf/MetadataReader.java
Date Wed, 16 Nov 2016 23:45:37 GMT
Author: desruisseaux
Date: Wed Nov 16 23:45:37 2016
New Revision: 1770076

URL: http://svn.apache.org/viewvc?rev=1770076&view=rev
Log:
Metadata generated from a NetCDF file should include the transfer function (scale factor and
offset).

Modified:
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java?rev=1770076&r1=1770075&r2=1770076&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Variable.java
[UTF-8] Wed Nov 16 23:45:37 2016
@@ -160,7 +160,7 @@ public abstract class Variable extends N
      *
      * @param  attributeName  the name of the attribute for which to get the values.
      * @param  numeric {@code true} if the values are expected to be numeric, or {@code false}
for strings.
-     * @return The sequence of {@link String} or {@link Number} values for the named attribute.
+     * @return the sequence of {@link String} or {@link Number} values for the named attribute.
      */
     public abstract Object[] getAttributeValues(String attributeName, boolean numeric);
 

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1770076&r1=1770075&r2=1770076&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
[UTF-8] Wed Nov 16 23:45:37 2016
@@ -70,6 +70,7 @@ import org.apache.sis.measure.Units;
 
 // The following dependency is used only for static final String constants.
 // Consequently the compiled class files should not have this dependency.
+import ucar.nc2.constants.CDM;
 import ucar.nc2.constants.CF;
 
 import static java.util.Collections.singleton;
@@ -849,7 +850,7 @@ final class MetadataReader {
      * @throws IOException if an I/O operation was necessary but failed.
      */
     private Band createSampleDimension(final Variable variable) throws IOException {
-        final DefaultBand band = new DefaultBand();
+        final DefaultBand band = new DefaultBand();     // TODO: not necessarily a band.
         String name = variable.getName();
         if (name != null && !(name = name.trim()).isEmpty()) {
             if (nameFactory == null) {
@@ -869,6 +870,16 @@ final class MetadataReader {
         } catch (ParserException e) {
             decoder.listeners.warning(errors().getString(Errors.Keys.CanNotAssignUnitToDimension_2,
name, units), e);
         }
+        Object[] v = variable.getAttributeValues(CDM.SCALE_FACTOR, true);
+        if (v.length == 1) {
+            band.setScaleFactor(((Number) v[0]).doubleValue());
+            band.setTransferFunctionType(TransferFunctionType.LINEAR);
+        }
+        v = variable.getAttributeValues(CDM.ADD_OFFSET, true);
+        if (v.length == 1) {
+            band.setOffset(((Number) v[0]).doubleValue());
+            band.setTransferFunctionType(TransferFunctionType.LINEAR);
+        }
         return band;
     }
 



Mime
View raw message