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 5b1a811 Modify the strategy of previous commit for geographic CRS detection: - Check
for "standard_name" attribute sooner because it is controlled vocabulary. - Check for "degree_east"
and "degree_north" units later because they are already verified by Axis constructor. This
allows that constructor to report a warning in case of inconsistency.
5b1a811 is described below
commit 5b1a811b0a9571ec9abeda0e75178d0a5fdb6245
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jun 11 00:02:30 2019 +0200
Modify the strategy of previous commit for geographic CRS detection:
- Check for "standard_name" attribute sooner because it is controlled vocabulary.
- Check for "degree_east" and "degree_north" units later because they are already verified
by Axis constructor. This allows that constructor to report a warning in case of inconsistency.
---
.../apache/sis/internal/netcdf/impl/GridInfo.java | 59 ++++++++++++++--------
1 file changed, 39 insertions(+), 20 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 f1dc9ce..7725d43 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,6 +24,7 @@ import java.util.Map;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.SortedMap;
+import javax.measure.Unit;
import org.opengis.referencing.cs.AxisDirection;
import org.apache.sis.internal.netcdf.Axis;
import org.apache.sis.internal.netcdf.Grid;
@@ -66,10 +67,10 @@ final class GridInfo extends Grid {
static {
addAxisTypes('λ', "longitude", "lon", "long");
addAxisTypes('φ', "latitude", "lat");
- addAxisTypes('H', "pressure", "height", "altitude", "elevation", "elev", "geoz");
- addAxisTypes('D', "depth");
- addAxisTypes('E', "geox");
- addAxisTypes('N', "geoy");
+ addAxisTypes('H', "pressure", "height", "altitude", "barometric_altitude", "elevation",
"elev", "geoz");
+ addAxisTypes('D', "depth", "depth_below_geoid");
+ addAxisTypes('E', "geox", "projection_x_coordinate");
+ addAxisTypes('N', "geoy", "projection_y_coordinate");
addAxisTypes('t', "t", "time", "runtime");
addAxisTypes('x', "x");
addAxisTypes('y', "y");
@@ -255,31 +256,49 @@ next: for (final String name : axisNames) {
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.
+ * exists, il will have precedence over all other heuristic rules in this method
because it is the most specific
+ * information about axis type. Otherwise the "standard_name" attribute is our
first fallback since valid values
+ * are standardized to "longitude" and "latitude" among others.
*/
char abbreviation = getAxisType(axis.getAxisType());
if (abbreviation == 0) {
- 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 = 'φ';
- }
- }
+ abbreviation = getAxisType(axis.getAttributeAsString(CF.STANDARD_NAME));
/*
- * 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 the abbreviation is still unknown, look at the "long_name", "description"
or "title" attribute. Those
+ * attributes are not standardized, so they are less reliable than "standard_name".
But they are still more
+ * reliable that the variable name since the long name may be "Longitude"
or "Latitude" while the variable
+ * name is only "x" or "y".
*/
if (abbreviation == 0) {
abbreviation = getAxisType(axis.getDescription());
if (abbreviation == 0) {
- abbreviation = getAxisType(axis.getName());
+ /*
+ * Actually the "degree_east" and "degree_north" units of measurement
are the most reliable way to
+ * identify geographic system, but we nevertheless check them almost
last because the direction is
+ * already verified by Axis constructor. By checking the variable
attributes first, we give a chance
+ * to Axis constructor to report a warning if there is an inconsistency.
+ */
+ 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 = 'φ';
+ }
+ }
+ /*
+ * We test the variable name last because that name is more at risk
of being an uninformative "x" or "y" name.
+ * If even the variable name is not sufficient, we use some easy
to recognize units.
+ */
if (abbreviation == 0) {
- if (Units.isTemporal(axis.getUnit())) {
- abbreviation = 't';
+ abbreviation = getAxisType(axis.getName());
+ if (abbreviation == 0) {
+ final Unit<?> unit = axis.getUnit();
+ if (Units.isTemporal(unit)) {
+ abbreviation = 't';
+ } else if (Units.isPressure(unit)) {
+ abbreviation = 'z';
+ }
}
}
}
|