package com.esri.arcgis.sample;
import com.esri.arcgisws.EsriImageFormat;
import com.esri.arcgisws.EsriImageReturnType;
import com.esri.arcgisws.ImageDescription;
import com.esri.arcgisws.ImageDisplay;
import com.esri.arcgisws.ImageType;
import com.esri.arcgisws.MapDescription;
import com.esri.arcgisws.MapImage;
import com.esri.arcgisws.MapServerBindingStub;
import com.esri.arcgisws.MapServerInfo;
public class ExportMap {
public static void main(String[] args) {
// TODO Auto-generated method stub
//地图服务的地址
String endpoint = "http://localhost:8399/arcgis/services/HWBaseMap/MapServer";
MapServerBindingStub mapserver;
try {
mapserver= new MapServerBindingStub(endpoint);
MapServerInfo mapinfo = mapserver.getServerInfo(mapserver.getDefaultMapName());
MapDescription mapdesc = mapinfo.getDefaultMapDescription();
//设置地图显示范围
// com.esri.arcgisws.MapArea ma=mapdesc.getMapArea();
// EnvelopeN envelopeN=(EnvelopeN) ma.getExtent();
// envelopeN.setXMin(800000.0);
// envelopeN.setXMax(1000000.0);
// envelopeN.setYMin(4000000.0);
// envelopeN.setYMax(4400000.0);
// ma.setExtent(envelopeN);
// MapLayerInfo[]layerInfos=mapinfo.getMapLayerInfos();
// MapLayerInfo[] newLayerInfos=new MapLayerInfo[layerInfos.length];
// for(int ii=0;ii<layerInfos.length;ii++){
// newLayerInfos[ii]=layerInfos[ii];
// }
// LayerDescription[] newLayerDescriptions = new LayerDescription[newLayerInfos.length];
// LayerDescription[] layerDescriptions=mapinfo.getDefaultMapDescription().getLayerDescriptions();
// for(int i=0;i<newLayerInfos.length;i++){
// newLayerDescriptions[i]=AGSUtil.getLayerDescription(newLayerInfos[i].getLayerID(),layerDescriptions);
// // if(newLayerInfos[i].getName().equalsIgnoreCase("country")){
// // newLayerDescriptions.setDefinitionExpression(sqlStr);
// // }
// }
// mapinfo.getDefaultMapDescription().setLayerDescriptions(newLayerDescriptions);
//设置输出图片格式
ImageType imgtype = new ImageType();
imgtype.setImageFormat(EsriImageFormat.esriImageGIF);
imgtype.setImageReturnType(EsriImageReturnType.esriImageReturnURL);
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.setImageHeight(600);
imgdisp.setImageWidth(800);
imgdisp.setImageDPI(96);
ImageDescription imgdesc = new ImageDescription();
imgdesc.setImageDisplay(imgdisp);
imgdesc.setImageType(imgtype);
System.out.println("imgdesc.getImageType(): "+imgdesc.getImageType().getImageFormat().getValue());
System.out.println("mapdesc.getName: "+mapdesc.getName());
System.out.println("mapserverName: "+mapserver.getDefaultMapName());
MapImage mapimg = mapserver.exportMapImage(mapdesc, imgdesc);
System.out.println("mapimg.getMapScale(): "+mapimg.getMapScale());
System.out.println("mapimg.getImageURL(): "+mapimg.getImageURL());
// System.out.println(((EnvelopeN)mapinfo.getExtent()).getXMax());
// System.out.println(((EnvelopeN)mapinfo.getExtent()).getXMin());
// System.out.println(((EnvelopeN)mapinfo.getExtent()).getYMax());
// System.out.println(((EnvelopeN)mapinfo.getExtent()).getYMin());
}catch (Exception e) {
e.printStackTrace();
System.out.println("FFFFF");
}
}
}
ArcGIS Server 导出地图图片(SOAP)
最新推荐文章于 2024-05-09 14:25:52 发布