Search in sources :

Example 1 with GDALImageReadParam

use of it.geosolutions.imageio.gdalframework.GDALImageReadParam in project imageio-ext by geosolutions-it.

the class GeoTiffTest method readWithWarp.

/**
 * Test Read exploiting JAI-ImageIO tools capabilities
 * and GDAL warp.
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void readWithWarp() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    final ParameterBlockJAI pbjImageRead;
    String fileName = "utmByte.tif";
    final File file = TestData.file(this, fileName);
    SpatialReference destinationReference = new SpatialReference();
    destinationReference.SetProjCS("UTM 17 (WGS84) in northern hemisphere.");
    destinationReference.SetWellKnownGeogCS("WGS84");
    destinationReference.SetUTM(17, 1);
    GDALImageReadParam readParam = new GDALImageReadParam();
    readParam.setDestinationWkt(destinationReference.ExportToWkt());
    readParam.setResampleAlgorithm(ResampleAlgorithm.CUBIC);
    pbjImageRead = new ParameterBlockJAI("ImageRead");
    pbjImageRead.setParameter("Input", new FileImageInputStreamExtImpl(file));
    pbjImageRead.setParameter("Reader", new GeoTiffImageReaderSpi().createReaderInstance());
    pbjImageRead.setParameter("ReadParam", readParam);
    RenderedOp image = JAI.create("ImageRead", pbjImageRead);
    if (TestData.isInteractiveTest())
        Viewer.visualizeAllInformation(image, "", true);
    else
        Assert.assertNotNull(image.getTiles());
}
Also used : RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) SpatialReference(org.gdal.osr.SpatialReference) FileImageInputStreamExtImpl(it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl) GDALImageReadParam(it.geosolutions.imageio.gdalframework.GDALImageReadParam) File(java.io.File) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest) Test(org.junit.Test)

Aggregations

AbstractGDALTest (it.geosolutions.imageio.gdalframework.AbstractGDALTest)1 GDALImageReadParam (it.geosolutions.imageio.gdalframework.GDALImageReadParam)1 FileImageInputStreamExtImpl (it.geosolutions.imageio.stream.input.FileImageInputStreamExtImpl)1 File (java.io.File)1 ParameterBlockJAI (javax.media.jai.ParameterBlockJAI)1 RenderedOp (javax.media.jai.RenderedOp)1 SpatialReference (org.gdal.osr.SpatialReference)1 Test (org.junit.Test)1