cdm/src/main/java/ucar/nc2/dataset/NetcdfDataset.java
public CoordinateAxis addCoordinateAxis(VariableDS v) {
    if (v == null) return null;
    CoordinateAxis oldVar = findCoordinateAxis(v.getFullName());
    if (oldVar != null)
      coordAxes.remove(oldVar);

    CoordinateAxis ca = (v instanceof CoordinateAxis) ? (CoordinateAxis) v : CoordinateAxis.factory(this, v);
    coordAxes.add(ca);

    if (v.isMemberOfStructure()) {
      Structure parentOrg = v.getParentStructure();  // gotta be careful to get the wrapping parent
      Structure parent = (Structure) findVariable(parentOrg.getFullNameEscaped());
      parent.replaceMemberVariable(ca);

    } else {
      removeVariable(v.getParentGroup(), v.getShortName()); // remove by short name if it exists
      addVariable(ca.getParentGroup(), ca);
    }

    return ca;
  }
public CoordinateAxis addCoordinateAxis(VariableDS v) {
    if (v == null) return null;
    CoordinateAxis oldVar = findCoordinateAxis(v.getFullName());
    if (oldVar != null)
      coordAxes.remove(oldVar);

    CoordinateAxis ca = (v instanceof CoordinateAxis) ? (CoordinateAxis) v : CoordinateAxis.factory(this, v);
    coordAxes.add(ca);

    if (v.isMemberOfStructure()) {
      Structure parentOrg = v.getParentStructure();  // gotta be careful to get the wrapping parent
      Structure parent = (Structure) findVariable(parentOrg.getFullNameEscaped());
      parent.replaceMemberVariable(ca);

    } else {
      removeVariable(v.getParentGroup(), v.getShortName()); // remove by short name if it exists
      addVariable(ca.getParentGroup(), ca);
    }

    return ca;
  }
public CoordinateAxis addCoordinateAxis ( VariableDS v ) { if ( v == null ) return null ; CoordinateAxis oldVar = findCoordinateAxis ( v . getFullName ( ) ) ; if ( oldVar != null ) coordAxes . remove ( oldVar ) ; CoordinateAxis ca = ( v instanceof CoordinateAxis ) ? ( CoordinateAxis ) v : CoordinateAxis . factory ( this , v ) ; coordAxes . add ( ca ) ; if ( v . isMemberOfStructure ( ) ) { Structure parentOrg = v . getParentStructure ( ) ; // gotta be careful to get the wrapping parent Structure parent = ( Structure ) findVariable ( parentOrg . getFullNameEscaped ( ) ) ; parent . replaceMemberVariable ( ca ) ; } else { removeVariable ( v . getParentGroup ( ) , v . getShortName ( ) ) ; // remove by short name if it exists addVariable ( ca . getParentGroup ( ) , ca ) ; } return ca ; }
Add a CoordinateAxis to the dataset, by turning the VariableDS into a CoordinateAxis (if needed).
Also adds it to the list of variables. Replaces any existing Variable and CoordinateAxis with the same name.

@param v make this VariableDS into a CoordinateAxis
@return the CoordinateAxis
Add a CoordinateAxis to the dataset by turning the VariableDS into a CoordinateAxis ( if needed ) . Also adds it to the list of variables . Replaces any existing Variable and CoordinateAxis with the same name .