Class GDALDataRaster

    • Field Detail

      • dsVRT

        protected org.gdal.gdal.Dataset dsVRT
      • srs

        protected org.gdal.osr.SpatialReference srs
      • srcFile

        protected java.io.File srcFile
      • usageLock

        protected final java.lang.Object usageLock
      • DEFAULT_MAX_RASTER_SIZE_LIMIT

        protected static final int DEFAULT_MAX_RASTER_SIZE_LIMIT
        See Also:
        Constant Field Values
    • Constructor Detail

      • GDALDataRaster

        public GDALDataRaster​(java.lang.Object source)
                       throws java.lang.IllegalArgumentException,
                              java.io.FileNotFoundException
        Opens a data raster
        Parameters:
        source - the location of the local file, expressed as either a String path, a File, or a file URL.
        Throws:
        java.lang.IllegalArgumentException - if the source is null
        java.io.FileNotFoundException - if the source (File) does not exist
      • GDALDataRaster

        public GDALDataRaster​(java.lang.Object source,
                              boolean quickReadingMode)
                       throws java.lang.IllegalArgumentException,
                              java.io.FileNotFoundException
        Opens a data raster
        Parameters:
        source - the location of the local file, expressed as either a String path, a File, or a file URL.
        quickReadingMode - if quick reading mode is enabled GDAL will not spend much time on heavy calculations, like for example calculating Min/Max for entire elevation raster
        Throws:
        java.lang.IllegalArgumentException - if the source is null
        java.io.FileNotFoundException - if the source (File) does not exist
      • GDALDataRaster

        public GDALDataRaster​(org.gdal.gdal.Dataset ds)
                       throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
    • Method Detail

      • getMaxRasterSizeLimit

        protected static int getMaxRasterSizeLimit()
      • setSector

        public void setSector​(Sector sector)
                       throws java.lang.IllegalArgumentException
        Set a new extent to the data raster. This operation is mostly required for rasters that does not have a georeferenced information. A new geo-transform matrix will be created. The coordinate system is set to Geographic.
        Parameters:
        sector - A valid sector instance
        Throws:
        java.lang.IllegalArgumentException - if the Sector is null
      • readSpatialReference

        protected org.gdal.osr.SpatialReference readSpatialReference​(org.gdal.gdal.Dataset ds)
      • init

        protected void init​(org.gdal.gdal.Dataset ds,
                            boolean quickReadingMode)
        Extracts metadata and sets next key/value pairs:

        AVKey.WIDTH - the maximum width of the image

        AVKey.HEIGHT - the maximum height of the image

        AVKey.COORDINATE_SYSTEM - one of the next values: AVKey.COORDINATE_SYSTEM_SCREEN AVKey.COORDINATE_SYSTEM_GEOGRAPHIC AVKey.COORDINATE_SYSTEM_PROJECTED

        AVKey.SECTOR - in case of Geographic CS, contains a regular Geographic Sector defined by lat/lon coordinates of corners in case of Projected CS, contains a bounding box of the area

        Parameters:
        ds - GDAL's Dataset
        quickReadingMode - if quick reading mode is enabled GDAL will not spend much time on heavy calculations, like for example calculating Min/Max for entire elevation raster
      • getMetadata

        public AVList getMetadata()
      • drawOnTo

        public void drawOnTo​(DataRaster canvas)
        Description copied from interface: DataRaster
        Copies this raster into a specified raster.
        Specified by:
        drawOnTo in interface DataRaster
        Parameters:
        canvas - - the raster to copy into.
      • doDrawOnTo

        protected void doDrawOnTo​(DataRaster canvas)
      • composeExceptionReason

        protected java.lang.String composeExceptionReason​(java.lang.Throwable t)
      • dispose

        public void dispose()
        Description copied from interface: Disposable
        Disposes of any internal resources allocated by the object.
        Specified by:
        dispose in interface Disposable
      • createMaskDataset

        protected org.gdal.gdal.Dataset createMaskDataset​(int width,
                                                          int height,
                                                          Sector sector)
      • getBestSuitedDataset

        protected org.gdal.gdal.Dataset getBestSuitedDataset​(int reqWidth,
                                                             int reqHeight,
                                                             Sector reqSector)
        The purpose of this method is to create the best suited dataset for the requested area. The dataset may contain overviews, so instead of retrieving raster from the highest resolution source, we will compose a temporary dataset from an overview, and/or we may clip only the requested area. This will accelerate reprojection (if needed), because the reporjection will be done on much smaller dataset.
        Parameters:
        reqWidth - width of the requested area
        reqHeight - height of the requested area
        reqSector - sector of the requested area
        Returns:
        a dataset with the best suitable raster for the request
      • buildNorthUpDatasetFromOverview

        protected org.gdal.gdal.Dataset buildNorthUpDatasetFromOverview​(Sector reqSector,
                                                                        int reqWidth,
                                                                        int reqHeight,
                                                                        int bestOverviewIdx,
                                                                        int srcWidth,
                                                                        int srcHeight)
      • buildNonNorthUpDatasetFromOverview

        protected org.gdal.gdal.Dataset buildNonNorthUpDatasetFromOverview​(int bestOverviewIdx,
                                                                           int destWidth,
                                                                           int destHeight)
      • createCompatibleDataset

        protected org.gdal.gdal.Dataset createCompatibleDataset​(int width,
                                                                int height,
                                                                Sector sector,
                                                                AVList destParams)
      • getSubRaster

        public DataRaster getSubRaster​(AVList params)
        Builds a writable data raster for the requested region of interest (ROI)
        Specified by:
        getSubRaster in interface DataRaster
        Overrides:
        getSubRaster in class AbstractDataRaster
        Parameters:
        params - Required parameters are:

        AVKey.HEIGHT as Integer, specifies a height of the desired ROI

        AVKey.WIDTH as Integer, specifies a width of the desired ROI

        AVKey.SECTOR as Sector, specifies an extent of the desired ROI

        Optional parameters are:

        AVKey.BAND_ORDER as array of integers, examples: for RGBA image: new int[] { 0, 1, 2, 3 }, or for ARGB image: new int[] { 3, 0, 1, 2 } , or if you want only RGB bands of the RGBA image: new int[] {0, 1, 2 }, or only Intensity (4th) band of the specific aerial image: new int[] { 3 }

        Returns:
        A writable data raster: BufferedImageRaster (if the source dataset is imagery) or ByteBufferRaster (if the source dataset is elevations)
      • doGetSubRaster

        protected DataRaster doGetSubRaster​(int roiWidth,
                                            int roiHeight,
                                            Sector roiSector,
                                            AVList roiParams)
      • findAlphaBand

        protected static org.gdal.gdal.Band findAlphaBand​(org.gdal.gdal.Dataset ds)
      • convertAVListToString

        protected static java.lang.String convertAVListToString​(AVList list)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • intersects

        protected boolean intersects​(Sector reqSector)
      • getSizeInBytes

        public long getSizeInBytes()
        Description copied from interface: Cacheable
        Retrieves the approximate size of this object in bytes. Implementors are encouraged to calculate the exact size for smaller objects, but use approximate values for objects that include such large components that the approximation would produce an error so small that the extra computation would be wasteful.
        Specified by:
        getSizeInBytes in interface Cacheable
        Returns:
        this Cacheable object's size in bytes