cdm/src/main/java/ucar/nc2/dataset/CoordTransBuilder.java
static public CoordinateTransform makeCoordinateTransform (NetcdfDataset ds, AttributeContainer ctv, Formatter parseInfo, Formatter errInfo) {
    // standard name
    String transform_name = ctv.findAttValueIgnoreCase("transform_name", null);
    if (null == transform_name)
      transform_name = ctv.findAttValueIgnoreCase("Projection_Name", null);

    // these names are from CF - dont want to have to duplicate
    if (null == transform_name)
      transform_name = ctv.findAttValueIgnoreCase(CF.GRID_MAPPING_NAME, null);
    if (null == transform_name)
      transform_name = ctv.findAttValueIgnoreCase(CF.STANDARD_NAME, null);

    if (null == transform_name) {
      parseInfo.format("**Failed to find Coordinate Transform name from Variable= %s%n", ctv);
      return null;
    }

    transform_name = transform_name.trim();

    // do we have a transform registered for this ?
    Class builderClass = null;
    for (Transform transform : transformList) {
      if (transform.transName.equals(transform_name)) {
        builderClass = transform.transClass;
        break;
      }
    }
    if (null == builderClass) {
      parseInfo.format("**Failed to find CoordTransBuilder name= %s from Variable= %s%n", transform_name, ctv);
      return null;
    }

         // get an instance of that class
    Object builderObject;
    try {
      builderObject = builderClass.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      log.error("Cant create new instance "+builderClass.getName(), e);
      return null;
    }

    if (null == builderObject) { // cant happen - because this was tested in registerTransform()
      parseInfo.format("**Failed to build CoordTransBuilder object from class= %s for Variable= %s%n", builderClass.getName(), ctv);
      return null;
    }

    CoordinateTransform ct;
    if (builderObject instanceof VertTransformBuilderIF){
      VertTransformBuilderIF vertBuilder = (VertTransformBuilderIF) builderObject;
      vertBuilder.setErrorBuffer(errInfo);
      ct = vertBuilder.makeCoordinateTransform(ds, ctv);

    } else if (builderObject instanceof HorizTransformBuilderIF){
      HorizTransformBuilderIF horizBuilder = (HorizTransformBuilderIF) builderObject;
      horizBuilder.setErrorBuffer(errInfo);
      String units = AbstractTransformBuilder.getGeoCoordinateUnits(ds, ctv); // barfola
      ct = horizBuilder.makeCoordinateTransform(ctv, units);

    } else {
      log.error("Illegals class "+builderClass.getName());
      return null;
    }

    if (ct != null) {
      parseInfo.format(" Made Coordinate transform %s from variable %s: %s%n", transform_name, ctv.getName(), builderObject.getClass().getName());
    }

    return ct;
  }
static public CoordinateTransform makeCoordinateTransform (NetcdfDataset ds, AttributeContainer ctv, Formatter parseInfo, Formatter errInfo) {
    // standard name
    String transform_name = ctv.findAttValueIgnoreCase("transform_name", null);
    if (null == transform_name)
      transform_name = ctv.findAttValueIgnoreCase("Projection_Name", null);

    // these names are from CF - dont want to have to duplicate
    if (null == transform_name)
      transform_name = ctv.findAttValueIgnoreCase(CF.GRID_MAPPING_NAME, null);
    if (null == transform_name)
      transform_name = ctv.findAttValueIgnoreCase(CF.STANDARD_NAME, null);

    if (null == transform_name) {
      parseInfo.format("**Failed to find Coordinate Transform name from Variable= %s%n", ctv);
      return null;
    }

    transform_name = transform_name.trim();

    // do we have a transform registered for this ?
    Class builderClass = null;
    for (Transform transform : transformList) {
      if (transform.transName.equals(transform_name)) {
        builderClass = transform.transClass;
        break;
      }
    }
    if (null == builderClass) {
      parseInfo.format("**Failed to find CoordTransBuilder name= %s from Variable= %s%n", transform_name, ctv);
      return null;
    }

         // get an instance of that class
    Object builderObject;
    try {
      builderObject = builderClass.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      log.error("Cant create new instance "+builderClass.getName(), e);
      return null;
    }

    if (null == builderObject) { // cant happen - because this was tested in registerTransform()
      parseInfo.format("**Failed to build CoordTransBuilder object from class= %s for Variable= %s%n", builderClass.getName(), ctv);
      return null;
    }

    CoordinateTransform ct;
    if (builderObject instanceof VertTransformBuilderIF){
      VertTransformBuilderIF vertBuilder = (VertTransformBuilderIF) builderObject;
      vertBuilder.setErrorBuffer(errInfo);
      ct = vertBuilder.makeCoordinateTransform(ds, ctv);

    } else if (builderObject instanceof HorizTransformBuilderIF){
      HorizTransformBuilderIF horizBuilder = (HorizTransformBuilderIF) builderObject;
      horizBuilder.setErrorBuffer(errInfo);
      String units = AbstractTransformBuilder.getGeoCoordinateUnits(ds, ctv); // barfola
      ct = horizBuilder.makeCoordinateTransform(ctv, units);

    } else {
      log.error("Illegals class "+builderClass.getName());
      return null;
    }

    if (ct != null) {
      parseInfo.format(" Made Coordinate transform %s from variable %s: %s%n", transform_name, ctv.getName(), builderObject.getClass().getName());
    }

    return ct;
  }
