⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layerlist.java

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JAVA
字号:
package com.esri.solutions.jitk.web.tasks.query.pointbuffer;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;

import org.apache.log4j.Logger;

import com.esri.adf.web.ags.data.AGSLocalMapResource;
import com.esri.adf.web.ags.data.AGSMapFunctionality;
import com.esri.adf.web.ags.data.AGSMapResource;
import com.esri.adf.web.aims.data.AIMSMapFunctionality;
import com.esri.adf.web.aims.data.AIMSMapResource;
import com.esri.adf.web.data.GISResource;
import com.esri.adf.web.data.WebContext;
import com.esri.adf.web.data.WebLayerInfo;
import com.esri.aims.mtier.model.map.Layers;
import com.esri.aims.mtier.model.map.Map;
import com.esri.aims.mtier.model.map.layer.Layer;
import com.esri.arcgisws.MapLayerInfo;
import com.esri.solutions.jitk.web.wfs.data.WFSMapResource;
import com.esri.solutions.jitk.web.wfs.data.WFSWebLayerInfo;

public class LayerList extends LinkedHashMap<String, String>{
	private static Logger _logger = Logger.getLogger(LayerList.class.getName());
	private static final long serialVersionUID = -1905879466691292018L;

	public LayerList(WebContext context) {		
		super();
		buildLayerList(context);
	}
	
	public void buildLayerList(WebContext context){					
		LinkedHashMap<String, GISResource> resources = (LinkedHashMap<String, GISResource>) context.getResources();				
		Object resource;
		
		for(Iterator<String> iter = resources.keySet().iterator(); iter.hasNext();) {
        	String id = (String)iter.next();
        	resource = resources.get(id);
        	
            if (resource instanceof AIMSMapResource){	            
            	AIMSMapResource tempAimsResource = (AIMSMapResource)resource;
            	appendAimsLayerList(tempAimsResource, id);
            }
            
			if (resource instanceof AGSMapResource){
				AGSMapResource tempAgsResource = (AGSMapResource)resource;
				appendAgsLayerList(tempAgsResource, id, context.getWebQuery().getQueryLayers());
			}
			
			if (resource instanceof WFSMapResource) {
				WFSMapResource wfsMapResource = (WFSMapResource) resource;
				appendWfsLayerList(wfsMapResource, id, context.getWebQuery().getQueryLayers());					
			}
		}			
	}	
	
	protected void appendWfsLayerList(WFSMapResource wfsMapResource, String resourceId, List<WebLayerInfo> queryLayerList) {
		if (wfsMapResource != null) {
			List<WFSWebLayerInfo> layers = wfsMapResource.getLayers();
			String mapSourceName = wfsMapResource.getAlias();
			
			for (WebLayerInfo webLayerInfo: layers) {					
				String layerName = webLayerInfo.getName();
				
				if (layerName != null) {
					String key = resourceId + "!" + webLayerInfo.getId();
					String value = mapSourceName + "." + layerName;
					this.put(key, value);	
				}
				else {
					_logger.warn("null layer name encountered for WFS service, ignoring");
				}
			}			
		}	
	}	
	
	protected void appendAimsLayerList(AIMSMapResource aimsMapResource, String resourceId){
		LinkedHashMap<String, String> newLayerList = new LinkedHashMap<String, String>();	
		
		if(aimsMapResource != null){			
			AIMSMapFunctionality aimsMapFunc = (AIMSMapFunctionality)(aimsMapResource).getFunctionality("map");
	    	Map aimsMap = aimsMapFunc.getMap();
			Layers aimsLayers = aimsMap.getLayers();
			
			for(int i = aimsLayers.getCount() - 1; i >= 0; i--){					
				Layer aimsLayer = aimsLayers.item(i);
				if (!checkLayer(newLayerList, aimsMapResource.getServiceName() + "." + aimsLayer.getName())){
					newLayerList.put(resourceId + "!" + i, 
						aimsMapResource.getServiceName() + "." + aimsLayer.getName());
				}
			}
		}	

		this.putAll(newLayerList);
	}	
	
	private static boolean checkLayer(LinkedHashMap<String, String> layerList, String layerName){
		if (layerList.containsValue(layerName)) return true;
		return false;
	}	
	
	public void appendAgsLayerList(AGSMapResource agsMapResource, String resourceId, List<WebLayerInfo> queryLayerList) {
		if(agsMapResource != null){
			AGSMapFunctionality agsMapFunc = (AGSMapFunctionality)(agsMapResource).getFunctionality("map");
			MapLayerInfo[] mapLayers = agsMapFunc.getLayerInfos();
			
			String mapSourceName = agsMapResource.getAlias();
			
			if (agsMapResource instanceof AGSLocalMapResource){
				mapSourceName = ((AGSLocalMapResource)agsMapResource).getServerObjectName();
			}
			
			Iterator<WebLayerInfo> it = queryLayerList.iterator();
			
			while (it.hasNext()){
				WebLayerInfo webLayerInfo = it.next();
				
				for (int i = 0; i < mapLayers.length; i++){
					MapLayerInfo mapLayer = mapLayers[i];	
					
					if (mapLayer.getSubLayerIDs() == null && mapLayer.getLayerID() == webLayerInfo.getId()){
						this.put(resourceId + "!" + mapLayer.getLayerID(), mapSourceName + "." + mapLayer.getName());							
					}
				}
			}				
		}	
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -