window.maps = {}; window.panels = {}; window.bs = {}; window.utils = {}; window.Q = {}; window.mapDatas = {}; panels.layerTreePanelIndex = undefined; panels.lastConditionPanelIndex = undefined; panels.lastResultPanelIndex = undefined; panels.getCesiumHeight = function() { return $('#cesiumContainer').height(); } panels.getCesiumWidth = function() { return $('#cesiumContainer').width(); } panels.getConditionPanelWidth = function() { return $("#panel-result").width(); } mapDatas.getLayerNameByCaption = function(caption) { for (let index = 0; index < CONST_VALUES.GX_Datas.length; index++) { const dat = CONST_VALUES.GX_Datas[index]; if (dat.name == caption) return dat.dataSetName; } return ""; } mapDatas.getDataInfoByName = function(name) { for (let index = 0; index < CONST_VALUES.GX_Datas.length; index++) { const dat = CONST_VALUES.GX_Datas[index]; if (dat.name == name) return dat; } return undefined; } mapDatas.getFeatureInfo = function() { mapDatas.infoboxContainer = document.getElementById("bubble"); maps.mapViewer.customInfobox = mapDatas.infoboxContainer; maps.mapViewer.pickEvent.addEventListener(function(feature) { $("blockquote").html(""); let attributes = "
' + selectedFeatures[i].fieldNames["0"] + ' | ' + selectedFeatures[i].fieldValues["0"] + ' |
---|---|
' + selectedFeatures[i].fieldNames[index] + ' | ' + selectedFeatures[i].fieldValues[index] + ' |
点击确定开挖区域中间点
右键单击结束绘制
'); } else { tooltip.showAt(windowPosition, '点击绘制开挖区域第一个点
右键单击结束绘制
'); } }; function getSpatialQueryGeometry(result) { let positions = result.object.positions; let geometries = []; for (let i = 0; i < positions.length; i++) { let position = positions[i]; let cartographic = Cesium.Cartographic.fromCartesian(position); let longitude = Cesium.Math.toDegrees(cartographic.longitude); let latitude = Cesium.Math.toDegrees(cartographic.latitude); let queryPoint = { // 查询点对象 x: longitude, y: latitude }; geometries.push(queryPoint) } sqatialQueryFromSvr(geometries); } handlerPolygonKW.movingEvt.addEventListener(funMovingEvt); handlerLinenKW.movingEvt.addEventListener(funMovingEvt); let funDrawEvt = function(result) { if (result.object.length > 0) { result.object.positions = result.object; } if (DoKW.handlerPolygonKW) DoKW.handlerPolygonKW.clear(); if (DoKW.handlerLinenKW) DoKW.handlerLinenKW.clear(); if (!result.object.positions) { DoKW.deactivate(); if (DoKW.isLine === false) { tooltip.showAt(result, '请绘制正确的多边形
'); DoKW.handlerPolygonKW.activate(); } else { tooltip.showAt(result, '请绘制正确的线路
'); DoKW.handlerLinenKW.activate(); } return; } let array = [].concat(result.object.positions); if (array.length < 2) return; tooltip.setVisible(false); if (SpatialQuery.current === true) { getSpatialQueryGeometry(result); } let positions = []; if (!DoKW.isLine) { for (let i = 0, len = array.length; i < len; i++) { let cartographic = Cesium.Cartographic.fromCartesian(array[i]); let longitude = Cesium.Math.toDegrees(cartographic.longitude); let latitude = Cesium.Math.toDegrees(cartographic.latitude); let h = cartographic.height; if (positions.indexOf(longitude) == -1 && positions.indexOf(latitude) == -1) { positions.push(longitude); positions.push(latitude); positions.push(h); } } } else { positions = DoKW.lineBuffer(array); } let dep = 1000; viewer.scene.globe.removeAllExcavationRegion(); viewer.scene.globe.addExcavationRegion({ name: 'ggg', position: positions, height: dep, transparent: false }); DoKW.deactivate(); DoKW.endDraw(); }; handlerPolygonKW.drawEvt.addEventListener(funDrawEvt); handlerLinenKW.drawEvt.addEventListener(funDrawEvt); if (isLine) handlerLinenKW.activate(); else handlerPolygonKW.activate(); DoKW.registered = true; DoKW.handlerPolygonKW = handlerPolygonKW; DoKW.handlerLinenKW = handlerLinenKW; } spatialToolBarMethod.DoKW = DoKW; DoKW.deactivate = function() { if (DoKW.handlerPolygonKW.polygon != undefined) DoKW.handlerPolygonKW.polygon.show = false; if (DoKW.handlerPolygonKW.polyline != undefined) DoKW.handlerPolygonKW.polyline.show = false; DoKW.handlerPolygonKW.deactivate(); if (DoKW.handlerLinenKW.polygon != undefined) DoKW.handlerLinenKW.polygon.show = false; if (DoKW.handlerLinenKW.polyline != undefined) DoKW.handlerLinenKW.polyline.show = false; DoKW.handlerLinenKW.deactivate(); } DoKW.endDraw = function() { tooltip.setVisible(false); viewer.enableCursorStyle = true; $('body').removeClass('drawCur'); DoKW.deactivate(); } DoKW.lineBuffer = function(array) { let positions = []; let lonLats = []; let maxHeight = -1; for (let i = 0, len = array.length; i < len; i++) { let cartographic = Cesium.Cartographic.fromCartesian(array[i]); let longitude = Cesium.Math.toDegrees(cartographic.longitude); let latitude = Cesium.Math.toDegrees(cartographic.latitude); let h = cartographic.height; if (h > maxHeight) maxHeight = h; //let h1 = cartographic1.height; lonLats.push([longitude, latitude]); } let polygon = turf.lineString(lonLats, { name: 'lineString' }); let buffered = turf.buffer(polygon, 0.1, { units: 'kilometers', steps: 1 }); for (let i = 0; i < buffered.geometry.coordinates[0].length; i++) { let coordinate = buffered.geometry.coordinates[0][i]; positions.push(coordinate[0]); positions.push(coordinate[1]); positions.push(maxHeight); } return positions; } function processCompleted(features) { afterQueryCompleted(features); } function sqatialQueryFromSvr(queryPoints) { maps.mapViewer.entities.removeAll(); let lyrs = CONST_VALUES.GX_Datas; //debugger; let lyrsSelect = '