/**
   * reads a deegree WCS configuration file and performs a DescribeCoverage request Steps:
   *
   * <ul>
   *   <li>read configuration file
   *   <li>read a DescribeCoverage request object
   *   <li>perform the request
   * </ul>
   */
  public void _testDescribeCoverage() {
    try {
      WCSConfiguration configuration =
          WCSConfiguration.create(Configuration.getWCSConfigurationURL());
      WCService service = new WCService(configuration);

      Map<String, String> map = new HashMap<String, String>();
      map.put("SERVICE", "WCS");
      map.put("REQUEST", "DescribeCoverage");
      map.put("VERSION", "1.0.0");
      map.put("COVERAGE", "europe");

      // StringBuffer sb = new StringBuffer();
      // sb.append(Configuration.PROTOCOL + "://" + Configuration.HOST).append(':').append(
      // Configuration.PORT).append('/').append(Configuration.WCS_WEB_CONTEXT).append(
      // '/').append(Configuration.WCS_SERVLET).append("?service=WCS&").append(
      // "request=DescribeCoverage&version=1.0.0&coverage=europe");

      DescribeCoverage desc = DescribeCoverage.create(map);
      CoverageDescription o = (CoverageDescription) service.doService(desc);
      LOG.logInfo(Arrays.toString(o.getCoverageOfferings()));
    } catch (Exception e) {
      fail(StringTools.stackTraceToString(e));
    }
  }
  /**
   * validates the passed <tt>GetCoverage</tt> against the passed <tt>WCSCapabilities</tt>
   *
   * @param capabilities
   * @param request
   * @throws InvalidParameterValueException
   */
  private static void validate(WCSCapabilities capabilities, GetCoverage request)
      throws InvalidParameterValueException {
    String coverage = request.getSourceCoverage();
    ContentMetadata cm = capabilities.getContentMetadata();
    // is coverage known by the WCS?
    CoverageOfferingBrief cob = cm.getCoverageOfferingBrief(coverage);
    if (cob == null) {
      throw new InvalidParameterValueException(
          "Coverage: " + coverage + " is not known by the WCS");
    }

    URL url = cob.getConfiguration();
    CoverageDescription cd = null;
    try {
      cd = CoverageDescription.createCoverageDescription(url);
    } catch (Exception e) {
      LOG.logError(e.getMessage(), e);
      throw new InvalidParameterValueException(e.getMessage());
    }
    CoverageOffering co = cd.getCoverageOffering(coverage);
    if (co == null) {
      throw new InvalidParameterValueException(
          "no coverage descrition " + "available for requested coverage: " + coverage);
    }
    // validate requested format
    String format = request.getOutput().getFormat().getCode();
    SupportedFormats sf = co.getSupportedFormats();
    CodeList[] codeList = sf.getFormats();
    if (!validate(codeList, null, format)) {
      throw new InvalidParameterValueException(
          "requested format: " + format + " is not known by the WCS for coverage:" + coverage);
    }
    // validate requested response CRS
    String crs = request.getOutput().getCrs().getCode();
    URI codeSpace = request.getOutput().getCrs().getCodeSpace();
    String space = null;
    if (codeSpace != null) {
      space = codeSpace.toString();
    }

    CodeList[] rrcrs = co.getSupportedCRSs().getRequestResponseSRSs();
    CodeList[] rescrs = co.getSupportedCRSs().getResponseSRSs();
    if (!validate(rrcrs, space, crs) && !validate(rescrs, space, crs)) {
      throw new InvalidParameterValueException(
          "requested response CRS: "
              + crs
              + " is not known by the WCS "
              + "for coverage:"
              + coverage);
    }
    // validate requested CRS
    crs = request.getDomainSubset().getRequestSRS().getCode();
    codeSpace = request.getDomainSubset().getRequestSRS().getCodeSpace();
    if (codeSpace != null) {
      space = codeSpace.toString();
    }
    CodeList[] reqcrs = co.getSupportedCRSs().getRequestSRSs();

    if (!validate(rrcrs, space, crs) && !validate(reqcrs, space, crs)) {
      throw new InvalidParameterValueException(
          "requested request CRS: " + crs + " is not known by the WCS for coverage:" + coverage);
    }
    // validate requested envelope
    Envelope envelope = request.getDomainSubset().getSpatialSubset().getEnvelope();
    LonLatEnvelope llEnv = cob.getLonLatEnvelope();
    Envelope[] domEnvs = co.getDomainSet().getSpatialDomain().getEnvelops();

    try {
      if (!intersects(envelope, request.getDomainSubset().getRequestSRS(), domEnvs, llEnv)) {
        throw new InvalidParameterValueException(
            "requested BBOX: doesn't intersect "
                + " the area of the requested coverage: "
                + coverage);
      }
    } catch (UnknownCRSException e) {
      throw new InvalidParameterValueException(e);
    }
  }