legacy/src/main/java/ucar/nc2/thredds/MetadataExtractor.java
static public ThreddsMetadata.GeospatialCoverage extractGeospatial(InvDatasetImpl threddsDataset) throws IOException {
    ThreddsDataFactory.Result result = null;

    try {
      result = new ThreddsDataFactory().openFeatureDataset(threddsDataset, null);
      if (result.fatalError) {
        System.out.println(" openDatatype errs=" + result.errLog);
        return null;
      }

      if (result.featureType == FeatureType.GRID) {
        System.out.println(" GRID=" + result.location);
        GridDataset gridDataset = (GridDataset) result.featureDataset;
        return extractGeospatial( gridDataset);

      } else if (result.featureType == FeatureType.POINT) {
        PointObsDataset pobsDataset = (PointObsDataset) result.featureDataset;
        LatLonRect llbb = pobsDataset.getBoundingBox();
        if (null != llbb) {
          ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
          gc.setBoundingBox(llbb);
          return gc;
        }
      } else if (result.featureType == FeatureType.STATION) {
        StationObsDataset sobsDataset = (StationObsDataset) result.featureDataset;
        LatLonRect llbb = sobsDataset.getBoundingBox();
        if (null != llbb) {
          ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
          gc.setBoundingBox(llbb);
          return gc;
        }
      }

    } finally {
      try {
        if ((result != null) && (result.featureDataset != null))
          result.featureDataset.close();
      } catch (IOException ioe) {
        logger.error("Closing dataset "+result.featureDataset, ioe);
      }
    }

    return null;
  }
static public ThreddsMetadata.GeospatialCoverage extractGeospatial(InvDatasetImpl threddsDataset) throws IOException {
    ThreddsDataFactory.Result result = null;

    try {
      result = new ThreddsDataFactory().openFeatureDataset(threddsDataset, null);
      if (result.fatalError) {
        System.out.println(" openDatatype errs=" + result.errLog);
        return null;
      }

      if (result.featureType == FeatureType.GRID) {
        System.out.println(" GRID=" + result.location);
        GridDataset gridDataset = (GridDataset) result.featureDataset;
        return extractGeospatial( gridDataset);

      } else if (result.featureType == FeatureType.POINT) {
        PointObsDataset pobsDataset = (PointObsDataset) result.featureDataset;
        LatLonRect llbb = pobsDataset.getBoundingBox();
        if (null != llbb) {
          ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
          gc.setBoundingBox(llbb);
          return gc;
        }
      } else if (result.featureType == FeatureType.STATION) {
        StationObsDataset sobsDataset = (StationObsDataset) result.featureDataset;
        LatLonRect llbb = sobsDataset.getBoundingBox();
        if (null != llbb) {
          ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
          gc.setBoundingBox(llbb);
          return gc;
        }
      }

    } finally {
      try {
        if ((result != null) && (result.featureDataset != null))
          result.featureDataset.close();
      } catch (IOException ioe) {
        logger.error("Closing dataset "+result.featureDataset, ioe);
      }
    }

    return null;
  }
static public ThreddsMetadata . GeospatialCoverage extractGeospatial ( InvDatasetImpl threddsDataset ) throws IOException { ThreddsDataFactory . Result result = null ; try { result = new ThreddsDataFactory ( ) . openFeatureDataset ( threddsDataset , null ) ; if ( result . fatalError ) { System . out . println ( " openDatatype errs=" + result . errLog ) ; return null ; } if ( result . featureType == FeatureType . GRID ) { System . out . println ( " GRID=" + result . location ) ; GridDataset gridDataset = ( GridDataset ) result . featureDataset ; return extractGeospatial ( gridDataset ) ; } else if ( result . featureType == FeatureType . POINT ) { PointObsDataset pobsDataset = ( PointObsDataset ) result . featureDataset ; LatLonRect llbb = pobsDataset . getBoundingBox ( ) ; if ( null != llbb ) { ThreddsMetadata . GeospatialCoverage gc = new ThreddsMetadata . GeospatialCoverage ( ) ; gc . setBoundingBox ( llbb ) ; return gc ; } } else if ( result . featureType == FeatureType . STATION ) { StationObsDataset sobsDataset = ( StationObsDataset ) result . featureDataset ; LatLonRect llbb = sobsDataset . getBoundingBox ( ) ; if ( null != llbb ) { ThreddsMetadata . GeospatialCoverage gc = new ThreddsMetadata . GeospatialCoverage ( ) ; gc . setBoundingBox ( llbb ) ; return gc ; } } } finally { try { if ( ( result != null ) && ( result . featureDataset != null ) ) result . featureDataset . close ( ) ; } catch ( IOException ioe ) { logger . error ( "Closing dataset " + result . featureDataset , ioe ) ; } } return null ; }
Extract the lat/lon/alt bounding boxes from the dataset.
@param threddsDataset open this dataset
@return ThreddsMetadata.GeospatialCoverage, or null if unable.
@throws IOException on read error
Extract the lat / lon / alt bounding boxes from the dataset .