Java Code Examples for mil.nga.geopackage.extension.coverage.GriddedTile#setStandardDeviation()

The following examples show how to use mil.nga.geopackage.extension.coverage.GriddedTile#setStandardDeviation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateCoverageDataTiffGeoPackageTestCase.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Draw a coverage data tile with random values
 *
 * @param coverageData
 * @param tileWidth
 * @param tileHeight
 * @param griddedCoverage
 * @param commonGriddedTile
 * @return
 */
private byte[] drawTile(CoverageDataTiff coverageData, int tileWidth,
                        int tileHeight, GriddedCoverage griddedCoverage,
                        GriddedTile commonGriddedTile) {

    coverageDataValues.tilePixels = new float[tileHeight][tileWidth];
    coverageDataValues.coverageData = new Double[tileHeight][tileWidth];
    coverageDataValues.tilePixelsFlat = new float[tileHeight * tileWidth];
    coverageDataValues.coverageDataFlat = new Double[tileHeight
            * tileWidth];

    GriddedTile griddedTile = new GriddedTile();
    griddedTile.setScale(commonGriddedTile.getScale());
    griddedTile.setOffset(commonGriddedTile.getOffset());
    griddedTile.setMin(commonGriddedTile.getMin());
    griddedTile.setMax(commonGriddedTile.getMax());
    griddedTile.setMean(commonGriddedTile.getMean());
    griddedTile.setStandardDeviation(commonGriddedTile
            .getStandardDeviation());

    float minValue = 8850.0f;
    float maxValue = 10994.0f;

    // Create the image and graphics
    for (int x = 0; x < tileWidth; x++) {
        for (int y = 0; y < tileHeight; y++) {
            float value;
            if (allowNulls && Math.random() < .05) {
                value = griddedCoverage.getDataNull().floatValue();
            } else {
                value = (float) ((Math.random() * (maxValue - minValue)) + minValue);
            }

            coverageDataValues.tilePixels[y][x] = value;
            coverageDataValues.coverageData[y][x] = coverageData
                    .getValue(griddedTile, value);

            coverageDataValues.tilePixelsFlat[(y * tileWidth) + x] = coverageDataValues.tilePixels[y][x];
            coverageDataValues.coverageDataFlat[(y * tileWidth) + x] = coverageDataValues.coverageData[y][x];
        }
    }

    byte[] imageData = coverageData
            .drawTileData(coverageDataValues.tilePixels);

    // GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
    // .drawTileData(griddedTile, coverageDataValues.coverageData));
    GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
            .drawTileData(coverageDataValues.tilePixelsFlat, tileWidth,
                    tileHeight));
    // GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
    // .drawTileData(griddedTile, coverageDataValues.coverageDataFlat,
    // tileWidth, tileHeight));

    return imageData;
}
 
Example 2
Source File: CreateCoverageDataGeoPackageTestCase.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Draw an coverage data tile with random values
 *
 * @param coverageData
 * @param tileWidth
 * @param tileHeight
 * @param griddedCoverage
 * @param commonGriddedTile
 * @return
 */
