Examples of GDALImageReaderSpi


Examples of it.geosolutions.imageio.gdalframework.GDALImageReaderSpi

    @SuppressWarnings("unchecked")
    private static void getExtensionsForFormat(GridFormatFactorySpi gridFormatFactorySpi,
            BaseGDALGridFormat format) {

        GDALImageReaderSpi gdalSPI = null;
        try {
            if (format.getClass().getSuperclass().equals(BaseGDALGridFormat.class)) {
                Class<BaseGDALGridFormat> baseGDALGridFormatClass = (Class<BaseGDALGridFormat>) format
                        .getClass().getSuperclass();

                // TODO REVIEW Is there an other API to get the Extensions for
                // Grid Format?
                Field field = baseGDALGridFormatClass.getDeclaredField(SPI_ATTRIBUTE_GRID_FORMAT);
                field.setAccessible(true);
                Class<?> type = field.getType();
                if (type != null && type.equals(ImageReaderSpi.class)) {
                    ImageReaderSpi spi = (ImageReaderSpi) field.get(format);
                    if (spi instanceof GDALImageReaderSpi) {
                        gdalSPI = (GDALImageReaderSpi) spi;
                    }
                }
            }
        } catch (Exception e) {
            Activator
                    .log("unable to load Extensions for imageio-ext Format " + format.getName(), e); //$NON-NLS-1$
            return;
        }

        if (gdalSPI != null) {
            HashSet<String> extensions = new HashSet<String>();
            List<String> supportedFormats = gdalSPI.getSupportedFormats();

            for (String supportedFormat : supportedFormats) {

                if (!GDALUtilities.isDriverAvailable(supportedFormat)) {
                    continue;
                }

                // check GDAL Driver
                Driver getDriverByName = gdal.GetDriverByName(supportedFormat);
                if (getDriverByName != null) {
                    String dmdExtension = getDriverByName
                            .GetMetadataItem(GDAL_METADATA_DMD_EXTENSION);
                    if (dmdExtension != null && dmdExtension.length() > 0) {
                        extensions.add(dmdExtension.trim().toLowerCase());
                    }
                }

                // TODO Review : File extension from SPI's
                // (it.geosolutions.imageio.plugins) seems to be different to
                // the GDAL Driver extensions
                String[] fileSuffixes = gdalSPI.getFileSuffixes();
                if (fileSuffixes != null) {
                    for (String fileSuffix : fileSuffixes) {
                        if (fileSuffix != null && fileSuffix.trim().length() > 0) {
                            extensions.add(fileSuffix.trim().toLowerCase());
                        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.