Class NetCDFImageReader

  • All Implemented Interfaces:
    InitializingReader, FileSetManager

    public class NetCDFImageReader
    extends GeoSpatialImageReader
    implements FileSetManager
    Base implementation for NetCDF-CF image flat reader. Pixels are assumed organized according the COARDS convention (a precursor of CF Metadata conventions), i.e. in (t,z,y,x) order, where x varies faster. The image is created from the two last dimensions (x,y).

    Each ImageIndex corresponds to a 2D-slice of NetCDF.

    NetCDFImageReader is a ImageReader able to create RenderedImage from NetCDF-CF sources.

    Author:
    Alessio Fabiani, GeoSolutions, Simone Giannecchini, GeoSolutions
    • Field Summary

      • Fields inherited from class ImageReader

        availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
    • Constructor Summary

      Constructors 
      Constructor Description
      NetCDFImageReader​(ImageReaderSpi originatingProvider)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFile​(String filePath)
      Add a file to the file set manager
      void dispose()  
      protected void finalize()  
      protected static void flipVertically​(ImageReadParam param, int srcHeight, Rectangle srcRegion)  
      protected VariableAdapter getCoverageDescriptor​(int imageIndex)
      Return the VariableWrapper related to that imageIndex
      VariableAdapter getCoverageDescriptor​(Name name)  
      List<Name> getCoveragesNames()
      Return the name of coverages made available by this provider
      int getCoveragesNumber()
      The number of coverages made available by this provider.
      int getHeight​(int imageIndex)  
      IIOMetadata getImageMetadata​(int imageIndex)  
      RasterLayerRequest getImageMosaicRequest()  
      Iterator<ImageTypeSpecifier> getImageTypes​(int imageIndex)  
      SimpleFeatureType getIndexSchema​(Name coverageName, CoordinateSystem cs)  
      SimpleFeatureType getIndexSchema​(Name coverageName, CoordinateSystem coordinateSystem, boolean isShared)  
      Slice2DIndex getSlice2DIndex​(int imageIndex)
      Return the Slice2DIndex associated to the specified imageIndex
      Variable getVariableByName​(String varName)
      Get a Variable by name.
      int getWidth​(int imageIndex)  
      protected int initIndex()
      Index Initialization. store indexing information.
      List<String> list()
      Return the list of all the files currently added to the manager
      protected IIOException netcdfFailure​(Exception e)
      Wraps a generic exception into a IIOException.
      void purge()
      Remove all the files from the manager (An implementation may also physically remove all the files)
      BufferedImage read​(int imageIndex, ImageReadParam param)  
      void removeFile​(String filePath)
      Remove a file from the manager (An implementation may also physically remove the file)
      void reset()
      Reset the status of this reader
      void setInput​(Object input, boolean seekForwardOnly, boolean ignoreMetadata)  
      protected void setNumImages​(int numImages)  
      void setRasterLayerRequest​(RasterLayerRequest request)  
      • Methods inherited from class ImageReader

        abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, setInput, setInput, setLocale
      • Methods inherited from class Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NetCDFImageReader

        public NetCDFImageReader​(ImageReaderSpi originatingProvider)
    • Method Detail

      • setRasterLayerRequest

        public void setRasterLayerRequest​(RasterLayerRequest request)
      • setNumImages

        protected void setNumImages​(int numImages)
      • getHeight

        public int getHeight​(int imageIndex)
                      throws IOException
        Specified by:
        getHeight in class ImageReader
        Throws:
        IOException
      • getImageTypes

        public Iterator<ImageTypeSpecifier> getImageTypes​(int imageIndex)
                                                   throws IOException
        Specified by:
        getImageTypes in class ImageReader
        Throws:
        IOException
      • getWidth

        public int getWidth​(int imageIndex)
                     throws IOException
        Specified by:
        getWidth in class ImageReader
        Throws:
        IOException
      • getVariableByName

        public Variable getVariableByName​(String varName)
        Get a Variable by name.
        Parameters:
        varName - the name of the Variable to pick.
        Returns:
        the variable or null.
      • reset

        public void reset()
        Reset the status of this reader
        Overrides:
        reset in class ImageReader
      • setInput

        public void setInput​(Object input,
                             boolean seekForwardOnly,
                             boolean ignoreMetadata)
        Overrides:
        setInput in class ImageReader
      • initIndex

        protected int initIndex()
                         throws InvalidRangeException,
                                IOException
        Index Initialization. store indexing information.
        Throws:
        InvalidRangeException
        IOException
      • netcdfFailure

        protected IIOException netcdfFailure​(Exception e)
                                      throws IOException
        Wraps a generic exception into a IIOException.
        Throws:
        IOException
      • getSlice2DIndex

        public Slice2DIndex getSlice2DIndex​(int imageIndex)
                                     throws IOException
        Return the Slice2DIndex associated to the specified imageIndex
        Throws:
        IOException
      • getCoverageDescriptor

        protected VariableAdapter getCoverageDescriptor​(int imageIndex)
        Return the VariableWrapper related to that imageIndex
      • read

        public BufferedImage read​(int imageIndex,
                                  ImageReadParam param)
                           throws IOException
        Specified by:
        read in class ImageReader
        Throws:
        IOException
        See Also:
        ImageReader.read(int, javax.imageio.ImageReadParam)
      • flipVertically

        protected static void flipVertically​(ImageReadParam param,
                                             int srcHeight,
                                             Rectangle srcRegion)
      • getIndexSchema

        public SimpleFeatureType getIndexSchema​(Name coverageName,
                                                CoordinateSystem cs)
                                         throws Exception
        Throws:
        Exception
      • getIndexSchema

        public SimpleFeatureType getIndexSchema​(Name coverageName,
                                                CoordinateSystem coordinateSystem,
                                                boolean isShared)
                                         throws Exception
        Throws:
        Exception
      • addFile

        public void addFile​(String filePath)
        Description copied from interface: FileSetManager
        Add a file to the file set manager
        Specified by:
        addFile in interface FileSetManager
      • list

        public List<String> list()
        Description copied from interface: FileSetManager
        Return the list of all the files currently added to the manager
        Specified by:
        list in interface FileSetManager
      • removeFile

        public void removeFile​(String filePath)
        Description copied from interface: FileSetManager
        Remove a file from the manager (An implementation may also physically remove the file)
        Specified by:
        removeFile in interface FileSetManager
      • purge

        public void purge()
        Description copied from interface: FileSetManager
        Remove all the files from the manager (An implementation may also physically remove all the files)
        Specified by:
        purge in interface FileSetManager