merge
parent
b220cc3f21
commit
d3c25a06dc
|
|
@ -7,7 +7,7 @@
|
|||
<SaveOutlined @click="saveAirLine" />
|
||||
|
||||
<div style="flex:1;">
|
||||
<a-input v-model:value="submitForm.airLineName" size="middle" placeholder="航线名称" />
|
||||
<a-input v-model:value="props.airLineForm.airLineName" size="middle" placeholder="航线名称" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
<div class="item">
|
||||
<div class="label">参考起飞点</div>
|
||||
<div class="content">
|
||||
<a-button type="link" style="color:#408eff" @click="setFlyPoint()">
|
||||
<a-button type="link" style="color:#408eff" @click="setTakeOffPoint()">
|
||||
<img src="./start-fly.png" style="width:24px;height:24px;position:relative;left:-2px;top:-2px;" alt="">
|
||||
设置起飞点
|
||||
</a-button>
|
||||
|
|
@ -224,7 +224,7 @@ import {uavModel,calculateHeight,calculateGsd,calculateSpacing} from '../lib/cal
|
|||
|
||||
|
||||
|
||||
const emits = defineEmits(["setFlyPoint","exitDraw","calculatParamChange"])
|
||||
const emits = defineEmits(["setTakeOffPoint","exitDraw","calculatParamChange"])
|
||||
|
||||
// const props = defineProps(["airInfo","polygonAirForm","airPoints","airLineForm","waylineInfo"])
|
||||
|
||||
|
|
@ -257,8 +257,8 @@ const airInfo = ref({
|
|||
picture:23
|
||||
})
|
||||
|
||||
const setFlyPoint = ()=>{
|
||||
emits("setFlyPoint");
|
||||
const setTakeOffPoint = ()=>{
|
||||
emits("setTakeOffPoint");
|
||||
}
|
||||
|
||||
// 航线计算参数
|
||||
|
|
@ -532,12 +532,14 @@ const pointInfo = {
|
|||
// 处理航点数据
|
||||
const handlerPointInfo = ()=>{
|
||||
|
||||
|
||||
if(props.airPoints?.length<=0){
|
||||
message.warning("请绘制航测区域!");
|
||||
return null;
|
||||
}
|
||||
|
||||
let placemarkArray = [];
|
||||
|
||||
props.airPoints?.forEach((item,index)=>{
|
||||
let point = {
|
||||
"Point": {
|
||||
|
|
@ -666,24 +668,14 @@ const saveAirLine = ()=>{
|
|||
|
||||
let handlerResult = handlerPointInfo();
|
||||
|
||||
|
||||
if(handlerResult){
|
||||
|
||||
const builder = new XMLBuilder();
|
||||
|
||||
let lineData = {...waylinesJson.value}
|
||||
|
||||
let obj = handlerPrefixWpml(lineData);
|
||||
|
||||
let xmlString = builder.build(obj);
|
||||
|
||||
let xmlString2 = xmlString.replace(/<\/?\d+>/g, "")
|
||||
|
||||
let xmlString3 = xmlString2.replace("<kml>",`<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2" xmlns:wpml="http://www.dji.com/wpmz/1.0.6">`)
|
||||
|
||||
|
||||
handlerCreateFile(xmlString3);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -734,18 +726,12 @@ const handlerPrefixWpml = (obj) => {
|
|||
}
|
||||
|
||||
|
||||
// 保存表单
|
||||
const submitForm = ref({})
|
||||
|
||||
// 传入表单
|
||||
submitForm.value = props.airLineForm;
|
||||
|
||||
|
||||
// 生成xml文件,创建航线
|
||||
const handlerCreateFile =async (xmlString3)=>{
|
||||
|
||||
console.log("submitForm",submitForm.value);
|
||||
|
||||
const blob =await convertXmlToKmz(xmlString3,templateStr);
|
||||
|
||||
// const blob = new Blob([content], { type: 'wpml/plain' });
|
||||
|
|
@ -758,15 +744,17 @@ const handlerCreateFile =async (xmlString3)=>{
|
|||
let res = await uploadXmlFile("默认文件夹/面状航线",formData);
|
||||
|
||||
if(res){
|
||||
submitForm.value.wpml = res.path;
|
||||
props.airLineForm.wpml = res.path;
|
||||
|
||||
let addAirLineRes = null;
|
||||
|
||||
if(props.editModel == 'add'){
|
||||
|
||||
addAirLineRes =await addAirLine(submitForm.value);
|
||||
addAirLineRes =await addAirLine(props.airLineForm);
|
||||
|
||||
}else if(props.editModel == 'edit'){
|
||||
|
||||
addAirLineRes =await editAirLine(submitForm.value);
|
||||
addAirLineRes =await editAirLine(props.airLineForm);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<airPoint
|
||||
:wayline="props.wayline"
|
||||
:airPoints="airPoints"
|
||||
@setFlyPoint="setFlyPoint"
|
||||
@setTakeOffPoint="setTakeOffPoint"
|
||||
@exitDraw="exitDraw"
|
||||
:airInfo="lineInfo"
|
||||
:airLineForm="props.airLineForm"
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<!-- 航面航线 -->
|
||||
<div v-if="props.airLineForm.airLineType == 'mapping2d'" class="airpolygon-container">
|
||||
<airPolygon
|
||||
@setFlyPoint="setFlyPoint"
|
||||
@setTakeOffPoint="setTakeOffPoint"
|
||||
:airInfo="airInfo"
|
||||
:editModel="props.editMode"
|
||||
:polygonAirForm="polygonAirForm"
|
||||
|
|
@ -285,10 +285,8 @@
|
|||
// 航线预览:生成点
|
||||
const generatePreviewPoint = (placemark)=>{
|
||||
|
||||
|
||||
|
||||
// 设置默认起飞点
|
||||
startPosition.value = [props.airLineForm?.taskOffLng, props.airLineForm?.taskOffLat, 70];
|
||||
takeOffPointPosition.value = [props.airLineForm?.taskOffLng, props.airLineForm?.taskOffLat, 70];
|
||||
|
||||
// 先清空所有数据
|
||||
clearAllLayer();
|
||||
|
|
@ -371,11 +369,11 @@ const generatePreviewPoint = (placemark)=>{
|
|||
|
||||
let graphicLayer: mars3d.layer.GraphicLayer;
|
||||
|
||||
let uavGraphicLayer: mars3d.layer.GraphicLayer;
|
||||
|
||||
// 设置参考起飞点图层
|
||||
let takeOffPointGraphicLayer:mars3d.layer.GraphicLayer;
|
||||
|
||||
let uavGraphicLayer: mars3d.layer.GraphicLayer;
|
||||
|
||||
// 测区面图层
|
||||
let polygonGraphicLayer: mars3d.layer.GraphicLayer;
|
||||
|
||||
|
|
@ -648,7 +646,7 @@ const initMap = () => {
|
|||
})
|
||||
|
||||
takeOffPointGraphicLayer.on(mars3d.EventType.editMovePoint, function (event) {
|
||||
flyPointMove(event);
|
||||
takeOffPointMove(event);
|
||||
});
|
||||
|
||||
map.addLayer(takeOffPointGraphicLayer);
|
||||
|
|
@ -683,14 +681,15 @@ const initMap = () => {
|
|||
text: '删除测区',
|
||||
icon: 'fa fa-camera-retro', // 支持 font-class 的字体方式图标
|
||||
callback: (e) => {
|
||||
handlerRemovePolygonArea(e);
|
||||
handlerClearPolygonGraphicLayer(e);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
polygonGraphicLayer.on(mars3d.EventType.editMovePoint,(event)=>{
|
||||
handlerPolygonEdit(event);
|
||||
onPolygonGraphicLayerEdit(event);
|
||||
})
|
||||
|
||||
map.addLayer(polygonGraphicLayer);
|
||||
|
||||
|
||||
|
|
@ -734,7 +733,7 @@ const handlerBindMapMenus = () => {
|
|||
text: '添加航点',
|
||||
icon: 'fa fa-camera-retro', // 支持 font-class 的字体方式图标
|
||||
callback: (e) => {
|
||||
if (!startPosition.value) {
|
||||
if (!takeOffPointPosition.value) {
|
||||
message.warning('请先设置起飞点');
|
||||
return null;
|
||||
}
|
||||
|
|
@ -758,7 +757,6 @@ const handlerBindMapMenus = () => {
|
|||
|
||||
///////////////////////////////图层和影像加载////////////////////////////////////////////
|
||||
|
||||
|
||||
// 加载长光卫星高分影像
|
||||
const loadChangGuangLayer = ()=>{
|
||||
var layer = new mars3d.layer.XyzLayer({
|
||||
|
|
@ -776,14 +774,13 @@ const loadChangGuangLayer = ()=>{
|
|||
map.addLayer(layer);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////参考起飞点////////////////////////////////////////////
|
||||
|
||||
// 全局参考起飞点 数据格式:[lng,lat,alt]
|
||||
const startPosition = ref(null);
|
||||
const takeOffPointPosition = ref(null);
|
||||
|
||||
// 设置起飞点
|
||||
const setFlyPoint = async () => {
|
||||
const setTakeOffPoint = async () => {
|
||||
|
||||
takeOffPointGraphicLayer ? takeOffPointGraphicLayer.clear() : null;
|
||||
|
||||
|
|
@ -801,29 +798,31 @@ const setFlyPoint = async () => {
|
|||
outlineColor: '#000000',
|
||||
pixelOffsetY: -50,
|
||||
},
|
||||
},
|
||||
}
|
||||
});
|
||||
startPosition.value = graphic.toJSON().position;
|
||||
|
||||
takeOffPointPosition.value = graphic.toJSON().position;
|
||||
polygonAirForm.value.startingPoint = graphic.toJSON().position;
|
||||
|
||||
|
||||
// 设置表单数据
|
||||
props.airLineForm.taskOffLng = startPosition.value[0]
|
||||
props.airLineForm.taskOffLat = startPosition.value[1]
|
||||
props.airLineForm.taskOffLng = takeOffPointPosition.value[0]
|
||||
props.airLineForm.taskOffLat = takeOffPointPosition.value[1]
|
||||
|
||||
// 更新航线
|
||||
updatePolygonLineByParams();
|
||||
};
|
||||
|
||||
// 参考起飞点移动
|
||||
const flyPointMove = (e) => {
|
||||
const takeOffPointMove = (e) => {
|
||||
|
||||
let res = handlerGetLngLatHeight(e);
|
||||
startPosition.value = [res.lng,res.lat,res.alt];
|
||||
|
||||
takeOffPointPosition.value = [res.lng,res.lat,res.alt];
|
||||
polygonAirForm.value.startingPoint = [res.lng,res.lat,res.alt];
|
||||
|
||||
// 设置表单数据
|
||||
props.airLineForm.taskOffLng = startPosition.value[0]
|
||||
props.airLineForm.taskOffLat = startPosition.value[1]
|
||||
props.airLineForm.taskOffLng = takeOffPointPosition.value[0]
|
||||
props.airLineForm.taskOffLat = takeOffPointPosition.value[1]
|
||||
|
||||
// 更新航线
|
||||
updatePolygonLineByParams();
|
||||
|
|
@ -890,9 +889,6 @@ const handlerDrawPolygon = async () => {
|
|||
|
||||
props.airLineForm.flyToFirstPointMode = polygonWkt;
|
||||
|
||||
console.log("props.airLineForm",props.airLineForm);
|
||||
|
||||
|
||||
let spceing = parseFloat(polygonCalculateParams.value?.spacing) / 10000;
|
||||
let lines = generateScanLines(polygon,spceing, 0);
|
||||
|
||||
|
|
@ -905,7 +901,7 @@ const handlerDrawPolygon = async () => {
|
|||
};
|
||||
|
||||
// 测区编辑后重新计算航线
|
||||
const handlerPolygonEdit = (e)=>{
|
||||
const onPolygonGraphicLayerEdit = (e)=>{
|
||||
|
||||
let coordinates = e.graphic.toJSON().positions;
|
||||
|
||||
|
|
@ -913,12 +909,13 @@ const handlerPolygonEdit = (e)=>{
|
|||
coordinates.push(coordinates[0]);
|
||||
}
|
||||
|
||||
console.log("coordinates",coordinates);
|
||||
|
||||
polygonGeoJson.value = coordinates;
|
||||
|
||||
let polygon = turf.polygon([coordinates]);
|
||||
|
||||
let polygonWkt = GeojsonToWkt(polygon['geometry']);
|
||||
props.airLineForm.flyToFirstPointMode = polygonWkt;
|
||||
|
||||
let spceing = parseFloat(polygonCalculateParams.value?.spacing) / 10000;
|
||||
let lines = generateScanLines(polygon,spceing, 0);
|
||||
|
||||
|
|
@ -934,27 +931,11 @@ const handlerPolygonEdit = (e)=>{
|
|||
// 绘制面航线
|
||||
const handlerDrawPolygonLine = (lines) => {
|
||||
|
||||
let nodeGraphic = polygonGraphicLayer.getGraphicById("polygon-node-1");
|
||||
|
||||
if(nodeGraphic){
|
||||
nodeGraphic.setOptions({
|
||||
id: 'polygon-node-1',
|
||||
name: '航点',
|
||||
// 设置首航点
|
||||
let firstAirLinePoint = polygonGraphicLayer.getGraphicById("polygon-node-1");
|
||||
if(firstAirLinePoint){
|
||||
firstAirLinePoint.setOptions({
|
||||
position: lines.geometry.coordinates[0],
|
||||
style: {
|
||||
image: '/map/node.png',
|
||||
scale: 1,
|
||||
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
||||
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
||||
label: {
|
||||
text: '',
|
||||
font_size: 14,
|
||||
color: '#ffffff',
|
||||
outline: true,
|
||||
outlineColor: '#000000',
|
||||
pixelOffsetY: -35,
|
||||
},
|
||||
},
|
||||
})
|
||||
}else{
|
||||
const graphic = new mars3d.graphic.BillboardEntity({
|
||||
|
|
@ -980,9 +961,7 @@ const handlerDrawPolygonLine = (lines) => {
|
|||
polygonGraphicLayer.addGraphic(graphic);
|
||||
}
|
||||
|
||||
|
||||
// 判断飞行模式
|
||||
|
||||
// 判断飞行模式 设置航点高度
|
||||
lines.geometry.coordinates.unshift([
|
||||
polygonAirForm.value.startingPoint[0],
|
||||
polygonAirForm.value.startingPoint[1],
|
||||
|
|
@ -1005,8 +984,6 @@ const handlerDrawPolygonLine = (lines) => {
|
|||
arcType: Cesium.ArcType.GEODESIC, // 使用大地线
|
||||
width: 2.0,
|
||||
color: '#0aed8b',
|
||||
// clampToGround: true,
|
||||
extrudedHeight: 100, // 相对于地形的高度(米)
|
||||
},
|
||||
},
|
||||
flyTo: true,
|
||||
|
|
@ -1096,7 +1073,6 @@ function generateScanLines(polygon, spacing, angle = 0) {
|
|||
airPoints.value?.push(point);
|
||||
})
|
||||
|
||||
|
||||
return connectedLine;
|
||||
}
|
||||
|
||||
|
|
@ -1113,7 +1089,7 @@ const connectLinesManual = (lines) => {
|
|||
|
||||
|
||||
// 相对起飞点高度
|
||||
let relativeHeight = startPosition.value[2] + parseFloat(polygonCalculateParams.value.height);
|
||||
let relativeHeight = takeOffPointPosition.value[2] + parseFloat(polygonCalculateParams.value.height);
|
||||
|
||||
line.geometry.coordinates?.forEach((item, idx) => {
|
||||
line.geometry.coordinates[idx].push(relativeHeight);
|
||||
|
|
@ -1180,13 +1156,11 @@ const CalculateAreaInfo = (polygon, lines) => {
|
|||
};
|
||||
|
||||
// 删除面状测区 和 面状航线
|
||||
const handlerRemovePolygonArea = () => {
|
||||
if (polygonGraphicLayer) {
|
||||
polygonGraphicLayer.clear();
|
||||
}
|
||||
if (polygonLineGraphicLayer) {
|
||||
polygonLineGraphicLayer.clear();
|
||||
}
|
||||
const handlerClearPolygonGraphicLayer = () => {
|
||||
|
||||
polygonGraphicLayer ? polygonGraphicLayer.clear() : null;
|
||||
|
||||
polygonLineGraphicLayer ? polygonLineGraphicLayer.clear() : null;
|
||||
|
||||
textLabelGraphicLayer ? textLabelGraphicLayer.clear() : null;
|
||||
|
||||
|
|
@ -1198,6 +1172,7 @@ const handlerRemovePolygonArea = () => {
|
|||
time: 0,
|
||||
picture: '- -',
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// 面状航线测区、参数改变
|
||||
|
|
@ -1237,7 +1212,6 @@ const updatePolygonLineByParams = ()=>{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// 计算绘制的多边形每条线的长度和中心点
|
||||
const polygonBorderInfo = ref([]);
|
||||
|
||||
|
|
@ -1307,10 +1281,14 @@ const handlerLoadtextLabelGraphicLayer = (info) => {
|
|||
// 编辑回显航线
|
||||
const handlerEditPolygonAirLine =async () => {
|
||||
|
||||
polygonAirForm.value.startingPoint = [props.airLineForm.taskOffLng,props.airLineForm.taskOffLat];
|
||||
// 设置参考起飞点
|
||||
|
||||
takeOffPointPosition.value = [props.airLineForm.taskOffLng,props.airLineForm.taskOffLat,props.airLineForm?.taskOffAlt ? props.airLineForm?.taskOffAlt : 71]
|
||||
|
||||
polygonAirForm.value.startingPoint = [props.airLineForm.taskOffLng,props.airLineForm.taskOffLat,props.airLineForm?.taskOffAlt ? props.airLineForm?.taskOffAlt : 71];
|
||||
|
||||
// 起点
|
||||
takeOffPointGraphicLayer ? takeOffPointGraphicLayer.clear() : null;
|
||||
|
||||
let startFlyGraphic = new mars3d.graphic.BillboardEntity({
|
||||
position:[props.airLineForm.taskOffLng,props.airLineForm.taskOffLat],
|
||||
style: {
|
||||
|
|
@ -1328,16 +1306,13 @@ const handlerEditPolygonAirLine =async () => {
|
|||
clampToGround: true,
|
||||
},
|
||||
})
|
||||
|
||||
takeOffPointGraphicLayer.addGraphic(startFlyGraphic);
|
||||
|
||||
startPosition.value = [props.airLineForm.taskOffLng,props.airLineForm.taskOffLat,71]
|
||||
|
||||
// 测区
|
||||
// 加载测区
|
||||
let areaJson = WktToGeojson(props.airLineForm.flyToFirstPointMode)
|
||||
|
||||
polygonGeoJson.value = areaJson.coordinates[0];
|
||||
|
||||
|
||||
let geojsonData = {
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
|
|
@ -1363,12 +1338,11 @@ const handlerEditPolygonAirLine =async () => {
|
|||
},
|
||||
})
|
||||
|
||||
// 文本标注
|
||||
// 加载文本标注
|
||||
handlerGetPolygonBorderInfo(areaJson.coordinates[0])
|
||||
|
||||
// 航线
|
||||
// 加载航线
|
||||
let placemark = props.waylineInfo?.Folder?.Placemark
|
||||
|
||||
placemark?.forEach((item, index) => {
|
||||
let coordinate = item.Point.coordinates.split(',');
|
||||
let airPointInfo = {
|
||||
|
|
@ -1386,6 +1360,7 @@ const handlerEditPolygonAirLine =async () => {
|
|||
});
|
||||
|
||||
let coordinates = [];
|
||||
|
||||
airPoints.value?.forEach((item, index) => {
|
||||
coordinates.push([item.lng, item.lat]);
|
||||
});
|
||||
|
|
@ -1393,7 +1368,6 @@ const handlerEditPolygonAirLine =async () => {
|
|||
let line = turf.lineString(coordinates);
|
||||
|
||||
handlerDrawPolygonLine(line);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////航点航线计算////////////////////////////////////////////
|
||||
|
|
@ -1446,15 +1420,16 @@ const pointMove = (e, id) => {
|
|||
|
||||
// 绘制航线
|
||||
const handlerDrawLine = () => {
|
||||
|
||||
let positions = [];
|
||||
|
||||
airPoints.value?.forEach((item, index) => {
|
||||
positions.push([item.lng, item.lat, item.alt]);
|
||||
});
|
||||
|
||||
positions.unshift([startPosition.value[0], startPosition.value[1], airPoints.value[0].alt]);
|
||||
positions.unshift([takeOffPointPosition.value[0], takeOffPointPosition.value[1], airPoints.value[0].alt]);
|
||||
|
||||
positions.unshift([startPosition.value[0], startPosition.value[1], startPosition.value[2]]);
|
||||
positions.unshift([takeOffPointPosition.value[0], takeOffPointPosition.value[1], takeOffPointPosition.value[2]]);
|
||||
|
||||
// 判断是否已经绘制
|
||||
if (positions.length > 1) {
|
||||
|
|
@ -2046,7 +2021,7 @@ const preViewPointWayLine = (position) => {
|
|||
|
||||
let startGraphic = new mars3d.graphic.BillboardEntity({
|
||||
id: 'start-graphic',
|
||||
position: startPosition.value,
|
||||
position: takeOffPointPosition.value,
|
||||
style: {
|
||||
image: '/map/start.png',
|
||||
scale: 1,
|
||||
|
|
@ -2128,8 +2103,11 @@ const preViewPolygonWayLine = (lines) => {
|
|||
|
||||
// 清空所有图层
|
||||
const clearAllLayer = () => {
|
||||
|
||||
graphicLayer ? graphicLayer.clear() : null;
|
||||
|
||||
stickGroundPointLayer ? stickGroundPointLayer.clear() : null;
|
||||
|
||||
lineGroundPointLayer ? lineGroundPointLayer.clear() : null;
|
||||
|
||||
polygonGraphicLayer ? polygonGraphicLayer.clear() : null;
|
||||
|
|
@ -2293,6 +2271,7 @@ const setUAVPosition = () => {
|
|||
},
|
||||
frameRate: 1,
|
||||
});
|
||||
|
||||
} else {
|
||||
const graphicModel = new mars3d.graphic.ModelPrimitive({
|
||||
id: 'set-uav',
|
||||
|
|
|
|||
Loading…
Reference in New Issue