コード例 #1
0
    public URLBuilder(AVList params) {
      this.layerNames = params.getStringValue(AVKey.LAYER_NAMES);
      this.styleNames = params.getStringValue(AVKey.STYLE_NAMES);
      this.imageFormat = params.getStringValue(AVKey.IMAGE_FORMAT);
      this.backgroundColor = params.getStringValue(AVKey.WMS_BACKGROUND_COLOR);
      String version = params.getStringValue(AVKey.WMS_VERSION);

      if (version == null || version.compareTo(MAX_VERSION) >= 0) {
        this.wmsVersion = MAX_VERSION;
        this.crs = "&crs=CRS:84";
      } else {
        this.wmsVersion = version;
        this.crs = "&srs=EPSG:4326";
      }
    }
コード例 #2
0
  /**
   * 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;
  }
コード例 #3
0
  /**
   * Parses WMS elevation model parameters from a specified WMS {@link Capabilities} document. This
   * also parses common WMS layer parameters by invoking {@link
   * DataConfigurationUtils#getWMSLayerParams(gov.nasa.worldwind.wms.Capabilities, String[],
   * gov.nasa.worldwind.avlist.AVList)}. This writes output as key-value pairs to params. Supported
   * key and parameter names are:
   *
   * <table> <th><td>Key</td><td>Value</td><td>Type</td></th> <tr><td>{@link
   * AVKey#ELEVATION_MAX}</td><td>WMS layer's maximum extreme elevation</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#ELEVATION_MIN}</td><td>WMS layer's minimum extreme elevation</td><td>Double</td></tr> <tr><td>{@link
   * AVKey#PIXEL_TYPE}</td><td>Translate WMS layer's image format to a matching pixel type</td><td>String</td></tr>
   * </table>
   *
   * @param caps the WMS Capabilities document to parse for WMS layer parameters.
   * @param formatOrderPreference an ordered array of preferred image formats, or null to use the
   *     default format.
   * @param params the output key-value pairs which recieve the WMS layer parameters.
   * @return a reference to params.
   * @throws IllegalArgumentException if either the document or params are null, or if params does
   *     not contain the required key-value pairs.
   * @throws gov.nasa.worldwind.exception.WWRuntimeException if the Capabilities document does not
   *     contain any of the required information.
   */
  public static AVList getWMSElevationModelParams(
      Capabilities caps, String[] formatOrderPreference, AVList params) {
    if (caps == null) {
      String message = Logging.getMessage("nullValue.WMSCapabilities");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    if (params == null) {
      String message = Logging.getMessage("nullValue.ElevationModelConfigParams");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    DataConfigurationUtils.getWMSLayerParams(caps, formatOrderPreference, params);

    // Attempt to extract the WMS layer names from the specified parameters.
    String layerNames = params.getStringValue(AVKey.LAYER_NAMES);
    if (layerNames == null || layerNames.length() == 0) {
      String message = Logging.getMessage("nullValue.WMSLayerNames");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    String[] names = layerNames.split(",");
    if (names == null || names.length == 0) {
      String message = Logging.getMessage("nullValue.WMSLayerNames");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    // Get the layer's extreme elevations.
    Double[] extremes = caps.getLayerExtremeElevations(caps, names);

    Double d = (Double) params.getValue(AVKey.ELEVATION_MIN);
    if (d == null && extremes != null && extremes[0] != null)
      params.setValue(AVKey.ELEVATION_MIN, extremes[0]);

    d = (Double) params.getValue(AVKey.ELEVATION_MAX);
    if (d == null && extremes != null && extremes[1] != null)
      params.setValue(AVKey.ELEVATION_MAX, extremes[1]);

    // Determine the internal pixel type from the image format.
    if (params.getValue(AVKey.PIXEL_TYPE) == null) {
      String imageFormat = params.getStringValue(AVKey.IMAGE_FORMAT);
      if (imageFormat != null) {
        if (imageFormat.equals("application/bil32"))
          params.setValue(AVKey.PIXEL_TYPE, AVKey.FLOAT32);
        else if (imageFormat.equals("application/bil16"))
          params.setValue(AVKey.PIXEL_TYPE, AVKey.INT16);
        else if (imageFormat.equals("application/bil"))
          params.setValue(AVKey.PIXEL_TYPE, AVKey.INT16);
        else if (imageFormat.equals("image/bil")) params.setValue(AVKey.PIXEL_TYPE, AVKey.INT16);
      }
    }

    // Use the default pixel type.
    if (params.getValue(AVKey.PIXEL_TYPE) == null) params.setValue(AVKey.PIXEL_TYPE, AVKey.INT16);

    // Use the default byte order.
    if (params.getValue(AVKey.BYTE_ORDER) == null)
      params.setValue(AVKey.BYTE_ORDER, AVKey.LITTLE_ENDIAN);

    return params;
  }