/** * Creates an attribute-value list from an xml document containing restorable state for this layer. * * @param stateInXml an xml document specified in a {@link String}. * * @return an attribute-value list containing the parameters in the specified restorable state. * * @throws ArgumentException if the state reference is null. */ public static AVList wmsRestorableStateToParams(String stateInXml) { if (stateInXml == null) { String message = Logging.getMessage("nullValue.StringIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } RestorableSupport rs; try { rs = RestorableSupport.parse(stateInXml); } catch (Exception e) { // Parsing the document specified by stateInXml failed. String message = Logging.getMessage("generic.ExceptionAttemptingToParseStateXml", stateInXml); Logging.logger().severe(message); throw new ArgumentException(message, e); } AVList parameters = new AVListImpl(); wmsRestoreStateToParams(rs, null, parameters); return(parameters); }
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)); }
protected void loadOffsetFile() { InputStream inputStream = WWIO.openFileOrResourceStream(this.offsetsFilePath, typeof(EGM96)); if (inputStream == null) { String msg = Logging.getMessage("generic.CannotOpenFile", this.offsetsFilePath); Logging.logger().severe(msg); throw new WWRuntimeException(msg); } try { AVList bufferParams = new AVListImpl(); bufferParams.setValue(AVKey.DATA_TYPE, AVKey.INT16); bufferParams.setValue(AVKey.BYTE_ORDER, AVKey.BIG_ENDIAN); this.deltas = BufferWrapper.wrap(WWIO.readStreamToBuffer(is, true), bufferParams); } catch (IOException e) { String msg = Logging.getMessage("generic.ExceptionAttemptingToReadFile", this.offsetsFilePath); Logging.logger().log(java.util.logging.Level.SEVERE, msg, e); throw e; } finally { WWIO.closeStream(is, this.offsetsFilePath); } }
/** * 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); }
/** * Appends layer configuration parameters as elements to the specified context. This appends elements for the * following parameters: <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>ScreenCredit</td></tr> * </table> * * @param parameters the key-value pairs which define the layer configuration parameters. * @param context the XML document root on which to append layer configuration elements. * * @return a reference to context. * * @throws ArgumentException if either the parameters or the context are null. */ public static Element createLayerConfigElements(AVList parameters, Element context) { if (parameters == null) { string message = Logging.getMessage("nullValue.ParametersIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } if (context == null) { string message = Logging.getMessage("nullValue.ContextIsNull"); Logging.logger().severe(message); throw new ArgumentException(message); } WWXML.checkAndAppendTextElement(parameters, AVKey.DISPLAY_NAME, context, "DisplayName"); WWXML.checkAndAppendDoubleElement(parameters, AVKey.OPACITY, context, "Opacity"); double?maxAlt = AVListImpl.getDoubleValue(parameters, AVKey.MAX_ACTIVE_ALTITUDE); double?minAlt = AVListImpl.getDoubleValue(parameters, AVKey.MIN_ACTIVE_ALTITUDE); if (maxAlt != null || minAlt != null) { Element el = WWXML.appendElementPath(context, "ActiveAltitudes"); if (maxAlt != null) { WWXML.setDoubleAttribute(el, "max", maxAlt.Value); } if (minAlt != null) { WWXML.setDoubleAttribute(el, "min", minAlt.Value); } } WWXML.checkAndAppendBooleanElement(parameters, AVKey.NETWORK_RETRIEVAL_ENABLED, context, "NetworkRetrievalEnabled"); WWXML.checkAndAppendDoubleElement(parameters, AVKey.MAP_SCALE, context, "MapScale"); WWXML.checkAndAppendScreenCreditElement(parameters, AVKey.SCREEN_CREDIT, context, "ScreenCredit"); WWXML.checkAndAppendBooleanElement(parameters, AVKey.PICK_ENABLED, context, "PickEnabled"); return(context); }
/** * 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); }
/** * Reads XML document and extracts raster sources * * @param config Parsed configuration document. * * @return TRUE, if all raster sources are available, FALSE otherwise * */ protected bool readRasterSources(RasterServerConfiguration config) { long startTime = System.currentTimeMillis(); bool hasUnavailableRasterSources = false; int numSources = 0; Sector extent = null; try { List <RasterServerConfiguration.Source> sources = config.getSources(); if (sources == null || sources.size() == 0) { return(false); } numSources = sources.size(); foreach (RasterServerConfiguration.Source source in sources) { Thread.yield(); try { String rasterSourcePath = source.getPath(); if (WWUtil.isEmpty(rasterSourcePath)) { continue; } AVList rasterMetadata = new AVListImpl(); File rasterSourceFile = new File(rasterSourcePath); // normalize rasterSourcePath = rasterSourceFile.getAbsolutePath(); if (!rasterSourceFile.exists()) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.FileDoesNotExists", rasterSourcePath); Logging.logger().warning(reason); continue; } if (!rasterSourceFile.canRead()) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.FileNoReadPermission", rasterSourcePath); Logging.logger().warning(reason); continue; } DataRasterReader rasterReader = this.findDataRasterReader(rasterSourceFile, rasterMetadata); if (null == rasterReader) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.UnknownFileFormatOrMatchingReaderNotFound", rasterSourcePath); Logging.logger().warning(reason); continue; } Sector sector = source.getSector(); if (null == sector) { rasterReader.readMetadata(rasterSourceFile, rasterMetadata); Object o = rasterMetadata.getValue(AVKey.SECTOR); sector = (o is Sector) ? (Sector)o : null; } else { rasterMetadata.setValue(AVKey.SECTOR, sector); } Object rasterPixelFormat = rasterMetadata.getValue(AVKey.PIXEL_FORMAT); String datasetPixelFormat = this.getDataSetPixelFormat(); if (!WWUtil.isEmpty(datasetPixelFormat)) { // verify all data rasters are the same type - we do not allow to mix elevations and imagery if (!datasetPixelFormat.Equals(rasterPixelFormat)) { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.UnexpectedRasterType", rasterSourcePath); Logging.logger().warning(reason); continue; } } else { if (AVKey.IMAGE.Equals(rasterPixelFormat) || AVKey.ELEVATION.Equals(rasterPixelFormat)) { this.setDataSetPixelFormat((String)rasterPixelFormat); } else { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.UnknownFileFormat", rasterSourcePath); Logging.logger().warning(reason); continue; } } if (null != sector) { extent = Sector.union(extent, sector); this.dataRasterList.add( new CachedDataRaster(rasterSourceFile, rasterMetadata, rasterReader, this.getCache()) ); } else { hasUnavailableRasterSources = true; String reason = Logging.getMessage("generic.NoSectorSpecified", rasterSourcePath); Logging.logger().warning(reason); } } catch (Throwable t) { String message = t.getMessage(); message = (WWUtil.isEmpty(message)) ? t.getCause().getMessage() : message; Logging.logger().log(java.util.logging.Level.WARNING, message, t); } } if (null != extent && extent.getDeltaLatDegrees() > 0d && extent.getDeltaLonDegrees() > 0d) { this.setValue(AVKey.SECTOR, extent); } } catch (Throwable t) { String message = t.getMessage(); message = (WWUtil.isEmpty(message)) ? t.getCause().getMessage() : message; Logging.logger().log(java.util.logging.Level.SEVERE, message, t); } finally { Logging.logger().finest(this.getStringValue(AVKey.DISPLAY_NAME) + ": " + numSources + " files in " + (System.currentTimeMillis() - startTime) + " milli-seconds"); } return(!hasUnavailableRasterSources); }
/** * Returns DataSet's pixel format (AVKey.IMAGE or AVKey.ELEVATION), or empty string if not set * * @return DataSet's pixel format (AVKey.IMAGE or AVKey.ELEVATION), or empty string if not set */ protected String getDataSetPixelFormat() { return(AVListImpl.getStringValue(this, AVKey.PIXEL_FORMAT, "")); }
protected String getDataSetName() { return(AVListImpl.getStringValue(this, AVKey.DATASET_NAME, "")); }