Exemple #1
0
  @Test
  public void testGrid2Grid() throws Exception {
    GeoRaster gr = GeoRasterFactory.createGeoRaster(otherData + "sample.asc");
    gr.open();
    final RasterMetadata originalMetadata = gr.getMetadata();
    final float[] pixels = gr.getFloatPixels();

    final File file2 = new File(tmpData + "1.asc");
    gr.save(file2.getAbsolutePath());
    gr = GeoRasterFactory.createGeoRaster(file2.getAbsolutePath());
    gr.open();

    final float[] gridPixels = gr.getFloatPixels();
    assertTrue(gridPixels.length == pixels.length);
    equals(pixels, gridPixels);
    final RasterMetadata newM = gr.getMetadata();

    assertTrue(newM.getEnvelope().equals(originalMetadata.getEnvelope()));
    assertTrue(newM.getNCols() == originalMetadata.getNCols());
    assertTrue(newM.getNRows() == originalMetadata.getNRows());
    assertTrue(newM.getPixelSize_X() == originalMetadata.getPixelSize_X());
    assertTrue(newM.getPixelSize_Y() == originalMetadata.getPixelSize_Y());
    assertTrue(newM.getRotation_X() == originalMetadata.getRotation_X());
    assertTrue(newM.getRotation_Y() == originalMetadata.getRotation_Y());
    assertTrue(newM.getXulcorner() == originalMetadata.getXulcorner());
    assertTrue(newM.getYulcorner() == originalMetadata.getYulcorner());
  }
Exemple #2
0
 @Test
 public void testCheckFloatRasterIO() throws Exception {
   RasterMetadata rasterMetadata = new RasterMetadata(0, 0, 10, 10, 2, 2);
   float[] floatPixels = new float[] {1.2f, 2000123.2f, -322225.2f, 4.3f};
   GeoRaster grBytes = GeoRasterFactory.createGeoRaster(floatPixels, rasterMetadata);
   GeoRaster gr = checkRasterMetadataIO(grBytes);
   float[] savedPixels = gr.getFloatPixels();
   assertEquals(savedPixels.length, floatPixels.length);
   assertArrayEquals(savedPixels, floatPixels, 0);
 }