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 47e7bf0 Try harder to detect when the coordinate reference system in
a netCDF file is geographic.
47e7bf0 is described below
commit 47e7bf090831f580590451d36bce423c55481ee4
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Mon Jun 10 21:10:59 2019 +0200
Try harder to detect when the coordinate reference system in a netCDF file
is geographic.
---
.../apache/sis/internal/netcdf/impl/GridInfo.java | 31 +++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
index 5f02906..f1dc9ce 100644
---
a/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
+++
b/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/GridInfo.java
@@ -24,11 +24,13 @@ import java.util.Map;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.SortedMap;
+import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.internal.netcdf.Axis;
import org.apache.sis.internal.netcdf.Grid;
import org.apache.sis.internal.netcdf.Decoder;
import org.apache.sis.internal.netcdf.Dimension;
import org.apache.sis.internal.netcdf.Resources;
+import org.apache.sis.internal.metadata.AxisDirections;
import org.apache.sis.internal.util.UnmodifiableArrayList;
import org.apache.sis.storage.DataStoreContentException;
import org.apache.sis.storage.DataStoreException;
@@ -251,12 +253,35 @@ next: for (final String name : axisNames) {
for (final SortedMap.Entry<VariableInfo,Integer> entry :
variables.entrySet()) {
final int targetDim = entry.getValue();
final VariableInfo axis = entry.getKey();
+ /*
+ * In Apache SIS implementation, the abbreviation determines the
axis type. If a "_coordinateaxistype" attribute
+ * exists, il will have precedence over all other heuristic rules
in this method. Otherwise check "degrees_east"
+ * and "degrees_west" units before other heuristic rules.
+ */
char abbreviation = getAxisType(axis.getAxisType());
if (abbreviation == 0) {
- abbreviation = getAxisType(axis.getName());
+ if (Units.isAngular(axis.getUnit())) {
+ final AxisDirection direction =
AxisDirections.absolute(Axis.direction(axis.getUnitsString()));
+ if (AxisDirection.EAST.equals(direction)) {
+ abbreviation = 'λ';
+ } else if (AxisDirection.NORTH.equals(direction)) {
+ abbreviation = 'φ';
+ }
+ }
+ /*
+ * If the abbreviation is still unknown, look at the
"long_name", "description", "title" or "standard_name"
+ * attributes. The long name is sometime "Longitude" or
"Latitude" while the variable name is only "x" or "y".
+ * We test the variable name last because that name is more at
risk of being an uninformative "x" or "y" name.
+ */
if (abbreviation == 0) {
- if (Units.isTemporal(axis.getUnit())) {
- abbreviation = 't';
+ abbreviation = getAxisType(axis.getDescription());
+ if (abbreviation == 0) {
+ abbreviation = getAxisType(axis.getName());
+ if (abbreviation == 0) {
+ if (Units.isTemporal(axis.getUnit())) {
+ abbreviation = 't';
+ }
+ }
}
}
}