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

📄 wmsservice.java

📁 联合国农粮署牵头开发的geonetwork源代码最新版
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	}		/** Not used yet */	public void setLayerVisible(String id, boolean visible) { this.visible = visible; }		/** Returns the default bounding box, as in LatLonBoundingBox */	public BoundingBox getDefBoundingBox() {		Element elBoundingBox = layerInfo.getChild("LatLonBoundingBox");				if (elBoundingBox != null) {			float minx = Float.parseFloat(elBoundingBox.getAttributeValue("minx"));			float miny = Float.parseFloat(elBoundingBox.getAttributeValue("miny"));			float maxx = Float.parseFloat(elBoundingBox.getAttributeValue("maxx"));			float maxy = Float.parseFloat(elBoundingBox.getAttributeValue("maxy"));						return new BoundingBox(maxy, miny, maxx, minx);		}		else return new BoundingBox();	}		/** Returns the current BoundingBox */	public BoundingBox getBoundingBox() { return bb; }		/** Not used yet */	public Vector getVisibleLayers() {		Vector v = new Vector();		if (visible)			v.add(new Integer(1));		return v;	}		/** Returns the legend for the currently selected style, as in the Style element */	public String getLegendUrl() throws Exception {		if (wmsVer.startsWith("1.1")) // 1.0 documentation was no clear for the legend URL		{			Namespace ns = org.jdom.Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");			List styles = layerInfo.getChildren("Style");			for (Iterator i = styles.iterator(); i.hasNext(); ) {				Element elStyle = (Element)i.next();				if (elStyle.getChildText("Name").equals(style))					try {						return  elStyle.getChild("LegendURL")							.getChild("OnlineResource").getAttributeValue("href", ns); // null if no legend					}				catch (Exception e) {} // LegendUrl is optional, so JDOM throws an exception if he doesn't find it,				// but we just return null			}		}				return null;	}		/** Converts this service into a Jdom Element, to be used by the Jeeves Map service */	public Element toElement() {		Element elService = new Element("service")			.setAttribute("type", "WMS")			.setAttribute("name", getName())			.addContent(getInfo())			.addContent(new Element(MapServices.LAST_RESPONSE_TAG).addContent(getLastResponse()));				if (style != null)			elService.setAttribute("style", style);				// add selected extents information		Element extents = new Element("selectedExtents");		for (Enumeration e = htExtents.keys(); e.hasMoreElements(); ) {			String key = (String)e.nextElement();			String value = (String)htExtents.get(key);			extents.addContent(new Element(key).setText(value));		}				elService.addContent(extents);				return elService;	}		/** Useless for WMS layers */	public void setActiveLayer(int layer) throws Exception {}		/** Sets the style for this service */	public void setStyle(String style) { this.style = style; }		public String getTitle() {		return layerInfo.getChildText("Title");	}	//	private Element getLayerInfo(String name, Element capabilities) {//		List layers = capabilities.getChild("Capability").getChildren("Layer");//		return findLayerInfo(name, layers);//	}////	private Element findLayerInfo(String name, List layers) {//		for (Iterator i = layers.iterator(); i.hasNext(); ) {//			Element layer = (Element)i.next();////			String layerName = layer.getChildText("Name");//			if (layerName != null && layerName.equals(name))//				return (Element)layer.clone();//			else {//				// Recursively apply this method//				Element info = findLayerInfo(name, layer.getChildren());//				if (info != null) return info;//			}//		}////		return null; // Layer not found//	}		public Element getExtents() {		Extents e = new Extents(layerInfo);		return e.getJdom();	}		private void getPrefixes() throws Exception {		Element request = info.getChild("Capability").getChild("Request");		if (wmsVer.startsWith("1.1")) {			// Required requests			getCapabilitiesPrefix = get11Prefix(request, "GetCapabilities");			getMapPrefix = get11Prefix(request, "GetMap");						// Optional requests			try { getFeatureInfoPrefix = get11Prefix(request, "GetFeatureInfo"); } catch (Exception e) {}			try { describeLayerPrefix = get11Prefix(request, "DescribeLayer"); } catch (Exception e) {}			try { getLegendGraphicPrefix = get11Prefix(request, "GetLegendGraphic"); } catch (Exception e) {}			try { getStylesPrefix = get11Prefix(request, "GetStyles"); } catch (Exception e) {}			try { putStylesPrefix = get11Prefix(request, "PutStyles"); } catch (Exception e) {}		}					else if (wmsVer.startsWith("1.0")) {			// Required requests			getCapabilitiesPrefix = get10Prefix(request, "Capabilities");			getMapPrefix = get10Prefix(request, "Map");						// Optional requests			try { getFeatureInfoPrefix = get10Prefix(request, "FeatureInfo"); } catch (Exception e) {}		}					else throw new Exception();	}		private String setPrefix(String prefix) {		if (prefix.indexOf("?") == -1) return prefix + "?";		else if (!prefix.endsWith("?")) return prefix + "&";		else return prefix;	}		private String get11Prefix(Element elRequest, String request) {		Namespace ns = org.jdom.Namespace.getNamespace("xlink", "http://www.w3.org/1999/xlink");		return elRequest.getChild(request).getChild("DCPType").getChild("HTTP")			.getChild("Get").getChild("OnlineResource").getAttributeValue("href", ns);	}		private String get10Prefix(Element elRequest, String request) {		return elRequest.getChild(request).getChild("DCPType").getChild("HTTP")			.getChild("Get").getAttributeValue("onlineResource");	}		/** Returns one of the image types returned by the server choosing	 *  from gif, ong and jpeg	 */	private String getImageType(Element capabilities) {		// WmtVer = 1.1.x		if (wmsVer.startsWith("1.1")) {			List typesEl = capabilities.getChild("Capability")				.getChild("Request")				.getChild("GetMap")				.getChildren("Format");			Vector types = new Vector();			for (Iterator i = typesEl.iterator(); i.hasNext(); )				types.add(((Element)i.next()).getText());			if (types.contains("image/png"))				return "image/png";			else if (types.contains("image/gif"))				return "image/gif";			else				return "image/jpeg"; // Try jpeg		}						// WmsVer = 1.0.x		else if (wmsVer.startsWith("1.0")) {			List typesEl = capabilities.getChild("Capability")				.getChild("Request")				.getChild("Map")				.getChild("Format")				.getChildren();			Vector types = new Vector();			for (Iterator i = typesEl.iterator(); i.hasNext(); )				types.add(((Element)i.next()).getName());			if (types.contains("JPEG"))				return "JPEG";			else if (types.contains("PNG"))				return "PNG";			else if (types.contains("GIF"))				return "GIF";			else				return "JPEG"; // Try jpeg		}				return "image/jpeg"; // Try to guess jpeg	}		private static Element toHtml(String s) {		Vector v = new Vector();				for (StringTokenizer t = new StringTokenizer(s, "\r\n"); t.hasMoreTokens(); ) {			Text line = new Text(t.nextToken());			v.add(line);			v.add(new Element("br"));		}				return new Element("html").setContent(v);	}	}//==============================================================================//=== $Log: WmsService.java,v $//=== Revision 1.15  2005/11/09 11:39:31  sgiaccio//=== More fixes to WMS get feature info//===//=== Revision 1.14  2005/11/09 10:38:51  sgiaccio//=== *** empty log message ***//===//=== Revision 1.13  2005/11/08 17:01:35  sgiaccio//=== *** empty log message ***//===//=== Revision 1.12  2005/11/08 17:00:07  sgiaccio//=== Some fix to the identify feature on wms layers.//===//=== Revision 1.11  2005/09/21 08:00:19  sgiaccio//=== Cleaned cache management//===//=== Revision 1.10  2005/09/19 16:39:26  sgiaccio//=== Some code cleaning//===//=== Revision 1.9  2005/09/13 10:18:10  ticheler//=== InterMap version 2.0//===//==============================================================================

⌨️ 快捷键说明

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