visad/src/main/java/ucar/nc2/iosp/gempak/GempakStationFileIOSP.java
protected List<Variable> makeStationVars(List<GempakStation> stations, Dimension dim) {
    int numStations = stations.size();
    List<Variable> vars = new ArrayList<>();
    List<String> stnKeyNames = gemreader.getStationKeyNames();
    for (String varName : stnKeyNames) {
      Variable v = makeStationVariable(varName, dim);
      Attribute stIDAttr = new Attribute(CF.STANDARD_NAME, "station_id");
      if (varName.equals(GempakStation.STID)) {  // Use STID as the station_id for the dataset.
        v.addAttribute(stIDAttr);
      }
      vars.add(v);
    }
    // see if we fill these in completely now
    if ((dim != null) && (numStations > 0)) {
      for (Variable v : vars) {
        Array varArray;
        if (v.getDataType().equals(DataType.CHAR)) {
          int[] shape = v.getShape();
          varArray = new ArrayChar.D2(shape[0], shape[1]);
        } else {
          varArray = get1DArray(v.getDataType(), numStations);
        }
        assert varArray != null;

        int index = 0;
        String varname = v.getFullName();
        for (GempakStation stn : stations) {
          String test = "";
          switch (varname) {
            case GempakStation.STID:
              test = stn.getName();
              break;
            case GempakStation.STNM:
              ((ArrayInt.D1) varArray).set(index, stn.getSTNM());
              break;
            case GempakStation.SLAT:
              ((ArrayFloat.D1) varArray).set(index, (float) stn.getLatitude());
              break;
            case GempakStation.SLON:
              ((ArrayFloat.D1) varArray).set(index, (float) stn.getLongitude());
              break;
            case GempakStation.SELV:
              ((ArrayFloat.D1) varArray).set(index, (float) stn.getAltitude());
              break;
            case GempakStation.STAT:
              test = stn.getSTAT();
              break;
            case GempakStation.COUN:
              test = stn.getCOUN();
              break;
            case GempakStation.STD2:
              test = stn.getSTD2();
              break;
            case GempakStation.SPRI:
              ((ArrayInt.D1) varArray).set(index, stn.getSPRI());
              break;
            case GempakStation.SWFO:
              test = stn.getSWFO();
              break;
            case GempakStation.WFO2:
              test = stn.getWFO2();
              break;
          }
          if (!test.equals("")) {
            ((ArrayChar.D2) varArray).setString(index, test);
          }
          index++;
        }
        v.setCachedData(varArray, false);
      }
    }
    return vars;
  }
protected List<Variable> makeStationVars(List<GempakStation> stations, Dimension dim) {
    int numStations = stations.size();
    List<Variable> vars = new ArrayList<>();
    List<String> stnKeyNames = gemreader.getStationKeyNames();
    for (String varName : stnKeyNames) {
      Variable v = makeStationVariable(varName, dim);
      Attribute stIDAttr = new Attribute(CF.STANDARD_NAME, "station_id");
      if (varName.equals(GempakStation.STID)) {  // Use STID as the station_id for the dataset.
        v.addAttribute(stIDAttr);
      }
      vars.add(v);
    }
    // see if we fill these in completely now
    if ((dim != null) && (numStations > 0)) {
      for (Variable v : vars) {
        Array varArray;
        if (v.getDataType().equals(DataType.CHAR)) {
          int[] shape = v.getShape();
          varArray = new ArrayChar.D2(shape[0], shape[1]);
        } else {
          varArray = get1DArray(v.getDataType(), numStations);
        }
        assert varArray != null;

        int index = 0;
        String varname = v.getFullName();
        for (GempakStation stn : stations) {
          String test = "";
          switch (varname) {
            case GempakStation.STID:
              test = stn.getName();
              break;
            case GempakStation.STNM:
              ((ArrayInt.D1) varArray).set(index, stn.getSTNM());
              break;
            case GempakStation.SLAT:
              ((ArrayFloat.D1) varArray).set(index, (float) stn.getLatitude());
              break;
            case GempakStation.SLON:
              ((ArrayFloat.D1) varArray).set(index, (float) stn.getLongitude());
              break;
            case GempakStation.SELV:
              ((ArrayFloat.D1) varArray).set(index, (float) stn.getAltitude());
              break;
            case GempakStation.STAT:
              test = stn.getSTAT();
              break;
            case GempakStation.COUN:
              test = stn.getCOUN();
              break;
            case GempakStation.STD2:
              test = stn.getSTD2();
              break;
            case GempakStation.SPRI:
              ((ArrayInt.D1) varArray).set(index, stn.getSPRI());
              break;
            case GempakStation.SWFO:
              test = stn.getSWFO();
              break;
            case GempakStation.WFO2:
              test = stn.getWFO2();
              break;
          }
          if (!test.equals("")) {
            ((ArrayChar.D2) varArray).setString(index, test);
          }
          index++;
        }
        v.setCachedData(varArray, false);
      }
    }
    return vars;
  }
