6.5 ITerrain5
主要用来获取三维场景中基础信息,包括MPT的投影信息、坐标信息、地形高度和地表透明度等;
MPTName | 返回当前使用的MPT文件名,如果当前未装载MPT文件,则返回“NO_MPT”; |
GroupKey | 定义工程的组键值; |
SystemKey | 定义工程的坐标系统键值; |
DatumKey | 定义工程的数据键值; |
UnitKey | 定义测量单位; |
EPSG | 定义工程的EPSG代码; |
Description | 用户定义描述(TerraExplorer Pro中Project中的Description设置); |
Opacity | 地表透明度(0.1-1); |
GetGroundHeight | 用此方法获取当前坐标距离地面的距离高度; |
GetGroundHeightEx | 用此方法获取当前坐标距离地面的距离高度,同时如果该坐标点上存有对象,可以获得该对象的ObjectID; |
GetExtent | 返回当前所使用的地形数据的范围; |
代码示例:
【C#】
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TerraExplorerX;
namespace ExCodeITerrain
{
public partial class Form1 : Form
{
private TerraExplorer TE;
private ITerraExplorer51 TE51;
private ITerrain5 ITerrain;
public Form1()
{
InitializeComponent();
this.TE = new TerraExplorerClass();
this.TE51 = (ITerraExplorer51)TE;
ITerrain = (ITerrain5)TE;
TE51.Load(Application.StartupPath + "\\Default.fly");
}
private void btnStart_Click(object sender, EventArgs e)
{
MessageBox.Show("$MPTName:"+ITerrain.MPTName+"\r\n"+
"$GroupKey:" + ITerrain.GroupKey + "\r\n" +
"$SystemKey:" + ITerrain.SystemKey + "\r\n" +
"$DatumKey:" + ITerrain.DatumKey + "\r\n" +
"$UnitKey:" + ITerrain.UnitKey + "\r\n" +
"$EPSG:" + ITerrain.EPSG.ToString() + "\r\n" +
"$Description:" + ITerrain.Description + "\r\n" +
"$Opacity:"+ITerrain.Opacity.ToString());
}
}
}
【javascript】
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ITerrain5.aspx.cs" Inherits="ExCode_ITerrain5" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Skyline二次开发教程【配套示例】</title>
<script type ="text/javascript">
function Init() {
var TE = _$SGCreateTEObj();
var ITerraExplorer = TE.interface("ITerraExplorer51");
ITerraExplorer.Load("D:\\2010售前演示系统\\WPFA-DEMO\\WPFA-DEMO\\bin\\Debug\\FLY\\Default.fly");
}
function Test() {
var ITerrain = TE.interface("ITerrain5");
alert("$MPTName:" + ITerrain.MPTName + "\r\n" +
"$GroupKey:" + ITerrain.GroupKey + "\r\n" +
"$SystemKey:" + ITerrain.SystemKey + "\r\n" +
"$DatumKey:" + ITerrain.DatumKey + "\r\n" +
"$UnitKey:" + ITerrain.UnitKey + "\r\n" +
"$EPSG:" + ITerrain.EPSG + "\r\n" +
"$Description:" + ITerrain.Description + "\r\n" +
"$Opacity:" + ITerrain.Opacity);
}
//------------------------------------------------------------
// 创ä建三维对象 赵贺 2009.01.25.
//------------------------------------------------------------
function _$SGCreateTEObj() {
var obj = window.document.getElementById("TE");
if (obj == null) {
obj = document.createElement('object');
document.body.appendChild(obj);
obj.name = "TE";
obj.id = "TE";
obj.classid = "CLSID:3a4f9191-65a8-11d5-85c1-0001023952c1";
}
return obj;
}
</script>
</head>
<body onload = "Init()">
<form id="form1" runat="server">
<div id = "Title">
<input id="Button1" type="button" value="测试" onclick = "Test()" />
</div>
<div id="Main">
<object id="TerraExplorer3DWindow" classid="CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1"
width="521" height="521">
</object>
</div>
</form>
</body>
</html>