コード例 #1
0
  /**
   * Sends image as an URL to IE 8 & 9, base64 data for others
   *
   * @param url
   * @param bufferedImage
   * @param bbox
   * @param isTiled
   */
  protected void sendWFSImage(
      String url,
      BufferedImage bufferedImage,
      Double[] bbox,
      boolean isTiled,
      boolean isboundaryTile) {
    if (bufferedImage == null) {
      log.warn("Failed to send image");
      return;
    }

    Map<String, Object> output = new HashMap<String, Object>();
    output.put(OUTPUT_LAYER_ID, this.layerId);

    Location location = this.session.getLocation();

    Tile tileSize = null;
    if (isTiled) {
      tileSize = this.session.getTileSize();
    } else {
      tileSize = this.session.getMapSize();
    }

    output.put(OUTPUT_IMAGE_SRS, location.getSrs());
    output.put(OUTPUT_IMAGE_BBOX, bbox);
    output.put(OUTPUT_IMAGE_ZOOM, location.getZoom());
    output.put(OUTPUT_IMAGE_TYPE, this.type.toString()); // "normal" | "highlight"
    output.put(OUTPUT_KEEP_PREVIOUS, this.session.isKeepPrevious());
    output.put(OUTPUT_BOUNDARY_TILE, isboundaryTile);
    output.put(OUTPUT_IMAGE_WIDTH, tileSize.getWidth());
    output.put(OUTPUT_IMAGE_HEIGHT, tileSize.getHeight());
    output.put(OUTPUT_IMAGE_URL, url);

    byte[] byteImage = WFSImage.imageToBytes(bufferedImage);
    String base64Image = WFSImage.bytesToBase64(byteImage);
    int base64Size = (base64Image.length() * 2) / 1024;

    // IE6 & IE7 doesn't support base64, max size in base64 for IE8 is 32KB
    if (!(this.session.getBrowser().equals(BROWSER_MSIE) && this.session.getBrowserVersion() < 8
        || this.session.getBrowser().equals(BROWSER_MSIE)
            && this.session.getBrowserVersion() == 8
            && base64Size >= 32)) {
      output.put(OUTPUT_IMAGE_DATA, base64Image);
    }

    this.service.addResults(this.session.getClient(), ResultProcessor.CHANNEL_IMAGE, output);
  }
コード例 #2
0
ファイル: MapDisplay.java プロジェクト: jufey/AoA
  public Color getColorForPoint(Point p) {
    for (Tile t : tiles) {
      double dx = t.x - display.getX();
      double dy = t.y - display.getY();

      Rectangle temp2 = new Rectangle((int) dx, (int) dy, (int) t.getWidth(), (int) t.getHeight());

      if (temp2.contains(p)) {
        int px = (int) (p.x - dx);
        int py = (int) (p.y - dy);

        Color c =
            new Color(
                ImageControl.getInstance().getShadowImageAt(t.getImageNumber()).getRGB(px, py));
        return c;
      }
    }
    return null;
  }
コード例 #3
0
    public URL getURL(Tile tile, String altImageFormat) throws MalformedURLException {
      StringBuffer sb;
      if (this.URLTemplate == null) {
        sb = new StringBuffer(WWXML.fixGetMapString(tile.getLevel().getService()));

        if (!sb.toString().toLowerCase().contains("service=wms")) sb.append("service=WMS");
        sb.append("&request=GetMap");
        sb.append("&version=").append(this.wmsVersion);
        sb.append(this.crs);
        sb.append("&layers=").append(this.layerNames);
        sb.append("&styles=").append(this.styleNames != null ? this.styleNames : "");
        sb.append("&transparent=TRUE");
        if (this.backgroundColor != null) sb.append("&bgcolor=").append(this.backgroundColor);

        this.URLTemplate = sb.toString();
      } else {
        sb = new StringBuffer(this.URLTemplate);
      }

      String format = (altImageFormat != null) ? altImageFormat : this.imageFormat;
      if (null != format) sb.append("&format=").append(format);

      sb.append("&width=").append(tile.getWidth());
      sb.append("&height=").append(tile.getHeight());

      Sector s = tile.getSector();
      sb.append("&bbox=");
      sb.append(s.getMinLongitude().getDegrees());
      sb.append(",");
      sb.append(s.getMinLatitude().getDegrees());
      sb.append(",");
      sb.append(s.getMaxLongitude().getDegrees());
      sb.append(",");
      sb.append(s.getMaxLatitude().getDegrees());
      //            sb.append("&"); // terminate the query string

      return new java.net.URL(sb.toString().replace(" ", "%20"));
    }