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

📄 gmlmultisurfaceconverter.java

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

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import com.esri.adf.web.data.geometry.WebGeometry;
import com.esri.adf.web.data.geometry.WebPoint;
import com.esri.adf.web.data.geometry.WebPolygon;
import com.esri.adf.web.data.geometry.WebRing;
import com.esri.solutions.jitk.datasources.ogc.gml.GMLLinearRing;
import com.esri.solutions.jitk.datasources.ogc.gml.GMLMultiSurface;
import com.esri.solutions.jitk.datasources.ogc.gml.IGMLGeometry;

public class GMLMultiSurfaceConverter implements IGMLGeometryConverter {
	private static final Logger _logger = LogManager.getLogger(GMLMultiSurfaceConverter.class);
	
	public GMLMultiSurfaceConverter() {
	}
	
	public WebGeometry toWebGeometry(IGMLGeometry geometry) throws Exception {
		GMLMultiSurface gmlMultiSurface = (GMLMultiSurface) geometry;
		WebPolygon webPolygon = new WebPolygon();
		String x = "";
		String y = "";
		Exception ex = null;
		int ringNm = 1;
		String posList = "";
		
		try {
			for (GMLLinearRing gmlRing : gmlMultiSurface.getRings()) {
				posList = gmlRing.getPostList();
				WebRing ring = new WebRing();
				
				if (posList != null) {
					String[] coords = posList.trim().split(" ");
					
					if (coords != null) {
						for (int index = 0; index < coords.length; index++) {
							WebPoint point = new WebPoint();
							y = coords[index];
							point.setY(Double.parseDouble(y));
							
							if ((index + 1) < coords.length) {
								index++;
								x = coords[index];
							}
							else {
								throw new Exception("Last coordinate missing x value");
							}
							
							point.setX(Double.parseDouble(x));
							ring.addPoint(point);
						}
						
						webPolygon.addRing(ring);
					}
				}
				
				ringNm++;
			}
		}
		catch (Exception ex2) {
			ex = ex2;
			_logger.error("Failed on converting ring #" + ringNm);
			_logger.error("Position List: " + posList);
			_logger.error("x: " + x + ", y: " + y);
			
		}
		finally {
			if (ex != null) {
				throw ex;
			}
		}
		
		return webPolygon;
	}
}

⌨️ 快捷键说明

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