protected List < Variable > makeStationVars ( List < GempakStation > stations , Dimension dim ) { int numStations = stations . size ( ) ; List < Variable > vars = new ArrayList <> ( ) ; List < String > stnKeyNames = gemreader . getStationKeyNames ( ) ; for ( String varName : stnKeyNames ) { Variable v = makeStationVariable ( varName , dim ) ; Attribute stIDAttr = new Attribute ( CF . STANDARD_NAME , "station_id" ) ; if ( varName . equals ( GempakStation . STID ) ) { // Use STID as the station_id for the dataset.
 v . addAttribute ( stIDAttr ) ; } vars . add ( v ) ; } // see if we fill these in completely now
 if ( ( dim != null ) && ( numStations > 0 ) ) { for ( Variable v : vars ) { Array varArray ; if ( v . getDataType ( ) . equals ( DataType . CHAR ) ) { int [ ] shape = v . getShape ( ) ; varArray = new ArrayChar . D2 ( shape [ 0 ] , shape [ 1 ] ) ; } else { varArray = get1DArray ( v . getDataType ( ) , numStations ) ; } assert varArray != null ; int index = 0 ; String varname = v . getFullName ( ) ; for ( GempakStation stn : stations ) { String test = "" ; switch ( varname ) { case GempakStation . STID : test = stn . getName ( ) ; break ; case GempakStation . STNM : ( ( ArrayInt . D1 ) varArray ) . set ( index , stn . getSTNM ( ) ) ; break ; case GempakStation . SLAT : ( ( ArrayFloat . D1 ) varArray ) . set ( index , ( float ) stn . getLatitude ( ) ) ; break ; case GempakStation . SLON : ( ( ArrayFloat . D1 ) varArray ) . set ( index , ( float ) stn . getLongitude ( ) ) ; break ; case GempakStation . SELV : ( ( ArrayFloat . D1 ) varArray ) . set ( index , ( float ) stn . getAltitude ( ) ) ; break ; case GempakStation . STAT : test = stn . getSTAT ( ) ; break ; case GempakStation . COUN : test = stn . getCOUN ( ) ; break ; case GempakStation . STD2 : test = stn . getSTD2 ( ) ; break ; case GempakStation . SPRI : ( ( ArrayInt . D1 ) varArray ) . set ( index , stn . getSPRI ( ) ) ; break ; case GempakStation . SWFO : test = stn . getSWFO ( ) ; break ; case GempakStation . WFO2 : test = stn . getWFO2 ( ) ; break ; } if ( ! test . equals ( "" ) ) { ( ( ArrayChar . D2 ) varArray ) . setString ( index , test ) ; } index ++ ; } v . setCachedData ( varArray , false ) ; } } return vars ; }
Make the station variables from a representative station

@param stations list of stations
@param dim      station dimension
@return the list of variables
Make the station variables from a representative station