define([
|
'dojo/_base/declare',
|
'dojo/_base/lang',
|
'dojo/_base/array',
|
'dojo/_base/html',
|
'dojo/topic',
|
'jimu/BaseWidget',
|
],
|
function (declare,
|
lang,
|
array,
|
html,
|
topic,
|
BaseWidget
|
) {
|
return declare([BaseWidget], {
|
baseClass: 'jimu-widget-volumeAnalysis',
|
name: 'volumeAnalysis',
|
flag: false,
|
startup: function () {
|
var that = this;
|
topic.subscribe("beginVolumeAnalysis", lang.hitch(this, this.beginVolumeAnalysis));
|
topic.subscribe("closesVolumeAnalysis", lang.hitch(this, this.closesVolumeAnalysis));
|
// topic.publish('getbeginSlope', that.beginSlope);
|
$(`.${that.baseClass}`).find('.closeOUR').click(() => {
|
$(`.${that.baseClass}`).hide();
|
that.closesVolumeAnalysis();
|
})
|
|
// that.beginVolumeAnalysis();
|
|
},
|
beginVolumeAnalysis: function () {
|
// console.log('kaishi');
|
var that = this
|
, viewer = this.map;
|
|
var clampMode = 0; // 空间模式
|
var scene = viewer.scene;
|
var widget = viewer.cesiumWidget;
|
|
var tooltip = window.MYcreateTooltip(document.body);
|
|
// var promise = scene.open('http://www.supermapol.com/realspace/services/3D-dxyx_ios2/rest/realspace')
|
// Cesium.when.all(promise, function (layers) {//等待promise加载
|
//设置相机位置、视角
|
// viewer.scene.camera.setView({
|
// destination: new Cesium.Cartesian3(-1206939.1925299785, 5337998.241228442, 3286279.2424502545),
|
// orientation: {
|
// heading: 1.4059101895600987,
|
// pitch: -0.20917672793046682,
|
// roll: 2.708944180085382e-13
|
// }
|
// });
|
|
var handlerPolygon = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, clampMode);
|
|
handlerPolygon.activeEvt.addEventListener(function (isActive) {
|
if (isActive == true) {
|
viewer.enableCursorStyle = false;
|
viewer._element.style.cursor = '';
|
$('body').removeClass('drawCur').addClass('drawCur');
|
} else {
|
viewer.enableCursorStyle = true;
|
$('body').removeClass('drawCur');
|
}
|
});
|
|
handlerPolygon.movingEvt.addEventListener(function (windowPosition) {
|
if (handlerPolygon.isDrawing) {
|
tooltip.showAt(windowPosition, '<p>点击确定多边形中间点</p><p>右键单击结束绘制</p>');
|
} else {
|
tooltip.showAt(windowPosition, '<p>点击绘制第一个点</p>');
|
}
|
});
|
|
handlerPolygon.drawEvt.addEventListener(function (result) {
|
handlerPolygon.polygon.show = false;
|
// handlerPolygon.polyline.show = false;
|
handlerPolygon.deactivate();
|
tooltip.setVisible(false);
|
|
var dep = document.getElementById("depthVolumeAnalysis").value;
|
|
var array = [].concat(result.object.positions);
|
var positions = [];
|
var positionsii = [];
|
for (var i = 0, len = array.length; i < len; i++) {
|
var cartographic = Cesium.Cartographic.fromCartesian(array[i]);
|
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
var h = cartographic.height;
|
if (positions.indexOf(longitude) == -1 && positions.indexOf(latitude) == -1) {
|
|
positions.push(longitude);
|
positions.push(latitude);
|
positions.push(parseInt(dep));
|
|
positionsii.push({
|
x: longitude,
|
y: latitude
|
});
|
}
|
}
|
|
//此处用的地形修改 而不是地形开挖
|
viewer.scene.globe.removeAllModifyRegion();
|
viewer.scene.globe.addModifyRegion({
|
name: 'ggg',
|
position: positions
|
});
|
|
var length = [];
|
length.push(positionsii.length);
|
|
//需要在此 动态构造一个 REGION类型的对象
|
var geometry = {
|
"id": 23,
|
"parts": length,
|
"points": positionsii,
|
"style": null,
|
"type": "REGION"
|
};
|
|
|
var queryObj = {
|
"cutFillType": "REGIONANDALTITUDE",
|
"baseAltitude": dep,
|
"region": geometry,
|
"resultDataset": "result",
|
"buildPyramid": true,
|
"deleteExistResultDataset": true
|
};
|
var queryObjJSON = JSON.stringify(queryObj);
|
$.ajax({
|
type: 'post',
|
url: "http://www.supermapol.com/realspace/services/spatialAnalysis-dxyx_ios/restjsr/spatialanalyst/datasets/DEM@%E5%9B%9B%E5%A7%91%E5%A8%98%E5%B1%B1/terraincalculation/cutfill.json?returnContent=true",
|
data: queryObjJSON,
|
success: function (data) {
|
console.log(data);
|
console.log(queryObj);
|
// var resultObj = JSON.parse(data);
|
var resultObj = data;
|
|
document.getElementById("cutareaVolumeAnalysis").value = resultObj.cutArea;
|
document.getElementById("cutVolumeVolumeAnalysis").value = resultObj.cutVolume;
|
document.getElementById("fillareaVolumeAnalysis").value = resultObj.fillArea;
|
document.getElementById("fillVolumeVolumeAnalysis").value = resultObj.fillVolume;
|
document.getElementById("remainderAreaVolumeAnalysis").value = resultObj.remainderArea;
|
}
|
});
|
|
});
|
|
document.getElementById("filladdVolumeAnalysis").onclick = function () {
|
handlerPolygon.activate();
|
};
|
|
document.getElementById("fillclearVolumeAnalysis").onclick = function () {
|
viewer.scene.globe.removeAllModifyRegion();
|
document.getElementById("cutareaVolumeAnalysis").value = "";
|
document.getElementById("cutVolumeVolumeAnalysis").value = "";
|
document.getElementById("fillareaVolumeAnalysis").value = "";
|
document.getElementById("fillVolumeVolumeAnalysis").value = "";
|
document.getElementById("remainderAreaVolumeAnalysis").value = "";
|
handlerPolygon.clear();
|
};
|
|
$('#toolbarVolumeAnalysis').show();
|
$('#loadingbar').remove();
|
|
|
if (!scene.pickPositionSupported) {
|
alert('不支持深度拾取,无法进行鼠标交互绘制!');
|
}
|
// })
|
that.handlerPolygon = handlerPolygon;
|
that.tooltip = tooltip;
|
|
},
|
handlerPolygon: '',
|
tooltip: '',
|
closesVolumeAnalysis: function (froms) {
|
// console.log('guanbi');
|
this.map.scene.globe.removeAllModifyRegion();
|
document.getElementById("cutareaVolumeAnalysis").value = "";
|
document.getElementById("cutVolumeVolumeAnalysis").value = "";
|
document.getElementById("fillareaVolumeAnalysis").value = "";
|
document.getElementById("fillVolumeVolumeAnalysis").value = "";
|
document.getElementById("remainderAreaVolumeAnalysis").value = "";
|
this.handlerPolygon.clear();
|
this.tooltip.setVisible(false);
|
},
|
onOpen: function () {
|
|
},
|
|
onClose: function () {
|
//面板关闭的时候触发 (when this panel is closed trigger)
|
console.log('jies')
|
},
|
|
onMinimize: function () {
|
this.resize();
|
},
|
|
onMaximize: function () {
|
this.resize();
|
},
|
|
resize: function () {
|
|
},
|
|
destroy: function () {
|
//销毁的时候触发
|
//todo
|
//do something before this func
|
this.inherited(arguments);
|
}
|
|
});
|
});
|