visad/src/main/java/ucar/nc2/iosp/gempak/GempakStationFileIOSP.java
protected Variable makeStationVariable(String varname, Dimension firstDim) {
    String longName = varname;
    String unit = null;
    DataType type = DataType.CHAR;
    List<Dimension> dims = new ArrayList<>();
    List<Attribute> attrs = new ArrayList<>();
    if (firstDim != null) {
      dims.add(firstDim);
    }

    switch (varname) {
      case GempakStation.STID:
        longName = "Station identifier";
        dims.add(DIM_LEN8);
        break;
      case GempakStation.STNM:
        longName = "WMO station id";
        type = DataType.INT;
        break;
      case GempakStation.SLAT:
        longName = "latitude";
        unit = CDM.LAT_UNITS;
        type = DataType.FLOAT;
        attrs.add(new Attribute(CF.STANDARD_NAME, "latitude"));
        break;
      case GempakStation.SLON:
        longName = "longitude";
        unit = CDM.LON_UNITS;
        type = DataType.FLOAT;
        attrs.add(new Attribute(CF.STANDARD_NAME, "longitude"));
        break;
      case GempakStation.SELV:
        longName = "altitude";
        unit = "meter";
        type = DataType.FLOAT;
        attrs.add(new Attribute(CF.POSITIVE, CF.POSITIVE_UP));
        attrs.add(new Attribute(CF.STANDARD_NAME, CF.STATION_ALTITUDE));
        break;
      case GempakStation.STAT:
        longName = "state or province";
        dims.add(DIM_LEN2);
        break;
      case GempakStation.COUN:
        longName = "country code";
        dims.add(DIM_LEN2);
        break;
      case GempakStation.STD2:
        longName = "Extended station id";
        dims.add(DIM_LEN4);
        break;
      case GempakStation.SPRI:
        longName = "Station priority";
        type = DataType.INT;
        break;
      case GempakStation.SWFO:
        longName = "WFO code";
        dims.add(DIM_LEN4);
        break;
      case GempakStation.WFO2:
        longName = "Second WFO code";
        dims.add(DIM_LEN4);
        break;
    }
    Variable v = new Variable(ncfile, null, null, varname);
    v.setDataType(type);
    v.addAttribute(new Attribute(CDM.LONG_NAME, longName));
    if (unit != null) {
      v.addAttribute(new Attribute(CDM.UNITS, unit));
    }
    if (type.equals(DataType.FLOAT)) {
      v.addAttribute(new Attribute(CDM.MISSING_VALUE, RMISS));
    } else if (type.equals(DataType.INT)) {
      v.addAttribute(new Attribute(CDM.MISSING_VALUE, IMISS));
    }
    if (!attrs.isEmpty()) {
      for (Attribute attr : attrs) {
        v.addAttribute(attr);
      }
    }
    if (!dims.isEmpty()) {
      v.setDimensions(dims);
    } else {
      v.setDimensions((String) null);
    }
    return v;
  }
protected Variable makeStationVariable(String varname, Dimension firstDim) {
    String longName = varname;
    String unit = null;
    DataType type = DataType.CHAR;
    List<Dimension> dims = new ArrayList<>();
    List<Attribute> attrs = new ArrayList<>();
    if (firstDim != null) {
      dims.add(firstDim);
    }

    switch (varname) {
      case GempakStation.STID:
        longName = "Station identifier";
        dims.add(DIM_LEN8);
        break;
      case GempakStation.STNM:
        longName = "WMO station id";
        type = DataType.INT;
        break;
      case GempakStation.SLAT:
        longName = "latitude";
        unit = CDM.LAT_UNITS;
        type = DataType.FLOAT;
        attrs.add(new Attribute(CF.STANDARD_NAME, "latitude"));
        break;
      case GempakStation.SLON:
        longName = "longitude";
        unit = CDM.LON_UNITS;
        type = DataType.FLOAT;
        attrs.add(new Attribute(CF.STANDARD_NAME, "longitude"));
        break;
      case GempakStation.SELV:
        longName = "altitude";
        unit = "meter";
        type = DataType.FLOAT;
        attrs.add(new Attribute(CF.POSITIVE, CF.POSITIVE_UP));
        attrs.add(new Attribute(CF.STANDARD_NAME, CF.STATION_ALTITUDE));
        break;
      case GempakStation.STAT:
        longName = "state or province";
        dims.add(DIM_LEN2);
        break;
      case GempakStation.COUN:
        longName = "country code";
        dims.add(DIM_LEN2);
        break;
      case GempakStation.STD2:
        longName = "Extended station id";
        dims.add(DIM_LEN4);
        break;
      case GempakStation.SPRI:
        longName = "Station priority";
        type = DataType.INT;
        break;
      case GempakStation.SWFO:
        longName = "WFO code";
        dims.add(DIM_LEN4);
        break;
      case GempakStation.WFO2:
        longName = "Second WFO code";
        dims.add(DIM_LEN4);
        break;
    }
    Variable v = new Variable(ncfile, null, null, varname);
    v.setDataType(type);
    v.addAttribute(new Attribute(CDM.LONG_NAME, longName));
    if (unit != null) {
      v.addAttribute(new Attribute(CDM.UNITS, unit));
    }
    if (type.equals(DataType.FLOAT)) {
      v.addAttribute(new Attribute(CDM.MISSING_VALUE, RMISS));
    } else if (type.equals(DataType.INT)) {
      v.addAttribute(new Attribute(CDM.MISSING_VALUE, IMISS));
    }
    if (!attrs.isEmpty()) {
      for (Attribute attr : attrs) {
        v.addAttribute(attr);
      }
    }
    if (!dims.isEmpty()) {
      v.setDimensions(dims);
    } else {
      v.setDimensions((String) null);
    }
    return v;
  }
