예제 #1
0
        protected bool doCanRead(Object source, AVList parameters)
        {
            if (!(source is java.io.File) && !(source is java.net.URL))
            {
                return(false);
            }

            // If the data source doesn't already have all the necessary metadata, then we determine whether or not
            // the missing metadata can be read.
            String error = this.validateMetadata(source, parameters);

            if (!WWUtil.isEmpty(error))
            {
                if (!WorldFile.hasWorldFiles(source))
                {
                    Logging.logger().fine(error);
                    return(false);
                }
            }

            if (null != parameters)
            {
                if (!params.hasKey(AVKey.PIXEL_FORMAT))
                {
                    parameters.setValue(AVKey.PIXEL_FORMAT, AVKey.ELEVATION);
                }
            }

            return(true);
        }
예제 #2
0
        protected static AVList wcsGetParamsFromCapsDoc(WCS100Capabilities caps, AVList parameters)
        {
            if (caps == null)
            {
                String message = Logging.getMessage("nullValue.WCSCapabilities");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (parameters == null)
            {
                String message = Logging.getMessage("nullValue.ElevationModelConfigParams");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            WCS100DescribeCoverage coverage = (WCS100DescribeCoverage)parameters.getValue(AVKey.DOCUMENT);

            if (coverage == null)
            {
                String message = Logging.getMessage("nullValue.WCSDescribeCoverage");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            getWCSElevationModelConfigParams(caps, coverage, parameters);

            wcsSetFallbacks(parameters);
            determineNumLevels(coverage, parameters);

            parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(caps.getVersion(), parameters));

            if (parameters.getValue(AVKey.ELEVATION_EXTREMES_FILE) == null)
            {
                // Use the default extremes file if there are at least as many levels in this new elevation model as the
                // level of the extremes file, which is level 5.
                int numLevels = (int)parameters.getValue(AVKey.NUM_LEVELS);
                if (numLevels >= 6)
                {
                    parameters.setValue(AVKey.ELEVATION_EXTREMES_FILE, "config/SRTM30Plus_ExtremeElevations_5.bil");
                }
            }

            return(parameters);
        }
예제 #3
0
        protected static void wcsSetFallbacks(AVList parameters)
        {
            if (parameters.getValue(AVKey.LEVEL_ZERO_TILE_DELTA) == null)
            {
                Angle delta = Angle.fromDegrees(20);
                parameters.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, new LatLon(delta, delta));
            }

            if (parameters.getValue(AVKey.TILE_WIDTH) == null)
            {
                parameters.setValue(AVKey.TILE_WIDTH, 150);
            }

            if (parameters.getValue(AVKey.TILE_HEIGHT) == null)
            {
                parameters.setValue(AVKey.TILE_HEIGHT, 150);
            }

            if (parameters.getValue(AVKey.FORMAT_SUFFIX) == null)
            {
                parameters.setValue(AVKey.FORMAT_SUFFIX, ".tif");
            }

            if (parameters.getValue(AVKey.MISSING_DATA_SIGNAL) == null)
            {
                parameters.setValue(AVKey.MISSING_DATA_SIGNAL, -9999d);
            }

            if (parameters.getValue(AVKey.NUM_LEVELS) == null)
            {
                parameters.setValue(AVKey.NUM_LEVELS, 18); // approximately 20 cm per pixel
            }
            if (parameters.getValue(AVKey.NUM_EMPTY_LEVELS) == null)
            {
                parameters.setValue(AVKey.NUM_EMPTY_LEVELS, 0);
            }

            if (parameters.getValue(AVKey.ELEVATION_MIN) == null)
            {
                parameters.setValue(AVKey.ELEVATION_MIN, -11000.0);
            }

            if (parameters.getValue(AVKey.ELEVATION_MAX) == null)
            {
                parameters.setValue(AVKey.ELEVATION_MAX, 8850.0);
            }
        }
예제 #4
0
        protected static void wcsRestoreStateForParams(RestorableSupport rs, RestorableSupport.StateObject context,
                                                       AVList parameters)
        {
            // Invoke the BasicElevationModel functionality.
            restoreStateForParams(rs, null, parameters);

            String s = rs.getStateValueAsString(context, AVKey.IMAGE_FORMAT);

            if (s != null)
            {
                parameters.setValue(AVKey.IMAGE_FORMAT, s);
            }

            s = rs.getStateValueAsString(context, AVKey.TITLE);
            if (s != null)
            {
                parameters.setValue(AVKey.TITLE, s);
            }

            s = rs.getStateValueAsString(context, AVKey.DISPLAY_NAME);
            if (s != null)
            {
                parameters.setValue(AVKey.DISPLAY_NAME, s);
            }

            RestorableSupport.adjustTitleAndDisplayName(parameters);

            s = rs.getStateValueAsString(context, AVKey.COVERAGE_IDENTIFIERS);
            if (s != null)
            {
                parameters.setValue(AVKey.COVERAGE_IDENTIFIERS, s);
            }

            s = rs.getStateValueAsString(context, AVKey.WCS_VERSION);
            if (s != null)
            {
                parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(s, parameters));
            }
        }
