예제 #1
0
        protected bool doCanRead(Object source, AVList parameters)
        {
            if (WWUtil.isEmpty(source))
            {
                return(false);
            }

            if (null == parameters)
            {
                File file = WWIO.getFileForLocalAddress(source);
                if (null == file)
                {
                    return(false);
                }

                return(GDALUtils.canOpen(file));
            }

            bool           canOpen = false;
            GDALDataRaster raster  = null;

            try
            {
                raster = new GDALDataRaster(source, true); // read data raster quietly
                parameters.setValues(raster.getMetadata());
                canOpen = true;
            }
            catch (Throwable t)
            {
                // we purposely ignore any exception here, this should be a very quiet mode
                canOpen = false;
            }
            finally
            {
                if (null != raster)
                {
                    raster.dispose();
                    raster = null;
                }
            }

            return(canOpen);
        }
예제 #2
0
        protected bool doCanRead(Object source, AVList parameters)
        {
            File file = this.getFile(source);

            if (null == file)
            {
                return(false);
            }

            // Assume that a proper suffix reliably identifies a DTED file. Otherwise the file will have to be loaded
            // to determine that, and there are often tens of thousands of DTED files, which causes raster server start-up
            // times to be excessive.
            if (this.canReadSuffix(source))
            {
                parameters.setValue(AVKey.PIXEL_FORMAT, AVKey.ELEVATION); // we know that DTED is elevation data
                return(true);
            }

            bool canRead = false;

            try
            {
                AVList metadata = DTED.readMetadata(file);
                if (null != metadata)
                {
                    if (null != parameters)
                    {
                        parameters.setValues(metadata);
                    }

                    canRead = AVKey.ELEVATION.Equals(metadata.getValue(AVKey.PIXEL_FORMAT));
                }
            }
            catch (Throwable t)
            {
                Logging.logger().finest(t.getMessage());
                canRead = false;
            }

            return(canRead);
        }