刘妍 2 months ago
commit 0b6a1c2d69

@ -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;
polygonAirForm.value.startingPoint = 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,28 +931,12 @@ const handlerPolygonEdit = (e)=>{
// 线
const handlerDrawPolygonLine = (lines) => {
let nodeGraphic = polygonGraphicLayer.getGraphicById("polygon-node-1");
if(nodeGraphic){
nodeGraphic.setOptions({
id: 'polygon-node-1',
name: '航点',
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,
},
},
})
//
let firstAirLinePoint = polygonGraphicLayer.getGraphicById("polygon-node-1");
if(firstAirLinePoint){
firstAirLinePoint.setOptions({
position: lines.geometry.coordinates[0],
})
}else{
const graphic = new mars3d.graphic.BillboardEntity({
id: 'polygon-node-1',
@ -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]
takeOffPointGraphicLayer.addGraphic(startFlyGraphic);
//
//
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…
Cancel
Save