private byte[] drawTile(CoverageDataPng coverageData, int tileWidth,
                        int tileHeight, GriddedCoverage griddedCoverage,
                        GriddedTile commonGriddedTile) {

    coverageDataValues.tilePixels = new short[tileHeight][tileWidth];
    coverageDataValues.tileUnsignedPixels = new int[tileHeight][tileWidth];
    coverageDataValues.coverageData = new Double[tileHeight][tileWidth];
    coverageDataValues.tilePixelsFlat = new short[tileHeight * tileWidth];
    coverageDataValues.tileUnsignedPixelsFlat = new int[tileHeight
            * tileWidth];
    coverageDataValues.coverageDataFlat = new Double[tileHeight
            * tileWidth];

    GriddedTile griddedTile = new GriddedTile();
    griddedTile.setScale(commonGriddedTile.getScale());
    griddedTile.setOffset(commonGriddedTile.getOffset());
    griddedTile.setMin(commonGriddedTile.getMin());
    griddedTile.setMax(commonGriddedTile.getMax());
    griddedTile.setMean(commonGriddedTile.getMean());
    griddedTile.setStandardDeviation(commonGriddedTile
            .getStandardDeviation());

    // Create the image and graphics
    for (int x = 0; x < tileWidth; x++) {
        for (int y = 0; y < tileHeight; y++) {
            int unsignedValue;
            if (allowNulls && Math.random() < .05) {
                unsignedValue = griddedCoverage.getDataNull().intValue();
            } else {
                unsignedValue = Short.MAX_VALUE - Short.MIN_VALUE - 1;
                unsignedValue = (int) Math.floor(Math.random()
                        * unsignedValue);
            }
            short value = (short) unsignedValue;

            coverageDataValues.tilePixels[y][x] = value;
            coverageDataValues.tileUnsignedPixels[y][x] = unsignedValue;
            coverageDataValues.coverageData[y][x] = coverageData
                    .getValue(griddedTile, value);

            coverageDataValues.tilePixelsFlat[(y * tileWidth) + x] = coverageDataValues.tilePixels[y][x];
            coverageDataValues.tileUnsignedPixelsFlat[(y * tileWidth) + x] = coverageDataValues.tileUnsignedPixels[y][x];
            coverageDataValues.coverageDataFlat[(y * tileWidth) + x] = coverageDataValues.coverageData[y][x];
        }
    }

    byte[] imageData = coverageData
            .drawTileData(coverageDataValues.tilePixels);

    GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
            .drawTileData(coverageDataValues.tileUnsignedPixels));
    GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
            .drawTileData(griddedTile, coverageDataValues.coverageData));
    GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
            .drawTileData(coverageDataValues.tilePixelsFlat, tileWidth,
                    tileHeight));
    GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
            .drawTileData(coverageDataValues.tileUnsignedPixelsFlat,
                    tileWidth, tileHeight));
    GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
            .drawTileData(griddedTile,
                    coverageDataValues.coverageDataFlat, tileWidth,
                    tileHeight));

    return imageData;
}
 
Example 3
Source File: CreateCoverageDataTiffGeoPackageTestCase.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Draw a coverage data tile with random values
 * 
 * @param coverageData
 * @param tileWidth
 * @param tileHeight
 * @param griddedCoverage
 * @param commonGriddedTile
 * @return
 */
private byte[] drawTile(CoverageDataTiff coverageData, int tileWidth,
		int tileHeight, GriddedCoverage griddedCoverage,
		GriddedTile commonGriddedTile) {

	coverageDataValues.tilePixels = new float[tileHeight][tileWidth];
	coverageDataValues.coverageData = new Double[tileHeight][tileWidth];
	coverageDataValues.tilePixelsFlat = new float[tileHeight * tileWidth];
	coverageDataValues.coverageDataFlat = new Double[tileHeight * tileWidth];

	GriddedTile griddedTile = new GriddedTile();
	griddedTile.setScale(commonGriddedTile.getScale());
	griddedTile.setOffset(commonGriddedTile.getOffset());
	griddedTile.setMin(commonGriddedTile.getMin());
	griddedTile.setMax(commonGriddedTile.getMax());
	griddedTile.setMean(commonGriddedTile.getMean());
	griddedTile.setStandardDeviation(commonGriddedTile
			.getStandardDeviation());

	float minValue = 8850.0f;
	float maxValue = 10994.0f;

	// Create the image and graphics
	for (int x = 0; x < tileWidth; x++) {
		for (int y = 0; y < tileHeight; y++) {
			float value;
			if (allowNulls && Math.random() < .05) {
				value = griddedCoverage.getDataNull().floatValue();
			} else {
				value = (float) ((Math.random() * (maxValue - minValue)) + minValue);
			}

			coverageDataValues.tilePixels[y][x] = value;
			coverageDataValues.coverageData[y][x] = coverageData.getValue(
					griddedTile, value);

			coverageDataValues.tilePixelsFlat[(y * tileWidth) + x] = coverageDataValues.tilePixels[y][x];
			coverageDataValues.coverageDataFlat[(y * tileWidth) + x] = coverageDataValues.coverageData[y][x];
		}
	}

	byte[] imageData = coverageData
			.drawTileData(coverageDataValues.tilePixels);

	// GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
	// .drawTileData(griddedTile, coverageDataValues.coverageData));
	GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
			.drawTileData(coverageDataValues.tilePixelsFlat, tileWidth,
					tileHeight));
	// GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
	// .drawTileData(griddedTile, coverageDataValues.coverageDataFlat,
	// tileWidth, tileHeight));

	return imageData;
}
 
