Package chunmap.example.service

Source Code of chunmap.example.service.GoogleMapService

/**
* 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.example.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import chunmap.data.provider.LayerFactory;
import chunmap.model.crs.CoordinateRef;
import chunmap.model.crs.proj.Mercator;
import chunmap.model.crs.proj.ReProjOp;
import chunmap.service.Service;
import chunmap.service.ServiceFactory;
import chunmap.service.gmap.GMService;
import chunmap.util.Logger;
import chunmap.view.layer.Layer;
import chunmap.view.layer.VectorLayer;
import chunmap.view.render.GeneralSymbol;
import chunmap.view.render.LabelSymbol;
import chunmap.view.render.Symbol;

public class GoogleMapService  extends HttpServlet{
  private static final long serialVersionUID = 1620311752296047028L;
  private static final Logger Log = new Logger(Logger.Debug,GoogleMapService.class.getName());

  @Override
  public void init(ServletConfig config) throws ServletException {
    Log.log(Logger.Info, "chunmap's googlemap service starting");
    super.init(config);

    List<Layer> layers=new ArrayList<Layer>();
    Layer layer = loadLayerData();
    layers.add(layer);

    Service gms = new GMService(layers);
    ServiceFactory.putService(gms, "GoogleMap");

    Log.log(Logger.Info, "chunmap's googlemap服务已启动");
  }

  private Layer loadLayerData() {
    String path1="D:\\Temp\\mapdata\\cntry02\\cntry02.shp";
    VectorLayer layer =  LayerFactory.openShapeFile(path1,1);
    layer.setDefaultStyle(new Symbol[]{new GeneralSymbol(),new LabelSymbol()});
   
    //reproj
    CoordinateRef target = new CoordinateRef();
        target.setProjection(new Mercator());
    ReProjOp.changeCRS(layer.getFeatures(), target);
   
    return layer;
  }

  // 请求地址参数
  // http://localhost:8080/chunmapService/test?SERVICE=GoogleMap&x=1&y=1&z=1

  public static void main(String[] args) {
    GoogleMapService ser = new GoogleMapService();

    try {
      ser.init(null);
    } catch (ServletException e) {
      e.printStackTrace();
    }
    System.out.println("ok");

  }
}
TOP

Related Classes of chunmap.example.service.GoogleMapService

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.