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

The following examples show how to use ucar.nc2.constants.FeatureType#IMAGE . 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: ThreddsDataFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ThreddsDataFactory.Result openFeatureDataset(FeatureType wantFeatureType, InvAccess access,
    ucar.nc2.util.CancelTask task, Result result) throws IOException {
  result.featureType = wantFeatureType;
  result.accessUsed = access;

  // special handling for IMAGE
  if (result.featureType == FeatureType.IMAGE) {
    result.imageURL = access.getStandardUrlName();
    result.location = result.imageURL;
    return result;
  }

  if (access.getService().getServiceType() == ServiceType.CdmrFeature) {
    Optional<FeatureDataset> opt = CdmrFeatureDataset.factory(wantFeatureType, access.getStandardUrlName());
    if (opt.isPresent())
      result.featureDataset = opt.get();
    else
      result.errLog.format("%s", opt.getErrorMessage());

  } else {

    // all other datatypes
    NetcdfDataset ncd = openDataset(access, true, task, result);
    if (null != ncd) {
      result.featureDataset = FeatureDatasetFactoryManager.wrap(result.featureType, ncd, task, result.errLog);
    }
  }

  if (null == result.featureDataset)
    result.fatalError = true;
  else {
    result.location = result.featureDataset.getLocation();
    result.featureType = result.featureDataset.getFeatureType();
  }

  return result;
}
 
Example 2
Source File: DataFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private DataFactory.Result openFeatureDataset(FeatureType wantFeatureType, Access access,
    ucar.nc2.util.CancelTask task, Result result) throws IOException {
  result.featureType = wantFeatureType;
  result.accessUsed = access;

  // special handling for IMAGE
  if (result.featureType == FeatureType.IMAGE) {
    result.imageURL = access.getStandardUrlName();
    result.location = result.imageURL;
    return result;
  }

  if (access.getService().getType() == ServiceType.CdmrFeature) {
    Optional<FeatureDataset> opt = CdmrFeatureDataset.factory(wantFeatureType, access.getStandardUrlName());
    if (opt.isPresent())
      result.featureDataset = opt.get();
    else
      result.errLog.format("%s", opt.getErrorMessage());

  } else {

    // all other datatypes
    NetcdfDataset ncd = openDataset(access, true, task, result);
    if (null != ncd) {
      result.featureDataset = FeatureDatasetFactoryManager.wrap(result.featureType, ncd, task, result.errLog);
    }
  }

  if (null == result.featureDataset)
    result.fatalError = true;
  else {
    result.location = result.featureDataset.getLocation();
    result.featureType = result.featureDataset.getFeatureType();
  }

  return result;
}
 
Example 3
Source File: DataFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Nonnull
public DataFactory.Result openFeatureDataset(FeatureType wantFeatureType, Dataset ds, ucar.nc2.util.CancelTask task,
    Result result) throws IOException {

  // deal with RESOLVER type
  Access resolverAccess = findAccessByServiceType(ds.getAccess(), ServiceType.Resolver);
  if (resolverAccess != null) {
    Dataset rds = openResolver(resolverAccess.getStandardUrlName(), task, result);
    if (rds != null)
      ds = rds;
  }

  try {
    result.featureType = ds.getFeatureType();
    if (result.featureType == null)
      result.featureType = wantFeatureType;

    // first choice would be remote FeatureDataset
    Access access = findAccessByServiceType(ds.getAccess(), ServiceType.CdmrFeature);
    if (access != null)
      return openFeatureDataset(result.featureType, access, task, result);

    // special handling for images
    if (result.featureType == FeatureType.IMAGE) {
      access = getImageAccess(ds, task, result);
      if (access != null) {
        return openFeatureDataset(result.featureType, access, task, result);
      } else
        result.fatalError = true;
      return result;
    }

    // otherwise, open as a remote NetcdfDataset (cdmremote or opendap)
    NetcdfDataset ncd = openDataset(ds, true, task, result);
    if (null != ncd)
      result.featureDataset = FeatureDatasetFactoryManager.wrap(result.featureType, ncd, task, result.errLog);

    if (null == result.featureDataset)
      result.fatalError = true;
    else {
      result.location = result.featureDataset.getLocation();
      if (result.featureType == null)
        result.featureType = result.featureDataset.getFeatureType();
    }

    return result;

  } catch (Throwable t) {
    result.close();
    if (t instanceof IOException)
      throw (IOException) t;
    throw new RuntimeException(t);
  }
}
 
Example 4
Source File: ToolsUI.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Jump to the appropriate tab based on datatype of threddsData
 */
private void jumptoThreddsDatatype(DataFactory.Result threddsData) {

  if (threddsData.fatalError) {
    JOptionPane.showMessageDialog(this, "Cant open dataset=" + threddsData.errLog);
    try {
      threddsData.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return;
  }

  if (threddsData.featureType.isCoverageFeatureType()) {
    if (threddsData.featureDataset instanceof FeatureDatasetCoverage) {
      makeComponent(ftTabPane, "Coverages");
      coveragePanel.setDataset(threddsData.featureDataset);
      tabbedPane.setSelectedComponent(ftTabPane);
      ftTabPane.setSelectedComponent(coveragePanel);
    } else if (threddsData.featureDataset instanceof GridDataset) {
      makeComponent(ftTabPane, "Grids");
      gridPanel.setDataset((GridDataset) threddsData.featureDataset);
      tabbedPane.setSelectedComponent(ftTabPane);
      ftTabPane.setSelectedComponent(gridPanel);
    }
  } else if (threddsData.featureType == FeatureType.IMAGE) {
    makeComponent(ftTabPane, "Images");
    imagePanel.setImageLocation(threddsData.imageURL);
    tabbedPane.setSelectedComponent(ftTabPane);
    ftTabPane.setSelectedComponent(imagePanel);
  } else if (threddsData.featureType == FeatureType.RADIAL) {
    makeComponent(ftTabPane, "Radial");
    radialPanel.setDataset((RadialDatasetSweep) threddsData.featureDataset);
    tabbedPane.setSelectedComponent(ftTabPane);
    ftTabPane.setSelectedComponent(radialPanel);
  } else if (threddsData.featureType.isPointFeatureType()) {
    makeComponent(ftTabPane, "PointFeature");
    pointFeaturePanel.setPointFeatureDataset((PointDatasetImpl) threddsData.featureDataset);
    tabbedPane.setSelectedComponent(ftTabPane);
    ftTabPane.setSelectedComponent(pointFeaturePanel);
  } else if (threddsData.featureType == FeatureType.STATION_RADIAL) {
    makeComponent(ftTabPane, "StationRadial");
    stationRadialPanel.setStationRadialDataset(threddsData.featureDataset);
    tabbedPane.setSelectedComponent(ftTabPane);
    ftTabPane.setSelectedComponent(stationRadialPanel);
  }
}