/** * Appends elevation model parameters as elements to a specified context. If a parameter key * exists, that parameter is appended to the context. Supported key and element paths are: * * <table> <th><td>Key</td><td>Name</td><td>Type</td></th> * <tr><td>{@link AVKey#DISPLAY_NAME}</td><td>DisplayName</td><td>String</td></tr> <tr><td>{@link * AVKey#NETWORK_RETRIEVAL_ENABLED}</td><td>NetworkRetrievalEnabled</td><td>Boolean</td></tr> <tr><td>{@link * AVKey#MISSING_DATA_SIGNAL}</td><td>MissingData/@signal</td><td>Double</td></tr> <tr><td>{@link * AVKey#MISSING_DATA_REPLACEMENT}</td><td>MissingData/@replacement</td><td>Double</td></tr> <tr><td>{@link * AVKey#DETAIL_HINT}</td><td>DataDetailHint</td><td>Double</td></tr> </table> * * @param params the key-value pairs which define the elevation model parameters. * @param context the XML document root on which to append parameter elements. * @return a reference to context. * @throws IllegalArgumentException if either the parameters or the context are null. */ public static Element createElevationModelElements(AVList params, Element context) { if (params == null) { String message = Logging.getMessage("nullValue.ParametersIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (context == null) { String message = Logging.getMessage("nullValue.ContextIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } WWXML.checkAndAppendTextElement(params, AVKey.DISPLAY_NAME, context, "DisplayName"); WWXML.checkAndAppendBooleanElement( params, AVKey.NETWORK_RETRIEVAL_ENABLED, context, "NetworkRetrievalEnabled"); if (params.getValue(AVKey.MISSING_DATA_SIGNAL) != null || params.getValue(AVKey.MISSING_DATA_REPLACEMENT) != null) { Element el = WWXML.getElement(context, "MissingData", null); if (el == null) el = WWXML.appendElementPath(context, "MissingData"); Double d = AVListImpl.getDoubleValue(params, AVKey.MISSING_DATA_SIGNAL); if (d != null) el.setAttribute("signal", Double.toString(d)); d = AVListImpl.getDoubleValue(params, AVKey.MISSING_DATA_REPLACEMENT); if (d != null) el.setAttribute("replacement", Double.toString(d)); } WWXML.checkAndAppendDoubleElement(params, AVKey.DETAIL_HINT, context, "DataDetailHint"); return context; }
/** * Creates a configuration document for the basic elevation model described by the specified * params. This document's root element may be passed to a ElevationModelConfiguration * constructor, and it may be passed to the constructor of a {@link * gov.nasa.worldwind.terrain.BasicElevationModel}. * * @param params parameters describing the basic elevation model. * @return a configuration document for the basic elevation model. */ public static Document createBasicElevationModelDocument(AVList params) { Document doc = WWXML.createDocumentBuilder(true).newDocument(); Element root = doc.createElement("ElevationModel"); root.setAttribute("version", Integer.toString(1)); // No type attribute denotes the default elevation model, which currently is // BasicElevationModel. doc.appendChild(root); createElevationModelElements(params, root); createBasicElevationModelElements(params, root); return doc; }
/** * Appends basic elevation model parameters as elements to a specified context. If a parameter key * exists, that parameter is appended to the context. This also writes LevelSet parameters by * invoking {@link DataConfigurationUtils#createLevelSetElements(gov.nasa.worldwind.avlist.AVList, * org.w3c.dom.Element)}. Supported key and element paths are: * * <table> <th><td>Key</td><td>Name</td><td>Type</td></th> <tr><td>{@link * AVKey#SERVICE_NAME}</td><td>Service/@serviceName</td><td>String</td></tr> <tr><td>{@link * AVKey#PIXEL_TYPE}</td><td>PixelType</td><td>String</td></tr> <tr><td>{@link AVKey#BYTE_ORDER}</td><td>ByteOrder</td><td>String</td></tr> * <tr><td>{@link AVKey#ELEVATION_EXTREMES_FILE}</td><td>ExtremeElevations/FileName</td><td>String</td></tr> * <tr><td>{@link AVKey#ELEVATION_MAX}</td><td>ExtremeElevations/@max</td><td>Double</td></tr> <tr><td>{@link * AVKey#ELEVATION_MIN}</td><td>ExtremeElevations/@min</td><td>Double</td></tr> </table> * * @param params the key-value pairs which define the basic elevation model parameters. * @param context the XML document root on which to append parameter elements. * @return a reference to context. * @throws IllegalArgumentException if either the parameters or the context are null. */ public static Element createBasicElevationModelElements(AVList params, Element context) { if (params == null) { String message = Logging.getMessage("nullValue.ParametersIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (context == null) { String message = Logging.getMessage("nullValue.ContextIsNull"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } XPath xpath = WWXML.makeXPath(); // LevelSet properties. DataConfigurationUtils.createLevelSetElements(params, context); // Service properties. // Try to get the SERVICE_NAME property, but default to "WWTileService". String s = AVListImpl.getStringValue(params, AVKey.SERVICE_NAME, "WWTileService"); if (s != null && s.length() > 0) { // The service element may already exist, in which case we want to append to it. Element el = WWXML.getElement(context, "Service", xpath); if (el == null) el = WWXML.appendElementPath(context, "Service"); el.setAttribute("serviceName", s); } WWXML.checkAndAppendBooleanElement( params, AVKey.RETRIEVE_PROPERTIES_FROM_SERVICE, context, "RetrievePropertiesFromService"); // Image format properties. if (params.getValue(AVKey.PIXEL_TYPE) != null || params.getValue(AVKey.BYTE_ORDER) != null) { Element el = WWXML.getElement(context, "DataType", null); if (el == null) el = WWXML.appendElementPath(context, "DataType"); s = params.getStringValue(AVKey.PIXEL_TYPE); if (s != null && s.length() > 0) { s = WWXML.dataTypeAsText(s); if (s != null && s.length() > 0) el.setAttribute("type", s); } s = params.getStringValue(AVKey.BYTE_ORDER); if (s != null && s.length() > 0) { s = WWXML.byteOrderAsText(s); if (s != null && s.length() > 0) el.setAttribute("byteOrder", s); } } // Elevation data properties. Element el = WWXML.appendElementPath(context, "ExtremeElevations"); WWXML.checkAndAppendTextElement(params, AVKey.ELEVATION_EXTREMES_FILE, el, "FileName"); Double d = AVListImpl.getDoubleValue(params, AVKey.ELEVATION_MAX); if (d != null) el.setAttribute("max", Double.toString(d)); d = AVListImpl.getDoubleValue(params, AVKey.ELEVATION_MIN); if (d != null) el.setAttribute("min", Double.toString(d)); return context; }