static public CoordinateTransform makeCoordinateTransform ( NetcdfDataset ds , AttributeContainer ctv , Formatter parseInfo , Formatter errInfo ) { // standard name
 String transform_name = ctv . findAttValueIgnoreCase ( "transform_name" , null ) ; if ( null == transform_name ) transform_name = ctv . findAttValueIgnoreCase ( "Projection_Name" , null ) ; // these names are from CF - dont want to have to duplicate
 if ( null == transform_name ) transform_name = ctv . findAttValueIgnoreCase ( CF . GRID_MAPPING_NAME , null ) ; if ( null == transform_name ) transform_name = ctv . findAttValueIgnoreCase ( CF . STANDARD_NAME , null ) ; if ( null == transform_name ) { parseInfo . format ( "**Failed to find Coordinate Transform name from Variable= %s%n" , ctv ) ; return null ; } transform_name = transform_name . trim ( ) ; // do we have a transform registered for this ?
 Class builderClass = null ; for ( Transform transform : transformList ) { if ( transform . transName . equals ( transform_name ) ) { builderClass = transform . transClass ; break ; } } if ( null == builderClass ) { parseInfo . format ( "**Failed to find CoordTransBuilder name= %s from Variable= %s%n" , transform_name , ctv ) ; return null ; } // get an instance of that class
 Object builderObject ; try { builderObject = builderClass . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException e ) { log . error ( "Cant create new instance " + builderClass . getName ( ) , e ) ; return null ; } if ( null == builderObject ) { // cant happen - because this was tested in registerTransform()
 parseInfo . format ( "**Failed to build CoordTransBuilder object from class= %s for Variable= %s%n" , builderClass . getName ( ) , ctv ) ; return null ; } CoordinateTransform ct ; if ( builderObject instanceof VertTransformBuilderIF ) { VertTransformBuilderIF vertBuilder = ( VertTransformBuilderIF ) builderObject ; vertBuilder . setErrorBuffer ( errInfo ) ; ct = vertBuilder . makeCoordinateTransform ( ds , ctv ) ; } else if ( builderObject instanceof HorizTransformBuilderIF ) { HorizTransformBuilderIF horizBuilder = ( HorizTransformBuilderIF ) builderObject ; horizBuilder . setErrorBuffer ( errInfo ) ; String units = AbstractTransformBuilder . getGeoCoordinateUnits ( ds , ctv ) ; // barfola
 ct = horizBuilder . makeCoordinateTransform ( ctv , units ) ; } else { log . error ( "Illegals class " + builderClass . getName ( ) ) ; return null ; } if ( ct != null ) { parseInfo . format ( " Made Coordinate transform %s from variable %s: %s%n" , transform_name , ctv . getName ( ) , builderObject . getClass ( ) . getName ( ) ) ; } return ct ; }
Make a CoordinateTransform object from the parameters in a Coordinate Transform Variable, using an intrinsic or registered CoordTransBuilder.
@param ds enclosing dataset, only used for vertical transforms
@param ctv the Coordinate Transform Variable - container for the transform parameters
@param parseInfo pass back information about the parsing.
@param errInfo pass back error information.
@return CoordinateTransform, or null if failure.
Make a CoordinateTransform object from the parameters in a Coordinate Transform Variable using an intrinsic or registered CoordTransBuilder .