Re: [netcdf-java] Understanding FeatureDatasetFactoryManager.findFeatureType(ncd)

On 5/11/2012 10:23 AM, Dave Neufeld wrote:
Hi All,

I'm trying to better understand how to use FeatureDatasetFactoryManager. Currently in NetCDF 4.2 when using FeatureDatasetFactoryManager.findFeatureType(ncd) I'm getting a null returned from my test dataset which is a grid. How is the featureType determined by, reading some internal data structure, or does cdm_data_type attribute need to popopulated, or ?

Thanks, Dave

_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: http://www.unidata.ucar.edu/mailing_lists/

Its really a helper routine to FeatureDatasetFactoryManager.open(). Its job is to look for global attributes that say what it is:

/**
* Try to determine the feature type of the dataset, by looking at its metadata.
   * @param ncd the dataset
   * @return FeatureType if found, else null
   */
  static public FeatureType findFeatureType(NetcdfDataset ncd) {
    // look for explicit guidance
String cdm_datatype = ncd.findAttValueIgnoreCase(null, "cdm_data_type", null);
    if (cdm_datatype == null)
cdm_datatype = ncd.findAttValueIgnoreCase(null, "cdm_datatype", null);
    if (cdm_datatype == null)
cdm_datatype = ncd.findAttValueIgnoreCase(null, "thredds_data_type", null);

    if (cdm_datatype != null) {
      for (FeatureType ft : FeatureType.values())
        if (cdm_datatype.equalsIgnoreCase(ft.name())) {
if (debug) System.out.println(" wrapUnknown found cdm_datatype " + cdm_datatype);
          return ft;
        }
    }

    // LOOK - compare to CF names when those are finalized
String ftypeS = ncd.findAttValueIgnoreCase(null, CF.FEATURE_TYPE, null);
    if (ftypeS == null)
      ftypeS = ncd.findAttValueIgnoreCase(null, CF.featureTypeAtt2, null);
    if (ftypeS == null)
      ftypeS = ncd.findAttValueIgnoreCase(null, CF.featureTypeAtt3, null);

    if (ftypeS != null) {
if (debug) System.out.println(" wrapUnknown found cf_datatype " + ftypeS);
      return FeatureType.getType(ftypeS);
    }

    return null;
  }



  • 2012 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: