/**
* 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 javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import chunmap.data.provider.LayerFactory;
import chunmap.service.Service;
import chunmap.service.ServiceFactory;
import chunmap.service.wms.Capabilities;
import chunmap.service.wms.WebMapService;
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;
/**
* @author yangjiandong
*
*/
public class ChunMapService extends HttpServlet {
private static final long serialVersionUID = 1620311752296047028L;
private static final Logger Log = new Logger(Logger.Debug,ChunMapService.class.getName());
protected String key;
@Override
public void init(ServletConfig config) throws ServletException {
Log.log(Logger.Info, "chunmap's wms service starting");
super.init(config);
key=config.getInitParameter("key");
Capabilities cap = new Capabilities();
Layer layer = loadLayerData();
cap.getLayers().add(layer);
cap.setBaseURL("http://localhost:8080/chunmapService/");
cap.setLink("http://localhost:8080/chunmapService/test");
cap.setUrl("http://localhost:8080/chunmapService/test");
cap.setServiceTile("hello");
cap.setSrs("4326");
Service wms = new WebMapService(cap);
ServiceFactory.putService(wms, "WMS");
Log.log(Logger.Info, "chunmap's wms服务已启动");
}
protected Layer loadLayerData() {
String path1=
"D:\\ChunMap\\ChunMap1.1.1\\Data\\gs\\region.shp";
VectorLayer layer = LayerFactory.openShapeFile(path1,1);
layer.setDefaultStyle(new Symbol[]{new GeneralSymbol(),new LabelSymbol()});
return layer;
}
// 请求地址参数
// http://localhost:8080/chunmapService/test?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetCapabilities
// http://localhost:8080/chunmapService/test?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=92.37175137842411,31.01897163866643,108.8716402641172,44.2188827472209&WIDTH=500&HEIGHT=400
public static void main(String[] args) {
ChunMapService ser = new ChunMapService();
try {
ser.init(null);
} catch (ServletException e) {
e.printStackTrace();
}
System.out.println("ok");
}
}