floodAnalysis.html
5.76 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
<!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">
<style>
.layui-form-item {
margin-top: 20px;
}
/* 输入框的样式 */
.layui-input {
height: 30px;
}
.layui-input-block {
margin-left: 110px;
margin-right: 20px;
padding-top: 4px;
}
</style>
</head>
<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" label-width="70px" label-position="left">
<div class="filter">
<h1 class="filter-title">参数设置</h1>
<div class="box">
<div class="layui-form-item">
<label class="layui-form-label">水面高度</label>
<div class="layui-input-block">
<input type="text" name="surfaceHeight" id="surfaceHeight" lay-verify="number"
autocomplete="off" value="5.0" class="layui-input" onchange="heightChange()">
</div>
</div>
</div>
<div style="padding:20px;">
<button type="button" class="short-search-btn" onclick="startDrawWater()">绘制水面</button>
<button type="button" class="short-search-btn" onclick="choiceWater()">选择水面</button>
</div>
</div>
</form>
</div>
</body>
<script>
var position = null,
floodObj = null;
function startDrawWater() {
var sgWorld = CreateSGObj();
position = null;
floodObj = null;
sgWorld.AttachEvent("OnLButtonClicked", drawWater);
sgWorld.AttachEvent("OnFrame", drawWaterFrame);
sgWorld.Window.SetInputMode(1, "", true);
}
function drawWater(Flags, X, Y) {
var sgWorld = CreateSGObj();
var wpi = sgWorld.Window.PixelToWorld(X, Y, -1);
if (null == position) {
//将屏幕的像素坐标转化为三位中的世界坐标
if (null == wpi) {
return false;
}
position = wpi.Position.Copy();
floodObj = sgWorld.Creator.CreateCircle(
position,
1,
"0xFF00FF00",
"0xFF646464",
"",
""
);
floodObj.FillStyle.Color.FromHTMLColor("#0000ff"); //设置圆形的颜色为蓝色
floodObj.FillStyle.Color.SetAlpha(0.2); //不透明度为0.2
floodObj.FillStyle.Texture.FileName = "$$WATER$$";
floodObj.Position.ChangeAltitudeType(0); //调整对象的高度类型为相对于地表
var height = parseFloat($("#surfaceHeight").val());
floodObj.Position.Altitude = height;
} else {
var pos = wpi.Position;
var radius = position.DistanceTo(pos);
floodObj.Radius = radius;
position = null;
sgWorld.DetachEvent("OnLButtonClicked", drawWater);
sgWorld.DetachEvent("OnFrame", drawWaterFrame);
sgWorld.Window.SetInputMode(0, "", true);
}
}
function drawWaterFrame() {
var sgWorld = CreateSGObj();
if (null == position) return;
var mi = sgWorld.Window.GetMouseInfo();
var pos = sgWorld.Window.PixelToWorld(mi.X, mi.Y, -1).Position;
var radius = position.DistanceTo(pos);
floodObj.Radius = radius;
}
function heightChange() {
if (null !== floodObj) {
var height = parseFloat($("#surfaceHeight").val());
floodObj.Position.Altitude = height;
}
}
function choiceWater() {
var sgWorld = CreateSGObj();
sgWorld.AttachEvent("OnLButtonClicked", choiceWaterClick);
sgWorld.Window.SetInputMode(1, "", true);
}
function choiceWaterClick(Flag, X, Y) {
var sgWorld = CreateSGObj();
var wpi = sgWorld.Window.PixelToWorld(X, Y, -1);
if (null == wpi) {
return false;
}
var obj = sgWorld.ProjectTree.GetObject(wpi.ObjectID),
objType = obj.ObjectType;
if (CheckType(objType)) {
floodObj = obj;
sgWorld.DetachEvent("OnLButtonClicked", choiceWaterClick);
sgWorld.Window.SetInputMode(0, "", true);
}
}
function CheckType(type) {
switch (type) {
case 2: //POLYGON 多边形
return true;
break;
case 3: //RECTANGLE 矩形
return true;
break;
case 4: //REGULAR_POLYGON 正多边形
return true;
break;
case 5: //CIRCLE 圆形
return true;
break;
case 12: //ELLIPSE 椭圆
return true;
break;
case 14: //ARROW 箭头
return true;
break;
default:
break;
}
return false;
}
</script>
</html>