search.js
2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* 获取传入的对象的自身的属性值
* @param {*} teobj 选中的要素对象
*/
function getObjectAttributes(teobj) {
var msgObj = {};
if (teobj.ObjectType === 33) //OT_FEATURE = 33
{
for (var j = 0; j < teobj.FeatureAttributes.Count; j++) {
var pIFeatureAttribute = teobj.FeatureAttributes.Item(j);
msgObj[pIFeatureAttribute.Name] = pIFeatureAttribute.Value;
}
return msgObj;
} else {
msgObj.error = true;
}
}
var layersList = [];
//遍历工程树,将所有的MeshLayer和FeatureLayer存入layerList
function ScanTree() {
try {
layersList = [];
var sgworld = new CreateSGObj();
// root is the first visible item in tree.
//获取根节点ID
var root = sgworld.ProjectTree.GetNextItem("", 18 /* ItemCode.ROOT*/);
//如果获取的根节点和隐藏组的节点相同,那么获取下一个对象
if (sgworld.ProjectTree.GetItemName(root) == sgworld.ProjectTree.HiddenGroupName)
root = sgworld.ProjectTree.GetNextItem(root, 13 /* ItemCode.NEXT*/);
BuildTreeRecursive(root);//根据根节点来遍历目录树
}
catch (ex) {
alert("Unexpected error: " + ex.description);
}
}
function BuildTreeRecursive(current) {
var sgworld = new CreateSGObj();
//如果提供的节点ID存在
while (current) {
// 获取节点名称
var currentName = sgworld.ProjectTree.GetItemName(current);
// 如果当前节点是一个组, 获取该节点的第一个子节点;
if (sgworld.ProjectTree.IsGroup(current)) {
//child 是第一个子节点
var child = sgworld.ProjectTree.GetNextItem(current, 11 /* ItemCode.CHILD */);
BuildTreeRecursive(child);//进行递归
}
//如果类型是IFeatureLayer或者IMeshLayer,将ID存入到layersList中
if (sgworld.ProjectTree.GetObject(current).ObjectType == 36 || sgworld.ProjectTree.GetObject(current).ObjectType == 38) {
layersList.push({ id: current, name: currentName });
}
// 获取当前节点的下一个兄弟节点
current = sgworld.ProjectTree.GetNextItem(current, 13 /* ItemCode.NEXT*/);
}
//return result;
}