protected Variable makeStationVariable ( String varname , Dimension firstDim ) { String longName = varname ; String unit = null ; DataType type = DataType . CHAR ; List < Dimension > dims = new ArrayList <> ( ) ; List < Attribute > attrs = new ArrayList <> ( ) ; if ( firstDim != null ) { dims . add ( firstDim ) ; } switch ( varname ) { case GempakStation . STID : longName = "Station identifier" ; dims . add ( DIM_LEN8 ) ; break ; case GempakStation . STNM : longName = "WMO station id" ; type = DataType . INT ; break ; case GempakStation . SLAT : longName = "latitude" ; unit = CDM . LAT_UNITS ; type = DataType . FLOAT ; attrs . add ( new Attribute ( CF . STANDARD_NAME , "latitude" ) ) ; break ; case GempakStation . SLON : longName = "longitude" ; unit = CDM . LON_UNITS ; type = DataType . FLOAT ; attrs . add ( new Attribute ( CF . STANDARD_NAME , "longitude" ) ) ; break ; case GempakStation . SELV : longName = "altitude" ; unit = "meter" ; type = DataType . FLOAT ; attrs . add ( new Attribute ( CF . POSITIVE , CF . POSITIVE_UP ) ) ; attrs . add ( new Attribute ( CF . STANDARD_NAME , CF . STATION_ALTITUDE ) ) ; break ; case GempakStation . STAT : longName = "state or province" ; dims . add ( DIM_LEN2 ) ; break ; case GempakStation . COUN : longName = "country code" ; dims . add ( DIM_LEN2 ) ; break ; case GempakStation . STD2 : longName = "Extended station id" ; dims . add ( DIM_LEN4 ) ; break ; case GempakStation . SPRI : longName = "Station priority" ; type = DataType . INT ; break ; case GempakStation . SWFO : longName = "WFO code" ; dims . add ( DIM_LEN4 ) ; break ; case GempakStation . WFO2 : longName = "Second WFO code" ; dims . add ( DIM_LEN4 ) ; break ; } Variable v = new Variable ( ncfile , null , null , varname ) ; v . setDataType ( type ) ; v . addAttribute ( new Attribute ( CDM . LONG_NAME , longName ) ) ; if ( unit != null ) { v . addAttribute ( new Attribute ( CDM . UNITS , unit ) ) ; } if ( type . equals ( DataType . FLOAT ) ) { v . addAttribute ( new Attribute ( CDM . MISSING_VALUE , RMISS ) ) ; } else if ( type . equals ( DataType . INT ) ) { v . addAttribute ( new Attribute ( CDM . MISSING_VALUE , IMISS ) ) ; } if ( ! attrs . isEmpty ( ) ) { for ( Attribute attr : attrs ) { v . addAttribute ( attr ) ; } } if ( ! dims . isEmpty ( ) ) { v . setDimensions ( dims ) ; } else { v . setDimensions ( ( String ) null ) ; } return v ; }
Make a station variable

@param varname  variable name
@param firstDim station dimension
@return corresponding variable
Make a station variable