Exemplo n.º 1
0
  /**
   * Creates a image of the WFS layer's data
   *
   * @return image
   */
  private BufferedImage draw() {
    MapContent content = new MapContent();
    MapViewport viewport = new MapViewport();

    CoordinateReferenceSystem crs = location.getCrs();
    ReferencedEnvelope bounds = location.getEnvelope();

    Rectangle screenArea;
    if (isTile && bufferSize != 0.0d) {
      double width = (location.getRight() - location.getLeft()) / 2 * bufferSize;
      double height = (location.getTop() - location.getBottom()) / 2 * bufferSize;
      bounds = location.createEnlargedEnvelope(width, height);
      screenArea = new Rectangle(0, 0, bufferedImageWidth, bufferedImageHeight);
    } else {
      screenArea = new Rectangle(0, 0, imageWidth, imageHeight); // image size
    }

    viewport.setCoordinateReferenceSystem(crs);
    viewport.setScreenArea(screenArea);
    viewport.setBounds(bounds);
    viewport.setMatchingAspectRatio(true);

    if (features.size() > 0) {
      Layer featureLayer = new FeatureLayer(features, style);
      content.addLayer(featureLayer);
    }

    content.setViewport(viewport);

    return saveImage(content);
  }