Exemple #1
0
 private static String generateDemoUrl(String layerName, String gridSetId, ImageMime imageMime) {
   return "<a href=\"demo/"
       + layerName
       + "?gridSet="
       + gridSetId
       + "&format="
       + imageMime.getFormat()
       + "\">"
       + imageMime.getFileExtension()
       + "</a>";
 }
Exemple #2
0
  protected void writeResponse(HttpServletResponse response, RuntimeStats stats)
      throws IOException, OutsideCoverageException, GeoWebCacheException {
    determineSourceResolution();
    determineCanvasLayout();
    createCanvas();
    renderCanvas();
    scaleRaster();

    response.setStatus(HttpServletResponse.SC_OK);
    response.setContentType(this.outputFormat.getMimeType());
    response.setCharacterEncoding("UTF-8");

    ServletOutputStream os = response.getOutputStream();
    AccountingOutputStream aos = new AccountingOutputStream(os);

    try {
      ImageIO.write(canvas, outputFormat.getInternalName(), aos);
      aos.close();
    } catch (IOException ioe) {
      log.debug("IOException writing untiled response to client: " + ioe.getMessage());
    }

    log.debug("WMS response size: " + aos.getCount() + "bytes.");

    stats.log(aos.getCount(), CacheResult.WMS);
  }
Exemple #3
0
  protected void createCanvas() {
    // TODO take bgcolor and transparency from request into account
    // should move this into a separate function

    Color bgColor = null;
    boolean transparent = true;

    if (layer instanceof WMSLayer) {
      WMSLayer wmsLayer = (WMSLayer) layer;
      int[] colorAr = wmsLayer.getBackgroundColor();

      if (colorAr != null) {
        bgColor = new Color(colorAr[0], colorAr[1], colorAr[2]);
      }
      transparent = wmsLayer.getTransparent();
    }

    int canvasType;
    if (bgColor == null
        && transparent
        && (outputFormat.supportsAlphaBit() || outputFormat.supportsAlphaChannel())) {
      canvasType = BufferedImage.TYPE_INT_ARGB;
    } else {
      canvasType = BufferedImage.TYPE_INT_RGB;
      if (bgColor == null) {
        bgColor = Color.WHITE;
      }
    }

    // Create the actual canvas and graphics object
    canvas = new BufferedImage(canvasSize[0], canvasSize[1], canvasType);
    gfx = (Graphics2D) canvas.getGraphics();

    if (bgColor != null) {
      gfx.setColor(bgColor);
      gfx.fillRect(0, 0, canvasSize[0], canvasSize[1]);
    }
  }
Exemple #4
0
  protected WMSTileFuser(TileLayerDispatcher tld, StorageBroker sb, HttpServletRequest servReq)
      throws GeoWebCacheException {
    this.sb = sb;

    String[] keys = {
      "layers", "format", "srs", "bbox", "width", "height", "transparent", "bgcolor"
    };

    Map<String, String> values =
        ServletUtils.selectedStringsFromMap(
            servReq.getParameterMap(), servReq.getCharacterEncoding(), keys);

    // TODO Parameter filters?

    String layerName = values.get("layers");
    layer = tld.getTileLayer(layerName);

    List<MimeType> ml = layer.getMimeTypes();
    Iterator<MimeType> iter = ml.iterator();
    while (iter.hasNext()) {
      MimeType mt = iter.next();
      if (mt.getInternalName().equalsIgnoreCase("png")) {
        this.srcFormat = (ImageMime) mt;
      }
    }

    gridSubset = layer.getGridSubsetForSRS(SRS.getSRS(values.get("srs")));

    outputFormat = (ImageMime) ImageMime.createFromFormat(values.get("format"));

    reqBounds = new BoundingBox(values.get("bbox"));

    reqWidth = Integer.valueOf(values.get("width"));

    reqHeight = Integer.valueOf(values.get("height"));

    // if(values[6] != null) {
    // this.reqTransparent = Boolean.valueOf(values[6]);
    // }

    // if(values[7] != null) {
    // this.reqBgColor = values[7];
    // }

    fullParameters =
        layer.getModifiableParameters(servReq.getParameterMap(), servReq.getCharacterEncoding());
  }