/**
         * Returns true if the specified DOM {@link org.w3c.dom.Element} should be accepted as a configuration document.
         *
         * @param domElement the Document in question.
         *
         * @return true if the Document should be accepted; false otherwise.
         *
         * @throws ArgumentException if the document is null.
         */
        public bool accept(Element domElement)
        {
            if (domElement == null)
            {
                String message = Logging.getMessage("nullValue.DocumentIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(DataConfigurationUtils.isDataConfig(domElement));
        }
Exemple #2
0
        /**
         * Appends WMS basic elevation model configuration elements to the superclass configuration document.
         *
         * @param parameters configuration parameters describing this WMS basic elevation model.
         *
         * @return a WMS basic elevation model configuration document.
         */
        protected XDocument createConfigurationDocument(AVList parameters)
        {
            XDocument doc = base.createConfigurationDocument(parameters);

            if (doc == null || doc.getDocumentElement() == null)
            {
                return(doc);
            }

            DataConfigurationUtils.createWMSLayerConfigElements(parameters, doc.getDocumentElement());

            return(doc);
        }
        public static AVList getWCSElevationModelConfigParams(WCS100Capabilities caps, WCS100DescribeCoverage coverage,
                                                              AVList parameters)
        {
            DataConfigurationUtils.getWCSConfigParameters(caps, coverage, parameters); // checks for null args

            // Ensure that we found all the necessary information.
            if (parameters.getStringValue(AVKey.DATASET_NAME) == null)
            {
                Logging.logger().warning(Logging.getMessage("WCS.NoCoverageName"));
                throw new WWRuntimeException(Logging.getMessage("WCS.NoCoverageName"));
            }

            if (parameters.getStringValue(AVKey.SERVICE) == null)
            {
                Logging.logger().warning(Logging.getMessage("WCS.NoGetCoverageURL"));
                throw new WWRuntimeException(Logging.getMessage("WCS.NoGetCoverageURL"));
            }

            if (parameters.getStringValue(AVKey.DATA_CACHE_NAME) == null)
            {
                Logging.logger().warning(Logging.getMessage("nullValue.DataCacheIsNull"));
                throw new WWRuntimeException(Logging.getMessage("nullValue.DataCacheIsNull"));
            }

            if (parameters.getStringValue(AVKey.IMAGE_FORMAT) == null)
            {
                Logging.logger().severe("WCS.NoImageFormats");
                throw new WWRuntimeException(Logging.getMessage("WCS.NoImageFormats"));
            }

            if (parameters.getValue(AVKey.SECTOR) == null)
            {
                Logging.logger().severe("WCS.NoLonLatEnvelope");
                throw new WWRuntimeException(Logging.getMessage("WCS.NoLonLatEnvelope"));
            }

            if (parameters.getStringValue(AVKey.COORDINATE_SYSTEM) == null)
            {
                String msg = Logging.getMessage("WCS.RequiredCRSNotSupported", "EPSG:4326");
                Logging.logger().severe(msg);
                throw new WWRuntimeException(msg);
            }

            return(parameters);
        }
        /**
         * Extracts parameters necessary to configure the layer from a WMS capabilities document.
         *
         * @param caps   the capabilities document.
         * @param parameters an attribute-value list in which to place the extracted parameters. May be null, in which case a
         *               new attribute-value list is created and returned.
         *
         * @return the attribute-value list passed as the second parameter, or the list created if the second parameter is
         *         null.
         *
         * @throws ArgumentException if the capabilities document reference is null.
         */
        public 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)
            {
                parameters = new AVListImpl();
            }

            try
            {
                DataConfigurationUtils.getWMSLayerConfigParams(caps, formatOrderPreference, parameters);
            }
            catch (ArgumentException e)
            {
                String message = Logging.getMessage("WMS.MissingLayerParameters");
                Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
                throw new ArgumentException(message, e);
            }
            catch (WWRuntimeException e)
            {
                String message = Logging.getMessage("WMS.MissingCapabilityValues");
                Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
                throw new ArgumentException(message, e);
            }

            setFallbacks(parameters);

            // Setup WMS URL builder.
            parameters.setValue(AVKey.WMS_VERSION, caps.getVersion());
            parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(params));
            // Setup default WMS tiled image layer behaviors.
            parameters.setValue(AVKey.USE_TRANSPARENT_TEXTURES, true);

            return(parameters);
        }
        /**
         * Extracts parameters necessary to configure the layer from an XML DOM element.
         *
         * @param domElement the element to search for parameters.
         * @param parameters     an attribute-value list in which to place the extracted parameters. May be null, in which case
         *                   a new attribue-value list is created and returned.
         *
         * @return the attribute-value list passed as the second parameter, or the list created if the second parameter is
         *         null.
         *
         * @throws ArgumentException if the DOM element is null.
         */
        protected static AVList wmsGetParamsFromDocument(Element domElement, AVList parameters)
        {
            if (domElement == null)
            {
                String message = Logging.getMessage("nullValue.DocumentIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (parameters == null)
            {
                parameters = new AVListImpl();
            }

            DataConfigurationUtils.getWMSLayerConfigParams(domElement, parameters);
            BasicTiledImageLayer.getParamsFromDocument(domElement, parameters);

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

            return(parameters);
        }
        protected static AVList wcsGetParamsFromDocument(XElement domElement, AVList parameters)
        {
            if (domElement == null)
            {
                String message = Logging.getMessage("nullValue.DocumentIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (parameters == null)
            {
                parameters = new AVListImpl();
            }

            DataConfigurationUtils.getWCSConfigParams(domElement, parameters);
            BasicElevationModel.getBasicElevationModelConfigParams(domElement, parameters);
            wcsSetFallbacks(parameters);

            parameters.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(parameters.getStringValue(AVKey.WCS_VERSION), parameters));

            return(parameters);
        }
Exemple #7
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);
        }