Skyline 留档

留档

涉及内容:

构建轨迹路线,可按照主视角飞行或置物飞行。

采用控件方式加载后,自定义目录树(控件无法加载目录树),并显示分级构建基础功能,控制图层显示和点击图层飞行,其他的后续添加。

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page import="com.thinkgem.jeesite.common.utils.SpringContextHolder"%>
<%@ page import="com.thinkgem.jeesite.common.test.SkylineHttpAcceptTest"%>
<%@ page import="com.thinkgem.jeesite.common.test.HotPoint"%>
<%@ page import="com.thinkgem.jeesite.common.test.JniDllConvert"%>


<%
SkylineHttpAcceptTest skylineHttpAcceptTest = SpringContextHolder.getBean(SkylineHttpAcceptTest.class); 
HotPoint hotPoint = skylineHttpAcceptTest.getData20170401();
JniDllConvert jniDllConvert = SpringContextHolder.getBean(JniDllConvert.class);
%>
<html>

<head>
    <title></title>
	<meta http-equiv="X-UA-Compatible" content="IE=10">
	<script src="${ctxStatic}/jquery/jquery-1.8.3.js" type="text/javascript"></script>
    <script type = "text/javascript" >
		var SGWorld66;
		var projectTreeFlag = true;
		var gPolyObj;
        function init()
        {
			setTimeout(function () {
				//方法1:采用控件方法加载
				SGWorld66 = TerraExplorer.CreateInstance("TerraExplorerX.SGWorld66");
				SGWorld66.Open("http://192.168.1.224:8090/xi.FLY");
		SGWorld66.Navigate.JumpTo(SGWorld66.Creator.CreatePosition(110.98775408994,19.64469583470,0,0,0,-30,0,700));
				
				//var firstItem = SGWorld66.ProjectTree.GetNextItem(SGWorld66.ProjectTree.RootID,18);
				//SGWorld66.Navigate.FlyTo(firstItem);
				
				SGWorld66.ProjectTree.EnableRedraw(0);
				//var itemObject = SGWorld66.ProjectTree.GetObject(item);
				var item = SGWorld66.ProjectTree.GetNextItem(SGWorld66.ProjectTree.RootID,18);
				while(projectTreeFlag){
					//var itemName = SGWorld66.ProjectTree.GetItemName(item);
					//var isLayer = SGWorld66.ProjectTree.IsLayer(item); //判断是否为单个对象
					//var isGroup = SGWorld66.ProjectTree.IsGroup(item);
					//var objModel;
					//if(!isGroup){
						//objModel = SGWorld66.ProjectTree.GetObject(item).ObjectType;
					//}
					//alert(itemName + " /图层:" + isLayer + " /组:" + isGroup + " /类型:" + objModel);
					//alert(SGWorld66.ProjectTree.GetItemName(item) + " 11:" + SGWorld66.ProjectTree.GetItemName(SGWorld66.ProjectTree.GetNextItem(item,11)) + " 13:" + SGWorld66.ProjectTree.GetItemName(SGWorld66.ProjectTree.GetNextItem(item,13)));
					
					if(!SGWorld66.ProjectTree.IsLayer(item)){
						var rootName = SGWorld66.ProjectTree.GetItemName(item);
						
						var checkBox=document.createElement("input");
						checkBox.setAttribute("type","checkbox");
						checkBox.setAttribute("checked",true);
						
						//input
						var input = document.createElement("input");
						input.setAttribute("type", "text");
						input.setAttribute("id", "");
						input.setAttribute("value", rootName);
						input.setAttribute("style", "border-style:none;color:red;");
						
						try{
							var Object = SGWorld66.Creator.GetObject(item);
							if(Object != null){
								checkBox.setAttribute("id",Object.ID);
								checkBox.setAttribute("value",Object.ID);
								input.setAttribute("name", Object.ID);
							}
						} catch(e){}
						
		        		//append
		        		$("#tree").append(checkBox);
		        		$("#tree").append(input);
		        		$("#tree").append("<br/>");
					}
					diguiData2(item,1);
					item = SGWorld66.ProjectTree.GetNextItem(item,13);
					if(null == item || "" == item){
						projectTreeFlag = false;
					}
				}
				SGWorld66.ProjectTree.EnableRedraw(1);
				//SGWorld66.Navigate.FlyTo(item);
				//var itemName = SGWorld66.ProjectTree.GetItemName(item);
				//var itemObject = SGWorld66.ProjectTree.GetObject(item);
				//alert(itemName + " " + itemObject.ID);
				//diguiData(item);
				
				
				
				//event-change
        		$('input:checkbox').change(function() {
        			var obj;
        			try{
        				obj = SGWorld66.ProjectTree.GetObject($(this).val());
						if ($(this).eq(0).attr('checked') == undefined) { 
	            			SGWorld66.ProjectTree.SetVisibility(obj.ID,false);
	        			} else {
	        				SGWorld66.ProjectTree.SetVisibility(obj.ID,true);
	        			}
					} catch(e){}
        			//alert($(this).val());
       				//alert($(this).eq(0).attr('checked'));
        			
        		});
				
        		//event-click
        		$('input:text').click(function() {
        			try{
        				var obj = SGWorld66.ProjectTree.GetObject($(this).attr('name'));
           				SGWorld66.Navigate.FlyTo(obj);
					} catch(e){}
        		});
				
				//var secondeItem = SGWorld66.ProjectTree.GetNextItem(firstItem,13);
				//SGWorld66.Navigate.FlyTo(secondeItem);
				
				//var rootItemsName = SGWorld66.ProjectTree.GetItemName(firstItem); // 获取图层名称
				//SGWorld66.ProjectTree.EditItem(firstItem); // 编辑图层
				
				//方法2:直接加载
				//var flyPath = "http://192.168.1.224:8090/xierdun.FLY";
				//SGWorld.Project.Open(flyPath);
				//SGWorld.Navigate.FlyTo(firstItem);
				
				//SGWorld66.Command.Execute(1058,0);
				//TerraExplorerNavigationMap.OnCommand();
				//TerraExplorerNavigationMap.LoadXML("");
				
		        //var geometry = SGWorld66.Creator.GeometryCreator.CreateLineStringGeometry("LineString(110.9898247 19.64392506 30,110.9896247 19.64653288 30,110.9876747 19.64603288 30)");
				//创建颜色
		        //var color = SGWorld66.Creator.CreateColor(255,0,0,0.7);
				//创建折线
				//var line = SGWorld66.Creator.CreatePolyline(geometry,color,0,"","几何折线");
				//第一种数据加载方式
				//var RouteWaypoint = [];
				//for (var i = 0; i < line.Geometry.Points.count; i++) {
					//RouteWaypoint.push(SGWorld66.Creator.CreateRouteWaypoint(line.Geometry.Points.Item(i).X, line.Geometry.Points.Item(i).Y,line.Geometry.Points.Item(i).Z,800,0,0,0,0,0,-1));
				//}
				//var gPolyObj = SGWorld66.Creator.CreateDynamicObject(RouteWaypoint, 1, 1, "010", 100, 0, "", "010");
				//gPolyObj = SGWorld66.Creator.CreateDynamicObject(RouteWaypoint,1,2,"轨迹线路");
				//gPolyObj.TurnSpeed = 1000;
				//gPolyObj.FileName= "http://192.168.1.222:9090/skyline/test/tv.png";
				//gPolyObj.CircularRoute = false;
				//gPolyObj.Pause = true;
				
				//第二种数据加载方式
				//var gPolyObj = SGWorld66.Creator.CreateDynamicObject(0, 1, 1, "010", 100, 0, "", "010");
				//for (var i = 0; i < line.Geometry.Points.count; i++) {
					//var RouteWaypoint = SGWorld66.Creator.CreateRouteWaypoint(line.Geometry.Points.Item(i).X, line.Geometry.Points.Item(i).Y,line.Geometry.Points.Item(i).Z,800,0,0,0,0,0,-1);
					//gPolyObj.Waypoints.AddWaypoint(RouteWaypoint);
				//}
				//SGWorld66.Navigate.FlyTo(gPolyObj,11); //飞行主视角
			
            }, 500);
        }
        
        function doPlay() {
        	gPolyObj.RestartRoute(0);
			gPolyObj.Pause = false;
		}
        
        function a(a,b,c){
        	//alert(a + " " + b + " " +c);
        }
        
      //searchGeometries
        function searchGeometries2(parentNode, callbackFunc) {
            SGWorld66.ProjectTree.EnableRedraw(0);
            searchGeometriesLeaf2(parentNode, callbackFunc);
            SGWorld66.ProjectTree.EnableRedraw(1);
        }
        //-------------------
        // searchGeometries
        function searchGeometriesLeaf2(parentNode, callbackFunc) {
        	var itemsName = SGWorld66.ProjectTree.GetItemName(parentNode);
			alert(itemsName);
            if (SGWorld66.ProjectTree.IsLayer(parentNode))  // Layer
            {
                var layer = SGWorld66.ProjectTree.GetLayer(parentNode);
                var featureGroups = layer.FeatureGroups;
                for (var i = 0; i < featureGroups.Count; i++) // Traverse all sub-layers
                {
                    var featureGroup = featureGroups.Item(i);
                    var altitudeType = AltitudeMethodToAltitudeType(featureGroup.GetProperty("Altitude Method"));
                    var features = featureGroup.Features;
                    for (var j = 0; j < features.Count; j++) {
                        var ret;
                        if (featureGroup.GeometryType != 0){
                            ret = callbackFunc(features.Item(j).Geometry, featureGroup.GeometryType, altitudeType);
                        	alert(features.Item(j).Geometry + " " + featureGroup.GeometryType + " " + altitudeType);
                        }
                        else {
                            if (features.Item(j).Geometry.GeometryType == 0) // Point
                            {
                                var position = SGWorld66.Creator.CreatePosition(features.Item(j).Geometry.X, features.Item(j).Geometry.Y, features.Item(j).Geometry.Z);
                                ret = callbackFunc(position, featureGroup.GeometryType, altitudeType);
                                alert(position + " " + featureGroup.GeometryType + " " + altitudeType);
                            }
                        }
                        if (!ret)
                            return;
                    }
                }
            }
            else {
                var node = SGWorld66.ProjectTree.GetNextItem(parentNode, 11);
                while (node != "") {
                    if (SGWorld66.ProjectTree.IsGroup(node) || SGWorld66.ProjectTree.IsLayer(node))
                        searchGeometriesLeaf2(node, callbackFunc);
                    else {
                        var Object = SGWorld66.Creator.GetObject(node);
                        if (Object != null) {
                            var altitudeType = Object.Position.AltitudeType;
                            var ret;
                            if (Object.ObjectType == 1 || Object.ObjectType == 2){
                               ret = callbackFunc(Object.Geometry, Object.ObjectType, altitudeType);
                               alert(Object.Geometry + " " + Object.ObjectType + " " + altitudeType);
                            }
                            else{
                                ret = callbackFunc(Object.Position, Object.ObjectType, altitudeType);
                                alert(Object.Position + " " + Object.ObjectType + " " + altitudeType);
                            }
                            if (!ret)
                                return;
                        }
                    }

                    node = SGWorld66.ProjectTree.GetNextItem(node, 13);
                }
            }
        }
        
        function diguiData2(parentNode,num){
        	//var itemName0 = SGWorld66.ProjectTree.GetItemName(parentNode);
			//var isLayer0 = SGWorld66.ProjectTree.IsLayer(parentNode); //判断是否为单个对象
			//var isGroup0 = SGWorld66.ProjectTree.IsGroup(parentNode);
        	//alert("当前:" + itemName0 + " /图层:" + isLayer0 + " /组:" + isGroup0);
        	
			if (SGWorld66.ProjectTree.IsLayer(parentNode)){ //Layer 单个对象
				//var itemName0 = SGWorld66.ProjectTree.GetItemName(parentNode);
			
				var rootName = SGWorld66.ProjectTree.GetItemName(parentNode);
				
				var checkBox=document.createElement("input");
				checkBox.setAttribute("type","checkbox");
				checkBox.setAttribute("checked",true);
				
				//input
				var input = document.createElement("input");
				input.setAttribute("type", "text");
				input.setAttribute("id", "");
				input.setAttribute("value", rootName);
				input.setAttribute("style", "border-style:none;color:green;");
				
        		//append
        		$("#tree").append(checkBox);
        		$("#tree").append(input);
        		$("#tree").append("<br/>");
				//alert(itemName0 + " layer:yes");
            } else {
            	var node = SGWorld66.ProjectTree.GetNextItem(parentNode, 11); //查询下级对象Child
            	//var itemName = SGWorld66.ProjectTree.GetItemName(node);
				//var isLayer = SGWorld66.ProjectTree.IsLayer(node); //判断是否为单个对象
				//var isGroup = SGWorld66.ProjectTree.IsGroup(node);
				//alert("子项" + itemName + " /图层:" + isLayer + " /组:" + isGroup);
				while(node != ""){
					if (SGWorld66.ProjectTree.IsGroup(node) || SGWorld66.ProjectTree.IsLayer(node)){
						//alert(SGWorld66.ProjectTree.GetItemName(node));
						var rootName = SGWorld66.ProjectTree.GetItemName(node);
						
						var checkBox=document.createElement("input");
						checkBox.setAttribute("type","checkbox");
						checkBox.setAttribute("checked",true);
						
						//input
						var input = document.createElement("input");
						input.setAttribute("type", "text");
						input.setAttribute("id", "");
						input.setAttribute("value", rootName);
						input.setAttribute("style", "border-style:none;color:blue;");
							
						try{
							var Object = SGWorld66.Creator.GetObject(node);
							if(Object != null){
								checkBox.setAttribute("id",Object.ID);
								checkBox.setAttribute("value",Object.ID);
								input.setAttribute("name", Object.ID);
								if(Object.ObjectType != 38){
									input.setAttribute("style", "border-style:none;color:black;");
								}
							}
						} catch(e){}
						
		        		//append
		        		$("#tree").append(checkBox);
		        		$("#tree").append(input);
		        		$("#tree").append("<br/>");
		        		
						diguiData2(node,num);
					}
					else {
						var Object = SGWorld66.Creator.GetObject(node);
						if (Object != null) {
							//alert(SGWorld66.ProjectTree.GetItemName(Object.ID));
							var rootName = SGWorld66.ProjectTree.GetItemName(Object.ID);
							
							var checkBox=document.createElement("input");
							checkBox.setAttribute("type","checkbox");
							checkBox.setAttribute("checked",true);
							checkBox.setAttribute("id",Object.ID);
							checkBox.setAttribute("value",Object.ID);
							
							//input
							var input = document.createElement("input");
							input.setAttribute("type", "text");
							input.setAttribute("id", "");
							input.setAttribute("value", rootName);
							input.setAttribute("style", "border-style:none;color:black;");
							input.setAttribute("name", Object.ID);
							
			        		//append
			        		$("#tree").append(checkBox);
			        		$("#tree").append(input);
			        		$("#tree").append("<br/>");
						}
					}
					node = SGWorld66.ProjectTree.GetNextItem(node, 13);
				}
            }
        }
        
        function diguiData(item){
        	var itemName = SGWorld66.ProjectTree.GetItemName(item);
        	alert(itemName);
        	var b = false;
        	while(!b){
        		var itemObject = SGWorld66.ProjectTree.GetObject(itemId);
	       		var itemName = SGWorld66.ProjectTree.GetItemName(itemId);
	       		var item = SGWorld66.ProjectTree.GetNextItem(itemObject.ID,10);
	       		//alert(itemName + " " + itemObject.ID);
	       		alert(itemObject.ObjectType);
				
	        	if(SGWorld66.ProjectTree.IsGroup(item) && itemObject.ObjectType != 39){//判断当前是否为组
					//alert(1);
					var checkBox=document.createElement("input");
					checkBox.setAttribute("type","checkbox");
					checkBox.setAttribute("checked",true);
					
					//input
					var input = document.createElement("input");
					input.setAttribute("type", "text");
					input.setAttribute("id", "");
					input.setAttribute("value", itemName);
					input.setAttribute("style", "border-style:none");
					
	        		//append
	        		$("#tree").append(checkBox);
	        		$("#tree").append(input);
	        		$("#tree").append("<br/>");
	        		
	        		// 判断为组后再次循环
	        		//alert("11---" + SGWorld66.ProjectTree.GetNextItem(itemId,11));
        			itemId = SGWorld66.ProjectTree.GetObject(SGWorld66.ProjectTree.GetNextItem(itemId,11)).ID;
        			diguiData(itemId);
	        	} else {
	        		//alert(2);
					//checkbox
					var checkBox=document.createElement("input");
					checkBox.setAttribute("type","checkbox");
					//checkBox.setAttribute("id",itemObject.ID);
					checkBox.setAttribute("checked",true);
					//checkBox.setAttribute("name",itemObject.ID);
					//checkBox.setAttribute("value",itemObject.ID);
					
					//input
					var input = document.createElement("input");
					input.setAttribute("type", "text");
					input.setAttribute("id", "");
					//input.setAttribute("name", itemObject.ID);
					input.setAttribute("value", itemName);
					input.setAttribute("style", "border-style:none");
					
	        		//append
	        		$("#tree").append(checkBox);
	        		$("#tree").append(input);
	        		$("#tree").append("<br/>");
	        		
	        		var c = SGWorld66.ProjectTree.GetNextItem(itemId,13);
	        		if(null == c || "" == c){
	        			b = true;
	        		} else {
	        			itemId = c;
	        		}
	        	}
        	}
        }
        
        function getData(){
        	$.ajax({
				type : "get",//使用get方法访问后台
				dataType : "text",//返回json格式的数据
				async: false,
				url : "http://192.168.1.222:9090/skyline/f/test",//要访问的后台地址
				complete : function() {
				},//AJAX请求完成时隐藏loading提示
				success : function(data) {//msg为返回的数据,在这里做数据绑定
					//alert(data);
					var labelStyle = createLabelStyle(0xFF0000,0,"微软雅黑",20,200,true);
					var str = data.substring(1,data.length-1).split(",");
					for(var i=0;i<str.length;i++){
						var zbxy = str[i].split(":");
						//alert(zbxy[0].substring(1,zbxy[0].length-1) + " " + zbxy[1].substring(1,zbxy[1].length-1));
						var p = SGWorld66.Creator.CreatePosition(zbxy[0].substring(1,zbxy[0].length-1),zbxy[1].substring(1,zbxy[1].length-1),50,0,0,0,0,700);
						SGWorld66.Creator.CreateLabel(p, "","http://192.168.1.222:9090/skyline/test/tv.png", labelStyle, "", "点位标签1-文字");
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					alert("发生异常,请联系管理员");
				}
			});
        }
        
    	/**
    	 *添加点位标签
    	 */
    	function createLabelEvent(){
    			var labelStyle = createLabelStyle(0xFF0000,0,"微软雅黑",20,200,true);
    			var p1 = SGWorld66.Creator.CreatePosition(110.98775408994,19.64469583470,50,0,0,0,0,700);
    			var p2 = SGWorld66.Creator.CreatePosition(110.9898247,19.64392506,50,0,0,0,0,700);
    			var cl1 = SGWorld66.Creator.CreateLabel(p1, "点位标签1","", labelStyle, "", "点位标签1-文字");
    			SGWorld66.Creator.CreateLabel(p2, "","http://192.168.1.222:9090/skyline/test/tv.png", labelStyle, "", "点位标签2-图标");
    			cl1.Message.MessageID = SGWorld66.Creator.CreateMessage(5,"模拟数据",0).ID;
    	}
    	
    	/**
    	 *设置文本标注样式
    	 */
    	function createLabelStyle(nBGRValue,dAlpha,FontName,FontSize,Scale,Bold){
    		// C1. Create label syle
    		var cLabelStyle = SGWorld66.Creator.CreateLabelStyle();
    		// C2. Change label style settings
    		var nBGRValue = nBGRValue;  // Blue
    		var dAlpha = dAlpha;        // 50% opacity
    		var cBackgroundColor = cLabelStyle.BackgroundColor;     // Get label style background color
    		cBackgroundColor.FromBGRColor(nBGRValue);               // Set background to blue
    		cBackgroundColor.SetAlpha(dAlpha);                      // Set transparency to 50%
    		cLabelStyle.BackgroundColor = cBackgroundColor;         // Set label style background color
    		cLabelStyle.FontName = FontName;                      // Set font name
    		cLabelStyle.FontSize = FontSize;                              // Set font size
    		cLabelStyle.Italic = false;                             // Set label style font to italic
    		cLabelStyle.Scale = Scale;                                 // Set label style scale 
    		cLabelStyle.Bold = Bold; 
    		//cLabelStyle.MaxViewingHeight = MaxViewingHeight;
    		cLabelStyle.LimitScreenSize = true;
    		cLabelStyle.LineToGround = true;
    		//cLabelStyle.MinViewingHeight = MinViewingHeight; 
    		return cLabelStyle;
    	}
    	
    	/**
    	 *创建标签
    	 */
    	function createPointList(Pos){
    		var current = SGWorld66.ProjectTree.FindItem("");
    		var labelStyle = createLabelStyle(0xFF0000,0,"微软雅黑",20,200,true);
    		var textLabelObj = SGWorld66.Creator.CreateImageLabel(Pos,"http://192.168.1.222:9090/skyline/test/tv.png", labelStyle, current, "");
    		return textLabelObj;
    	}
    	
    </script>
</head>
<body onload="init()">
	<!--定义插件对象-->
	<object id="TerraExplorer" classid="CLSID:3a4f9196-65a8-11d5-85c1-0001023952c1" width="80%" height="1000px" style="float: left;"></object>
	<!--定义导航对象TerraExplorerNavigationMap-->
	<OBJECT ID="TerraExplorerNavigationMap" CLASSID="CLSID:3a4f9194-65a8-11d5-85c1-0001023952c1" style="width: 19%;height: 20%;margin-top: 15px;"></OBJECT>
	<div id="tree">
		<!-- 
		<p><input value="获取数据" onclick="getData()" type="button" class="btn"/></p>
		<p><input value="轨迹数据" onclick="doPlay()" type="button" class="btn"/></p> -->
		<p>自定义目录树</p>
		
	</div>
	
	<!--定义3D窗口对象
	<object id="TE" classid="clsid:3a4f9192-65a8-11d5-85c1-0001023952c1" style="width: 19%;height: 10%;" ></object>-->
    <!--定义TerraExplorer对象SGWorld
    <object id="SGWorld" classid="CLSID:3A4F9199-65A8-11D5-85C1-0001023952C1" style="visibility:hidden;height:0 "></object>-->
</body>
</html>

 

爱编程-编程爱好者经验分享平台

文章评论

  

版权所有 爱编程 © Copyright 2012. w2bc.com. All Rights Reserved.
闽ICP备12017094号-3