Example 4
Source File: CreateCoverageDataGeoPackageTestCase.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Draw a coverage data tile with random values
 * 
 * @param coverage
 *            data
 * @param tileWidth
 * @param tileHeight
 * @param griddedCoverage
 * @param commonGriddedTile
 * @return
 */
private byte[] drawTile(CoverageDataPng coverageData, int tileWidth,
		int tileHeight, GriddedCoverage griddedCoverage,
		GriddedTile commonGriddedTile) {

	coverageDataValues.tilePixels = new short[tileHeight][tileWidth];
	coverageDataValues.tileUnsignedPixels = new int[tileHeight][tileWidth];
	coverageDataValues.coverageData = new Double[tileHeight][tileWidth];
	coverageDataValues.tilePixelsFlat = new short[tileHeight * tileWidth];
	coverageDataValues.tileUnsignedPixelsFlat = new int[tileHeight
			* tileWidth];
	coverageDataValues.coverageDataFlat = new Double[tileHeight * tileWidth];

	GriddedTile griddedTile = new GriddedTile();
	griddedTile.setScale(commonGriddedTile.getScale());
	griddedTile.setOffset(commonGriddedTile.getOffset());
	griddedTile.setMin(commonGriddedTile.getMin());
	griddedTile.setMax(commonGriddedTile.getMax());
	griddedTile.setMean(commonGriddedTile.getMean());
	griddedTile.setStandardDeviation(commonGriddedTile
			.getStandardDeviation());

	// Create the image and graphics
	for (int x = 0; x < tileWidth; x++) {
		for (int y = 0; y < tileHeight; y++) {
			int unsignedValue;
			if (allowNulls && Math.random() < .05) {
				unsignedValue = griddedCoverage.getDataNull().intValue();
			} else {
				unsignedValue = Short.MAX_VALUE - Short.MIN_VALUE - 1;
				unsignedValue = (int) Math.floor(Math.random()
						* unsignedValue);
			}
			short value = (short) unsignedValue;

			coverageDataValues.tilePixels[y][x] = value;
			coverageDataValues.tileUnsignedPixels[y][x] = unsignedValue;
			coverageDataValues.coverageData[y][x] = coverageData.getValue(
					griddedTile, value);

			coverageDataValues.tilePixelsFlat[(y * tileWidth) + x] = coverageDataValues.tilePixels[y][x];
			coverageDataValues.tileUnsignedPixelsFlat[(y * tileWidth) + x] = coverageDataValues.tileUnsignedPixels[y][x];
			coverageDataValues.coverageDataFlat[(y * tileWidth) + x] = coverageDataValues.coverageData[y][x];
		}
	}

	byte[] imageData = coverageData
			.drawTileData(coverageDataValues.tilePixels);

	GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
			.drawTileData(coverageDataValues.tileUnsignedPixels));
	GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
			.drawTileData(griddedTile, coverageDataValues.coverageData));
	GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
			.drawTileData(coverageDataValues.tilePixelsFlat, tileWidth,
					tileHeight));
	GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
			.drawTileData(coverageDataValues.tileUnsignedPixelsFlat,
					tileWidth, tileHeight));
	GeoPackageGeometryDataUtils.compareByteArrays(imageData, coverageData
			.drawTileData(griddedTile, coverageDataValues.coverageDataFlat,
					tileWidth, tileHeight));

	return imageData;
}