예제 #5
0
        protected static void determineNumLevels(WCS100DescribeCoverage coverage, AVList parameters)
        {
            List <GMLRectifiedGrid> grids =
                coverage.getCoverageOfferings().get(0).getDomainSet().getSpatialDomain().getRectifiedGrids();

            if (grids.Count < 1 || grids[0].getOffsetVectors().Count < 2)
            {
                parameters.setValue(AVKey.NUM_LEVELS, 18);
                return;
            }

            double xRes           = Math.Abs(grids[0].getOffsetVectors().get(0).x);
            double yRes           = Math.Abs(grids[0].getOffsetVectors().get(1).y);
            double dataResolution = Math.Min(xRes, yRes);

            int    tileSize    = (int)parameters.getValue(AVKey.TILE_WIDTH);
            LatLon level0Delta = (LatLon)parameters.getValue(AVKey.LEVEL_ZERO_TILE_DELTA);

            double n = Math.Log(level0Delta.getLatitude().degrees / (dataResolution * tileSize)) / Math.Log(2);

            parameters.setValue(AVKey.NUM_LEVELS, (int)(Math.Ceiling(n) + 1));
        }
        protected static void legacyWmsRestoreStateToParams(RestorableSupport rs, RestorableSupport.StateObject context,
                                                            AVList parameters)
        {
            // WMSTiledImageLayer has historically used a different format for storing LatLon and Sector properties
            // in the restorable state XML documents. Although WMSTiledImageLayer no longer writes these properties,
            // we must provide support for reading them here.
            Double lat = rs.getStateValueAsDouble(context, AVKey.LEVEL_ZERO_TILE_DELTA + ".Latitude");
            Double lon = rs.getStateValueAsDouble(context, AVKey.LEVEL_ZERO_TILE_DELTA + ".Longitude");

            if (lat != null && lon != null)
            {
                parameters.setValue(AVKey.LEVEL_ZERO_TILE_DELTA, LatLon.fromDegrees(lat, lon));
            }

            Double minLat = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MinLatitude");
            Double minLon = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MinLongitude");
            Double maxLat = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MaxLatitude");
            Double maxLon = rs.getStateValueAsDouble(context, AVKey.SECTOR + ".MaxLongitude");

            if (minLat != null && minLon != null && maxLat != null && maxLon != null)
            {
                parameters.setValue(AVKey.SECTOR, Sector.fromDegrees(minLat, maxLat, minLon, maxLon));
            }
        }
        protected static void wmsRestoreStateToParams(RestorableSupport rs, RestorableSupport.StateObject context,
                                                      AVList parameters)
        {
            // Invoke the BasicTiledImageLayer functionality.
            restoreStateForParams(rs, context, parameters);
            // Parse any legacy WMSTiledImageLayer state values.
            legacyWmsRestoreStateToParams(rs, context, parameters);

            String s = rs.getStateValueAsString(context, AVKey.IMAGE_FORMAT);

            if (s != null)
            {
                parameters.setValue(AVKey.IMAGE_FORMAT, s);
            }

            s = rs.getStateValueAsString(context, AVKey.TITLE);
            if (s != null)
            {
                parameters.setValue(AVKey.TITLE, s);
            }

            s = rs.getStateValueAsString(context, AVKey.DISPLAY_NAME);
            if (s != null)
            {
                parameters.setValue(AVKey.DISPLAY_NAME, s);
            }

            RestorableSupport.adjustTitleAndDisplayName(params);

            s = rs.getStateValueAsString(context, AVKey.LAYER_NAMES);
            if (s != null)
            {
                parameters.setValue(AVKey.LAYER_NAMES, s);
            }

            s = rs.getStateValueAsString(context, AVKey.STYLE_NAMES);
            if (s != null)
            {
                parameters.setValue(AVKey.STYLE_NAMES, s);
            }

            s = rs.getStateValueAsString(context, "wms.Version");
            if (s != null)
            {
                parameters.setValue(AVKey.WMS_VERSION, s);
            }
            parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(parameters));
        }
