<textarea name="code" class="java" cols="50" rows="15">package mapServlet; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import unit.GPolyline2; import unit.KmlParseForCoordinate; /** * KML 标签coordinates解析Servlet * @author libin * */ public class KmlParseForCoordinate_servelt extends HttpServlet { private String filePath = "E://eclipseworkspace//lw_tracing//WebRoot//kml//test.kml"; /** * 缺省串行版本标识 */ private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ArrayList coorArr = new ArrayList(); StringBuffer result = new StringBuffer(); String coorPolyline = ""; String levels = "";//编码级别 response.setContentType("text/xml;charset=UTF-8"); // String coordinates = KmlParseForCoordinate.getCoordinates(filePath);//用于单条线处理 coorArr = KmlParseForCoordinate.getCoordinatesForArr(filePath);//用于多条线路处理 for(int index = 0; index < coorArr.size(); index++){ //得到每一条线路内容 String coordinates = coorArr.get(index).toString(); StringBuffer linePolyStbuf = new StringBuffer(); //解析每一条线路 int coorLength = coordinates.split(",").length; String[] coorArray = coordinates.split(","); for(int i = 0; i <= coorLength-1;i++){ if(i==0){ linePolyStbuf.append(coorArray[i+1]); linePolyStbuf.append(","); } if(i==1){ linePolyStbuf.append(coorArray[i-1]); linePo