Java Code Examples for ucar.nc2.constants.FeatureType#ANY

The following examples show how to use ucar.nc2.constants.FeatureType#ANY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RadialDatasetStandardFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Object isMine(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) throws IOException {

    if ((wantFeatureType != FeatureType.RADIAL) && (wantFeatureType != FeatureType.ANY))
      return null;

    for (FeatureDatasetFactory fac : factories) {
      Object anal = fac.isMine(FeatureType.RADIAL, ds, errlog);
      if (anal != null)
        return anal;
    }

    return null;
  }
 
Example 2
Source File: FeatureDatasetFactoryManager.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Wrap a NetcdfDataset as a FeatureDataset.
 *
 * @param wantFeatureType open this kind of FeatureDataset; may be null, which means search all factories.
 *        If datatype is not null, only return FeatureDataset with objects of that type
 * @param ncd the NetcdfDataset to wrap as a FeatureDataset
 * @param task user may cancel
 * @param errlog place errors here, may not be null
 * @return a subclass of FeatureDataset, or null if no suitable factory was found
 * @throws java.io.IOException on io error
 */
public static FeatureDataset wrap(FeatureType wantFeatureType, NetcdfDataset ncd, ucar.nc2.util.CancelTask task,
    Formatter errlog) throws IOException {
  if (debug)
    System.out.println("wrap " + ncd.getLocation() + " want = " + wantFeatureType);

  // the case where we dont know what type it is
  if ((wantFeatureType == null) || (wantFeatureType == FeatureType.ANY)) {
    return wrapUnknown(ncd, task, errlog);
  }

  // find a Factory that claims this dataset by passing back an "analysis result" object
  Object analysis = null;
  FeatureDatasetFactory useFactory = null;
  for (Factory fac : factoryList) {
    if (!featureTypeOk(wantFeatureType, fac.featureType))
      continue;
    if (debug)
      System.out.println(" wrap try factory " + fac.factory.getClass().getName());

    analysis = fac.factory.isMine(wantFeatureType, ncd, errlog);
    if (analysis != null) {
      useFactory = fac.factory;
      break;
    }
  }

  if (null == useFactory) {
    errlog.format("**Failed to find FeatureDatasetFactory for= %s datatype=%s%n", ncd.getLocation(), wantFeatureType);
    return null;
  }

  // this call must be thread safe - done by implementation
  return useFactory.open(wantFeatureType, ncd, analysis, task, errlog);
}
 
Example 3
Source File: BufrConfig.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private FeatureType guessFeatureType(StandardFields.StandardFieldsFromMessage standardFields) {
  if (standardFields.hasStation())
    return FeatureType.STATION;
  if (standardFields.hasTime())
    return FeatureType.POINT;
  return FeatureType.ANY;
}
 
Example 4
Source File: InvDatasetImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * take all elements from tmd and add to the public metadata of this dataset.
 * for InvMetadata elements, only add if inheritAll || InvMetadata.isInherited().
 *
 * @param tmd tahe metadata from here
 * @param inheritAll true if all should be inherited, else only those which are specifically mareked
 */
private void transfer2PublicMetadata(ThreddsMetadata tmd, boolean inheritAll) {
  if (tmd == null)
    return;

  logger.debug("  transferMetadata " + tmd);

  if (authorityName == null)
    authorityName = tmd.getAuthority();
  if (dataType == null || (dataType == FeatureType.ANY))
    dataType = tmd.getDataType();
  if (dataFormatType == null || dataFormatType == DataFormatType.NONE)
    dataFormatType = tmd.getDataFormatType();

  if (defaultService == null)
    defaultService = findService(tmd.getServiceName());

  if (gc == null) {
    ThreddsMetadata.GeospatialCoverage tgc = tmd.getGeospatialCoverage();
    if ((tgc != null) && !tgc.isEmpty())
      gc = tgc;
  }

  if (tc == null) {
    DateRange ttc = tmd.getTimeCoverage();
    if (ttc != null) {
      tc = ttc;
    }
  }

  if (tc == null)
    tc = tmd.getTimeCoverage();

  for (InvProperty item : tmd.getProperties()) {
    logger.debug("  add Property " + item + " to " + getID());
    properties.add(item);
  }

  creators.addAll(tmd.getCreators());
  contributors.addAll(tmd.getContributors());
  dates.addAll(tmd.getDates());
  docs.addAll(tmd.getDocumentation());
  keywords.addAll(tmd.getKeywords());
  projects.addAll(tmd.getProjects());
  publishers.addAll(tmd.getPublishers());
  variables.addAll(tmd.getVariables());
  if (variableMapLink == null)
    variableMapLink = tmd.variableMapLink;

  for (InvMetadata meta : tmd.getMetadata()) {
    if (meta.isInherited() || inheritAll) {
      if (!meta.isThreddsMetadata()) {
        metadata.add(meta);
      } else {
        logger.debug("  add metadata Element " + tmd.isInherited() + " " + meta);
        meta.finish(); // make sure XLink is read in.
        transfer2PublicMetadata(meta.getThreddsMetadata(), inheritAll);
        metadata.add(meta);
      }
    }
  }

}
 
Example 5
Source File: GridDatasetStandardFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private boolean match(FeatureType wantFeatureType, FeatureType covType) {
  if (wantFeatureType == null || wantFeatureType == FeatureType.ANY)
    return true;
  // LOOK ever have to return false?
  return true;
}
 
Example 6
Source File: SimpleGeometryStandardFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private boolean match(FeatureType wantFeatureType, FeatureType covType) {
  if (wantFeatureType == null || wantFeatureType == FeatureType.ANY)
    return true;
  return true;
}