<!DOCTYPE html>
|
<html lang="en">
|
|
<head>
|
<meta charset="UTF-8">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<title>Document</title>
|
<!-- <script src="./../iS/iquery-1.8.2.min.is"></script> -->
|
<script src="../JS/jquery-1.10.2.min.js"></script>
|
<script src="../JS/VariableChange.js"></script>
|
<script src="../JS/turf.min.js"></script>
|
<script src="../JS/volumeCal.js"></script>
|
<style>
|
html,
|
body {
|
height: 100%;
|
width: 100%;
|
margin: 0;
|
overflow: hidden;
|
padding: 0;
|
background: rgba(0, 0, 0, 1);
|
}
|
|
#rightMenu {
|
height: 100%;
|
width: 100%;
|
}
|
|
.image {
|
height: 44px;
|
width: 44px;
|
}
|
|
.right_div {
|
padding-left: 21px;
|
padding-top: 13px;
|
padding-bottom: 13px;
|
padding-right: 21px;
|
width: 98px;
|
text-align: center;
|
font-weight: bolder;
|
color: white;
|
}
|
|
.right_div:hover {
|
background-color: rgba(255, 255, 255, 0.2);
|
}
|
</style>
|
</head>
|
|
<body>
|
<div id="rightMenu">
|
<div class="right_div" onclick="showrightmenu(1)">
|
<img src="./../Image/right/测量 (1).png" class="image" alt=""><br>
|
<span>测量工具</span>
|
</div>
|
<div class="right_div" onclick="HierarchicalDiscrete()">
|
<img src="./../Image/right/圆角矩形 6 拷贝 4.png" class="image" alt=""><br>
|
<span>分层离散</span>
|
</div>
|
<div class="right_div" onclick="showrightmenu(3)">
|
<img src="./../Image/right/矩形 16 拷贝 9.png" class="image" alt=""><br>
|
<span>剖切分析</span>
|
</div>
|
<div class="right_div" onclick="showrightpolygonmenu()">
|
<img src="./../Image/right/图层 13.png" class="image" alt=""><br>
|
<span>储量计算</span>
|
</div>
|
<div class="right_div" onclick="showrightmenu(5)">
|
<img src="./../Image/right/矿体.png" class="image" alt=""><br>
|
<span>数据导入</span>
|
</div>
|
<div class="right_div" onclick="showrightmenu(6)">
|
<img src="./../Image/right/zuankongchaxun.png" class="image" alt=""><br>
|
<span>钻孔查询</span>
|
</div>
|
</div>
|
|
<script>
|
var sgworld = window.external.createSgworld();
|
var RS6 = 0;
|
var RS1 = 0;
|
var elevation = null; //高程数据
|
var elGroup = null;
|
var volume_val_std = [];
|
var obvar = null;
|
var pPolygon = null; //多边形对象
|
var tPolyLine = null;
|
var bluk = 0;
|
var el_group = [];
|
var Geo_Polygon = null;
|
var lonlat_heighter = 0;
|
var poly_bulk = 0;
|
// 总体积计算
|
|
//储量计算
|
var volume =[];
|
|
function showrightpolygonmenu () {
|
// if (bluk == 0) {
|
// showBluck();
|
// }
|
var gid = sgworld.ProjectTree.FindItem("图形绘制");
|
if (gid != null) {
|
var gid = sgworld.ProjectTree.DeleteItem(gid);
|
}
|
|
|
var polygon_Geometry = DrawPolygon.start(sgworld, function (polygon) {
|
|
if (polygon) {
|
var heighter = prompt("请输入标高", ""); //第二个
|
|
var ring = polygon.Geometry.ExteriorRing.Wks.ExportToWKT()
|
|
|
var gid = sgworld.ProjectTree.FindItem("图形绘制");
|
if (!gid) {
|
gid = sgworld.ProjectTree.CreateLockedGroup("图形绘制", SG.ProjectTree.RootID);
|
}
|
|
lonlat_heighter = parseFloat(heighter)
|
$.ajax({
|
type: "GET",
|
url:"http://localhost:8066/Calc/GetPoints?type=02&wkt="+ring,
|
dataType: "json",
|
success: function (res) {
|
showMineLayer(res);
|
}
|
});
|
function showMineLayer(result){
|
getMineLayers(result)
|
}
|
|
// // var geo = polygon.Geometry.ExteriorRing.Clone();
|
// //var fillColor = sgworld.Creator.CreateColor(0, 0, 255, 51);
|
// // Geo_Polygon = sgworld.Creator.Create3DPolygon(polygon.Geometry.ExteriorRing, latter, "#0000ff", fillColor, 0, gid, "3DPolygon");
|
// // alert(Geo_Polygon.Geometry.IPolygon.rings.Count)
|
// //Geo_Polygon = sgworld.Creator.CreatePolygon(polygon, "#0000ff", fillColor, 3, gid, "3DPolygon");
|
|
// //sgworld.ProjectTree.DeleteItem(polygon.ID);
|
|
}
|
});
|
|
//
|
}
|
|
|
|
|
var DrawPolygon = {
|
SG: null,
|
polygon: null,
|
|
callback: null,
|
|
isDrawing: false,
|
|
isEditing: false,
|
|
groupName: "图形绘制",
|
|
polygonName: "_polygon_",
|
|
// 开始
|
start: function (sg, callback) {
|
try {
|
if (this.isDrawing) {
|
return;
|
}
|
|
this.SG = sg;
|
this.polygon = null;
|
this.isDrawing = true;
|
this.isEditing = false;
|
this.callback = callback;
|
this.SG.Window.SetInputMode(1);
|
//this.SG.Application.CPUSaveMode = true;
|
|
this.addEvent();
|
} catch (e) {
|
console.error(e);
|
}
|
},
|
|
// 添加事件
|
addEvent: function () {
|
this.SG.AttachEvent("OnLButtonDown", this.onLButtonDown);
|
this.SG.AttachEvent("OnRButtonDown", this.onRButtonDown);
|
this.SG.AttachEvent("OnFrame", this.onFrame);
|
},
|
|
// 移除事件
|
rmEvent: function () {
|
this.SG.DetachEvent("OnLButtonDown", this.onLButtonDown);
|
this.SG.DetachEvent("OnRButtonDown", this.onRButtonDown);
|
this.SG.DetachEvent("OnFrame", this.onFrame);
|
},
|
|
// 左键按下事件
|
onLButtonDown: function (Flags, X, Y) {
|
var _this = DrawPolygon;
|
try {
|
if (X < 0 || Y < 0 || _this.isEditing) {
|
return;
|
}
|
|
var wpi = _this.SG.Window.PixelToWorld(X, Y, 0); // 0-Terrain
|
//wpi.Position.ChangeAltitudeType(0); // 0-RELATIVE,3-ABSOLUTE
|
if (wpi.Position.X == 0 || wpi.Position.Y == 0) {
|
return;
|
}
|
|
_this.isEditing = true;
|
if (_this.polygon) {
|
_this.polygon.Geometry.ExteriorRing.Points.AddPoint(wpi.Position.X, wpi.Position.Y, 0);
|
} else {
|
_this.polygon = _this.createPolygon(wpi);
|
_this.polygon.Geometry.StartEdit();
|
}
|
_this.isEditing = false;
|
} catch (e) {
|
_this.isEditing = false;
|
console.error(e);
|
}
|
|
return true;
|
},
|
|
// 创建多边形
|
createPolygon: function (wpi) {
|
var arr = [
|
wpi.Position.X,
|
wpi.Position.Y,
|
0,
|
wpi.Position.X + 0.0000001,
|
wpi.Position.Y + 0.0000001,
|
0,
|
wpi.Position.X + 0.0000002,
|
wpi.Position.Y + 0.0000002,
|
0
|
];
|
|
var gid = this.SG.ProjectTree.FindItem(this.groupName);
|
if (!gid) {
|
gid = this.SG.ProjectTree.CreateLockedGroup(this.groupName, this.SG.ProjectTree.RootID);
|
}
|
|
var id = this.SG.ProjectTree.FindItem(this.groupName + "\\" + this.polygonName);
|
if (id) {
|
this.SG.ProjectTree.DeleteItem(id);
|
}
|
|
var fillColor = this.SG.Creator.CreateColor(255, 0, 0, 51);
|
var ring = this.SG.Creator.GeometryCreator.CreateLinearRingGeometry(arr);
|
var geometry = this.SG.Creator.GeometryCreator.CreatePolygonGeometry(ring, null);
|
var polygon = this.SG.Creator.CreatePolygon(geometry, "#ff0000", fillColor, 2, gid, this.polygonName);
|
|
return polygon;
|
},
|
|
// 右键按下事件
|
onRButtonDown: function (Flags, X, Y) {
|
try {
|
DrawPolygon.end();
|
} catch (e) {
|
console.error(e);
|
}
|
|
return true;
|
},
|
|
// 帧事件
|
onFrame: function () {
|
try {
|
var _this = DrawPolygon;
|
if (_this.polygon == null || _this.isEditing) {
|
return;
|
}
|
|
var mi = _this.SG.Window.GetMouseInfo();
|
if (mi.X < 0 || mi.Y < 0) {
|
return;
|
}
|
|
var wpi = _this.SG.Window.PixelToWorld(mi.X, mi.Y, -1); // 0-Terrain
|
if (wpi.Position.X == 0 || wpi.Position.Y == 0) {
|
return;
|
}
|
|
var p = _this.polygon.Geometry.ExteriorRing.Points.Item(_this.polygon.Geometry.ExteriorRing.Points.Count - 1);
|
p.X = wpi.Position.X;
|
p.Y = wpi.Position.Y;
|
} catch (e) {
|
console.error(e);
|
}
|
},
|
|
// 结束
|
end: function () {
|
this.rmEvent();
|
if (this.polygon) {
|
if (this.polygon.Geometry.ExteriorRing.Points.Count < 5) {
|
this.polygon.Geometry.EndEdit();
|
this.SG.ProjectTree.DeleteItem(this.polygon.ID);
|
this.polygon = null;
|
} else {
|
this.polygon.Geometry.ExteriorRing.Points.DeletePoint(1);
|
this.polygon.Geometry.ExteriorRing.Points.DeletePoint(this.polygon.Geometry.ExteriorRing.Points.Count - 1);
|
this.polygon.Geometry.EndEdit();
|
}
|
}
|
|
//this.SG.ProjectTree.EndEdit();
|
this.SG.Window.SetInputMode(0);
|
this.isEditing = false;
|
this.isDrawing = false;
|
|
if (this.callback) {
|
this.callback(this.polygon);
|
}
|
|
}
|
};
|
|
|
|
function showrightmenu (rest) {
|
if (rest == 1) {
|
if (RS1 == 0) {
|
window.external.loadMainWebFunc('showrighttool', 'r1');
|
RS1 = 1
|
} else {
|
window.external.closeDialog("测量工具");
|
RS1 = 0;
|
}
|
} else if (rest == 2) {
|
|
} else if (rest == 3) {
|
CuttingAnalysis();
|
} else if (rest == 4) {
|
|
|
} else if (rest == 5) {
|
window.external.loadMainWebFunc('showrighttool', 'r5');
|
} else if (rest == 6) {
|
sessionStorage.removeItem("obvar");
|
if (RS6 == 0) {
|
window.external.loadMainWebFunc('showrighttool', 'r6');
|
sgworld.AttachEvent("OnLButtonClicked", RotorSearch);
|
RS6 = 1;
|
sgworld.Command.Execute(1027, 0)
|
} else if (RS6 == 1) {
|
window.external.closeDialog("转孔数据展示")
|
RS6 = 0;
|
sgworld.DetachEvent("OnLButtonClicked", RotorSearch);
|
sgworld.Command.Execute(1027, 0);
|
|
for (var i = 0; i < el_group.length; i++) {
|
var el_id = sgworld.ProjectTree.FindItem("test");
|
sgworld.ProjectTree.DeleteItem(el_id);
|
}
|
el_group = [];
|
}
|
}
|
}
|
|
|
|
|
|
|
|
|
var MX_URL = "http://127.0.0.1:8088/"
|
|
function ajaxget (lon, lat) {
|
|
$.ajax({
|
type: "GET",
|
url: MX_URL + "gisserver/rest/services/THdemhebing9/THdemhebing9/ImageServer/identify?geometry=" + lon + "," + lat + "&geometryType=esriGeometryPoint",
|
dataType: "json",
|
success: function (res) {
|
var val_data = res.volume_val.split(",");
|
obvar = lon + "," + lat + "," + res.volume_val;
|
sessionStorage.setItem("obvar", obvar);
|
for (var i in val_data) {
|
if (i == 7) {
|
cFillColor = sgworld.Creator.CreateColor(255, 0, 0, 1);
|
} else if (i == 6) {
|
cFillColor = sgworld.Creator.CreateColor(255, 165, 0, 1);
|
} else if (i == 5) {
|
cFillColor = sgworld.Creator.CreateColor(255, 255, 0, 1);
|
} else if (i == 4) {
|
cFillColor = sgworld.Creator.CreateColor(0, 255, 0, 1);
|
} else if (i == 3) {
|
cFillColor = sgworld.Creator.CreateColor(0, 127, 255, 1);
|
} else if (i == 2) {
|
cFillColor = sgworld.Creator.CreateColor(0, 0, 255, 1);
|
} else if (i == 1) {
|
cFillColor = sgworld.Creator.CreateColor(139, 0, 255, 1);
|
} else {
|
cFillColor = sgworld.Creator.CreateColor(255, 0, 0, 1);
|
}
|
var position_Height = parseFloat(val_data[i]);
|
var position = sgworld.Creator.CreatePosition(lon, lat, position_Height);
|
position.AltitudeType = 3;
|
var height = parseFloat(elevation) - parseFloat(position_Height)
|
var attributt = "test_" + i;
|
sgworld.Creator.CreateCylinder(position, 10, height, cFillColor, cFillColor, 20, elGroup, attributt);
|
elevation = position_Height;
|
}
|
|
},
|
error: function (result) {
|
errorToast(result.msg);
|
}
|
});
|
|
}
|
|
|
function RotorSearch (Flags, X, Y, pbHandled) {
|
var CursorCoord = sgworld.Window.PixelToWorld(X, Y);
|
var lonnger = parseFloat(CursorCoord.Position.x);
|
var latter = parseFloat(CursorCoord.Position.y);
|
var pWorldPointInfo = sgworld.Terrain.GetGroundHeightInfo(lonnger, latter, 2, 1);
|
elevation = pWorldPointInfo.Position.Altitude;
|
var _groupname = "test";
|
elGroup = sgworld.ProjectTree.CreateGroup(_groupname, "")
|
el_group.push(elGroup)
|
ajaxget(lonnger, latter);
|
}
|
|
function colorchange (result) {
|
var color;
|
|
return color;
|
}
|
|
//分层离散
|
var Hierarch_flag = 1;
|
|
function HierarchicalDiscrete () {
|
|
var _id_xpl = sgworld.ProjectTree.FindItem("腾辉矿山\\地质体");
|
|
var _id_current = sgworld.ProjectTree.GetNextItem(_id_xpl, 11);
|
BuildTreeRecursive(_id_current, 13)
|
|
}
|
|
function BuildTreeRecursive (current, indent) {
|
if (Hierarch_flag == 1) {
|
Hierarch_flag = 2;
|
} else {
|
Hierarch_flag = 1;
|
}
|
var flag = 100
|
var i = 0;
|
while (current != null && current != undefined) {
|
var volume_val = sgworld.ProjectTree.GetObject(current).Position.Altitude;
|
if (Hierarch_flag == 2) {
|
sgworld.ProjectTree.GetObject(current).Position.Altitude = volume_val + (flag + (i * 200));
|
} else {
|
sgworld.ProjectTree.GetObject(current).Position.Altitude = volume_val - (flag + (i * 200));
|
}
|
i++;
|
current = sgworld.ProjectTree.GetNextItem(current, indent);
|
}
|
}
|
|
function RecoverTreeRecursive (current, indent) {
|
var flag = 200;
|
var i = 0;
|
while (current != null) {
|
var volume_val = sgworld.ProjectTree.GetObject(current).Position.Altitude;
|
sgworld.ProjectTree.GetObject(current).Position.Altitude = volume_val - flag + (i * 10);
|
i++;
|
current = sgworld.ProjectTree.GetNextItem(current, indent);
|
}
|
|
}
|
|
//剖面分析
|
function CuttingAnalysis () {
|
window.external.loadMainWebFunc('showbottomtool', 'bx2');
|
}
|
|
|
|
function closemeasure () {
|
window.external.closeDialog("测量工具");
|
}
|
|
//体积计算
|
function getMineLayers(result){
|
volume =[];
|
|
for(var i =0 ; i< result.length;i++){
|
|
var volume_val = result[i].Points;
|
let up= [
|
{
|
name: "a1",
|
coords: volume_val[0].X+","+volume_val[0].Y+","+volume_val[0].Z1,
|
},
|
{
|
name: "b1",
|
coords: volume_val[1].X+","+volume_val[1].Y+","+volume_val[1].Z1,
|
},
|
{
|
name: "c1",
|
coords: volume_val[2].X+","+volume_val[2].Y+","+volume_val[2].Z1,
|
},
|
]
|
let down= [
|
{
|
name: "a2",
|
coords: volume_val[0].X+","+volume_val[0].Y+","+volume_val[0].Z2,
|
},
|
{
|
name: "b2",
|
coords: volume_val[1].X+","+volume_val[1].Y+","+volume_val[1].Z2,
|
},
|
{
|
name: "c2",
|
coords: volume_val[2].X+","+volume_val[2].Y+","+volume_val[2].Z2,
|
},
|
]
|
|
|
getvolume(up,down)
|
|
|
|
|
}
|
console.log(JSON.stringify(volume))
|
//计算数组的总和
|
var sum = volume.reduce(function(prev,cur,index,array){
|
return prev + cur
|
})
|
alert(sum); //15
|
|
}
|
function getvolume(up,down){
|
|
|
let num = initPoints(up,down);
|
|
let num1 =parseInt(num)
|
|
volume.push(num1);
|
|
|
}
|
|
|
|
</script>
|
</body>
|
|
</html>
|