增加修改功能

tykong-cidian
dongjiajun 2024-07-05 16:58:32 +08:00
parent b1051f7579
commit 8db90be785
2 changed files with 115 additions and 10 deletions

View File

@ -98,6 +98,7 @@
type="primary" type="primary"
size="small" size="small"
icon="el-icon-edit" icon="el-icon-edit"
@click="editSelected(scope.$index, simpleData)"
></el-button> ></el-button>
<el-button <el-button
type="danger" type="danger"
@ -136,12 +137,17 @@
/> />
</div> </div>
<canvas v-show="checkRealityWait" id="scaleBar"></canvas> <canvas v-show="checkRealityWait" id="scaleBar"></canvas>
<div class="update-btns" v-show="updatePointVisible">
<div><el-button type="primary" @click="selectPoint"></el-button></div>
<div><el-button type="primary" @click="savePoint"></el-button></div>
</div>
</div> </div>
</div> </div>
<div v-show="checkRealityWait" class="bottomCont"> <div v-show="checkRealityWait" class="bottomCont">
<span>制图单位中国科学院空天信息创新研究院</span><br /> <span>制图单位中国科学院空天信息创新研究院</span><br />
<span>制图日期{{ createImgTime }}</span> <span>制图日期{{ createImgTime }}</span>
</div> </div>
</div> </div>
</div> </div>
<SampleSetting <SampleSetting
@ -252,6 +258,9 @@ export default {
isDeepSpace: false, isDeepSpace: false,
depthList: [], depthList: [],
createImgTime: null, createImgTime: null,
updatePointVisible:false,
currentSelectPoint: null, //
updatedPoint:null, //
}; };
}, },
mounted() { mounted() {
@ -594,6 +603,61 @@ export default {
simpleData.splice(index, 1); simpleData.splice(index, 1);
}); });
}, },
editSelected(index, simpleData) {
//
this.updatePointVisible = true;
cu.removePoint()
//
if (simpleData.length !== 0) {
for (let i in simpleData) {
if( i == index ){
cu.addPoint(simpleData[index].lng, simpleData[index].lat, 10,true);
}else{
cu.addPoint(simpleData[i].lng, simpleData[i].lat, 10);
}
}
}
//
this.currentSelectPoint = simpleData[index];
// this.$confirm(``, "", {
// confirmButtonText: "",
// cancelButtonText: "",
// type: "warning",
// }).then(async () => {
// simpleData.splice(index, 1);
// });
},
//
async selectPoint(){
//
let res = await cu.clickToAddPoint()
cu.addPoint(res.lng, res.lat, 10);
this.updatedPoint = {
...this.currentSelectPoint,
lng: res.lng,
lat: res.lat
}
console.log(this.updatedPoint,'查看点');
console.log(this.simpleData[2],'查看simpleData');
},
//
savePoint(){
//
cu.removePoint();
let index = this.simpleData.indexOf(this.currentSelectPoint)
//table
this.simpleData.splice(index,1,this.updatedPoint)
//
if (this.simpleData.length !== 0) {
for (let i in this.simpleData) {
cu.addPoint(this.simpleData[i].lng, this.simpleData[i].lat, 10);
}
}
this.$refs.multipleTable.toggleAllSelection();
//
this.updatePointVisible = false;
}
}, },
computed: { computed: {
globalSampleFun: function () { globalSampleFun: function () {
@ -741,6 +805,20 @@ export default {
margin-left: 100%; margin-left: 100%;
white-space: nowrap; white-space: nowrap;
} }
.update-btns{
width: 100px;
height: 70px;
background-color: #ffffff;
position: absolute;
right: 10px;
bottom: 10px;
z-index: 99;
display: flex;
justify-content: space-around;
align-items: center;
border-radius: 10px;
flex-direction: column;
}
} }
.onBorder { .onBorder {

View File

@ -162,26 +162,53 @@ class CesiumUtils {
this.viewer.imageryLayers.remove(this.privide); this.viewer.imageryLayers.remove(this.privide);
} }
static addPoint(pLon, pLat, pAlt) { static addPoint(pLon, pLat, pAlt, isSelected = false) {
var pointEntity = this.viewer.entities.add({ var pointEntity = this.viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(pLon, pLat, pAlt), position: Cesium.Cartesian3.fromDegrees(pLon, pLat, pAlt),
point: { point: {
pixelSize: 10, pixelSize: 10,
color: Cesium.Color.YELLOW color: isSelected ? Cesium.Color.RED : Cesium.Color.YELLOW,
} },
}); });
} }
static removePoint() { static removePoint() {
this.viewer.entities.removeAll(); this.viewer.entities.removeAll();
} }
//修改点的位置
static clickToAddPoint(){
return new Promise((resolve, reject) => {
var scene = this.viewer.scene;
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
const that = this;
handler.setInputAction(function (movement) {
// 清除历史单击点
// handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
// movement.position 像素的x、y坐标
var cartesian = that.viewer.camera.pickEllipsoid(
movement.position,
scene.globe.ellipsoid
);
if (cartesian) {
var cartographic = Cesium.Cartographic.fromCartesian(cartesian); // 转弧度
// 将弧度转换为度数
var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(6);
var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(6);
let lng = Number(longitudeString);
let lat = Number(latitudeString);
resolve({ lng, lat });
}else{
reject('未获取到坐标');
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
});
}
//鼠标点击 //鼠标点击
static handleClick() { static handleClick() {
var scene = this.viewer.scene; var scene = this.viewer.scene;
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
const that = this; const that = this;
handler.setInputAction(function (movement) { handler.setInputAction(function (movement) {
// 清除历史单击点 // 清除历史单击点
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK); handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
@ -206,10 +233,10 @@ class CesiumUtils {
angleDataIds: [], angleDataIds: [],
geoX: longitudeString, geoX: longitudeString,
geoY: latitudeString, geoY: latitudeString,
metaDataId: sessionStorage.getItem('metaDataId'), metaDataId: sessionStorage.getItem("metaDataId"),
referImageIds: [] referImageIds: [],
} };
getProductValue(of).then(res => { getProductValue(of).then((res) => {
if (res.code == 200) pValue = res.data.imagePixel; if (res.code == 200) pValue = res.data.imagePixel;
// 清空容器 // 清空容器
const pendPreview = const pendPreview =