static public String getCoordinateName(NetcdfDataset ds, AxisType a) {
    List<Variable> varList = ds.getVariables();
    for (Variable v : varList) {
      if (v instanceof Structure) {
        List<Variable> vars = ((Structure) v).getVariables();
        for (Variable vs : vars) {
          String axisType = ds.findAttValueIgnoreCase(vs, _Coordinate.AxisType, null);
          if ((axisType != null) && axisType.equals(a.toString()))
            return vs.getShortName();
        }
      } else {
        String axisType = ds.findAttValueIgnoreCase(v, _Coordinate.AxisType, null);
        if ((axisType != null) && axisType.equals(a.toString()))
          return v.getShortName();
      }
    }

    if (a == AxisType.Lat)
      return findVariableName( ds, "latitude");

    if (a == AxisType.Lon)
      return findVariableName( ds, "longitude");

    if (a == AxisType.Time)
      return findVariableName( ds, "time");

    if (a == AxisType.Height) {
      Variable v = findVariable( ds, "altitude");
      if (null == v) v = findVariable( ds, "depth");
      if (v != null) return v.getShortName();
    }

    // I think the CF part is done by the CoordSysBuilder adding the _CoordinateAxisType attrinutes.
    return null;
  }
static public String getCoordinateName ( NetcdfDataset ds , AxisType a ) { List < Variable > varList = ds . getVariables ( ) ; for ( Variable v : varList ) { if ( v instanceof Structure ) { List < Variable > vars = ( ( Structure ) v ) . getVariables ( ) ; for ( Variable vs : vars ) { String axisType = ds . findAttValueIgnoreCase ( vs , _Coordinate . AxisType , null ) ; if ( ( axisType != null ) && axisType . equals ( a . toString ( ) ) ) return vs . getShortName ( ) ; } } else { String axisType = ds . findAttValueIgnoreCase ( v , _Coordinate . AxisType , null ) ; if ( ( axisType != null ) && axisType . equals ( a . toString ( ) ) ) return v . getShortName ( ) ; } } if ( a == AxisType . Lat ) return findVariableName ( ds , "latitude" ) ; if ( a == AxisType . Lon ) return findVariableName ( ds , "longitude" ) ; if ( a == AxisType . Time ) return findVariableName ( ds , "time" ) ; if ( a == AxisType . Height ) { Variable v = findVariable ( ds , "altitude" ) ; if ( null == v ) v = findVariable ( ds , "depth" ) ; if ( v != null ) return v . getShortName ( ) ; } return null ; }
Tries to find the coordinate variable of the specified type.
@param ds search in this dataset
@param a AxisType.LAT, LON, HEIGHT, or TIME
@return coordinate variable, or null if not found.