Package chunmap.service.wms

Source Code of chunmap.service.wms.GetMap

/**
* Copyright (c) 2009-2011, chunquedong(YangJiandong)
*
* This file is part of ChunMap project
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
*
* History:
*     2010-05-05  Jed Young  Creation
*/
package chunmap.service.wms;

import java.awt.Image;
import java.io.IOException;
import java.io.PrintStream;

import chunmap.model.elem.Envelope;
import chunmap.util.image.ImageUtil;
import chunmap.view.Map;

/**
* @author yangjiandong
*
*/
public class GetMap {

  private Envelope envelop;
  private Capabilities capbilities;
  private int height;
  private int width;
  private String formatName = "png";

  public GetMap(Capabilities capbilities) {
    this.capbilities = capbilities;
  }

  public void reponse(PrintStream out) throws IOException {
    byte[] data = createData();
    out.write(data);
  }

  private byte[] createData() throws IOException {
    // create map
//    View view = new ViewPort(width, height,3);
//    Painter painter = new Painter(width, height);
    Map map = new Map(width, height);
    map.getLayerCollection().setLayers(capbilities.getLayers());

    // getImage
    map.getView().setViewEnvelop(envelop);
    map.render();
    Image image = (Image)map.getPainter().getData();

    // toByteArray
    return ImageUtil.Image2ByteArray(image, formatName);
  }

  // -------------------------------------------------------------------------

  public Envelope getEnvelop() {
    return envelop;
  }
  public void setEnvelop(Envelope envelop) {
    this.envelop = envelop;
  }
  public Capabilities getCapbilities() {
    return capbilities;
  }
  public void setCapbilities(Capabilities capbilities) {
    this.capbilities = capbilities;
  }
  public int getHeight() {
    return height;
  }
  public void setHeight(int height) {
    this.height = height;
  }
  public int getWidth() {
    return width;
  }
  public void setWidth(int width) {
    this.width = width;
  }
  public String getFormatName() {
    return formatName;
  }
  public void setFormatName(String formatName) {
    this.formatName = formatName;
  }
}
TOP

Related Classes of chunmap.service.wms.GetMap

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.