Esempio n. 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());
  }
Esempio n. 2
0
  @Test
  public void testLoadSaveGrid() throws Exception {
    GeoRaster gr = GeoRasterFactory.createGeoRaster(internalData + "3x3.asc");
    gr.open();
    check3x3(gr);
    gr.save(tmpData + "1.png");

    gr = GeoRasterFactory.createGeoRaster(tmpData + "1.png");
    gr.open();
    check3x3(gr);
  }
Esempio n. 3
0
 @Test
 public void testXYZDEMReader() throws Exception {
   final GeoRaster gr =
       GeoRasterFactory.createGeoRaster(
           internalData + "MNT_Nantes_Lambert.xyz", GeoProcessorType.FLOAT, 10);
   gr.open();
   gr.save(tmpData + "xyzdem.tif");
 }
Esempio n. 4
0
 private void testOpen(File file) throws Exception {
   GeoRaster gr = GeoRasterFactory.createGeoRaster(file.getAbsolutePath());
   gr.open();
   int rasterType = gr.getType();
   DataSource ds = dsf.getDataSource(file);
   ds.open();
   Metadata metadata = ds.getMetadata();
   Type fieldType = metadata.getFieldType(0);
   assertTrue(fieldType.getIntConstraint(Constraint.RASTER_TYPE) == rasterType);
   ds.getFieldValue(0, 0);
   ds.close();
 }
Esempio n. 5
0
  public void testCropLeHavre() throws Exception {
    String src = externalData + "geotif/littlelehavre.tif";
    GeoRaster geoRaster = GeoRasterFactory.createGeoRaster(src);
    geoRaster.open();
    RasterMetadata metadata = geoRaster.getMetadata();
    Crop crop =
        new Crop(
            new Rectangle2D.Double(metadata.getXulcorner(), metadata.getYulcorner(), 10, -110));
    // Just test it doesn't throw any exception
    geoRaster.doOperation(crop);

    assertTrue(true);
  }
Esempio n. 6
0
  @Test
  public void testAllWatersheds() throws Exception {
    // load the DEM
    geoRasterSrc.open();

    // compute the slopes directions
    final Operation slopesDirections = new D8OpDirection();
    final GeoRaster grSlopesDirections = geoRasterSrc.doOperation(slopesDirections);

    // compute all watersheds
    final Operation allWatersheds = new D8OpAllWatersheds();
    final GeoRaster grAllWatersheds = grSlopesDirections.doOperation(allWatersheds);

    // compare the computed watersheds with previous ones
    printGeoRasterAndArray(grAllWatersheds, allWatershedsForDEM);
    compareGeoRasterAndArray(grAllWatersheds, allWatershedsForDEM);
  }
Esempio n. 7
0
 @Test(expected = IOException.class)
 public void testPNGWithoutWorldFile() throws Exception {
   final GeoRaster gr = GeoRasterFactory.createGeoRaster(internalData + "noWorldFile.png");
   gr.open();
   gr.getType();
 }
Esempio n. 8
0
 @Test
 public void testJPGReader() throws Exception {
   final GeoRaster gr = GeoRasterFactory.createGeoRaster(internalData + "smallChezineLambert.jpg");
   gr.open();
 }
Esempio n. 9
0
 @Test(expected = IOException.class)
 public void testGridWithoutHeader() throws Exception {
   final GeoRaster gr = GeoRasterFactory.createGeoRaster(externalData + "ij3x3.asc");
   gr.open();
 }
Esempio n. 10
0
 protected void setUp() throws Exception {
   super.setUp();
   geoRasterSrc = GeoRasterFactory.createGeoRaster(externalData + "grid/sample.asc");
   geoRasterSrc.open();
 }