Package chunmap.raster.gmap

Source Code of chunmap.raster.gmap.StaticGMConn

/**
* 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.raster.gmap;

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

import chunmap.model.coord.CPoint;
import chunmap.raster.Tile;
import chunmap.util.image.ImageUtil;

public class StaticGMConn extends GMConnection {
  public Image getImage(GMTile tile_) {
    Tile tile = (tile_.proxy == null) ? tile_ : tile_.proxy;

    String name = tile.toString();
    Image image = cache.find(name);
    if (image != null)
      return image;

    CPoint p=tile.getEnvelop().getCenter();
//    Mercator proj=new Mercator();
//    p=proj.getReverseTransform().convert(p);
   
    String url = getString(p.getX(),p.getY(), tile.z);
    try {
      Image tm = request(url);
      image=ImageUtil.imageCopy(tm, 0, 0, GoogleMapCode.tileSize, GoogleMapCode.tileSize);
     
    } catch (IOException exp) {
      // return Resources.chun;
      // TODO
      return null;
    }

    cache.save(image, name);
    return image;
  }

  private String getString(double x, double y, int z) {
    String url="http://ditu.google.cn/staticmap?center="+y+","+x+"&zoom="+z
    +"&size=256x285&maptype="+maptype+"&key="+key+"&sensor=true_or_false";
   
    System.out.println(url);
    return url;
  }
  public String key="MAPS_API_KEY";
  public String maptype="satellite";
}
TOP

Related Classes of chunmap.raster.gmap.StaticGMConn

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.