Esempio n. 1
0
 /** Set up common objects used for all tests. */
 @Before
 public void setUp() {
   coverage = EXAMPLES.get(0);
   indexedCoverage = EXAMPLES.get(2);
   indexedCoverageWithTransparency = EXAMPLES.get(3);
   floatCoverage = EXAMPLES.get(4);
   ushortCoverage = EXAMPLES.get(5);
   Hints.putSystemDefault(Hints.RESAMPLE_TOLERANCE, 0.333);
 }
Esempio n. 2
0
 /**
  * Tests the "Multiply" operation.
  *
  * @throws IOException
  */
 @Test
 public void testMultiply() throws IOException {
   final GridCoverage2D shortCoverage = EXAMPLES.get(5);
   final GridCoverage2D floatCoverage = EXAMPLES.get(4);
   final GridCoverage2D result = doOp("Multiply", shortCoverage, floatCoverage);
   final RenderedImage image = result.getRenderedImage();
   final RenderedImage extrema = ExtremaDescriptor.create(image, null, 1, 1, false, 1, null);
   double[][] minMax = (double[][]) extrema.getProperty("Extrema");
   assertEquals(minMax[0][0], 0.0, DELTA);
   assertEquals(minMax[1][0], 6.5272192E7, DELTA);
 }
  @Test
  public void testOptimizedWarp() throws Exception {
    // do it again, make sure the image does not turn black since
    GridCoverage2D ushortCoverage = EXAMPLES.get(5);
    GridCoverage2D coverage =
        project(ushortCoverage, CRS.parseWKT(GOOGLE_MERCATOR_WKT), null, "nearest", null, true);
    RenderedImage ri = coverage.getRenderedImage();

    ImageWorker.WARP_REDUCTION_ENABLED = false;
    AffineTransform at = new AffineTransform(0.4, 0, 0, 0.5, -200, -200);
    RenderedOp fullChain =
        (RenderedOp)
            new ImageWorker(ri)
                .affine(
                    at, Interpolation.getInstance(Interpolation.INTERP_NEAREST), new double[] {0})
                .getRenderedImage();
    assertEquals("Scale", fullChain.getOperationName());
    fullChain.getTiles();

    ImageWorker.WARP_REDUCTION_ENABLED = true;
    RenderedOp reduced =
        (RenderedOp)
            new ImageWorker(ri)
                .affine(
                    at, Interpolation.getInstance(Interpolation.INTERP_NEAREST), new double[] {0})
                .getRenderedImage();
    // force computation, to make sure it does not throw exceptions
    reduced.getTiles();
    // check the chain has been reduced
    assertEquals("Warp", reduced.getOperationName());
    assertEquals(1, reduced.getSources().size());
    assertSame(ushortCoverage.getRenderedImage(), reduced.getSourceImage(0));

    // check the bounds of the output image has not changed
    assertEquals(fullChain.getBounds(), reduced.getBounds());
  }