Class CoverageDataCore<TImage extends CoverageDataImage>

    • Field Detail

      • EXTENSION_NAME_NO_AUTHOR

        public static final String EXTENSION_NAME_NO_AUTHOR
        Extension name without the author
        See Also:
        Constant Field Values
      • EXTENSION_NAME

        public static final String EXTENSION_NAME
        Extension, with author and name
      • EXTENSION_DEFINITION

        public static final String EXTENSION_DEFINITION
        Extension definition URL
      • width

        protected Integer width
        Coverage data results width
      • height

        protected Integer height
        Coverage data results height
      • requestProjection

        protected final Projection requestProjection
        Projection of the requests
      • coverageProjection

        protected final Projection coverageProjection
        Projection of the coverage data
      • coverageBoundingBox

        protected final BoundingBox coverageBoundingBox
        Coverage data bounding box
      • sameProjection

        protected final boolean sameProjection
        Flag indicating the coverage data and request projections are the same
      • zoomIn

        protected boolean zoomIn
        True if zooming in should be performed to find a tile matrix with coverage data values
      • zoomOut

        protected boolean zoomOut
        True if zooming out should be performed to find a tile matrix with coverage data values
      • zoomInBeforeOut

        protected boolean zoomInBeforeOut
        True if zoom in in before zooming out, false to zoom out first
    • Constructor Detail

      • CoverageDataCore

        protected CoverageDataCore​(GeoPackageCore geoPackage,
                                   TileMatrixSet tileMatrixSet,
                                   Integer width,
                                   Integer height,
                                   Projection requestProjection)
        Constructor
        Parameters:
        geoPackage - GeoPackage
        tileMatrixSet - tile matrix set
        width - specified results width
        height - specified results height
        requestProjection - request projection
      • CoverageDataCore

        protected CoverageDataCore​(GeoPackageCore geoPackage,
                                   TileMatrixSet tileMatrixSet)
        Constructor for creating extension rows when creating a new coverage data tile table
        Parameters:
        geoPackage - GeoPackage
        tileMatrixSet - tile matrix set
    • Method Detail

      • getValue

        public abstract Double getValue​(GriddedTile griddedTile,
                                        TImage image,
                                        int x,
                                        int y)
        Get the coverage data value from the image at the coordinate
        Parameters:
        griddedTile - gridded tile
        image - coverage data image
        x - x coordinate
        y - y coordinate
        Returns:
        coverage data value
      • getValues

        public abstract CoverageDataResults getValues​(CoverageDataRequest request,
                                                      Integer width,
                                                      Integer height)
        Get the requested coverage data values with the requested width and height
        Parameters:
        request - coverage data request
        width - coverage data request width
        height - coverage data request height
        Returns:
        coverage data results
      • getValuesUnbounded

        public abstract CoverageDataResults getValuesUnbounded​(CoverageDataRequest request)
        Get the requested unbounded coverage data values. Unbounded results retrieves and returns each coverage data pixel. The results size equals the width and height of all matching pixels.
        Parameters:
        request - coverage data request
        Returns:
        coverage data results
      • getTileMatrixSet

        public TileMatrixSet getTileMatrixSet()
        Get the Tile Matrix Set
        Returns:
        Tile Matrix Set
      • getWidth

        public Integer getWidth()
        Get the requested coverage data width
        Returns:
        width
      • setWidth

        public void setWidth​(Integer width)
        Set the requested coverage data width
        Parameters:
        width - requested coverage data width
      • getHeight

        public Integer getHeight()
        Get the requested coverage data height
        Returns:
        height
      • setHeight

        public void setHeight​(Integer height)
        Set the requested coverage data height
        Parameters:
        height - requested coverage data height
      • getRequestProjection

        public Projection getRequestProjection()
        Get the request projection
        Returns:
        request projection
      • getCoverageProjection

        public Projection getCoverageProjection()
        Get the coverage data projection
        Returns:
        coverage data projection
      • getCoverageBoundingBox

        public BoundingBox getCoverageBoundingBox()
        Get the coverage data bounding box
        Returns:
        coverage data bounding box
      • isSameProjection

        public boolean isSameProjection()
        Is the request and coverage data projection the same
        Returns:
        true if the same
      • isZoomIn

        public boolean isZoomIn()
        Is the zooming in (higher zoom level values) enabled to find matching coverage data
        Returns:
        true if zoom in enabled
      • setZoomIn

        public void setZoomIn​(boolean zoomIn)
        Set the zoom in enabled state
        Parameters:
        zoomIn - true to zoom in when finding coverage data, false to disable
      • isZoomOut

        public boolean isZoomOut()
        Is the zooming out (lower zoom level values) enabled to find matching coverage data
        Returns:
        true if zoom out enabled
      • setZoomOut

        public void setZoomOut​(boolean zoomOut)
        Set the zoom out enabled state
        Parameters:
        zoomOut - true to zoom out when finding coverage data, false to disable
      • isZoomInBeforeOut

        public boolean isZoomInBeforeOut()
        Is zooming in (when enabled) performed before zooming out (when enabled)
        Returns:
        true to zoom in for results first, false to zoom out for results first
      • setZoomInBeforeOut

        public void setZoomInBeforeOut​(boolean zoomInBeforeOut)
        Set the zoom order between in and out
        Parameters:
        zoomInBeforeOut - true to zoom in for results first, false to zoom out first
      • getAlgorithm

        public CoverageDataAlgorithm getAlgorithm()
        Get the interpolation algorithm
        Returns:
        algorithm
      • setAlgorithm

        public void setAlgorithm​(CoverageDataAlgorithm algorithm)
        Set the interpolation algorithm
        Parameters:
        algorithm - algorithm type
      • setEncoding

        public void setEncoding​(GriddedCoverageEncodingType encoding)
        Set the value pixel encoding type
        Parameters:
        encoding - encoding type
        Since:
        2.0.1
      • getOrCreate

        public List<Extensions> getOrCreate()
        Get or create the extension
        Returns:
        extensions list
      • has

        public boolean has()
        Determine if the Tile Matrix Set has the extension
        Returns:
        true if has extension
      • getGriddedCoverageDao

        public GriddedCoverageDao getGriddedCoverageDao()
        Get a 2D Gridded Coverage DAO
        Returns:
        2d gridded coverage dao
      • getGriddedCoverageDao

        public static GriddedCoverageDao getGriddedCoverageDao​(GeoPackageCore geoPackage)
        Get a 2D Gridded Coverage DAO
        Parameters:
        geoPackage - GeoPackage
        Returns:
        2d gridded coverage dao
        Since:
        4.0.0
      • getGriddedCoverageDao

        public static GriddedCoverageDao getGriddedCoverageDao​(GeoPackageCoreConnection db)
        Get a 2D Gridded Coverage DAO
        Parameters:
        db - database connection
        Returns:
        2d gridded coverage dao
        Since:
        4.0.0
      • createGriddedCoverageTable

        public boolean createGriddedCoverageTable()
        Create the 2D Gridded Coverage Table if it does not exist
        Returns:
        true if created
        Since:
        4.0.0
      • getGriddedTileDao

        public GriddedTileDao getGriddedTileDao()
        Get a 2D Gridded Tile DAO
        Returns:
        2d gridded tile dao
      • getGriddedTileDao

        public static GriddedTileDao getGriddedTileDao​(GeoPackageCore geoPackage)
        Get a 2D Gridded Tile DAO
        Parameters:
        geoPackage - GeoPackage
        Returns:
        2d gridded tile dao
        Since:
        4.0.0
      • getGriddedTileDao

        public static GriddedTileDao getGriddedTileDao​(GeoPackageCoreConnection db)
        Get a 2D Gridded Tile DAO
        Parameters:
        db - database connection
        Returns:
        2d gridded tile dao
        Since:
        4.0.0
      • createGriddedTileTable

        public boolean createGriddedTileTable()
        Create the 2D Gridded Tile Table if it does not exist
        Returns:
        true if created
        Since:
        4.0.0
      • getGriddedCoverage

        public GriddedCoverage getGriddedCoverage()
        Get the gridded coverage
        Returns:
        gridded coverage
      • queryGriddedCoverage

        public GriddedCoverage queryGriddedCoverage()
        Query and update the gridded coverage
        Returns:
        gridded coverage
      • getGriddedTile

        public List<GriddedTile> getGriddedTile()
        Get the gridded tile
        Returns:
        gridded tiles
      • getGriddedTile

        public GriddedTile getGriddedTile​(long tileId)
        Get the gridded tile by id
        Parameters:
        tileId - tile id
        Returns:
        gridded tile
      • getDataNull

        public Double getDataNull()
        Get the data null value
        Returns:
        data null value or null
      • isDataNull

        public boolean isDataNull​(double value)
        Check the pixel value to see if it is the null equivalent
        Parameters:
        value - pixel value
        Returns:
        true if equivalent to data null
      • getTables

        public static List<String> getTables​(GeoPackageCore geoPackage)
        Get the coverage data tile tables
        Parameters:
        geoPackage - GeoPackage
        Returns:
        table names
      • reprojectCoverageData

        protected Double[][] reprojectCoverageData​(Double[][] values,
                                                   int requestedCoverageWidth,
                                                   int requestedCoverageHeight,
                                                   BoundingBox requestBoundingBox,
                                                   ProjectionTransform transformRequestToCoverage,
                                                   BoundingBox coverageBoundingBox)
        Reproject the coverage data to the requested projection
        Parameters:
        values - coverage data values
        requestedCoverageWidth - requested coverage data width
        requestedCoverageHeight - requested coverage data height
        requestBoundingBox - request bounding box in the request projection
        transformRequestToCoverage - transformation from request to coverage data
        coverageBoundingBox - coverage data bounding box
        Returns:
        projected coverage data
      • formatUnboundedResults

        protected Double[][] formatUnboundedResults​(TileMatrix tileMatrix,
                                                    Map<Long,​Map<Long,​Double[][]>> rowsMap,
                                                    int tileCount,
                                                    long minRow,
                                                    long maxRow,
                                                    long minColumn,
                                                    long maxColumn)
        Format the unbounded results from coverage data tiles into a single double array of coverage data
        Parameters:
        tileMatrix - tile matrix
        rowsMap - rows map
        tileCount - tile count
        minRow - min row
        maxRow - max row
        minColumn - min column
        maxColumn - max column
        Returns:
        coverage data
      • getXSource

        protected float getXSource​(int x,
                                   float destLeft,
                                   float srcLeft,
                                   float widthRatio)
        Determine the x source pixel location
        Parameters:
        x - x pixel
        destLeft - destination left most pixel
        srcLeft - source left most pixel
        widthRatio - source over destination width ratio
        Returns:
        x source pixel
      • getYSource

        protected float getYSource​(int y,
                                   float destTop,
                                   float srcTop,
                                   float heightRatio)
        Determine the y source pixel location
        Parameters:
        y - y pixel
        destTop - destination top most pixel
        srcTop - source top most pixel
        heightRatio - source over destination height ratio
        Returns:
        y source pixel
      • getNearestNeighbors

        protected List<int[]> getNearestNeighbors​(float xSource,
                                                  float ySource)
        Determine the nearest neighbors of the source pixel, sorted by closest to farthest neighbor
        Parameters:
        xSource - x source pixel
        ySource - y source pixel
        Returns:
        nearest neighbor pixels
      • getXSourceMinAndMax

        protected CoverageDataSourcePixel getXSourceMinAndMax​(float source)
        Get the min, max, and offset of the source X pixel
        Parameters:
        source - source x pixel
        Returns:
        source x pixel information
      • getYSourceMinAndMax

        protected CoverageDataSourcePixel getYSourceMinAndMax​(float source)
        Get the min, max, and offset of the source Y pixel
        Parameters:
        source - source y pixel
        Returns:
        source y pixel information
      • getBilinearInterpolationValue

        protected Double getBilinearInterpolationValue​(CoverageDataSourcePixel sourcePixelX,
                                                       CoverageDataSourcePixel sourcePixelY,
                                                       Double[][] values)
        Get the Bilinear Interpolation coverage data value
        Parameters:
        sourcePixelX - source pixel x
        sourcePixelY - source pixel y
        values - 2 x 2 coverage data values as [y][x]
        Returns:
        coverage data value
      • getBilinearInterpolationValue

        protected Double getBilinearInterpolationValue​(float offsetX,
                                                       float offsetY,
                                                       float minX,
                                                       float maxX,
                                                       float minY,
                                                       float maxY,
                                                       Double[][] values)
        Get the Bilinear Interpolation coverage data value
        Parameters:
        offsetX - x source pixel offset
        offsetY - y source pixel offset
        minX - min x value
        maxX - max x value
        minY - min y value
        maxY - max y value
        values - 2 x 2 coverage data values as [y][x]
        Returns:
        coverage data value
      • getBilinearInterpolationValue

        protected Double getBilinearInterpolationValue​(float offsetX,
                                                       float offsetY,
                                                       float minX,
                                                       float maxX,
                                                       float minY,
                                                       float maxY,
                                                       Double topLeft,
                                                       Double topRight,
                                                       Double bottomLeft,
                                                       Double bottomRight)
        Get the Bilinear Interpolation coverage data value
        Parameters:
        offsetX - x source pixel offset
        offsetY - y source pixel offset
        minX - min x value
        maxX - max x value
        minY - min y value
        maxY - max y value
        topLeft - top left coverage value
        topRight - top right coverage value
        bottomLeft - bottom left coverage value
        bottomRight - bottom right coverage value
        Returns:
        coverage data value
      • getBicubicInterpolationValue

        protected Double getBicubicInterpolationValue​(Double[][] values,
                                                      CoverageDataSourcePixel sourcePixelX,
                                                      CoverageDataSourcePixel sourcePixelY)
        Get the bicubic interpolation coverage data value from the 4 x 4 coverage data values
        Parameters:
        values - coverage data values
        sourcePixelX - source pixel x
        sourcePixelY - source pixel y
        Returns:
        bicubic coverage data value
      • getBicubicInterpolationValue

        protected Double getBicubicInterpolationValue​(Double[][] values,
                                                      float offsetX,
                                                      float offsetY)
        Get the bicubic interpolation coverage data value from the 4 x 4 coverage data values
        Parameters:
        values - coverage data values
        offsetX - x source pixel offset
        offsetY - y source pixel offset
        Returns:
        bicubic coverage data value
      • getCubicInterpolationValue

        protected Double getCubicInterpolationValue​(Double[] values,
                                                    double offset)
        Interpolate 4 values using the offset between value1 and value2
        Parameters:
        values - coverage data values
        offset - offset between the middle two pixels
        Returns:
        value coverage data value
      • getCubicInterpolationValue

        protected Double getCubicInterpolationValue​(Double value0,
                                                    Double value1,
                                                    Double value2,
                                                    Double value3,
                                                    double offset)
        Interpolate 4 values using the offset between value1 and value2
        Parameters:
        value0 - index 0 value
        value1 - index 1 value
        value2 - index 2 value
        value3 - index 3 value
        offset - offset between the middle two pixels
        Returns:
        value coverage data value
      • padBoundingBox

        protected BoundingBox padBoundingBox​(TileMatrix tileMatrix,
                                             BoundingBox boundingBox,
                                             int overlap)
        Pad the bounding box with extra space for the overlapping pixels
        Parameters:
        tileMatrix - tile matrix
        boundingBox - bounding box
        overlap - overlapping pixels
        Returns:
        padded bounding box
      • getPixelValue

        public short getPixelValue​(short[] pixelValues,
                                   int width,
                                   int x,
                                   int y)
        Get the pixel value as an "unsigned short" at the coordinate from the "unsigned short" pixel values
        Parameters:
        pixelValues - "unsigned short" pixel values
        width - image width
        x - x coordinate
        y - y coordinate
        Returns:
        "unsigned short" pixel value
      • getUnsignedPixelValue

        public int getUnsignedPixelValue​(short[] pixelValues,
                                         int width,
                                         int x,
                                         int y)
        Get the pixel value as a 16 bit unsigned value as an integer
        Parameters:
        pixelValues - "unsigned short" pixel values
        width - image width
        x - x coordinate
        y - y coordinate
        Returns:
        unsigned int pixel value
      • getUnsignedPixelValue

        public int getUnsignedPixelValue​(int[] unsignedPixelValues,
                                         int width,
                                         int x,
                                         int y)
        Get the pixel value as a 16 bit unsigned value at the coordinate from the 16 bit unsigned pixel values
        Parameters:
        unsignedPixelValues - unsigned int pixel values
        width - image width
        x - x coordinate
        y - y coordinate
        Returns:
        16 bit unsigned pixel value
      • getUnsignedPixelValue

        public int getUnsignedPixelValue​(short pixelValue)
        Get the unsigned pixel value. The value saved as an "unsigned short" in the short is returned as an integer which stores the positive 16 bit value
        Parameters:
        pixelValue - "unsigned short" pixel value
        Returns:
        unsigned 16 bit pixel value as an integer
      • getPixelValue

        public short getPixelValue​(int unsignedPixelValue)
        Get the "unsigned short" value from the unsigned 16 bit integer pixel value
        Parameters:
        unsignedPixelValue - unsigned 16 bit integer pixel value
        Returns:
        "unsigned short" pixel value
      • getUnsignedPixelValues

        public int[] getUnsignedPixelValues​(short[] pixelValues)
        Get the unsigned pixel values. The values saved as "unsigned shorts" in the short array is returned as an integer which stores the positive 16 bit value
        Parameters:
        pixelValues - pixel values as "unsigned shorts"
        Returns:
        unsigned 16 bit pixel values as an integer array
      • getValue

        public Double getValue​(GriddedTile griddedTile,
                               short pixelValue)
        Get the coverage data value for the "unsigned short" pixel value
        Parameters:
        griddedTile - gridded tile
        pixelValue - pixel value as an unsigned short
        Returns:
        coverage data value
      • getValue

        public Double getValue​(GriddedTile griddedTile,
                               int unsignedPixelValue)
        Get the coverage data value for the unsigned short pixel value
        Parameters:
        griddedTile - gridded tile
        unsignedPixelValue - pixel value as an unsigned 16 bit integer
        Returns:
        coverage data value
      • getValues

        public Double[] getValues​(GriddedTile griddedTile,
                                  short[] pixelValues)
        Get the coverage data values from the "unsigned short" pixel values
        Parameters:
        griddedTile - gridded tile
        pixelValues - pixel values as "unsigned shorts"
        Returns:
        coverage data values
      • getValues

        public Double[] getValues​(GriddedTile griddedTile,
                                  int[] unsignedPixelValues)
        Get the coverage data values from the "unsigned short" pixel values
        Parameters:
        griddedTile - gridded tile
        unsignedPixelValues - pixel values as 16 bit integers
        Returns:
        coverage data values
      • createTileTable

        public static TileTable createTileTable​(GeoPackageCore geoPackage,
                                                TileTableMetadata metadata)
        Create the coverage data tile table
        Parameters:
        geoPackage - GeoPackage
        metadata - tile table metadata
        Returns:
        tile table
        Since:
        4.0.0
      • getUnsignedPixelValue

        public int getUnsignedPixelValue​(GriddedTile griddedTile,
                                         Double value)
        Get the unsigned 16 bit integer pixel value of the coverage data value
        Parameters:
        griddedTile - gridded tile
        value - coverage data value
        Returns:
        16 bit integer pixel value
      • getPixelValue

        public short getPixelValue​(GriddedTile griddedTile,
                                   Double value)
        Get the "unsigned short" pixel value of the coverage data value
        Parameters:
        griddedTile - gridded tile
        value - coverage data value
        Returns:
        "unsigned short" pixel value
      • getPixelValue

        public float getPixelValue​(float[] pixelValues,
                                   int width,
                                   int x,
                                   int y)
        Get the pixel value at the coordinate from the pixel values
        Parameters:
        pixelValues - pixel values
        width - image width
        x - x coordinate
        y - y coordinate
        Returns:
        pixel value
      • getValue

        public Double getValue​(GriddedTile griddedTile,
                               float pixelValue)
        Get the coverage data value for the pixel value
        Parameters:
        griddedTile - gridded tile
        pixelValue - pixel value
        Returns:
        coverage data value
      • getValues

        public Double[] getValues​(GriddedTile griddedTile,
                                  float[] pixelValues)
        Get the coverage data values from the pixel values
        Parameters:
        griddedTile - gridded tile
        pixelValues - pixel values
        Returns:
        coverage data values
      • getFloatPixelValue

        public float getFloatPixelValue​(GriddedTile griddedTile,
                                        Double value)
        Get the pixel value of the coverage data value
        Parameters:
        griddedTile - gridded tile
        value - coverage data value
        Returns:
        pixel value
      • getValue

        public Double getValue​(double latitude,
                               double longitude)
        Get the coverage data value at the coordinate
        Parameters:
        latitude - latitude
        longitude - longitude
        Returns:
        coverage data value
      • getValues

        public CoverageDataResults getValues​(BoundingBox requestBoundingBox)
        Get the coverage data values within the bounding box
        Parameters:
        requestBoundingBox - request bounding box
        Returns:
        coverage data results
      • getValues

        public CoverageDataResults getValues​(BoundingBox requestBoundingBox,
                                             Integer width,
                                             Integer height)
        Get the coverage data values within the bounding box with the requested width and height result size
        Parameters:
        requestBoundingBox - request bounding box
        width - coverage data request width
        height - coverage data request height
        Returns:
        coverage data results
      • getValues

        public CoverageDataResults getValues​(CoverageDataRequest request)
        Get the requested coverage data values
        Parameters:
        request - coverage data request
        Returns:
        coverage data results
      • getValuesUnbounded

        public CoverageDataResults getValuesUnbounded​(BoundingBox requestBoundingBox)
        Get the unbounded coverage data values within the bounding box. Unbounded results retrieves and returns each coverage data pixel. The results size equals the width and height of all matching pixels.
        Parameters:
        requestBoundingBox - request bounding box
        Returns:
        coverage data results
      • getBilinearInterpolationValue

        protected Double getBilinearInterpolationValue​(GriddedTile griddedTile,
                                                       TImage image,
                                                       Double[][] leftLastColumns,
                                                       Double[][] topLeftRows,
                                                       Double[][] topRows,
                                                       int y,
                                                       int x,
                                                       float widthRatio,
                                                       float heightRatio,
                                                       float destTop,
                                                       float destLeft,
                                                       float srcTop,
                                                       float srcLeft)
        Get the bilinear interpolation coverage data value
        Parameters:
        griddedTile - gridded tile
        image - image
        leftLastColumns - last columns in the tile to the left
        topLeftRows - last rows of the tile to the top left
        topRows - last rows of the tile to the top
        y - y coordinate
        x - x coordinate
        widthRatio - width source over destination ratio
        heightRatio - height source over destination ratio
        destTop - destination top most pixel
        destLeft - destination left most pixel
        srcTop - source top most pixel
        srcLeft - source left most pixel
        Returns:
        bilinear coverage data value
      • getBicubicInterpolationValue

        protected Double getBicubicInterpolationValue​(GriddedTile griddedTile,
                                                      TImage image,
                                                      Double[][] leftLastColumns,
                                                      Double[][] topLeftRows,
                                                      Double[][] topRows,
                                                      int y,
                                                      int x,
                                                      float widthRatio,
                                                      float heightRatio,
                                                      float destTop,
                                                      float destLeft,
                                                      float srcTop,
                                                      float srcLeft)
        Get the bicubic interpolation coverage data value
        Parameters:
        griddedTile - gridded tile
        image - image
        leftLastColumns - last columns in the tile to the left
        topLeftRows - last rows of the tile to the top left
        topRows - last rows of the tile to the top
        y - y coordinate
        x - x coordinate
        widthRatio - width source over destination ratio
        heightRatio - height source over destination ratio
        destTop - destination top most pixel
        destLeft - destination left most pixel
        srcTop - source top most pixel
        srcLeft - source left most pixel
        Returns:
        bicubic coverage data value
      • getNearestNeighborValue

        protected Double getNearestNeighborValue​(GriddedTile griddedTile,
                                                 TImage image,
                                                 Double[][] leftLastColumns,
                                                 Double[][] topLeftRows,
                                                 Double[][] topRows,
                                                 int y,
                                                 int x,
                                                 float widthRatio,
                                                 float heightRatio,
                                                 float destTop,
                                                 float destLeft,
                                                 float srcTop,
                                                 float srcLeft)
        Get the nearest neighbor coverage data value
        Parameters:
        griddedTile - gridded tile
        image - image
        leftLastColumns - last columns in the tile to the left
        topLeftRows - last rows of the tile to the top left
        topRows - last rows of the tile to the top
        y - y coordinate
        x - x coordinate
        widthRatio - width source over destination ratio
        heightRatio - height source over destination ratio
        destTop - destination top most pixel
        destLeft - destination left most pixel
        srcTop - source top most pixel
        srcLeft - source left most pixel
        Returns:
        nearest neighbor coverage data value