コード例 #1
0
ファイル: GeoWaveRasterIT.java プロジェクト: rfecher/geowave
  private void ingestGeneralPurpose(
      final String coverageName,
      final int tileSize,
      final double westLon,
      final double eastLon,
      final double southLat,
      final double northLat,
      final int numBands,
      final int numRasters,
      final RasterTileMergeStrategy<?> mergeStrategy)
      throws IOException {

    // just ingest a number of rasters
    final DataStore dataStore = dataStoreOptions.createDataStore();
    final RasterDataAdapter basicAdapter =
        RasterUtils.createDataAdapterTypeDouble(
            coverageName, numBands, tileSize, new NoDataMergeStrategy());
    final RasterDataAdapter mergeStrategyOverriddenAdapter =
        new RasterDataAdapter(basicAdapter, coverageName, mergeStrategy);
    basicAdapter.getMetadata().put("test-key", "test-value");
    try (IndexWriter writer =
        dataStore.createWriter(mergeStrategyOverriddenAdapter, TestUtils.DEFAULT_SPATIAL_INDEX)) {
      for (int r = 0; r < numRasters; r++) {
        final WritableRaster raster = RasterUtils.createRasterTypeDouble(numBands, tileSize);
        for (int x = 0; x < tileSize; x++) {
          for (int y = 0; y < tileSize; y++) {
            for (int b = 0; b < numBands; b++) {
              raster.setSample(x, y, b, getValue(x, y, b, r, tileSize));
            }
          }
        }
        writer.write(
            RasterUtils.createCoverageTypeDouble(
                coverageName, westLon, eastLon, southLat, northLat, raster));
      }
    }
  }
コード例 #2
0
ファイル: GeoWaveRasterIT.java プロジェクト: rfecher/geowave
  private void ingestNoDataMergeStrategy(
      final String coverageName,
      final int tileSize,
      final double westLon,
      final double eastLon,
      final double southLat,
      final double northLat)
      throws IOException {
    final int numBands = 8;
    final DataStore dataStore = dataStoreOptions.createDataStore();
    final RasterDataAdapter adapter =
        RasterUtils.createDataAdapterTypeDouble(
            coverageName, numBands, tileSize, new NoDataMergeStrategy());
    final WritableRaster raster1 = RasterUtils.createRasterTypeDouble(numBands, tileSize);
    final WritableRaster raster2 = RasterUtils.createRasterTypeDouble(numBands, tileSize);
    // for raster1 do the following:
    // set every even row in bands 0 and 1
    // set every value incorrectly in band 2
    // set no values in band 3 and set every value in 4

    // for raster2 do the following:
    // set no value in band 0 and 4
    // set every odd row in band 1
    // set every value in bands 2 and 3

    // for band 5, set the lower 2x2 samples for raster 1 and the rest for
    // raster 2
    // for band 6, set the upper quadrant samples for raster 1 and the rest
    // for raster 2
    // for band 7, set the lower 2x2 samples to the wrong value for raster 1
    // and the expected value for raster 2 and set everything but the upper
    // quadrant for raster 2
    for (int x = 0; x < tileSize; x++) {
      for (int y = 0; y < tileSize; y++) {

        // just use x and y to arbitrarily end up with some wrong value
        // that can be ingested
        final double wrongValue = (getValue(y, x, y, tileSize) * 3) + 1;
        if ((x < 2) && (y < 2)) {
          raster1.setSample(x, y, 5, getValue(x, y, 5, tileSize));
          raster1.setSample(x, y, 7, wrongValue);
          raster2.setSample(x, y, 7, getValue(x, y, 7, tileSize));
        } else {
          raster2.setSample(x, y, 5, getValue(x, y, 5, tileSize));
        }
        if ((x > ((tileSize * 3) / 4)) && (y > ((tileSize * 3) / 4))) {
          raster1.setSample(x, y, 6, getValue(x, y, 6, tileSize));
        } else {
          raster2.setSample(x, y, 6, getValue(x, y, 6, tileSize));
          raster2.setSample(x, y, 7, getValue(x, y, 7, tileSize));
        }
        if ((y % 2) == 0) {
          raster1.setSample(x, y, 0, getValue(x, y, 0, tileSize));
          raster1.setSample(x, y, 1, getValue(x, y, 1, tileSize));
        }
        raster1.setSample(x, y, 2, wrongValue);

        raster1.setSample(x, y, 4, getValue(x, y, 4, tileSize));
        if ((y % 2) == 1) {
          raster2.setSample(x, y, 1, getValue(x, y, 1, tileSize));
        }
        raster2.setSample(x, y, 2, getValue(x, y, 2, tileSize));

        raster2.setSample(x, y, 3, getValue(x, y, 3, tileSize));
      }
    }

    try (IndexWriter writer = dataStore.createWriter(adapter, TestUtils.DEFAULT_SPATIAL_INDEX)) {
      writer.write(
          RasterUtils.createCoverageTypeDouble(
              coverageName, westLon, eastLon, southLat, northLat, raster1));
      writer.write(
          RasterUtils.createCoverageTypeDouble(
              coverageName, westLon, eastLon, southLat, northLat, raster2));
    }
  }