六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 317|回复: 0

Skyline软件二次开发初级——6如何在WEB页面中的三维地图上进行坐标和方向计算

[复制链接]

升级  57.33%

40

主题

40

主题

40

主题

秀才

Rank: 2

积分
136
 楼主| 发表于 2012-10-25 00:54:18 | 显示全部楼层 |阅读模式
Skyline软件二次开发初级——6如何在WEB页面中的三维地图上进行坐标和方向计算

“1.距离和角度:
<html>
    <head>
        <title>Coordinates 1</title>
        <object id="SGWorld" classid="CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1" style="visibility:hidden;height:0 "></object>
        <script type="text/javascript">
        
        
var popup = null;
        
        
function Init()
        {
            
            
// defining two coordinates
            var coord1 = SGWorld.Creator.CreatePosition(-71.07542, 42.34930, 232.0); // The Hancock building            
            var coord2 = SGWorld.Creator.CreatePosition(-71.05507, 42.35561, 105.0); // Target building
            
            
// Placing some annotation on the terrain
            SGWorld.Creator.CreateTextLabel(coord1, "Hancock Building",SGWorld.Creator.CreateLabelStyle());
            SGWorld.Creator.CreateTextLabel(coord2,
"Building 2",SGWorld.Creator.CreateLabelStyle());
            SGWorld.Creator.CreatePolyline(SGWorld.Creator.GeometryCreator.CreateLineStringGeometry([coord1, coord2]), SGWorld.Creator.CreateColor(
255, 255, 0), 0, 0, "line");

            
// Set a good view point for the scene
            SGWorld.Navigate.SetPosition(SGWorld.Creator.CreatePosition(-71.07802, 42.33974, 550.0,0, 34, -13));           
            
            
// Calculating the distance and angles from the Hancock building to building #2
            var distance = coord1.DistanceTo(coord2);

            
var angles = coord1.AimTo(coord2);
                        
            
// Display a message to the user
            popup = SGWorld.Creator.CreatePopupMessage("Coordinate sample","",0,0,450,120);            
            popup.InnerText
= "The aerial distance between the roofs of the\r\nHancock building and building #2 is " + Math.floor(distance) + " Meters\r\n\r\n" +
                              
"The aiming angles from the Hancock building to building #2 are:\r\nyaw: " + angles.Yaw.toFixed(5) + "  pitch: " + angles.Pitch.toFixed(5);                        
            popup.Align
= "TopLeft";
            SGWorld.Window.ShowPopup(popup);                        
        }
        
        
function Uninit()
        {
            
if(SGWorld.Project.Name == "")
               
return;
            
if(popup)
                SGWorld.Window.RemovePopup(popup);
        }
        
        
</script>
    </head>
    <body onload="Init();" onunload="Uninit()">
    </body>
</html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表