예제 #8
0
        protected bool doCanRead(Object source, AVList parameters)
        {
            if (!(source is java.io.File))
            {
                return(false);
            }

            java.io.File file     = (java.io.File)source;
            String       filename = file.getName().toUpperCase();

            bool canRead = RPFFrameFilename.isFilename(filename);

            if (canRead && null != parameters && !params.hasKey(AVKey.PIXEL_FORMAT))
            {
                parameters.setValue(AVKey.PIXEL_FORMAT, AVKey.IMAGE);
            }

            return(canRead);
        }
예제 #9
0
        protected static AVList wmsGetParamsFromCapsDoc(WMSCapabilities caps, AVList parameters)
        {
            if (caps == null)
            {
                String message = Logging.getMessage("nullValue.WMSCapabilities");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (parameters == null)
            {
                String message = Logging.getMessage("nullValue.ElevationModelConfigParams");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            String wmsVersion;

            try
            {
                wmsVersion = caps.getVersion();
                getWMSElevationModelConfigParams(caps, formatOrderPreference, parameters);
            }
            catch (ArgumentException e)
            {
                String message = Logging.getMessage("WMS.MissingLayerParameters");
                Logging.logger().severe(message, e);
                throw new ArgumentException(message, e);
            }
            catch (WWRuntimeException e)
            {
                String message = Logging.getMessage("WMS.MissingCapabilityValues");
                Logging.logger().severe(message, e);
                throw new ArgumentException(message, e);
            }

            wmsSetFallbacks(parameters);

            parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(wmsVersion, parameters));

            return(parameters);
        }
예제 #10
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);
        }
