示例#1
0
        public static double?getDoubleValue(AVList avList, string key)
        {
            object o = avList.getValue(key);

            if (o == null)
            {
                return(null);
            }

            if (o is double)
            {
                return((double)o);
            }

            string v = getStringValue(avList, key);

            if (v == null)
            {
                return(null);
            }

            try
            {
                return(double.Parse(v));
            }
            catch (Exception e)
            {
                Logging.logger().log(Level.SEVERE, "Configuration.ConversionError", v);
                return(null);
            }
        }
        protected bool doCanRead(Object source, AVList parameters)
        {
            String path = WWIO.getSourcePath(source);

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

            GeotiffReader reader = null;

            try
            {
                reader = new GeotiffReader(path);
                bool isGeoTiff = reader.isGeotiff(0);
                if (!isGeoTiff)
                {
                    isGeoTiff = WorldFile.hasWorldFiles(source);
                }
                return(isGeoTiff);
            }
            catch (Exception e)
            {
                // Intentionally ignoring exceptions.
                return(false);
            }
            finally
            {
                if (reader != null)
                {
                    reader.close();
                }
            }
        }
        public static DataRaster wrap(BufferedImage image, AVList parameters)
        {
            if (null == image)
            {
                String message = Logging.getMessage("nullValue.ImageIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            if (null == parameters)
            {
                String msg = Logging.getMessage("nullValue.AVListIsNull");
                Logging.logger().finest(msg);
                throw new ArgumentException(msg);
            }

            if (params.hasKey(AVKey.WIDTH))
            {
                int width = (Integer)parameters.getValue(AVKey.WIDTH);
                if (width != image.getWidth())
                {
                    String msg = Logging.getMessage("generic.InvalidWidth", "" + width + "!=" + image.getWidth());
                    Logging.logger().finest(msg);
                    throw new ArgumentException(msg);
                }
            }
示例#4
0
        /**
         * Parses layer configuration parameters from the specified DOM document. This writes output as key-value pairs to
         * parameters. If a parameter from the XML document already exists in parameters, that parameter is ignored. Supported key
         * and parameter names are: <table> <tr><th>Parameter</th><th>Element Path</th><th>Type</th></tr> <tr><td>{@link
         * AVKey#DISPLAY_NAME}</td><td>DisplayName</td><td>string</td></tr> <tr><td>{@link
         * AVKey#OPACITY}</td><td>Opacity</td><td>Double</td></tr> <tr><td>{@link AVKey#MAX_ACTIVE_ALTITUDE}</td><td>ActiveAltitudes/@max</td><td>Double</td></tr>
         * <tr><td>{@link AVKey#MIN_ACTIVE_ALTITUDE}</td><td>ActiveAltitudes/@min</td><td>Double</td></tr> <tr><td>{@link
         * AVKey#NETWORK_RETRIEVAL_ENABLED}</td><td>NetworkRetrievalEnabled</td><td>Boolean</td></tr> <tr><td>{@link
         * AVKey#MAP_SCALE}</td><td>MapScale</td><td>Double</td></tr> <tr><td>{@link AVKey#SCREEN_CREDIT}</td><td>ScreenCredit</td><td>{@link
         * ScreenCredit}</td></tr> </table>
         *
         * @param domElement the XML document root to parse for layer configuration elements.
         * @param parameters     the output key-value pairs which recieve the layer configuration parameters. A null reference
         *                   is permitted.
         *
         * @return a reference to parameters, or a new AVList if parameters is null.
         *
         * @throws ArgumentException if the document is null.
         */
        public static AVList getLayerConfigParams(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();
            }

            XPath xpath = WWXML.makeXPath();

            WWXML.checkAndSetStringParam(domElement, parameters, AVKey.DISPLAY_NAME, "DisplayName", xpath);
            WWXML.checkAndSetDoubleParam(domElement, parameters, AVKey.OPACITY, "Opacity", xpath);
            WWXML.checkAndSetDoubleParam(domElement, parameters, AVKey.MAX_ACTIVE_ALTITUDE, "ActiveAltitudes/@max", xpath);
            WWXML.checkAndSetDoubleParam(domElement, parameters, AVKey.MIN_ACTIVE_ALTITUDE, "ActiveAltitudes/@min", xpath);
            WWXML.checkAndSetBooleanParam(domElement, parameters, AVKey.NETWORK_RETRIEVAL_ENABLED, "NetworkRetrievalEnabled",
                                          xpath);
            WWXML.checkAndSetDoubleParam(domElement, parameters, AVKey.MAP_SCALE, "MapScale", xpath);
            WWXML.checkAndSetScreenCreditParam(domElement, parameters, AVKey.SCREEN_CREDIT, "ScreenCredit", xpath);
            WWXML.checkAndSetIntegerParam(domElement, parameters, AVKey.MAX_ABSENT_TILE_ATTEMPTS, "MaxAbsentTileAttempts",
                                          xpath);
            WWXML.checkAndSetIntegerParam(domElement, parameters, AVKey.MIN_ABSENT_TILE_CHECK_INTERVAL,
                                          "MinAbsentTileCheckInterval", xpath);
            WWXML.checkAndSetBooleanParam(domElement, parameters, AVKey.PICK_ENABLED, "PickEnabled", xpath);

            return(parameters);
        }
示例#5
0
        /** {@inheritDoc} */
        public DataRasterReader findReaderFor(Object source, AVList parameters, DataRasterReader[] readers)
        {
            if (source == null)
            {
                String message = Logging.getMessage("nullValue.SourceIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

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

            foreach (DataRasterReader reader in readers)
            {
                if (reader != null && reader.canRead(source, parameters))
                {
                    return(reader);
                }
            }

            return(null);
        }
示例#6
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);
        }
示例#7
0
        public static bool?getBooleanValue(AVList avList, string key)
        {
            object o = avList.getValue(key);

            if (o == null)
            {
                return(null);
            }

            if (o is bool)
            {
                return((bool)o);
            }

            if (!(o is string))
            {
                return(null);
            }

            string text = (string)o;
            bool   result;

            if (bool.TryParse(text, out result))
            {
                return(result);
            }
            Logging.logger().log(Level.SEVERE, "Configuration.ConversionError", new Exception().Message);
            return(null);
        }
        DataRaster doGetSubRaster(int width, int height, Sector sector, AVList parameters)
        {
            DataRaster canvas = this.createSubRaster(width, height, sector, parameters);

            this.drawOnTo(canvas);
            return(canvas);
        }
        /**
         * Create the objects described in an XML element containing layer and/or layer-list descriptions. Nested layer
         * lists and included layers are created recursively.
         *
         * @param domElement an XML element describing the layers and/or layer lists.
         * @param parameters     any properties to apply when creating the included layers.
         *
         * @return a <code>Layer</code>, <code>LayerList</code> or array of <code>LayerList</code>s, as described by the
         *         specified description.
         *
         * @throws Exception if an exception occurs during creation. Exceptions occurring during creation of internal layers
         *                   or layer lists are not re-thrown but are logged. The layer or layer list associated with the
         *                   exception is not contained in the returned object.
         */
        protected override Object doCreateFromElement(Element domElement, AVList parameters)
        {
            Element[] elements = WWXML.getElements(domElement, "//LayerList", null);
            if (elements != null && elements.Length > 0)
            {
                return(createLayerLists(elements, parameters));
            }

            elements = WWXML.getElements(domElement, "./Layer", null);
            if (elements != null && elements.Length > 1)
            {
                return(createLayerList(elements, parameters));
            }

            if (elements != null && elements.Length == 1)
            {
                return(this.createFromLayerDocument(elements[0], parameters));
            }

            String localName = WWXML.getUnqualifiedName(domElement);

            if (localName != null && localName.Equals("Layer"))
            {
                return(this.createFromLayerDocument(domElement, parameters));
            }

            return(null);
        }
示例#10
0
            protected URLBuilder(String version, AVList parameters)
            {
                Double d = (Double)parameters.getValue(AVKey.MISSING_DATA_SIGNAL);

                this.layerNames  = parameters.getStringValue(AVKey.LAYER_NAMES);
                this.styleNames  = parameters.getStringValue(AVKey.STYLE_NAMES);
                this.imageFormat = parameters.getStringValue(AVKey.IMAGE_FORMAT);

                String coordSystemKey;
                String defaultCS;

                if (version == null || WWUtil.compareVersion(version, "1.3.0") >= 0) // version 1.3.0 or greater
                {
                    this.wmsVersion = MAX_VERSION;
                    coordSystemKey  = "&crs=";
                    defaultCS       = "CRS:84"; // would like to do EPSG:4326 but that's incompatible with our old WMS server, see WWJ-474
                }
                else
                {
                    this.wmsVersion = version;
                    coordSystemKey  = "&srs=";
                    defaultCS       = "EPSG:4326";
                }

                String coordinateSystem = parameters.getStringValue(AVKey.COORDINATE_SYSTEM);

                this.crs = coordSystemKey + (coordinateSystem != null ? coordinateSystem : defaultCS);
            }
        protected Layer doCreateFromCapabilities(OGCCapabilities caps, AVList parameters)
        {
            string serviceName = caps.getServiceInformation().getServiceName();

            if (serviceName == null || !(serviceName.equalsIgnoreCase(OGCConstants.WMS_SERVICE_NAME) ||
                                         serviceName.Contains("WMS")))
            {
                string message = Logging.getMessage("WMS.NotWMSService", serviceName != null ? serviceName : "null");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

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

            if (parameters.getStringValue(AVKey.LAYER_NAMES) == null)
            {
                // Use the first named layer since no other guidance given
                List <WMSLayerCapabilities> namedLayers = ((WMSCapabilities)caps).getNamedLayers();

                if (namedLayers == null || namedLayers.Count == 0 || namedLayers[0] == null)
                {
                    String message = Logging.getMessage("WMS.NoLayersFound");
                    Logging.logger().severe(message);
                    throw new IllegalStateException(message);
                }

                parameters.setValue(AVKey.LAYER_NAMES, namedLayers[0].getName());
            }

            return(new WMSTiledImageLayer((WMSCapabilities)caps, parameters));
        }
            public URLBuilder(AVList parameters)
            {
                this.layerNames      = parameters.getStringValue(AVKey.LAYER_NAMES);
                this.styleNames      = parameters.getStringValue(AVKey.STYLE_NAMES);
                this.imageFormat     = parameters.getStringValue(AVKey.IMAGE_FORMAT);
                this.backgroundColor = parameters.getStringValue(AVKey.WMS_BACKGROUND_COLOR);
                String version = parameters.getStringValue(AVKey.WMS_VERSION);

                String coordSystemKey;
                String defaultCS;

                if (version == null || WWUtil.compareVersion(version, "1.3.0") >= 0)
                {
                    this.wmsVersion = MAX_VERSION;
                    coordSystemKey  = "&crs=";
                    defaultCS       = "CRS:84"; // would like to do EPSG:4326 but that's incompatible with our old WMS server, see WWJ-474
                }
                else
                {
                    this.wmsVersion = version;
                    coordSystemKey  = "&srs=";
                    defaultCS       = "EPSG:4326";
                }

                String coordinateSystem = parameters.getStringValue(AVKey.COORDINATE_SYSTEM);

                this.crs = coordSystemKey + (coordinateSystem != null ? coordinateSystem : defaultCS);
            }
 public LocalRasterServerRetriever(AVList parameters, RasterServer rasterServer, RetrievalPostProcessor postProcessor)
 {
     if (null != parameters)
     {
         this.setValues(params);
     }
     this.server        = rasterServer;
     this.postProcessor = postProcessor;
 }
        protected void createRasterServer(AVList parameters)
        {
            if (params == null)
            {
                String reason = Logging.getMessage("nullValue.ParamsIsNull");
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            if (this.getDataFileStore() == null)
            {
                String reason = Logging.getMessage("nullValue.FileStoreIsNull");
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            String datasetName = parameters.getStringValue(AVKey.DATASET_NAME);

            if (WWUtil.isEmpty(datasetName))
            {
                String reason = Logging.getMessage("generic.MissingRequiredParameter", AVKey.DATASET_NAME);
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            String dataCacheName = parameters.getStringValue(AVKey.DATA_CACHE_NAME);

            if (WWUtil.isEmpty(dataCacheName))
            {
                String reason = Logging.getMessage("generic.MissingRequiredParameter", AVKey.DATA_CACHE_NAME);
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            String rasterServerConfigFilename = dataCacheName + File.separator + datasetName + ".RasterServer.xml";

            final URL rasterServerFileURL = this.getDataFileStore().findFile(rasterServerConfigFilename, false);

            if (WWUtil.isEmpty(rasterServerFileURL))
            {
                String reason = Logging.getMessage("Configuration.ConfigNotFound", rasterServerConfigFilename);
                String msg    = Logging.getMessage("generic.CannotCreateRasterServer", reason);
                Logging.logger().severe(msg);
                throw new IllegalStateException(msg);
            }

            final AVList rasterServerParams = parameters.copy();

            rasterServerParams.setValue(AVKey.FILE_STORE, this.getDataFileStore());

            RetrieverFactory retrieverFactory = new RetrieverFactory()
            {
                final protected RasterServer rasterServer = new BasicRasterServer(rasterServerFileURL, rasterServerParams);
示例#15
0
        /** {@inheritDoc} */
        public DataRasterReader findReaderFor(Object source, AVList parameters)
        {
            if (source == null)
            {
                String message = Logging.getMessage("nullValue.SourceIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            return(findReaderFor(source, parameters, readers));
        }
示例#16
0
 public static String getStringValue(AVList avList, String key)
 {
     try
     {
         return(avList.getStringValue(key));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
        public Object createFromConfigSource(Object configSource, AVList parameters)
        {
            ElevationModel model = (ElevationModel)super.createFromConfigSource(configSource, parameters);

            if (model == null)
            {
                String msg = Logging.getMessage("generic.UnrecognizedDocument", configSource);
                throw new WWUnrecognizedException(msg);
            }

            return(model);
        }
示例#18
0
        public bool canRead(Object source, AVList parameters)
        {
            if (source == null)
            {
                return(false);
            }

            // RPF imagery cannot be identified by a small set of suffixes or mime types, so we override the standard
            // suffix comparison behavior here.

            return(this.doCanRead(source, parameters));
        }
        /**
         * Creates a layer or layer list from a general configuration source. The source can be one of the following: <ul>
         * <li>a {@link java.net.URL}</li> <li>a {@link java.io.File}</li> <li>a {@link java.io.InputStream}</li> <li>{@link
         * Element}</li> <li>a {@link String} holding a file name, a name of a resource on the classpath, or a string
         * representation of a URL</li> </ul>
         * <p/>
         * For tiled image layers, this maps the <code>serviceName</code> attribute of the <code>Layer/Service</code>
         * element of the XML configuration file to the appropriate base tiled image layer type. Service types recognized
         * are: <ul> <li>"WMS" for layers that draw their data from a WMS web service.</li> <li>"WWTileService" for layers
         * that draw their data from a World Wind tile service.</li> <li>"Offline" for layers that draw their data only from
         * the local cache.</li> </ul>
         *
         * @param configSource the configuration source. See above for supported types.
         *
         * @return a layer or layer list.
         *
         * @throws ArgumentException if the configuration file name is null or an empty string.
         * @throws WWUnrecognizedException  if the layer service type is unrecognized.
         * @throws WWRuntimeException       if object creation fails. The exception indicating the source of the failure is
         *                                  included as the {@link Exception#initCause(Throwable)}.
         */
        public object createFromConfigSource(object configSource, AVList parameters)
        {
            object layerOrLists = base.createFromConfigSource(configSource, parameters);

            if (layerOrLists == null)
            {
                string msg = Logging.getMessage("generic.UnrecognizedDocument", configSource);
                throw new WWUnrecognizedException(msg);
            }

            return(layerOrLists);
        }
        //**************************************************************//
        //********************  Configuration  *************************//
        //**************************************************************//

        /**
         * Appends WMS tiled image layer configuration elements to the superclass configuration document.
         *
         * @param parameters configuration parameters describing this WMS tiled image layer.
         *
         * @return a WMS tiled image layer configuration document.
         */
        protected Document createConfigurationDocument(AVList parameters)
        {
            Document doc = super.createConfigurationDocument(params);

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

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

            return(doc);
        }
        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));
        }
                public Retriever createRetriever(AVList tileParams, RetrievalPostProcessor postProcessor)
                {
                    LocalRasterServerRetriever retriever =
                        new LocalRasterServerRetriever(tileParams, this.rasterServer, postProcessor);

                    // copy only values that do not exist in destination AVList
                    // from rasterServerParams (source) to retriever (destination)

                    String[] keysToCopy = new String[] {
                        AVKey.DATASET_NAME, AVKey.DISPLAY_NAME, AVKey.FILE_STORE, AVKey.IMAGE_FORMAT, AVKey.FORMAT_SUFFIX
                    };

                    WWUtil.copyValues(rasterServerParams, retriever, keysToCopy, false);

                    return(retriever);
                }
        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);
            }
        }
示例#24
0
        public AVList setValues(AVList list)
        {
            if (list == null)
            {
                String message = Logging.getMessage("nullValue.AttributesIsNull");
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            var entries = list.getEntries();

            foreach (var entry in entries)
            {
                setValue(entry.Key, entry.Value);
            }
            return(this);
        }
        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);
        }
        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);
        }
示例#27
0
        /**
         * Static method to create an object from a factory, a configuration source, and an optional configuration parameter
         * list.
         *
         * @param factoryKey   the key identifying the factory in {@link Configuration}.
         * @param configSource the configuration source. May be any of the types listed for {@link
         *                     #createFromConfigSource(object, SharpEarth.avlist.AVList)}
         * @param parameters       key-value parameters to override or supplement the information provided in the specified
         *                     configuration source. May be null.
         *
         * @return a new instance of the requested object.
         *
         * @throws ArgumentException if the factory key is null, or if the configuration source is null or an empty
         *                                  string.
         */
        public static object create(string factoryKey, object configSource, AVList parameters)
        {
            if (factoryKey == null)
            {
                string message = Logging.getMessage("generic.FactoryKeyIsNull");
                throw new ArgumentException(message);
            }

            if (WWUtil.isEmpty(configSource))
            {
                string message = Logging.getMessage("generic.ConfigurationSourceIsInvalid", configSource);
                throw new ArgumentException(message);
            }

            Factory factory = (Factory)WorldWind.createConfigurationComponent(factoryKey);

            return(factory.createFromConfigSource(configSource, parameters));
        }
                public Retriever createRetriever(AVList tileParams, RetrievalPostProcessor postProcessor)
                {
                    LocalRasterServerRetriever retriever =
                        new LocalRasterServerRetriever(tileParams, rasterServer, postProcessor);

                    // copy only values that do not exist in destination AVList
                    // from rasterServerParams (source) to retriever (destination)
                    String[] keysToCopy = new String[] {
                        AVKey.DATASET_NAME, AVKey.DISPLAY_NAME,
                        AVKey.FILE_STORE, AVKey.BYTE_ORDER,
                        AVKey.IMAGE_FORMAT, AVKey.DATA_TYPE, AVKey.FORMAT_SUFFIX,
                        AVKey.MISSING_DATA_SIGNAL, AVKey.MISSING_DATA_REPLACEMENT,
                        AVKey.ELEVATION_MIN, AVKey.ELEVATION_MAX,
                    };

                    WWUtil.copyValues(rasterServerParams, retriever, keysToCopy, false);

                    return(retriever);
                }
        /**
         * Create a list of layers described by an array of XML layer description elements.
         * <p/>
         * Any exceptions occurring during creation of the layers are logged and not re-thrown. The layers associated with
         * the exceptions are not included in the returned layer list.
         *
         * @param layerElements the XML elements describing the layers to create.
         * @param parameters        any parameters to apply when creating the layers.
         *
         * @return a layer list containing the specified layers.
         */
        protected LayerList createLayerList(Element[] layerElements, AVList parameters)
        {
            LayerList layerList = new LayerList();

            foreach (Element element in layerElements)
            {
                try
                {
                    layerList.add(this.createFromLayerDocument(element, parameters));
                }
                catch (Exception e)
                {
                    Logging.logger().log(java.util.logging.Level.WARNING, e.getMessage(), e);
                    // keep going to create other layers
                }
            }

            return(layerList);
        }
示例#30
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);
        }