/**
         * Constructs a downloader to retrieve imagery not currently available in a specified file store.
         * <p/>
         * The thread returned is not started during construction, the caller must start the thread.
         *
         * @param layer      the layer for which to download imagery.
         * @param sector     the sector to download data for. This value is final.
         * @param resolution the target resolution, provided in radians of latitude per texel. This value is final.
         * @param fileStore  the file store in which to place the downloaded elevations.
         * @param listener   an optional retrieval listener. May be null.
         *
         * @throws ArgumentException if either the layer, the sector or file store are null, or the resolution is
         *                                  less than zero.
         */
        public BasicTiledImageLayerBulkDownloader(BasicTiledImageLayer layer, Sector sector, double resolution,
                                                  FileStore fileStore, BulkRetrievalListener listener)
        {
            // Arguments checked in parent constructor
            super(layer, sector, resolution, fileStore, listener);

            this.layer = layer;
            this.level = this.layer.computeLevelForResolution(sector, resolution);
        }
        /**
         * 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);
        }
        /**
         * Create a {@link TiledImageLayer} layer described by an XML layer description.
         *
         * @param domElement the XML element describing the layer to create. The element must inculde a service name
         *                   identifying the type of service to use to retrieve layer data. Recognized service types are
         *                   "Offline", "WWTileService" and "OGC:WMS".
         * @param parameters     any parameters to apply when creating the layer.
         *
         * @return a new layer
         *
         * @throws WWUnrecognizedException if the service type given in the describing element is unrecognized.
         */
        protected Layer createTiledImageLayer(Element domElement, AVList parameters)
        {
            Layer layer;

            String serviceName = WWXML.getText(domElement, "Service/@serviceName");

            if ("Offline".Equals(serviceName))
            {
                layer = new BasicTiledImageLayer(domElement, parameters);
            }
            else if ("WWTileService".Equals(serviceName))
            {
                layer = new BasicTiledImageLayer(domElement, parameters);
            }
            else if (OGCConstants.WMS_SERVICE_NAME.Equals(serviceName))
            {
                layer = new WMSTiledImageLayer(domElement, parameters);
            }
            else if (AVKey.SERVICE_NAME_LOCAL_RASTER_SERVER.Equals(serviceName))
            {
                layer = new LocalRasterServerLayer(domElement, parameters);
            }
            else
            {
                String msg = Logging.getMessage("generic.UnrecognizedServiceName", serviceName);
                throw new WWUnrecognizedException(msg);
            }
//
//        String name = layer.getStringValue(AVKey.DISPLAY_NAME);
//        System.out.println(name);

            String actuate = WWXML.getText(domElement, "@actuate");

            layer.setEnabled(actuate != null && actuate.Equals("onLoad"));

            return(layer);
        }