예제 #11
0
        public static void checkAndSetValue(VPFRecord record, String paramName, String paramKey, AVList parameters)
        {
            if (record == null)
            {
                String message = Logging.getMessage("nullValue.RecordIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (paramName == null)
            {
                String message = Logging.getMessage("nullValue.ParameterNameIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (paramKey == null)
            {
                String message = Logging.getMessage("nullValue.ParameterKeyIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (params == null)
            {
                String message = Logging.getMessage("nullValue.ParamsIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (record.hasValue(paramName))
            {
                Object o = record.getValue(paramName);
                if (o != null)
                {
                    parameters.setValue(paramKey, o);
                }
            }
        }
예제 #12
0
        //**************************************************************//
        //********************  Configuration  *************************//
        //**************************************************************//

        /**
         * Parses WMSBasicElevationModel configuration parameters from a specified WMS Capabilities source. This writes
         * output as key-value pairs to parameters. Supported key and parameter names are: <table>
         * <th><td>Parameter</td><td>Value</td><td>Type</td></th> <tr><td>{@link AVKey#ELEVATION_MAX}</td><td>WMS layer's
         * maximum extreme elevation</td><td>Double</td></tr> <tr><td>{@link AVKey#ELEVATION_MIN}</td><td>WMS layer's
         * minimum extreme elevation</td><td>Double</td></tr> <tr><td>{@link AVKey#DATA_TYPE}</td><td>Translate WMS layer's
         * image format to a matching data type</td><td>String</td></tr> </table> This also parses common WMS layer
         * parameters by invoking {@link DataConfigurationUtils#getWMSLayerConfigParams(gov.nasa.worldwind.ogc.wms.WMSCapabilities,
         * String[], SharpEarth.avlist.AVList)}.
         *
         * @param caps                  the WMS Capabilities source to parse for WMSBasicElevationModel configuration
         *                              parameters.
         * @param formatOrderPreference an ordered array of preferred image formats, or null to use the default format.
         * @param parameters                the output key-value pairs which recieve the WMSBasicElevationModel configuration
         *                              parameters.
         *
         * @return a reference to parameters.
         *
         * @throws ArgumentException if either the document or parameters are null, or if parameters does not contain the
         *                                  required key-value pairs.
         * @throws SharpEarth.exception.WWRuntimeException
         *                                  if the Capabilities document does not contain any of the required information.
         */
        public static AVList getWMSElevationModelConfigParams(WMSCapabilities caps, String[] formatOrderPreference,
                                                              AVList parameters)
        {
            if (caps == null)
            {
                String message = Logging.getMessage("nullValue.WMSCapabilities");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (parameters == null)
            {
                String message = Logging.getMessage("nullValue.ElevationModelConfigParams");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            // Get common WMS layer parameters.
            DataConfigurationUtils.getWMSLayerConfigParams(caps, formatOrderPreference, parameters);

            // Attempt to extract the WMS layer names from the specified parameters.
            String layerNames = parameters.getStringValue(AVKey.LAYER_NAMES);

            if (layerNames == null || layerNames.Length == 0)
            {
                String message = Logging.getMessage("nullValue.WMSLayerNames");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            String[] names = layerNames.Split(',');
            if (names == null || names.Length == 0)
            {
                String message = Logging.getMessage("nullValue.WMSLayerNames");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            // Get the layer's extreme elevations.
            Double[] extremes = caps.getLayerExtremeElevations(names);

            Double d = (Double)parameters.getValue(AVKey.ELEVATION_MIN);

            if (d == null && extremes != null && extremes[0] != null)
            {
                parameters.setValue(AVKey.ELEVATION_MIN, extremes[0]);
            }

            d = (Double)parameters.getValue(AVKey.ELEVATION_MAX);
            if (d == null && extremes != null && extremes[1] != null)
            {
                parameters.setValue(AVKey.ELEVATION_MAX, extremes[1]);
            }

            // Compute the internal pixel type from the image format.
            if (parameters.getValue(AVKey.DATA_TYPE) == null && parameters.getValue(AVKey.IMAGE_FORMAT) != null)
            {
                String s = WWIO.makeDataTypeForMimeType(parameters.getValue(AVKey.IMAGE_FORMAT).ToString());
                if (s != null)
                {
                    parameters.setValue(AVKey.DATA_TYPE, s);
                }
            }

            // Use the default data type.
            if (parameters.getValue(AVKey.DATA_TYPE) == null)
            {
                parameters.setValue(AVKey.DATA_TYPE, AVKey.INT16);
            }

            // Use the default byte order.
            if (parameters.getValue(AVKey.BYTE_ORDER) == null)
            {
                parameters.setValue(AVKey.BYTE_ORDER, AVKey.LITTLE_ENDIAN);
            }

            return(parameters);
        }
예제 #13
0
        public LevelSet(AVList parameters)
        {
            StringBuffer sb = new StringBuffer();

            Object o = parameters.getValue(AVKey.LEVEL_ZERO_TILE_DELTA);

            if (o == null || !(o is LatLon))
            {
                sb.append(Logging.getMessage("term.tileDelta")).append(" ");
            }

            o = parameters.getValue(AVKey.SECTOR);
            if (o == null || !(o is Sector))
            {
                sb.append(Logging.getMessage("term.sector")).append(" ");
            }

            int numLevels = 0;

            o = parameters.getValue(AVKey.NUM_LEVELS);
            if (o == null || !(o is Integer) || (numLevels = (Integer)o) < 1)
            {
                sb.append(Logging.getMessage("term.numLevels")).append(" ");
            }

            int numEmptyLevels = 0;

            o = parameters.getValue(AVKey.NUM_EMPTY_LEVELS);
            if (o != null && o is Integer && (Integer)o > 0)
            {
                numEmptyLevels = (Integer)o;
            }

            String[] inactiveLevels = null;
            o = parameters.getValue(AVKey.INACTIVE_LEVELS);
            if (o != null && !(o is String))
            {
                sb.append(Logging.getMessage("term.inactiveLevels")).append(" ");
            }
            else if (o != null)
            {
                inactiveLevels = ((String)o).split(",");
            }

            SectorResolution[] sectorLimits = null;
            o = parameters.getValue(AVKey.SECTOR_RESOLUTION_LIMITS);
            if (o != null && !(o is SectorResolution[]))
            {
                sb.append(Logging.getMessage("term.sectorResolutionLimits")).append(" ");
            }
            else if (o != null)
            {
                sectorLimits = (SectorResolution[])o;
                foreach (SectorResolution sr in sectorLimits)
                {
                    if (sr.levelNumber > numLevels - 1)
                    {
                        String message =
                            Logging.getMessage("LevelSet.sectorResolutionLimitsTooHigh", sr.levelNumber, numLevels - 1);
                        Logging.logger().warning(message);
                        break;
                    }
                }
            }
            this.sectorLevelLimits = sectorLimits;

            if (sb.length() > 0)
            {
                String message = Logging.getMessage("layers.LevelSet.InvalidLevelDescriptorFields", sb.ToString());
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            this.sector             = (Sector)parameters.getValue(AVKey.SECTOR);
            this.levelZeroTileDelta = (LatLon)parameters.getValue(AVKey.LEVEL_ZERO_TILE_DELTA);

            o = parameters.getValue(AVKey.TILE_ORIGIN);
            if (o != null && o is LatLon)
            {
                this.tileOrigin = (LatLon)o;
            }
            else
            {
                this.tileOrigin = new LatLon(Angle.NEG90, Angle.NEG180);
            }

            parameters = parameters.copy(); // copy so as not to modify the user's parameters

            TileUrlBuilder tub = (TileUrlBuilder)parameters.getValue(AVKey.TILE_URL_BUILDER);

            if (tub == null)
            {
                parameters.setValue(AVKey.TILE_URL_BUILDER, new TileUrlBuilder()
                {