tubeAnalysis.html
8.7 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>淹没分析</title>
<script src="/static/js/jquery-3.4.1.min.js"></script>
<script src="/static/js/JavaScript.js"></script>
<script src="/static/js/popupJS.js"></script>
<script src="/static/js/layui/layui.js"></script>
<link rel="stylesheet" href="/static/js/layui/css/layui.css">
<link rel="stylesheet" href="/static/css/analysis.css">
</head>
<style>
.tiaojian .short-search-btn {
width: 100%;
}
</style>
<body marginwidth="0" marginheight="0">
<div id="mainDiv" class="dialog tiaojian">
<h1 class="title" onmousedown="MouseDown(event)" onmouseup="MouseUp(event)" onmouseout="MouseUp(event)">
爆管分析<i class="guanbibtn" onclick="Close()">X</i>
</h1>
<form class="main">
<div class="filter">
<div style="padding:20px;">
<button type="button" class="short-search-btn" onclick="selectTube()">选择管线</button>
</div>
</div>
</form>
</div>
</body>
<script language="JavaScript">
let pointLayerName = "dx_point";//管点图层的名称(在TE Pro显示的名称)
let pipeLayerKey = "pipe";//管线图层的名称的关键字
let startField = "起点点号";//管线图层中一条管线中标志着起点点号的字段
let endField = "连接方向";//管线图层中一条管线中标志着终点点号的字段
let pointLayerDot = "图上点号";//管点图层中用于标志点号的字段
let pointLayerDotType = "特征";//管点图层中用于标志是否是指定类型的字段
let pointLayerSelect = "阀门";//管点图层中所想要的指定类型名称
function selectTube() {
let sgworld = new CreateSGObj();
sgworld.Window.HideMessageBarText();//隐藏下面的信息栏
//鼠标左键单击管线,选中管线(如何限定点击的对象时想要查询的对象类型,比如如何确定鼠标点击的是管线而不是设备)
sgworld.AttachEvent("OnLButtonClicked", SelectPipeLButtonEvent);
//sgworld.AttachEvent("OnLButtonDown", SelectPipeLButtonEvent);
sgworld.Window.SetInputMode(1, "", true);
}
/**
* 绑定鼠标左键单击事件的监听函数
* @param Flag
* @param X
* @param Y
*/
function SelectPipeLButtonEvent(Flag, X, Y) {
var SGWorld = new CreateSGObj();
//将屏幕的像素坐标转化为三位中的世界坐标
var wpi = SGWorld.Window.PixelToWorld(X, Y, -1);//最后一个可以设置点击的对象是什么类型的 -1为默认值
if (null == wpi) {
return false;
}
alert("点击选中的对象ID为:" + wpi.ObjectID + "\n 对象的类型是:" + wpi.Type);
let feature = SGWorld.ProjectTree.GetObject(wpi.ObjectID);//获取点击的对象
//这里需要判断选中的是不是管线
if (feature.ObjectType === 33)//OT_FEATURE = 33
{
//获取父图层判断是否是管线图层
//如果是管线图层的话,获取该管线的起点点号和终点点号
let layerName = SGWorld.ProjectTree.GetItemName(feature.LayerID);
if (layerName.indexOf(pipeLayerKey) >= 0) {
let startP = feature.FeatureAttributes.GetFeatureAttribute(startField).Value;
let endP = feature.FeatureAttributes.GetFeatureAttribute(endField).Value;
//获取所有的上游的阀门点号
alert("startP:" + startP + ",endP:" + endP);
//判断上游点号是否是阀门,如果是阀门,则直接将该阀门标记,否则遍历查询
if (judgePointIsValve(startP)) {
alert("上游的阀门点号为ddd" + startP);
} else {
let AA = getUpOrDownStreamValve(startP, feature.LayerID, endField, startField);
for (var i = 0; i < AA.length; i++) {
alert("上游的阀门点号为" + AA[i]);
}
}
//判断下游点号是否是阀门,如果是阀门,则直接将该阀门标记,否则遍历查询
if (judgePointIsValve(endP)) {
alert("下游的阀门点号为ddd" + endP);
} else {
let BB = getUpOrDownStreamValve(endP, feature.LayerID, startField, endField);
for (var i = 0; i < BB.length; i++) {
alert("下游的阀门点号为" + BB[i]);
}
if (BB.length === 0) {
alert("下游无阀门!");
}
}
}
}
}
/**
* 根据传入的信息获取管线上游或下游的阀门
* @param point 已知的管线管点
* @param layerID 管线图层的ID
* @param knownName 已知管点在被选中的管线上是作为起点还是终点
* @param unknownName 想要获取的管线管点的类型(起点或终点)
*/
function getUpOrDownStreamValve(point, layerID, knownName, unknownName) {
//alert("运行函数getUpOrDownStreamValve");
let pointArr = [];
let arr = getUpOrDownStreamByPoint(point, layerID, knownName, unknownName);
if (arr.length > 0) {
//遍历点号,判断是否是阀门,如果不是阀门,则继续向上遍历查找上有点号,如果是,则传入数组中
for (var i = 0; i < arr.length; i++) {
if (judgePointIsValve(arr[i])) {
pointArr.push(arr[i]);
} else {
pointArr.push.apply(pointArr, getUpOrDownStreamValve(arr[i], layerID, knownName, unknownName));
}
}
} else {
//alert("Error:" + point + "上游的点位的数量为" + arr.length);
}
return pointArr;
}
/**
* 根据点号获取上游或下游点号数组(即根据提供的点号遍历图层获取连接方向是该点号的要素)
* aq----A----az(bq)----B-----bz 若A,B代表两根管线,aq和bq分别为AB的起始端点,az和bz分别为AB的终结端点
* 求上游的阀门,那么knownName就是选中管线B的起始端点bq,上游管线A的终结端点,unknownName是上游管线A的起始端点aq
* 求下游的阀门,那么knownName就是选中管线A的终结端点az,下游管线B的起始端点,unknownName是下游管线B的终结端点bz
* @param point 已知的点号
* @param layerID 管线数据存在的图层ID
* @param knownName 已知的端点
* @param unknownName 未知的端点
*/
function getUpOrDownStreamByPoint(point, layerID, knownName, unknownName) {
let sgworld = new CreateSGObj();
let pointArray = [];
let layer = sgworld.ProjectTree.GetObject(layerID);
layer.Filter = "'" + knownName + "'='" + point + "'";
layer.Streaming = 0;
layer.Refresh();
let features = layer.FeatureGroups(0).GetCurrentFeatures();
for (var i = 0; i < features.Count; i++) {
let feature = features.Item(i);
pointArray.push(feature.FeatureAttributes.GetFeatureAttribute(unknownName).Value);
//alert(point + "的查询点号为" + feature.FeatureAttributes.GetFeatureAttribute(unknownName).Value);
}
layer.Filter = "";
layer.Refresh();
return pointArray;
}
/**
* judgePointIsValve() 判断传入的point点是否是管点图层中的阀门
* @param point 需要传入的待验证的点号
*/
function judgePointIsValve(point) {
//alert(point);
let sgworld = new CreateSGObj();
let pointLayerID = sgworld.ProjectTree.FindItem(pointLayerName);
let pointLayer = sgworld.ProjectTree.GetObject(pointLayerID);
pointLayer.Filter = "'" + pointLayerDot + "'='" + point + "'";
pointLayer.Streaming = 0;
pointLayer.Refresh();
let features = pointLayer.FeatureGroups(0).GetCurrentFeatures();
for (var i = 0; i < features.Count; i++) {
let feature = features.Item(i);
if (feature.FeatureAttributes.GetFeatureAttribute(pointLayerDotType).Value === pointLayerSelect) {
//return feature.ID;//返回要素的ID
pointLayer.Filter = "";
pointLayer.Refresh();
return true;
}
}
//return null;//若没有
pointLayer.Filter = "";
pointLayer.Refresh();
return false;
}
</script>
</html>