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();
}
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();
}
}
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();
}
Aggregations