cdm/src/main/java/ucar/nc2/dataset/CoordSysBuilder.java
protected void assignCoordinateSystemsExplicit(NetcdfDataset ncDataset) {

    // look for explicit references to coord sys variables
    for (VarProcess vp : varList) {
      if (vp.coordSys != null && !vp.isCoordinateTransform) {
        StringTokenizer stoker = new StringTokenizer(vp.coordSys);
        while (stoker.hasMoreTokens()) {
          String vname = stoker.nextToken();
          VarProcess ap = findVarProcess(vname, vp);
          if (ap == null) {
            parseInfo.format("***Cant find Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            userAdvice.format("***Cant find Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            continue;
          }
          if (ap.cs == null) {
            parseInfo.format("***Not a Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            userAdvice.format("***Not a Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            continue;
          }

          VariableEnhanced ve = (VariableEnhanced) vp.v;
          ve.addCoordinateSystem(ap.cs);
        }
      }
    }

    // look for explicit references from coord sys variables to data variables
    for (VarProcess csVar : varList) {
      if (!csVar.isCoordinateSystem || (csVar.coordSysFor == null))
        continue;

      // get list of dimensions from '_CoordinateSystemFor' attribute
      List<Dimension> dimList = new ArrayList<>(6);
      StringTokenizer stoker = new StringTokenizer(csVar.coordSysFor);
      while (stoker.hasMoreTokens()) {
        String dname = stoker.nextToken();
        Dimension dim = ncDataset.getRootGroup().findDimension(dname);
        if (dim == null) {
          parseInfo.format("***Cant find Dimension %s referenced from CoordSys var= %s%n", dname, csVar.v.getFullName());
          userAdvice.format("***Cant find Dimension %s referenced from CoordSys var= %s%n", dname, csVar.v.getFullName());
        } else
          dimList.add(dim);
      }

      // look for vars with those dimensions
      for (VarProcess vp : varList) {
        if (!vp.hasCoordinateSystem() && vp.isData() && (csVar.cs != null)) {
          VariableEnhanced ve = (VariableEnhanced) vp.v;
          if (CoordinateSystem.isSubset(dimList, vp.v.getDimensionsAll()) && CoordinateSystem.isSubset(vp.v.getDimensionsAll(), dimList))
            ve.addCoordinateSystem(csVar.cs);
        }
      }
    }

    // look for explicit listings of coordinate axes
    for (VarProcess vp : varList) {
      VariableEnhanced ve = (VariableEnhanced) vp.v;

      if (!vp.hasCoordinateSystem() && (vp.coordAxes != null) && vp.isData()) {
        List<CoordinateAxis> dataAxesList = getAxes(vp, vp.coordAxes, vp.v.getFullName());
        if (dataAxesList.size() > 1) {
          String coordSysName = CoordinateSystem.makeName(dataAxesList);
          CoordinateSystem cs = ncDataset.findCoordinateSystem(coordSysName);
          if (cs != null) {
            ve.addCoordinateSystem(cs);
            parseInfo.format(" assigned explicit CoordSystem '%s' for var= %s%n", cs.getName(), vp.v.getFullName());
          } else {
            CoordinateSystem csnew = new CoordinateSystem(ncDataset, dataAxesList, null);
            ve.addCoordinateSystem(csnew);
            ncDataset.addCoordinateSystem(csnew);
            parseInfo.format(" created explicit CoordSystem '%s' for var= %s%n", csnew.getName(), vp.v.getFullName());
          }
        }
      }
    }
  }
protected void assignCoordinateSystemsExplicit(NetcdfDataset ncDataset) {

    // look for explicit references to coord sys variables
    for (VarProcess vp : varList) {
      if (vp.coordSys != null && !vp.isCoordinateTransform) {
        StringTokenizer stoker = new StringTokenizer(vp.coordSys);
        while (stoker.hasMoreTokens()) {
          String vname = stoker.nextToken();
          VarProcess ap = findVarProcess(vname, vp);
          if (ap == null) {
            parseInfo.format("***Cant find Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            userAdvice.format("***Cant find Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            continue;
          }
          if (ap.cs == null) {
            parseInfo.format("***Not a Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            userAdvice.format("***Not a Coordinate System variable %s referenced from var= %s%n", vname, vp.v.getFullName());
            continue;
          }

          VariableEnhanced ve = (VariableEnhanced) vp.v;
          ve.addCoordinateSystem(ap.cs);
        }
      }
    }

    // look for explicit references from coord sys variables to data variables
    for (VarProcess csVar : varList) {
      if (!csVar.isCoordinateSystem || (csVar.coordSysFor == null))
        continue;

      // get list of dimensions from '_CoordinateSystemFor' attribute
      List<Dimension> dimList = new ArrayList<>(6);
      StringTokenizer stoker = new StringTokenizer(csVar.coordSysFor);
      while (stoker.hasMoreTokens()) {
        String dname = stoker.nextToken();
        Dimension dim = ncDataset.getRootGroup().findDimension(dname);
        if (dim == null) {
          parseInfo.format("***Cant find Dimension %s referenced from CoordSys var= %s%n", dname, csVar.v.getFullName());
          userAdvice.format("***Cant find Dimension %s referenced from CoordSys var= %s%n", dname, csVar.v.getFullName());
        } else
          dimList.add(dim);
      }

      // look for vars with those dimensions
      for (VarProcess vp : varList) {
        if (!vp.hasCoordinateSystem() && vp.isData() && (csVar.cs != null)) {
          VariableEnhanced ve = (VariableEnhanced) vp.v;
          if (CoordinateSystem.isSubset(dimList, vp.v.getDimensionsAll()) && CoordinateSystem.isSubset(vp.v.getDimensionsAll(), dimList))
            ve.addCoordinateSystem(csVar.cs);
        }
      }
    }

    // look for explicit listings of coordinate axes
    for (VarProcess vp : varList) {
      VariableEnhanced ve = (VariableEnhanced) vp.v;

      if (!vp.hasCoordinateSystem() && (vp.coordAxes != null) && vp.isData()) {
        List<CoordinateAxis> dataAxesList = getAxes(vp, vp.coordAxes, vp.v.getFullName());
        if (dataAxesList.size() > 1) {
          String coordSysName = CoordinateSystem.makeName(dataAxesList);
          CoordinateSystem cs = ncDataset.findCoordinateSystem(coordSysName);
          if (cs != null) {
            ve.addCoordinateSystem(cs);
            parseInfo.format(" assigned explicit CoordSystem '%s' for var= %s%n", cs.getName(), vp.v.getFullName());
          } else {
            CoordinateSystem csnew = new CoordinateSystem(ncDataset, dataAxesList, null);
            ve.addCoordinateSystem(csnew);
            ncDataset.addCoordinateSystem(csnew);
            parseInfo.format(" created explicit CoordSystem '%s' for var= %s%n", csnew.getName(), vp.v.getFullName());
          }
        }
      }
    }
  }
protected void assignCoordinateSystemsExplicit ( NetcdfDataset ncDataset ) { // look for explicit references to coord sys variables
 for ( VarProcess vp : varList ) { if ( vp . coordSys != null && ! vp . isCoordinateTransform ) { StringTokenizer stoker = new StringTokenizer ( vp . coordSys ) ; while ( stoker . hasMoreTokens ( ) ) { String vname = stoker . nextToken ( ) ; VarProcess ap = findVarProcess ( vname , vp ) ; if ( ap == null ) { parseInfo . format ( "***Cant find Coordinate System variable %s referenced from var= %s%n" , vname , vp . v . getFullName ( ) ) ; userAdvice . format ( "***Cant find Coordinate System variable %s referenced from var= %s%n" , vname , vp . v . getFullName ( ) ) ; continue ; } if ( ap . cs == null ) { parseInfo . format ( "***Not a Coordinate System variable %s referenced from var= %s%n" , vname , vp . v . getFullName ( ) ) ; userAdvice . format ( "***Not a Coordinate System variable %s referenced from var= %s%n" , vname , vp . v . getFullName ( ) ) ; continue ; } VariableEnhanced ve = ( VariableEnhanced ) vp . v ; ve . addCoordinateSystem ( ap . cs ) ; } } } // look for explicit references from coord sys variables to data variables
 for ( VarProcess csVar : varList ) { if ( ! csVar . isCoordinateSystem || ( csVar . coordSysFor == null ) ) continue ; // get list of dimensions from '_CoordinateSystemFor' attribute
 List < Dimension > dimList = new ArrayList <> ( 6 ) ; StringTokenizer stoker = new StringTokenizer ( csVar . coordSysFor ) ; while ( stoker . hasMoreTokens ( ) ) { String dname = stoker . nextToken ( ) ; Dimension dim = ncDataset . getRootGroup ( ) . findDimension ( dname ) ; if ( dim == null ) { parseInfo . format ( "***Cant find Dimension %s referenced from CoordSys var= %s%n" , dname , csVar . v . getFullName ( ) ) ; userAdvice . format ( "***Cant find Dimension %s referenced from CoordSys var= %s%n" , dname , csVar . v . getFullName ( ) ) ; } else dimList . add ( dim ) ; } // look for vars with those dimensions
 for ( VarProcess vp : varList ) { if ( ! vp . hasCoordinateSystem ( ) && vp . isData ( ) && ( csVar . cs != null ) ) { VariableEnhanced ve = ( VariableEnhanced ) vp . v ; if ( CoordinateSystem . isSubset ( dimList , vp . v . getDimensionsAll ( ) ) && CoordinateSystem . isSubset ( vp . v . getDimensionsAll ( ) , dimList ) ) ve . addCoordinateSystem ( csVar . cs ) ; } } } // look for explicit listings of coordinate axes
 for ( VarProcess vp : varList ) { VariableEnhanced ve = ( VariableEnhanced ) vp . v ; if ( ! vp . hasCoordinateSystem ( ) && ( vp . coordAxes != null ) && vp . isData ( ) ) { List < CoordinateAxis > dataAxesList = getAxes ( vp , vp . coordAxes , vp . v . getFullName ( ) ) ; if ( dataAxesList . size ( ) > 1 ) { String coordSysName = CoordinateSystem . makeName ( dataAxesList ) ; CoordinateSystem cs = ncDataset . findCoordinateSystem ( coordSysName ) ; if ( cs != null ) { ve . addCoordinateSystem ( cs ) ; parseInfo . format ( " assigned explicit CoordSystem '%s' for var= %s%n" , cs . getName ( ) , vp . v . getFullName ( ) ) ; } else { CoordinateSystem csnew = new CoordinateSystem ( ncDataset , dataAxesList , null ) ; ve . addCoordinateSystem ( csnew ) ; ncDataset . addCoordinateSystem ( csnew ) ; parseInfo . format ( " created explicit CoordSystem '%s' for var= %s%n" , csnew . getName ( ) , vp . v . getFullName ( ) ) ; } } } } }
Assign explicit CoordinateSystem objects to variables.

@param ncDataset why
Assign explicit CoordinateSystem objects to variables .