Search in sources :

Example 1 with GDALCommonIIOImageMetadata

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

the class GeoTiffVrtTest method testGCP.

/**
 * Test Read exploiting JAI-ImageIO tools capabilities
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void testGCP() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    String fileName = "gcp.tif.vrt";
    final File file = TestData.file(this, fileName);
    ImageReader reader = new VRTImageReaderSpi().createReaderInstance();
    reader.setInput(file);
    GDALCommonIIOImageMetadata metadata = (GDALCommonIIOImageMetadata) reader.getImageMetadata(0);
    final int gcpNumber = metadata.getGcpNumber();
    Assert.assertEquals(gcpNumber, 4);
    final List<GCP> gcps = metadata.getGCPs();
    Assert.assertNotNull(gcps);
    Assert.assertFalse(gcps.isEmpty());
    for (int i = 0; i < 4; i++) {
        Assert.assertEquals(gcps.get(i), referenceGCPs.get(i));
    }
    reader.dispose();
}
Also used : GCP(it.geosolutions.imageio.core.GCP) GDALCommonIIOImageMetadata(it.geosolutions.imageio.gdalframework.GDALCommonIIOImageMetadata) ImageReader(javax.imageio.ImageReader) File(java.io.File) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest) Test(org.junit.Test)

Example 2 with GDALCommonIIOImageMetadata

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

the class MrSIDTest method metadataAccess.

/**
 * Test retrieving all available metadata properties
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void metadataAccess() throws FileNotFoundException, IOException {
    if (!isMrSidAvailable) {
        return;
    }
    try {
        final File file = TestData.file(this, fileName);
        final ParameterBlockJAI pbjImageRead = new ParameterBlockJAI("ImageRead");
        pbjImageRead.setParameter("Input", file);
        RenderedOp image = JAI.create("ImageRead", pbjImageRead);
        IIOMetadata metadata = (IIOMetadata) image.getProperty(ImageReadDescriptor.PROPERTY_NAME_METADATA_IMAGE);
        Assert.assertTrue(metadata instanceof GDALCommonIIOImageMetadata);
        Assert.assertTrue(metadata instanceof MrSIDIIOImageMetadata);
        GDALCommonIIOImageMetadata commonMetadata = (GDALCommonIIOImageMetadata) metadata;
        ImageIOUtilities.displayImageIOMetadata(commonMetadata.getAsTree(GDALCommonIIOImageMetadata.nativeMetadataFormatName));
        ImageIOUtilities.displayImageIOMetadata(commonMetadata.getAsTree(MrSIDIIOImageMetadata.mrsidImageMetadataName));
        if (TestData.isInteractiveTest())
            Viewer.visualizeAllInformation(image, "", TestData.isInteractiveTest());
        else {
            ImageIOUtilities.disposeImage(image);
        }
    } catch (FileNotFoundException fnfe) {
        warningMessage();
    }
    try {
        final File file = TestData.file(this, fileName);
        ImageReader reader = new MrSIDImageReaderSpi().createReaderInstance();
        reader.setInput(ImageIO.createImageInputStream(file));
        Assert.assertEquals(618, reader.getWidth(0));
        Assert.assertEquals(1265, reader.getHeight(0));
        IIOMetadata metadata = (IIOMetadata) reader.getImageMetadata(0);
        Assert.assertTrue(metadata instanceof GDALCommonIIOImageMetadata);
        Assert.assertTrue(metadata instanceof MrSIDIIOImageMetadata);
        GDALCommonIIOImageMetadata commonMetadata = (GDALCommonIIOImageMetadata) metadata;
        ImageIOUtilities.displayImageIOMetadata(commonMetadata.getAsTree(GDALCommonIIOImageMetadata.nativeMetadataFormatName));
        ImageIOUtilities.displayImageIOMetadata(commonMetadata.getAsTree(MrSIDIIOImageMetadata.mrsidImageMetadataName));
        reader.dispose();
    } catch (FileNotFoundException fnfe) {
        warningMessage();
    }
}
Also used : IIOMetadata(javax.imageio.metadata.IIOMetadata) RenderedOp(javax.media.jai.RenderedOp) ParameterBlockJAI(javax.media.jai.ParameterBlockJAI) FileNotFoundException(java.io.FileNotFoundException) GDALCommonIIOImageMetadata(it.geosolutions.imageio.gdalframework.GDALCommonIIOImageMetadata) ImageReader(javax.imageio.ImageReader) File(java.io.File) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest) Test(org.junit.Test)

Example 3 with GDALCommonIIOImageMetadata

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

the class GeoTiffTest method testGCP.

/**
 * Test Read exploiting JAI-ImageIO tools capabilities
 *
 * @throws FileNotFoundException
 * @throws IOException
 */
@Test
public void testGCP() throws FileNotFoundException, IOException {
    if (!isGDALAvailable) {
        return;
    }
    String fileName = "gcp.tif";
    final File file = TestData.file(this, fileName);
    ImageReader reader = new GeoTiffImageReaderSpi().createReaderInstance();
    reader.setInput(file);
    GDALCommonIIOImageMetadata metadata = (GDALCommonIIOImageMetadata) reader.getImageMetadata(0);
    final int gcpNumber = metadata.getGcpNumber();
    Assert.assertEquals(gcpNumber, 4);
    final List<GCP> gcps = metadata.getGCPs();
    Assert.assertNotNull(gcps);
    Assert.assertFalse(gcps.isEmpty());
    for (int i = 0; i < 4; i++) {
        Assert.assertEquals(gcps.get(i), referenceGCPs.get(i));
    }
    reader.dispose();
}
Also used : GCP(it.geosolutions.imageio.core.GCP) GDALCommonIIOImageMetadata(it.geosolutions.imageio.gdalframework.GDALCommonIIOImageMetadata) ImageReader(javax.imageio.ImageReader) File(java.io.File) AbstractGDALTest(it.geosolutions.imageio.gdalframework.AbstractGDALTest) Test(org.junit.Test)

Aggregations

AbstractGDALTest (it.geosolutions.imageio.gdalframework.AbstractGDALTest)3 GDALCommonIIOImageMetadata (it.geosolutions.imageio.gdalframework.GDALCommonIIOImageMetadata)3 File (java.io.File)3 ImageReader (javax.imageio.ImageReader)3 Test (org.junit.Test)3 GCP (it.geosolutions.imageio.core.GCP)2 FileNotFoundException (java.io.FileNotFoundException)1 IIOMetadata (javax.imageio.metadata.IIOMetadata)1 ParameterBlockJAI (javax.media.jai.ParameterBlockJAI)1 RenderedOp (javax.media.jai.RenderedOp)1