コード例 #1
0
  /**
   * reads a deegree WCS configuration file and performs a GetCoverage request Steps:
   *
   * <ul>
   *   <li>read configuration file
   *   <li>read a GetCoverage request object
   *   <li>perform the request
   * </ul>
   */
  public void _testGetCoverage3() {
    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", "GetCoverage");
      map.put("VERSION", "1.0.0");
      map.put("COVERAGE", "europe");
      map.put("CRS", "EPSG:4326");
      map.put("BBOX", "-5,40,20,60");
      map.put("WIDTH", "800");
      map.put("HEIGHT", "800");
      map.put("FORMAT", "jpeg");

      // 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=GetCoverage&version=1.0.0&coverage=europe&")
      // .append( "crs=EPSG:4326&BBOX=-5,40,20,60&Width=800&height=800&")
      // .append("format=jpeg");
      GetCoverage desc = GetCoverage.create(map);
      ResultCoverage o = (ResultCoverage) service.doService(desc);
      BufferedImage bi = ((AbstractGridCoverage) o.getCoverage()).getAsImage(800, 800);

      FileOutputStream fos =
          new FileOutputStream(Configuration.getWCSBaseDir().getPath() + "/kannweg3.tif");
      ImageUtils.saveImage(bi, fos, "tif", 1);
      fos.close();
    } catch (Exception e) {
      fail(StringTools.stackTraceToString(e));
    }
  }
コード例 #2
0
  /**
   * reads a deegree WCS configuration file and performs a GetCoverage request. same as
   * testGetCoverage1() but uses nameIndexed data source Steps:
   *
   * <ul>
   *   <li>read configuration file
   *   <li>read a GetCoverage request object
   *   <li>perform the request
   * </ul>
   */
  public void _testGetCoverage2() {
    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", "GetCoverage");
      map.put("VERSION", "1.0.0");
      map.put("COVERAGE", "dem");
      map.put("CRS", "EPSG:4326");
      map.put("BBOX", "-122.6261,37.4531,-122.0777,38.0");
      map.put("WIDTH", "828");
      map.put("HEIGHT", "823");
      map.put("FORMAT", "GeoTiff");

      // 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=GetCoverage&version=1.0.0&coverage=dem&").append(
      // "crs=EPSG:4326&BBOX=-122.6261,37.4531,-122.0777,38.0&Width=828&height=823&")
      // .append("format=GeoTiff");
      GetCoverage desc = GetCoverage.create(map);
      ResultCoverage o = (ResultCoverage) service.doService(desc);
      BufferedImage bi = ((AbstractGridCoverage) o.getCoverage()).getAsImage(828, 823);
      LOG.logInfo(o.toString());
      FileOutputStream fos =
          new FileOutputStream(new URL(Configuration.getWCSBaseDir(), "/kannweg2.tif").getFile());
      ImageUtils.saveImage(bi, fos, "tif", 1);
      fos.close();
    } catch (Exception e) {
      fail(StringTools.stackTraceToString(e));
    }
  }