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: Provides default values for more properties in a netCDF Coordinate Reference System for making possible to open a file even if the CRS is not well defined.
Date Fri, 28 Feb 2020 15:08:03 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 ca055b6  Provides default values for more properties in a netCDF Coordinate Reference
System for making possible to open a file even if the CRS is not well defined.
ca055b6 is described below

commit ca055b6ed523e0414c5fa009cf0d4d4c1f14fa1d
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Feb 28 16:07:17 2020 +0100

    Provides default values for more properties in a netCDF Coordinate Reference System for
making possible to open a file even if the CRS is not well defined.
---
 .../java/org/apache/sis/internal/netcdf/Axis.java  | 23 ++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
index 5be89ad..05717d6 100644
--- a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
+++ b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/Axis.java
@@ -62,7 +62,7 @@ import ucar.nc2.constants.CF;
  * {@link ucar.nc2.dataset.CoordinateAxis1D} or {@link ucar.nc2.dataset.CoordinateAxis2D}
respectively.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.1
  *
  * @see Grid#getAxes(Decoder)
  *
@@ -542,10 +542,9 @@ public final class Axis extends NamedElement {
         /*
          * Axis abbreviation, direction and unit of measurement are mandatory. If any of
them is null,
          * creation of CoordinateSystemAxis is likely to fail with an InvalidGeodeticParameterException.
-         * We provide default values for the most well-identified axes and leave other values
to null.
-         * Those null values can be accepted if users specify their own factory.
+         * We provide default values for the most well-identified axes.
          *
-         * The default values are SI base units except degrees, which is the usually angular
units for netCDF files.
+         * The default values are SI base units except degrees, which is the usual angular
units for netCDF files.
          * Providing default units is a little bit dangerous, but we can not create CRS otherwise.
Note that wrong
          * defaults become harmless if the CRS is overwritten by GridMapping attributes in
Variable.getGridGeometry().
          */
@@ -564,16 +563,24 @@ public final class Axis extends NamedElement {
                     if (increment != null && increment.doubleValue() == 1) {
                         // Do not test values.doubleValue(0) since different conventions
exit (0-based, 1-based, etc).
                         unit = Units.PIXEL;
+                    } else {
+                        unit = Units.UNITY;
                     }
                     break;
                 }
+                default: unit = Units.UNITY; break;
             }
         }
         AxisDirection dir = direction;
         if (dir == null) {
-            switch (order) {
-                case 0: dir = AxisDirection.COLUMN_POSITIVE; break;
-                case 1: dir = AxisDirection.ROW_POSITIVE; break;
+            if (Units.isTemporal(unit)) {
+                dir = AxisDirection.FUTURE;
+            } else if (Units.isPressure(unit)) {
+                dir = AxisDirection.UP;
+            } else switch (order) {
+                case 0:  dir = AxisDirection.COLUMN_POSITIVE; break;
+                case 1:  dir = AxisDirection.ROW_POSITIVE;    break;
+                default: dir = AxisDirection.OTHER;           break;
             }
         }
         final String abbr;
@@ -582,7 +589,7 @@ public final class Axis extends NamedElement {
         } else if (dir != null && unit != null) {
             abbr = AxisDirections.suggestAbbreviation(name, dir, unit);
         } else {
-            abbr = null;
+            abbr = "A" + (order + 1);
         }
         return factory.createCoordinateSystemAxis(properties, abbr, dir, unit);
     }


Mime
View raw message