/**
   * Parses basic elevation model parameters from a specified DOM document. This also parses
   * LevelSet parameters by invoking {@link
   * gov.nasa.worldwind.util.DataConfigurationUtils#getLevelSetParams(org.w3c.dom.Element,
   * gov.nasa.worldwind.avlist.AVList)}. This writes output as key-value pairs to params. If a
   * parameter from the XML document already exists in params, that parameter is ignored. Supported
   * key and parameter names 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>DataType</td><td>String</td></tr> <tr><td>{@link
   * AVKey#BYTE_ORDER}</td><td>DataType/@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 domElement the XML document root to parse for basic elevation model parameters.
   * @param params the output key-value pairs which recieve the basic elevation model parameters. A
   *     null reference is permitted.
   * @return a reference to params, or a new AVList if params is null.
   * @throws IllegalArgumentException if the document is null.
   */
  public static AVList getBasicElevationModelParams(Element domElement, AVList params) {
    if (domElement == null) {
      String message = Logging.getMessage("nullValue.DocumentIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) params = new AVListImpl();

    XPath xpath = WWXML.makeXPath();

    // LevelSet properties.
    DataConfigurationUtils.getLevelSetParams(domElement, params);

    // Service properties.
    WWXML.checkAndSetStringParam(
        domElement, params, AVKey.SERVICE_NAME, "Service/@serviceName", xpath);
    WWXML.checkAndSetBooleanParam(
        domElement,
        params,
        AVKey.RETRIEVE_PROPERTIES_FROM_SERVICE,
        "RetrievePropertiesFromService",
        xpath);

    // Image format properties.
    if (params.getValue(AVKey.PIXEL_TYPE) == null) {
      String s = WWXML.getText(domElement, "DataType/@type", xpath);
      if (s != null && s.length() > 0) {
        s = WWXML.parseDataType(s);
        if (s != null && s.length() > 0) params.setValue(AVKey.PIXEL_TYPE, s);
      }
    }

    if (params.getValue(AVKey.BYTE_ORDER) == null) {
      String s = WWXML.getText(domElement, "DataType/@byteOrder", xpath);
      if (s != null && s.length() > 0) {
        s = WWXML.parseByteOrder(s);
        if (s != null && s.length() > 0) params.setValue(AVKey.BYTE_ORDER, s);
      }
    }

    // Elevation data properties.
    WWXML.checkAndSetStringParam(
        domElement, params, AVKey.ELEVATION_EXTREMES_FILE, "ExtremeElevations/FileName", xpath);
    WWXML.checkAndSetDoubleParam(
        domElement, params, AVKey.ELEVATION_MAX, "ExtremeElevations/@max", xpath);
    WWXML.checkAndSetDoubleParam(
        domElement, params, AVKey.ELEVATION_MIN, "ExtremeElevations/@min", xpath);

    return params;
  }
  /**
   * Parses elevation model parameters from a specified DOM document. This writes output as
   * key-value pairs to params. If a parameter from the XML document already exists in params, that
   * parameter is ignored. Supported key and parameter names are:
   *
   * <table> <th><td>Key</td><td>Name</td><td>Type</td></th> <tr><td>{@link
   * gov.nasa.worldwind.avlist.AVKey#DISPLAY_NAME}</td><td>DisplayName</td><td>String</td></tr> <tr><td>{@link
   * gov.nasa.worldwind.avlist.AVKey#NETWORK_RETRIEVAL_ENABLED}</td><td>NetworkRetrievalEnabled</td><td>Boolean</td></tr>
   * <tr><td>{@link gov.nasa.worldwind.avlist.AVKey#MISSING_DATA_SIGNAL}</td><td>MissingData/@signal</td><td>Double</td></tr>
   * <tr><td>{@link gov.nasa.worldwind.avlist.AVKey#MISSING_DATA_REPLACEMENT}</td><td>MissingData/@replacement</td><td>Double</td></tr>
   * <tr><td>{@link gov.nasa.worldwind.avlist.AVKey#DETAIL_HINT}</td><td>DataDetailHint</td><td>Double</td></tr>
   * </table>
   *
   * @param domElement the XML document root to parse for elevaiton model parameters.
   * @param params the output key-value pairs which recieve the elevation model parameters. A null
   *     reference is permitted.
   * @return a reference to params, or a new AVList if params is null.
   * @throws IllegalArgumentException if the document is null.
   */
  public static AVList getElevationModelParams(Element domElement, AVList params) {
    if (domElement == null) {
      String message = Logging.getMessage("nullValue.DocumentIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) params = new AVListImpl();

    XPath xpath = WWXML.makeXPath();

    WWXML.checkAndSetStringParam(domElement, params, AVKey.DISPLAY_NAME, "DisplayName", xpath);
    WWXML.checkAndSetBooleanParam(
        domElement, params, AVKey.NETWORK_RETRIEVAL_ENABLED, "NetworkRetrievalEnabled", xpath);
    WWXML.checkAndSetDoubleParam(
        domElement, params, AVKey.MISSING_DATA_SIGNAL, "MissingData/@signal", xpath);
    WWXML.checkAndSetDoubleParam(
        domElement, params, AVKey.MISSING_DATA_REPLACEMENT, "MissingData/@replacement", xpath);
    WWXML.checkAndSetDoubleParam(domElement, params, AVKey.DETAIL_HINT, "DataDetailHint", xpath);

    return params;
  }
  protected static AVList getParamsFromDocument(Element domElement, AVList params) {
    if (params == null) {
      params = new AVListImpl();
    }

    XPath xpath = WWXML.makeXPath();

    // Common layer properties.
    AbstractLayer.getLayerConfigParams(domElement, params);

    WWXML.checkAndSetStringParam(domElement, params, AVKey.URL, "URL", xpath);
    WWXML.checkAndSetIntegerParam(domElement, params, AVKey.WIDTH, "Size/@width", xpath);
    WWXML.checkAndSetIntegerParam(domElement, params, AVKey.HEIGHT, "Size/@height", xpath);
    WWXML.checkAndSetDoubleParam(domElement, params, AVKeyMore.SCALE, "Scale", xpath);
    WWXML.checkAndSetSectorParam(domElement, params, AVKey.SECTOR, "Sector", xpath);
    WWXML.checkAndSetBooleanParam(domElement, params, AVKeyMore.WRAP, "Wrap", xpath);

    return params;
  }