float xSource = getXSource(x, destLeft, srcLeft, widthRatio); float ySource = getYSource(y, destTop, srcTop, heightRatio); CoverageDataSourcePixel sourcePixelX = getXSourceMinAndMax(xSource); CoverageDataSourcePixel sourcePixelY = getYSourceMinAndMax(ySource); populateValues(griddedTile, image, leftLastColumns, topLeftRows, topRows, sourcePixelX, sourcePixelY, values); value = getBilinearInterpolationValue(sourcePixelX, sourcePixelY, values);
/** * Interpolate 4 values using the offset between value1 and value2 * * @param values * coverage data values * @param offset * offset between the middle two pixels * @return value coverage data value */ protected Double getCubicInterpolationValue(Double[] values, double offset) { Double value = null; if (values != null) { value = getCubicInterpolationValue(values[0], values[1], values[2], values[3], offset); } return value; }
/** * Check the pixel value to see if it is the null equivalent * * @param value * pixel value * @return true if equivalent to data null */ public boolean isDataNull(double value) { Double dataNull = getDataNull(); boolean isDataNull = dataNull != null && dataNull == value; return isDataNull; }
/** * Get the "unsigned short" pixel value of the coverage data value * * @param griddedTile * gridded tile * @param value * coverage data value * @return "unsigned short" pixel value */ public short getPixelValue(GriddedTile griddedTile, Double value) { int unsignedPixelValue = getUnsignedPixelValue(griddedTile, value); short pixelValue = getPixelValue(unsignedPixelValue); return pixelValue; }
/** * Determine the y source pixel location * * @param y * y pixel * @param destTop * destination top most pixel * @param srcTop * source top most pixel * @param heightRatio * source over destination height ratio * @return y source pixel */ protected float getYSource(int y, float destTop, float srcTop, float heightRatio) { float dest = getYEncodedLocation(y, encoding); float source = getSource(dest, destTop, srcTop, heightRatio); return source; }
/** * Determine the x source pixel location * * @param x * x pixel * @param destLeft * destination left most pixel * @param srcLeft * source left most pixel * @param widthRatio * source over destination width ratio * @return x source pixel */ protected float getXSource(int x, float destLeft, float srcLeft, float widthRatio) { float dest = getXEncodedLocation(x, encoding); float source = getSource(dest, destLeft, srcLeft, widthRatio); return source; }
float xSource = getXSource(x, destLeft, srcLeft, widthRatio); float ySource = getYSource(y, destTop, srcTop, heightRatio); CoverageDataSourcePixel sourcePixelX = getXSourceMinAndMax(xSource); sourcePixelX.setMin(sourcePixelX.getMin() - 1); sourcePixelX.setMax(sourcePixelX.getMax() + 1); CoverageDataSourcePixel sourcePixelY = getYSourceMinAndMax(ySource); sourcePixelY.setMin(sourcePixelY.getMin() - 1); sourcePixelY.setMax(sourcePixelY.getMax() + 1); populateValues(griddedTile, image, leftLastColumns, topLeftRows, topRows, sourcePixelX, sourcePixelY, values); value = getBicubicInterpolationValue(values, sourcePixelX, sourcePixelY);
float xSource = getXSource(x, destLeft, srcLeft, widthRatio); float ySource = getYSource(y, destTop, srcTop, heightRatio); List<int[]> nearestNeighbors = getNearestNeighbors(xSource, ySource); value = getValueOverBorders(griddedTile, image, leftLastColumns, topLeftRows, topRows, nearestNeighbor[0], nearestNeighbor[1]);
.createTileTableWithMetadata(geoPackage, tableName, contentsBoundingBox, contentsSrsId, tileMatrixSetBoundingBox, tileMatrixSetSrsId);
/** * Get the min, max, and offset of the source Y pixel * * @param source * source y pixel * @return source y pixel information */ protected CoverageDataSourcePixel getYSourceMinAndMax(float source) { int floor = (int) Math.floor(source); float valueLocation = getYEncodedLocation(floor, griddedCoverage.getGridCellEncodingType()); CoverageDataSourcePixel pixel = getSourceMinAndMax(source, floor, valueLocation); return pixel; }
/** * Get the min, max, and offset of the source X pixel * * @param source * source x pixel * @return source x pixel information */ protected CoverageDataSourcePixel getXSourceMinAndMax(float source) { int floor = (int) Math.floor(source); float valueLocation = getXEncodedLocation(floor, griddedCoverage.getGridCellEncodingType()); CoverageDataSourcePixel pixel = getSourceMinAndMax(source, floor, valueLocation); return pixel; }
/** * Get the Bilinear Interpolation coverage data value * * @param offsetX * x source pixel offset * @param offsetY * y source pixel offset * @param minX * min x value * @param maxX * max x value * @param minY * min y value * @param maxY * max y value * @param values * 2 x 2 coverage data values as [y][x] * @return coverage data value */ protected Double getBilinearInterpolationValue(float offsetX, float offsetY, float minX, float maxX, float minY, float maxY, Double[][] values) { Double value = null; if (values != null) { value = getBilinearInterpolationValue(offsetX, offsetY, minX, maxX, minY, maxY, values[0][0], values[0][1], values[1][0], values[1][1]); } return value; }
/** * Get or create the extension * * @return extensions list */ public List<Extensions> getOrCreate() { // Create tables geoPackage.createGriddedCoverageTable(); geoPackage.createGriddedTileTable(); List<Extensions> extensionList = new ArrayList<>(); Extensions coverage = getOrCreate(EXTENSION_NAME, GriddedCoverage.TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); Extensions tile = getOrCreate(EXTENSION_NAME, GriddedTile.TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); Extensions table = getOrCreate(EXTENSION_NAME, tileMatrixSet.getTableName(), TileTable.COLUMN_TILE_DATA, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); extensionList.add(coverage); extensionList.add(tile); extensionList.add(table); return extensionList; }
/** * Get the bicubic interpolation coverage data value from the 4 x 4 coverage * data values * * @param values * coverage data values * @param sourcePixelX * source pixel x * @param sourcePixelY * source pixel y * @return bicubic coverage data value */ protected Double getBicubicInterpolationValue(Double[][] values, CoverageDataSourcePixel sourcePixelX, CoverageDataSourcePixel sourcePixelY) { return getBicubicInterpolationValue(values, sourcePixelX.getOffset(), sourcePixelY.getOffset()); }
/** * Get the pixel value as a 16 bit unsigned value as an integer * * @param pixelValues * "unsigned short" pixel values * @param width * image width * @param x * x coordinate * @param y * y coordinate * @return unsigned int pixel value */ public int getUnsignedPixelValue(short[] pixelValues, int width, int x, int y) { short pixelValue = getPixelValue(pixelValues, width, x, y); int unsignedPixelValue = getUnsignedPixelValue(pixelValue); return unsignedPixelValue; }
.createTileTableWithMetadata(geoPackage, tableName, contentsBoundingBox, contentsSrsId, tileMatrixSetBoundingBox, tileMatrixSetSrsId);
/** * Get the Bilinear Interpolation coverage data value * * @param sourcePixelX * source pixel x * @param sourcePixelY * source pixel y * @param values * 2 x 2 coverage data values as [y][x] * @return coverage data value */ protected Double getBilinearInterpolationValue( CoverageDataSourcePixel sourcePixelX, CoverageDataSourcePixel sourcePixelY, Double[][] values) { return getBilinearInterpolationValue(sourcePixelX.getOffset(), sourcePixelY.getOffset(), sourcePixelX.getMin(), sourcePixelX.getMax(), sourcePixelY.getMin(), sourcePixelY.getMax(), values); }
/** * Get the bicubic interpolation coverage data value from the 4 x 4 coverage * data values * * @param values * coverage data values * @param offsetX * x source pixel offset * @param offsetY * y source pixel offset * @return bicubic coverage data value */ protected Double getBicubicInterpolationValue(Double[][] values, float offsetX, float offsetY) { Double value = null; Double[] rowValues = new Double[4]; for (int y = 0; y < 4; y++) { Double rowValue = getCubicInterpolationValue(values[y][0], values[y][1], values[y][2], values[y][3], offsetX); if (rowValue == null) { rowValues = null; break; } rowValues[y] = rowValue; } if (rowValues != null) { value = getCubicInterpolationValue(rowValues, offsetY); } return value; }