tds/src/main/java/thredds/server/opendap/NcDDS.java
private void createFromDataset(NetcdfDataset ncd) {
        // get coordinate variables, disjunct from variables
    for (CoordinateAxis axis : ncd.getCoordinateAxes()) {
      coordvars.put(axis.getShortName(), axis);
    }

    // dup the variable set
    ddsvars = new ArrayList<>(50);

    // collect grid array variables and set of coordinate variables used in grids
    for (Variable v : ncd.getVariables()) {
      if (coordvars.containsKey(v.getShortName())) continue;  // skip coordinate variables
      ddsvars.add(v);

      boolean isgridarray = (v.getRank() > 1) && (v.getDataType() != DataType.STRUCTURE) && (v.getParentStructure() == null);
      if (!isgridarray) continue;
      List<Dimension> dimset = v.getDimensions();
      int rank = dimset.size();
      for (int i = 0; isgridarray && i < rank; i++) {
        Dimension dim = dimset.get(i);
        if (dim.getShortName() == null)
          isgridarray = false;
        else {
          Variable gv = coordvars.get(dim.getShortName());
          if (gv == null)
            isgridarray = false;
        }
      }
      if (isgridarray) {
        gridarrays.put(v.getFullName(), v);
        for (Dimension dim : dimset) {
          Variable gv = coordvars.get(dim.getShortName());
          if (gv != null)
            used.put(gv.getFullName(), gv);
        }
      }
    }

        // Create the set of coordinates
    for (Variable cv : ncd.getCoordinateAxes()) {
      BaseType bt = createVariable(ncd, cv);
      addVariable(bt);
    }

    // Create the set of variables
    for (Variable cv : ddsvars) {
      BaseType bt = createVariable(ncd, cv);
      addVariable(bt);
    }
  }
private void createFromDataset(NetcdfDataset ncd) {
        // get coordinate variables, disjunct from variables
    for (CoordinateAxis axis : ncd.getCoordinateAxes()) {
      coordvars.put(axis.getShortName(), axis);
    }

    // dup the variable set
    ddsvars = new ArrayList<>(50);

    // collect grid array variables and set of coordinate variables used in grids
    for (Variable v : ncd.getVariables()) {
      if (coordvars.containsKey(v.getShortName())) continue;  // skip coordinate variables
      ddsvars.add(v);

      boolean isgridarray = (v.getRank() > 1) && (v.getDataType() != DataType.STRUCTURE) && (v.getParentStructure() == null);
      if (!isgridarray) continue;
      List<Dimension> dimset = v.getDimensions();
      int rank = dimset.size();
      for (int i = 0; isgridarray && i < rank; i++) {
        Dimension dim = dimset.get(i);
        if (dim.getShortName() == null)
          isgridarray = false;
        else {
          Variable gv = coordvars.get(dim.getShortName());
          if (gv == null)
            isgridarray = false;
        }
      }
      if (isgridarray) {
        gridarrays.put(v.getFullName(), v);
        for (Dimension dim : dimset) {
          Variable gv = coordvars.get(dim.getShortName());
          if (gv != null)
            used.put(gv.getFullName(), gv);
        }
      }
    }

        // Create the set of coordinates
    for (Variable cv : ncd.getCoordinateAxes()) {
      BaseType bt = createVariable(ncd, cv);
      addVariable(bt);
    }

    // Create the set of variables
    for (Variable cv : ddsvars) {
      BaseType bt = createVariable(ncd, cv);
      addVariable(bt);
    }
  }
private void createFromDataset ( NetcdfDataset ncd ) { // get coordinate variables, disjunct from variables for ( CoordinateAxis axis : ncd . getCoordinateAxes ( ) ) { coordvars . put ( axis . getShortName ( ) , axis ) ; } // dup the variable set ddsvars = new ArrayList <> ( 50 ) ; // collect grid array variables and set of coordinate variables used in grids for ( Variable v : ncd . getVariables ( ) ) { if ( coordvars . containsKey ( v . getShortName ( ) ) ) continue ; // skip coordinate variables ddsvars . add ( v ) ; boolean isgridarray = ( v . getRank ( ) > 1 ) && ( v . getDataType ( ) != DataType . STRUCTURE ) && ( v . getParentStructure ( ) == null ) ; if ( ! isgridarray ) continue ; List < Dimension > dimset = v . getDimensions ( ) ; int rank = dimset . size ( ) ; for ( int i = 0 ; isgridarray && i < rank ; i ++ ) { Dimension dim = dimset . get ( i ) ; if ( dim . getShortName ( ) == null ) isgridarray = false ; else { Variable gv = coordvars . get ( dim . getShortName ( ) ) ; if ( gv == null ) isgridarray = false ; } } if ( isgridarray ) { gridarrays . put ( v . getFullName ( ) , v ) ; for ( Dimension dim : dimset ) { Variable gv = coordvars . get ( dim . getShortName ( ) ) ; if ( gv != null ) used . put ( gv . getFullName ( ) , gv ) ; } } } // Create the set of coordinates for ( Variable cv : ncd . getCoordinateAxes ( ) ) { BaseType bt = createVariable ( ncd , cv ) ; addVariable ( bt ) ; } // Create the set of variables for ( Variable cv : ddsvars ) { BaseType bt = createVariable ( ncd , cv ) ; addVariable ( bt ) ; } }
take advantage of the work already done by NetcdfDataset
take advantage of the work already done by NetcdfDataset